Commit 222cc479251c4e68d263e745f63a12162c663121
1 parent
d2bb38ca
1、饼图添加过程返回自定义颜色
Showing
2 changed files
with
27 additions
and
12 deletions
src/mixins/queryform.js
| ... | ... | @@ -153,7 +153,7 @@ export default { |
| 153 | 153 | } |
| 154 | 154 | ananysicData["xAxis"] = axis; |
| 155 | 155 | ananysicData["series"] = series; |
| 156 | - console.log(ananysicData); | |
| 156 | + // console.log(ananysicData); | |
| 157 | 157 | return ananysicData; |
| 158 | 158 | }, |
| 159 | 159 | // 柱状图、折线图、柱线图 |
| ... | ... | @@ -262,7 +262,9 @@ export default { |
| 262 | 262 | const value = chartProperties[key]; |
| 263 | 263 | if (value === "name") { |
| 264 | 264 | obj["name"] = data[i][key]; |
| 265 | - } else { | |
| 265 | + } else if (value === "color") { | |
| 266 | + obj["color"] = data[i][key]; | |
| 267 | + }else { | |
| 266 | 268 | obj["value"] = data[i][key]; |
| 267 | 269 | } |
| 268 | 270 | } | ... | ... |
src/views/bigscreenDesigner/designer/widget/pie/widgetPiechart.vue
| ... | ... | @@ -88,9 +88,9 @@ export default { |
| 88 | 88 | this.setOptionsValue(); |
| 89 | 89 | this.setOptionsTooltip(); |
| 90 | 90 | this.setOptionsLegend(); |
| 91 | - this.setOptionsColor(); | |
| 92 | 91 | this.setOptionsData(); |
| 93 | 92 | this.setOptionsPiechartStyle(); |
| 93 | + // this.setOptionsColor(); | |
| 94 | 94 | }, |
| 95 | 95 | // 饼图样式 |
| 96 | 96 | setOptionsPiechartStyle() { |
| ... | ... | @@ -194,13 +194,17 @@ export default { |
| 194 | 194 | legend.itemWidth = optionsSetup.legendWidth; |
| 195 | 195 | }, |
| 196 | 196 | // 图例颜色修改 |
| 197 | - setOptionsColor() { | |
| 198 | - const optionsSetup = this.optionsSetup; | |
| 199 | - const customColor = optionsSetup.customColor; | |
| 200 | - if (!customColor) return; | |
| 201 | - const arrColor = []; | |
| 202 | - for (let i = 0; i < customColor.length; i++) { | |
| 203 | - arrColor.push(customColor[i].color); | |
| 197 | + setOptionsColor(arrColorData) { | |
| 198 | + let arrColor = []; | |
| 199 | + if(arrColorData!==undefined && arrColorData.length>0){ | |
| 200 | + arrColor = arrColorData; | |
| 201 | + }else{ | |
| 202 | + const optionsSetup = this.optionsSetup; | |
| 203 | + const customColor = optionsSetup.customColor; | |
| 204 | + if (!customColor) return; | |
| 205 | + for (let i = 0; i < customColor.length; i++) { | |
| 206 | + arrColor.push(customColor[i].color); | |
| 207 | + } | |
| 204 | 208 | } |
| 205 | 209 | this.options.color = arrColor; |
| 206 | 210 | this.options = Object.assign({}, this.options); |
| ... | ... | @@ -232,9 +236,18 @@ export default { |
| 232 | 236 | }, |
| 233 | 237 | getEchartData(val) { |
| 234 | 238 | const data = this.queryEchartsData(val); |
| 235 | - data.then(res => { | |
| 239 | + const arrColorData = []; | |
| 240 | + for (let i = 0; i < data.length; i++) { | |
| 241 | + const res = data[i]; | |
| 236 | 242 | this.renderingFn(res); |
| 237 | - }); | |
| 243 | + if(this.isNotBlank(res.color)){ | |
| 244 | + arrColorData[i]=res.color; | |
| 245 | + } | |
| 246 | + } | |
| 247 | + this.setOptionsColor(arrColorData) | |
| 248 | + // data.then(res => { | |
| 249 | + // this.renderingFn(res); | |
| 250 | + // }); | |
| 238 | 251 | }, |
| 239 | 252 | renderingFn(val) { |
| 240 | 253 | for (const key in this.options.series) { | ... | ... |