-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
docs(demo): add line multiple demo, add make subTickLine = null as de…
…fault
- Loading branch information
Showing
3 changed files
with
112 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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(); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters