From 7300d95f31541f13f28f822364f8c0d4e00e4fd1 Mon Sep 17 00:00:00 2001 From: Bowen Date: Mon, 24 Sep 2018 19:32:20 +0800 Subject: [PATCH] feat: chart layout in analysis tab --- mock/chart.js | 2 +- src/components/AnalysisTab.vue | 80 +++++++++++++++++++++++++++++++--- src/view/Analysis/index.vue | 21 ++++----- 3 files changed, 85 insertions(+), 18 deletions(-) diff --git a/mock/chart.js b/mock/chart.js index 0d4af7f..1c4a43b 100644 --- a/mock/chart.js +++ b/mock/chart.js @@ -15,7 +15,7 @@ const randomData = [] for (let i = 0; i < 12; i++) { randomData.push({ month: `${i + 1}月`, - totalSales: Math.floor(Math.random() * 1000) + 200 + total: Math.floor(Math.random() * 1000) + 200 }) } diff --git a/src/components/AnalysisTab.vue b/src/components/AnalysisTab.vue index 6821c97..0b900e8 100644 --- a/src/components/AnalysisTab.vue +++ b/src/components/AnalysisTab.vue @@ -1,12 +1,50 @@ @@ -24,7 +62,20 @@ export default { data () { return { - activeTab: 'totalSales' + activeTab: 'totalSales', + chartOptions: { + responsive: true, + maintainAspectRatio: false, + scales: { + xAxes: [{ + display: true + }], + yAxes: [{ + display: true + }] + } + // scaleShowLabels: false + } } }, @@ -35,7 +86,7 @@ export default { const chartData = [...this.chartData] for (const point of chartData) { labels.push(point.month) - datasets.push(point.totalSales) + datasets.push(point.total) } return { labels, @@ -55,4 +106,19 @@ export default { &__tab padding: 16px background-color: white + font-size: 14px + +.chart__title, .rank__title + margin-top: 0 + margin-bottom: 20px + color: rgba(0,0,0,.85) + font-weight: 500 + +.chart + &__body + height: 290px + +/deep/ .el-tabs__header + margin-bottom: 24px + diff --git a/src/view/Analysis/index.vue b/src/view/Analysis/index.vue index 98b0228..082f70e 100644 --- a/src/view/Analysis/index.vue +++ b/src/view/Analysis/index.vue @@ -1,7 +1,7 @@