Commit 222cc479251c4e68d263e745f63a12162c663121

Authored by qianbao
1 parent d2bb38ca

1、饼图添加过程返回自定义颜色

src/mixins/queryform.js
@@ -153,7 +153,7 @@ export default { @@ -153,7 +153,7 @@ export default {
153 } 153 }
154 ananysicData["xAxis"] = axis; 154 ananysicData["xAxis"] = axis;
155 ananysicData["series"] = series; 155 ananysicData["series"] = series;
156 - console.log(ananysicData); 156 + // console.log(ananysicData);
157 return ananysicData; 157 return ananysicData;
158 }, 158 },
159 // 柱状图、折线图、柱线图 159 // 柱状图、折线图、柱线图
@@ -262,7 +262,9 @@ export default { @@ -262,7 +262,9 @@ export default {
262 const value = chartProperties[key]; 262 const value = chartProperties[key];
263 if (value === "name") { 263 if (value === "name") {
264 obj["name"] = data[i][key]; 264 obj["name"] = data[i][key];
265 - } else { 265 + } else if (value === "color") {
  266 + obj["color"] = data[i][key];
  267 + }else {
266 obj["value"] = data[i][key]; 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,9 +88,9 @@ export default {
88 this.setOptionsValue(); 88 this.setOptionsValue();
89 this.setOptionsTooltip(); 89 this.setOptionsTooltip();
90 this.setOptionsLegend(); 90 this.setOptionsLegend();
91 - this.setOptionsColor();  
92 this.setOptionsData(); 91 this.setOptionsData();
93 this.setOptionsPiechartStyle(); 92 this.setOptionsPiechartStyle();
  93 + // this.setOptionsColor();
94 }, 94 },
95 // 饼图样式 95 // 饼图样式
96 setOptionsPiechartStyle() { 96 setOptionsPiechartStyle() {
@@ -194,13 +194,17 @@ export default { @@ -194,13 +194,17 @@ export default {
194 legend.itemWidth = optionsSetup.legendWidth; 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 this.options.color = arrColor; 209 this.options.color = arrColor;
206 this.options = Object.assign({}, this.options); 210 this.options = Object.assign({}, this.options);
@@ -232,9 +236,18 @@ export default { @@ -232,9 +236,18 @@ export default {
232 }, 236 },
233 getEchartData(val) { 237 getEchartData(val) {
234 const data = this.queryEchartsData(val); 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 this.renderingFn(res); 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 renderingFn(val) { 252 renderingFn(val) {
240 for (const key in this.options.series) { 253 for (const key in this.options.series) {