Skip to content

Commit c9a72ef

Browse files
tangying1027xuying.xu
and
xuying.xu
authored
chore: 补充官网阶梯图demo (#2000)
* chore: 补充官网阶梯图demo * chore: 修复曲线单测 --------- Co-authored-by: xuying.xu <xuying.xu@alibaba-inc.com>
1 parent e0ccc98 commit c9a72ef

File tree

4 files changed

+119
-0
lines changed

4 files changed

+119
-0
lines changed

packages/f2/test/components/line/line.test.tsx

+38
Original file line numberDiff line numberDiff line change
@@ -383,6 +383,44 @@ describe('折线图', () => {
383383
});
384384

385385
it('曲线', async () => {
386+
const data = [
387+
{
388+
time: '2016-08-08 00:00:00',
389+
tem: 10,
390+
},
391+
{
392+
time: '2016-08-08 00:10:00',
393+
tem: 22,
394+
},
395+
{
396+
time: '2016-08-08 00:30:00',
397+
tem: 20,
398+
},
399+
{
400+
time: '2016-08-09 00:35:00',
401+
tem: 26,
402+
},
403+
{
404+
time: '2016-08-09 01:00:00',
405+
tem: 20,
406+
},
407+
{
408+
time: '2016-08-09 01:20:00',
409+
tem: 26,
410+
},
411+
{
412+
time: '2016-08-10 01:40:00',
413+
tem: 28,
414+
},
415+
{
416+
time: '2016-08-10 02:00:00',
417+
tem: 20,
418+
},
419+
{
420+
time: '2016-08-10 02:20:00',
421+
tem: 18,
422+
},
423+
];
386424
const context = createContext('曲线');
387425
const chartRef = { current: null };
388426
const lineRef = { current: null };

site/.dumi/tsconfig.json

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"extends": "../tsconfig.json",
3+
"include": [
4+
"**/*"
5+
]
6+
}

site/examples/line/line/demo/meta.json

+5
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@
1919
"title": "曲线",
2020
"screenshot": "https://gw.alipayobjects.com/mdn/rms_4f0ff1/afts/img/A*LU4qRJrOSQkAAAAAAAAAAABkARQnAQ"
2121
},
22+
{
23+
"filename": "step.jsx",
24+
"title": "阶梯",
25+
"screenshot": "https://gw.alipayobjects.com/zos/finxbff/compress-tinypng/nnBatWjRpi6HtWmjwdPd4/line_test_tsx_zhexiantu_jichuzhexiantu_jietitu_1_snap.png"
26+
},
2227
{
2328
"filename": "pan.jsx",
2429
"title": "折线图平移",

site/examples/line/line/demo/step.jsx

+70
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
import { Axis, Canvas, Chart, Line } from '@antv/f2';
2+
3+
const data = [];
4+
5+
[
6+
{
7+
time: '2016-08-01',
8+
tem: 15,
9+
type: 'start',
10+
},
11+
{
12+
time: '2016-08-02',
13+
tem: 22,
14+
type: 'start',
15+
},
16+
{
17+
time: '2016-08-03',
18+
tem: 15,
19+
type: 'start',
20+
},
21+
{
22+
time: '2016-08-04',
23+
tem: 26,
24+
type: 'start',
25+
},
26+
{
27+
time: '2016-08-05',
28+
tem: 20,
29+
type: 'start',
30+
},
31+
{
32+
time: '2016-08-06',
33+
tem: 26,
34+
type: 'start',
35+
},
36+
].map((d) => {
37+
data.push(d);
38+
data.push({ ...d, tem: d.tem + 15, type: 'middle' });
39+
data.push({ ...d, tem: d.tem + 30, type: 'end' });
40+
});
41+
42+
const context = document.getElementById('container').getContext('2d');
43+
const { props } = (
44+
<Canvas context={context}>
45+
<Chart data={data}>
46+
<Axis
47+
field="time"
48+
tickCount={2}
49+
style={{
50+
label: {
51+
align: 'between',
52+
},
53+
}}
54+
/>
55+
<Axis field="tem" tickCount={5} max={60} />
56+
<Line
57+
x="time"
58+
y="tem"
59+
color="type"
60+
shape={{
61+
field: 'type',
62+
range: ['step-start', 'step-middle', 'step-end'],
63+
}}
64+
/>
65+
</Chart>
66+
</Canvas>
67+
);
68+
69+
const canvas = new Canvas(props);
70+
canvas.render();

0 commit comments

Comments
 (0)