@@ -14,6 +14,7 @@ import Big from "big.js";
14
14
import { googleMapsApiUrl } from "../chartComp/chartConfigs/chartUrls" ;
15
15
import { chartStyleWrapper , styleWrapper } from "../../util/styleWrapper" ;
16
16
import parseBackground from "../../util/gradientBackgroundColor" ;
17
+ import isColorString from "../../util/isColorString" ;
17
18
18
19
export function transformData (
19
20
originData : JSONObject [ ] ,
@@ -135,6 +136,10 @@ export function getEchartsConfig(
135
136
chartSize ?: ChartSize ,
136
137
theme ?: any ,
137
138
) : EChartsOptionWithMap {
139
+ console . log ( props . echartsOption && props ?. echartsOption ?. data ?. map ( item => ( {
140
+ name : item . name ,
141
+ itemStyle : item . color && { color : item . color }
142
+ } ) ) )
138
143
if ( props . mode === "json" ) {
139
144
let opt = {
140
145
title : {
@@ -148,43 +153,46 @@ export function getEchartsConfig(
148
153
backgroundColor : parseBackground (
149
154
props ?. chartStyle ?. background || theme ?. chartStyle ?. backgroundColor || "#FFFFFF"
150
155
) ,
151
- "tooltip" : props . tooltip && {
152
- "trigger" : "item" ,
153
- "formatter" : "{a} <br/>{b} : {c}%"
154
- } ,
155
- "series" : [
156
- {
157
- "name" : props . echartsConfig . type ,
158
- "type" : props . echartsConfig . type ,
159
- left : `${ props ?. left } %` ,
160
- right : `${ props ?. right } %` ,
161
- bottom : `${ props ?. bottom } %` ,
162
- top : `${ props ?. top } %` ,
163
- "label" : {
164
- "show" : true ,
165
- "position" : props . echartsLabelConfig . top ,
166
- ...styleWrapper ( props ?. detailStyle , theme ?. detailStyle , 15 )
156
+ tooltip : props . tooltip && {
157
+ trigger : "item" ,
158
+ formatter : "{a} <br/>{b} : {c}%"
167
159
} ,
168
- "data" : props . echartsOption ?. data ?. map ( item => ( { name : item . name , itemStyle : { color : item . color } } ) ) ,
169
- "links" :props . echartsOption . links ,
170
- emphasis : {
171
- focus : props ?. focus ? 'adjacency' : undefined ,
172
- } ,
173
- lineStyle : {
174
- ...chartStyleWrapper ( props ?. lineStyle , theme ?. lineStyle ) ,
175
- color : 'gradient' ,
176
- curveness : props ?. curveness ,
177
- opacity : props ?. opacity ,
178
- } ,
179
- itemStyle : {
180
- ...chartStyleWrapper ( props ?. chartStyle , theme ?. chartStyle ) ,
181
- } ,
182
- nodeWidth : props ?. nodeWidth ,
183
- nodeGap : props ?. nodeGap ,
184
- draggable : props ?. draggable ,
160
+ series : [
161
+ {
162
+ name : props . echartsConfig . type ,
163
+ type : props . echartsConfig . type ,
164
+ left : `${ props ?. left } %` ,
165
+ right : `${ props ?. right } %` ,
166
+ bottom : `${ props ?. bottom } %` ,
167
+ top : `${ props ?. top } %` ,
168
+ label : {
169
+ show : true ,
170
+ position : props . echartsLabelConfig . top ,
171
+ ...styleWrapper ( props ?. detailStyle , theme ?. detailStyle , 15 )
172
+ } ,
173
+ data : props . echartsOption && props ?. echartsOption ?. data ?. map ( item => ( {
174
+ name : item . name ,
175
+ itemStyle : isColorString ( item . color ) && { color : item . color }
176
+ } ) ) ,
177
+ links :props . echartsOption . links ,
178
+ emphasis : {
179
+ focus : props ?. focus ? 'adjacency' : undefined ,
180
+ } ,
181
+ lineStyle : {
182
+ ...chartStyleWrapper ( props ?. lineStyle , theme ?. lineStyle ) ,
183
+ color : 'gradient' ,
184
+ curveness : props ?. curveness ,
185
+ opacity : props ?. opacity ,
186
+ } ,
187
+ itemStyle : {
188
+ ...chartStyleWrapper ( props ?. chartStyle , theme ?. chartStyle ) ,
189
+ } ,
190
+ nodeWidth : props ?. nodeWidth ,
191
+ nodeGap : props ?. nodeGap ,
192
+ draggable : props ?. draggable ,
193
+ }
194
+ ]
185
195
}
186
- ]
187
- }
188
196
return props . echartsOption ? opt : { } ;
189
197
190
198
}
0 commit comments