forked from alibaba/ice
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathChartPoint.jsx
More file actions
78 lines (71 loc) · 1.94 KB
/
ChartPoint.jsx
File metadata and controls
78 lines (71 loc) · 1.94 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
import React, { Component } from 'react';
import axios from 'axios';
import IceContainer from '@icedesign/container';
import { Chart, Geom, Axis, Tooltip } from 'bizcharts';
export default class ChartPoint extends Component {
static displayName = 'ChartPoint';
static propTypes = {};
static defaultProps = {};
constructor(props) {
super(props);
this.state = {
data: [],
};
}
componentDidMount() {
axios
.get('/mock/chart-point.json')
.then((response) => {
console.log(response.data.data);
this.setState({
data: response.data.data,
});
})
.catch((error) => {
console.log(error);
});
}
render() {
return (
<div className="chart-point">
<IceContainer>
<h4 style={styles.title}>点图</h4>
<Chart height={400} data={this.state.data} forceFit>
<Tooltip
showTitle={false}
crosshairs={{ type: 'cross' }}
itemTpl="<li data-index={index} style="margin-bottom:4px;"><span style="background-color:{color};" class="g2-tooltip-marker"></span>{name}<br/>{value}</li>"
/>
<Axis name="height" />
<Axis name="weight" />
<Geom
type="point"
position="height*weight"
opacity={0.65}
shape="circle"
size={4}
tooltip={[
'gender*height*weight',
(gender, height, weight) => {
return {
name: gender,
value: `${height}(cm), ${weight}(kg)`,
};
},
]}
/>
</Chart>
</IceContainer>
</div>
);
}
}
const styles = {
title: {
margin: '0 0 40px',
fontSize: '18px',
paddingBottom: '15px',
fontWeight: 'bold',
borderBottom: '1px solid #eee',
},
};