@@ -2,10 +2,11 @@ import * as React from 'react'
2
2
import { inject , observer } from 'mobx-react'
3
3
import { Row , Col , Form , Button } from 'antd' ;
4
4
import { IBall } from '@models/ball'
5
- import * as Echart from 'echarts'
5
+ import * as Echart from 'echarts/lib/echarts '
6
6
// const Echart = require('echarts/lib/echarts')
7
7
// 引入柱状图
8
8
require ( 'echarts/lib/chart/bar' ) ;
9
+ require ( 'echarts/lib/chart/line' ) ;
9
10
// 引入提示框和标题组件
10
11
require ( 'echarts/lib/component/tooltip' ) ;
11
12
require ( 'echarts/lib/component/title' ) ;
@@ -16,8 +17,10 @@ export default class BallChart extends React.Component<IProps> {
16
17
17
18
chartRef : any = React . createRef ( )
18
19
blueRef : any = React . createRef ( )
20
+ redChartRef : any = React . createRef ( )
19
21
ballCountChart : Echart . ECharts
20
22
blueBallCountChart : Echart . ECharts
23
+ redBallDistributionChart : Echart . ECharts
21
24
22
25
state = {
23
26
visible : false
@@ -46,12 +49,26 @@ export default class BallChart extends React.Component<IProps> {
46
49
componentDidMount ( ) {
47
50
this . ballCountChart = Echart . init ( this . chartRef . current )
48
51
this . blueBallCountChart = Echart . init ( this . blueRef . current )
52
+ this . redBallDistributionChart = Echart . init ( this . redChartRef . current )
53
+
49
54
const { fetchChartData } = this . props . ballChartStore
50
55
51
- fetchChartData ( ( reds :[ any ] , blues :[ any ] ) => {
56
+ fetchChartData ( ( reds :[ any ] , blues :[ any ] , redDisList :[ [ any ] ] ) => {
57
+ const series : any = redDisList . map ( ( item , i ) => {
58
+ return {
59
+ name : `红球${ i + 1 } ` ,
60
+ type : 'line' ,
61
+ smooth : true ,
62
+ showSymbol : false ,
63
+ symbol : 'circle' ,
64
+ symbolSize : 6 ,
65
+ data : item . map ( v => v . value )
66
+ }
67
+ } )
68
+
52
69
this . ballCountChart . setOption ( {
53
70
title : {
54
- text : '红球'
71
+ text : '红球'
55
72
} ,
56
73
tooltip : { } ,
57
74
grid : {
@@ -61,13 +78,13 @@ export default class BallChart extends React.Component<IProps> {
61
78
containLabel : true
62
79
} ,
63
80
xAxis : {
64
- data : reds . map ( v => v . name )
81
+ data : reds . map ( v => v . name )
65
82
} ,
66
83
yAxis : { } ,
67
84
series : [ {
68
- name : '次数' ,
69
- type : 'bar' ,
70
- data : reds . map ( v => v . value )
85
+ name : '次数' ,
86
+ type : 'bar' ,
87
+ data : reds . map ( v => v . value )
71
88
} ] ,
72
89
color : [ '#f54646' ]
73
90
} )
@@ -84,16 +101,36 @@ export default class BallChart extends React.Component<IProps> {
84
101
containLabel : true
85
102
} ,
86
103
xAxis : {
87
- data : blues . map ( v => v . name )
104
+ data : blues . map ( v => v . name )
88
105
} ,
89
106
yAxis : { } ,
90
107
series : [ {
91
- name : '次数' ,
92
- type : 'bar' ,
93
- data : blues . map ( v => v . value )
108
+ name : '次数' ,
109
+ type : 'bar' ,
110
+ data : blues . map ( v => v . value )
94
111
} ] ,
95
112
color : [ '#3399ff' ]
96
113
} )
114
+
115
+ this . redBallDistributionChart . setOption ( {
116
+ title : {
117
+ text : '红球分布图'
118
+ } ,
119
+ tooltip : { } ,
120
+ grid : {
121
+ left : '2%' ,
122
+ right : '2%' ,
123
+ bottom : '3%' ,
124
+ containLabel : true
125
+ } ,
126
+ xAxis : {
127
+ data : reds . map ( v => v . name )
128
+ } ,
129
+ yAxis : { } ,
130
+ series : series ,
131
+ // color: ['#f54646','#f5464685','#f5464670','#f5464655','#f5464640','#f5464625']
132
+ color : [ '#f54646' , '#c23531' , '#2f4554' , '#61a0a8' , '#d48265' , '#91c7ae' , '#749f83' , '#ca8622' , '#bda29a' , '#6e7074' , '#546570' , '#c4ccd3' ]
133
+ } )
97
134
} )
98
135
}
99
136
@@ -109,6 +146,12 @@ export default class BallChart extends React.Component<IProps> {
109
146
< div className = 'chart-w' ref = { this . blueRef } > </ div >
110
147
</ Col >
111
148
</ Row >
149
+ < h3 > 红球历史出现分布图</ h3 >
150
+ < Row >
151
+ < Col span = { 24 } >
152
+ < div className = 'chart-w' style = { { borderRight : 'none' } } ref = { this . redChartRef } > </ div >
153
+ </ Col >
154
+ </ Row >
112
155
</ div >
113
156
</ React . Fragment >
114
157
0 commit comments