forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindices-line-brush-series.ts
48 lines (46 loc) · 1.08 KB
/
indices-line-brush-series.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
import { csv } from 'd3-fetch';
import { autoType } from 'd3-dsv';
import { G2Spec, PLOT_CLASS_NAME } from '../../../src';
import { brush } from './penguins-point-brush';
export async function indicesLineBrushSeries(): Promise<G2Spec> {
const data = await csv('data/indices.csv', autoType);
return {
type: 'view',
children: [
{
type: 'line',
data,
axis: {
y: { labelAutoRotate: false },
},
transform: [{ type: 'normalizeY', basis: 'first', groupBy: 'color' }],
legend: false,
encode: {
x: 'Date',
y: 'Close',
color: 'Symbol',
key: 'Symbol',
},
state: {
active: { stroke: 'red' },
},
},
],
interaction: {
brushHighlight: {
series: true,
},
},
};
}
indicesLineBrushSeries.steps = ({ canvas }) => {
const { document } = canvas;
const plot = document.getElementsByClassName(PLOT_CLASS_NAME)[0];
return [
{
changeState: () => {
brush(plot, 400, 300, 600, 400);
},
},
];
};