forked from alibaba/rax
-
Notifications
You must be signed in to change notification settings - Fork 0
/
LinePoint.js
56 lines (53 loc) · 1.43 KB
/
LinePoint.js
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
49
50
51
52
53
54
55
56
import {createElement, Component, render} from 'rax';
import Chart, {Line, Point, Axis} from 'rax-charts';
class LinePointDemo extends Component {
render() {
const linePointData = [
{time: '2016-08-08 00:00:00', tem: 10},
{time: '2016-08-08 00:10:00', tem: 22},
{time: '2016-08-08 00:30:00', tem: 20},
{time: '2016-08-09 00:35:00', tem: 26},
{time: '2016-08-09 01:00:00', tem: 20},
{time: '2016-08-09 01:20:00', tem: 26},
{time: '2016-08-10 01:40:00', tem: 28},
{time: '2016-08-10 02:00:00', tem: 20},
{time: '2016-08-10 02:20:00', tem: 28}
];
return <Chart style={{
width: 750,
height: 350
}} data={linePointData} config={{
time: {
type: 'timeCat',
mask: 'yyyy-mm-dd',
tickCount: 2,
range: [0, 1]
},
tem: {
tickCount: 5,
min: 0
}
}}>
<Axis name="time" label={(text, index, total) => {
let cfg = {
fill: '#979797',
font: '14px san-serif',
offset: 6
};
if (index === 0) {
cfg.textAlign = 'start';
}
if (index > 0 && index === total - 1) {
cfg.textAlign = 'end';
}
return cfg;
}} />
<Axis name="tem" label={{
fontSize: 14
}} />
<Line position="time*tem" shape="smooth" />
<Point position="time*tem" />
</Chart>;
}
}
export default LinePointDemo;