forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindices-line-items.ts
40 lines (38 loc) · 999 Bytes
/
indices-line-items.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
import { csv } from 'd3-fetch';
import { autoType } from 'd3-dsv';
import { G2Spec } from '../../../src';
import { seriesTooltipSteps } from './utils';
export async function indicesLineItems(): Promise<G2Spec> {
const data = await csv('data/indices.csv', autoType);
return {
type: 'view',
width: 800,
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',
},
tooltip: {
title: (d) => new Date(d.Date).toUTCString(),
items: [
(d, i, D, V) => ({
name: 'Close',
value: V.y.value[i as number].toFixed(1),
}),
],
},
},
],
};
}
indicesLineItems.steps = seriesTooltipSteps([200, 300]);