Skip to content

Commit

Permalink
docs(demo): add line multiple demo, add make subTickLine = null as de…
Browse files Browse the repository at this point in the history
…fault
  • Loading branch information
hustcc committed Nov 27, 2019
1 parent 5c0adfd commit 2a4be81
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 8 deletions.
54 changes: 54 additions & 0 deletions examples/line/multiple/demo/kernel-smooth-regression-1.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
import { Chart } from '@antv/g2';

fetch('../data/diamond.json')
.then((res) => res.json())
.then((data) => {
const chart = new Chart({
container: 'container',
forceFit: true,
height: 500,
});
chart.scale({
x: {
alias: 'depth',
min: 50,
max: 70,
sync: true,
},
y: {
alias: '概率密度分布',
sync: true,
},
});

// TODO 如何引入 dataset 模块

// [
// 'boxcar',
// 'cosine',
// 'epanechnikov',
// 'gaussian',
// 'quartic',
// 'triangular',
// 'tricube',
// 'triweight',
// 'uniform'
// ].forEach((method, i) => {
// const dv = new DataSet.View().source(data);
// dv.transform({
// type: 'kernel-smooth.regression',
// method,
// field: 'depth',
// extent: [ 50, 70 ]
// });
//
// const view = chart.view();
// !!i && view.axis(false);
// view.data(dv.rows);
// view.line()
// .position('x*y')
// .color(G2.Global.colors_16[i]);
// });

chart.render();
});
57 changes: 57 additions & 0 deletions examples/line/multiple/demo/kernel-smooth-regression-2.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { Chart } from '@antv/g2';

fetch('../data/diamond.json')
.then((res) => res.json())
.then((data) => {
const chart = new Chart({
container: 'container',
height: 500,
});

chart.data(data);
chart.scale({
carat: {
alias: '克拉数',
min: 0,
max: 4,
sync: true,
},
price: {
alias: '价格',
sync: true,
},
});
chart.point().position('carat*price');

// TODO 如何引入 dataset 模块!
// [
// 'boxcar',
// 'cosine',
// 'epanechnikov',
// 'gaussian',
// 'quartic',
// 'triangular',
// 'tricube',
// 'triweight',
// 'uniform'
// ].forEach((method, i) => {
// const dv = new DataSet.View().source(data);
// dv.transform({
// type: 'kernel-smooth.regression',
// method,
// fields: [ 'carat', 'price' ],
// as: [ 'carat', 'price' ],
// bandwidth: 0.5,
// extent: [ 0, 4 ]
// });
//
// const view = chart.createView();
// view.axis(false);
// view.data(dv.rows);
// view.line()
// .position('carat*price')
// .color(view.getTheme().colors[i]);
// });

chart.render();
});
9 changes: 1 addition & 8 deletions src/theme/antv.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,14 +137,7 @@ const AXIS_STYLE = {
alignTick: false,
length: 5,
},
subTickLine: {
style: {
lineWidth: 1,
stroke: '#BFBFBF',
},
count: 4,
length: 2,
},
subTickLine: null,
};

const GRID_STYLE = {
Expand Down

0 comments on commit 2a4be81

Please sign in to comment.