From ae878dbca21b943dbe22e3b2fa2964323e4ef92b Mon Sep 17 00:00:00 2001 From: xianfuxing Date: Tue, 14 Aug 2018 16:57:39 +0800 Subject: [PATCH] # up history linechart x-axis --- src/views/dashboard/admin/components/LineChart.vue | 10 +++++++++- src/views/dashboard/admin/index.vue | 9 +++++++-- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/views/dashboard/admin/components/LineChart.vue b/src/views/dashboard/admin/components/LineChart.vue index ad7aa02..ba17191 100644 --- a/src/views/dashboard/admin/components/LineChart.vue +++ b/src/views/dashboard/admin/components/LineChart.vue @@ -27,6 +27,9 @@ export default { }, chartData: { type: Object + }, + xAxis: { + type: Array } }, data() { @@ -35,6 +38,7 @@ export default { } }, mounted() { + console.log(this.xAxis) this.initChart() if (this.autoResize) { this.__resizeHanlder = debounce(() => { @@ -75,8 +79,12 @@ export default { setOptions({ totalHistoryData, actualData } = {}) { this.chart.setOption({ xAxis: { - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + // data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + data: this.xAxis, boundaryGap: false, + axisLabel: { + interval: 0 + }, axisTick: { show: false } diff --git a/src/views/dashboard/admin/index.vue b/src/views/dashboard/admin/index.vue index fdf65ad..b01ffe7 100644 --- a/src/views/dashboard/admin/index.vue +++ b/src/views/dashboard/admin/index.vue @@ -12,7 +12,7 @@ - + @@ -74,7 +74,9 @@ import const lineChartData = { historyData: { - totalHistoryData: [] + totalHistoryData: [], + incrementHistoryData: [], + xAxis: [] }, messages: { expectedData: [200, 192, 120, 144, 160, 130, 140], @@ -134,10 +136,13 @@ export default { }, handleHistoryLine(historyList) { var totalList = [] + var dateList = [] historyList.forEach((item, index) => { totalList.push(item.total) + dateList.push(item.date.substr(5)) }) this.lineChartData.totalHistoryData = totalList.reverse() + this.lineChartData.xAxis = dateList.reverse() // console.log(this.lineChartData.totalHistoryData) } // getLogStatisticHistory() {