diff --git a/src/components/chart-bar.js b/src/components/chart-bar.js new file mode 100644 index 0000000..e574eec --- /dev/null +++ b/src/components/chart-bar.js @@ -0,0 +1,71 @@ +import Vue from 'vue' +Vue.component("chart-bar", { + template: ` +
+ + `, + props: { + fn:{ + type:Function + }, + height:{ + type:Number + }, + optData:{ + type:Array, + default:()=>[] + } + }, + data() { + return { + } + }, + mounted(){ + this.init() + }, + methods: { + doClick(){ + this.$emit("clickme"); + }, + init(){ + this.getChartData() + }, + getChartData(){ + //品类金额占比 饼图 + var chChartPie = echarts.init(this.$refs.warningPieChart); + this.echartPie(chChartPie) + }, + echartPie(chChart){ + let newPromise = new Promise((resolve) => { + resolve() + }) + + //然后异步执行echarts的初始化函数 + newPromise.then(() => { + this.option = { + legend: { + show:false + }, + tooltip: { trigger: 'axis', + }, + dataset: { + source: this.optData + }, + xAxis: { type: 'category' }, + yAxis: {}, + series: [{ type: 'bar' }, { type: 'bar' }, { type: 'bar' }] + } + if(this.fn){ + this.option=this.fn(this.option); + } + chChart.setOption(this.option); + window.onresize = chChart.resize; + }) + }, + }, + +}) diff --git a/src/components/project-overview-chart.js b/src/components/project-overview-chart.js index 1e38c40..90c8d27 100644 --- a/src/components/project-overview-chart.js +++ b/src/components/project-overview-chart.js @@ -10,6 +10,9 @@ Vue.component("project-overview-chart", { `, props: { + fn:{ + type:Function + }, typedata:{ type: Array, }, @@ -115,12 +118,11 @@ Vue.component("project-overview-chart", { if(total_datas==0){ percent=0; } - return "{name| " + name + "}"+this.sp+"{percent|" + res[0].value + "}{percent|" + percent + "%}"; + return "{name| " + name + "}"+this.sp+"{value|" + res[0].value + "} {percent|" + percent + "%}"; }, }; let opt={...legendOption,...(this.legendOpt||{})}; - this.option = { - + this.option = { title: { text: this.maintitle||total_datas, subtext: this.text, @@ -201,6 +203,9 @@ Vue.component("project-overview-chart", { }, ], } + if(this.fn){ + this.option=this.fn(this.option); + } chChart.setOption(this.option); window.onresize = chChart.resize; }) diff --git a/src/pages/projectEngin.vue b/src/pages/projectEngin.vue index f18364d..6f4c1f4 100644 --- a/src/pages/projectEngin.vue +++ b/src/pages/projectEngin.vue @@ -24,6 +24,7 @@