File tree 4 files changed +119
-0
lines changed
packages/f2/test/components/line
4 files changed +119
-0
lines changed Original file line number Diff line number Diff line change @@ -383,6 +383,44 @@ describe('折线图', () => {
383
383
} ) ;
384
384
385
385
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
+ ] ;
386
424
const context = createContext ( '曲线' ) ;
387
425
const chartRef = { current : null } ;
388
426
const lineRef = { current : null } ;
Original file line number Diff line number Diff line change
1
+ {
2
+ "extends" : " ../tsconfig.json" ,
3
+ "include" : [
4
+ " **/*"
5
+ ]
6
+ }
Original file line number Diff line number Diff line change 19
19
"title" : " 曲线" ,
20
20
"screenshot" : " https://gw.alipayobjects.com/mdn/rms_4f0ff1/afts/img/A*LU4qRJrOSQkAAAAAAAAAAABkARQnAQ"
21
21
},
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
+ },
22
27
{
23
28
"filename" : " pan.jsx" ,
24
29
"title" : " 折线图平移" ,
Original file line number Diff line number Diff line change
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 ( ) ;
You can’t perform that action at this time.
0 commit comments