diff --git a/src/views/dashboard/components/ProgressChart.vue b/src/views/dashboard/components/ProgressChart.vue index 327e13d49..2597c56c3 100644 --- a/src/views/dashboard/components/ProgressChart.vue +++ b/src/views/dashboard/components/ProgressChart.vue @@ -42,23 +42,26 @@ export default { options() { const seriesList = [] const labels = this.data.map(item => item.label) - for (let i = 0; i < this.data.length; i++) { + const total = _.sumBy(this.data, function(i) { return i.total }) + for (let i = 0, len = this.data.length; i < len; i++) { const current = this.data[i] + const num = (current.total / total) * 100 + const color = '#' + Math.floor(Math.random() * (256 * 256 * 256 - 1)).toString(16) seriesList.push({ type: 'bar', stack: 'total', barWidth: 32, name: current.label, itemStyle: { - borderRadius: 0 - }, - data: [{ - value: current.total, - itemStyle: { - color: this.colors[i] + borderRadius: 0, + color: () => { + return this.colors[i] || color } - }], - color: this.colors[i] + }, + data: [num], + color: () => { + return this.colors[i] || color + } }) } return { @@ -69,8 +72,9 @@ export default { itemHeight: 10, textStyle: { color: '#000', - lineHeight: 30 + lineHeight: 10 }, + bottom: 30, data: labels }, @@ -126,11 +130,11 @@ export default { } }, grid: { - top: '0%', + top: '60%', containLabel: true, - bottom: '-50%', + bottom: '0', left: '0%', - right: '0%' + right: 1 }, series: seriesList, xAxis: {