forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindices-line-chart-facet.ts
60 lines (57 loc) · 1.38 KB
/
indices-line-chart-facet.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
import { csv } from 'd3-fetch';
import { autoType } from 'd3-dsv';
import { G2Spec, PLOT_CLASS_NAME } from '../../../src';
import { step } from './utils';
export async function indicesLineChartFacet(): Promise<G2Spec> {
const data = await csv('data/indices.csv', autoType);
return {
type: 'facetRect',
height: 600,
width: 700,
paddingRight: 80,
paddingBottom: 50,
paddingLeft: 60,
encode: { y: 'Symbol' },
scale: { y: { paddingInner: 0.2 } },
data,
children: [
{
type: 'line',
frame: false,
scale: { y: { nice: true, facet: false } },
axis: { y: { labelAutoHide: false } },
encode: {
x: 'Date',
y: 'Close',
color: 'Symbol',
key: 'Symbol',
},
tooltip: {
title: (d) => new Date(d.Date).toUTCString(),
},
interaction: { tooltip: false },
},
],
interaction: {
tooltip: {
series: true,
facet: true,
body: false,
crosshairs: true,
crosshairsStrokeWidth: 30,
marker: false,
},
},
};
}
indicesLineChartFacet.tooltip = true;
indicesLineChartFacet.steps = ({ canvas }) => {
const { document } = canvas;
const [plot] = document.getElementsByClassName(PLOT_CLASS_NAME);
return [
step(plot, 'pointermove', {
offsetX: 450,
offsetY: 350,
}),
];
};