forked from antvis/G2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcassette-area-series.ts
41 lines (39 loc) · 1.05 KB
/
cassette-area-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
import { G2Spec } from '../../../src';
import { seriesTooltipSteps } from './utils';
export async function cassetteAreaSeries(): Promise<G2Spec> {
return {
type: 'view',
width: 800,
height: 720,
data: { type: 'fetch', value: 'data/cassette.json' },
encode: {
x: (d) => new Date(d.year),
y: 'revenue',
series: 'format',
shape: 'smooth',
},
transform: [{ type: 'stackY', orderBy: 'maxIndex', reverse: true }],
axis: { y: { labelFormatter: '~s' } },
interaction: {
tooltip: { filter: (d) => parseInt(d.value as string) > 0 },
},
children: [
{
type: 'area',
encode: { color: 'group' },
tooltip: {
title: (d) => new Date(d.year).toUTCString(),
items: [
{
channel: 'y',
valueFormatter: '~s',
name: 'revenue',
},
],
},
},
{ type: 'line', style: { stroke: 'white' }, tooltip: false },
],
};
}
cassetteAreaSeries.steps = seriesTooltipSteps([100, 300]);