diff --git a/src/router/index.js b/src/router/index.js index 883ea2d..a14773d 100644 --- a/src/router/index.js +++ b/src/router/index.js @@ -68,7 +68,7 @@ export const constantRoutes = [ children: [ { path: 'index', - component: () => import('@/views/index'), + component: () => import('@/views/index.vue'), name: 'Index', meta: { title: '首页', icon: 'dashboard', affix: true } } diff --git a/src/views/dashboard/LineAreaChart.vue b/src/views/dashboard/LineAreaChart.vue new file mode 100644 index 0000000..7df20c1 --- /dev/null +++ b/src/views/dashboard/LineAreaChart.vue @@ -0,0 +1,114 @@ + + + diff --git a/src/views/dashboard/LineChart.vue b/src/views/dashboard/LineChart.vue index 702ff73..aaeb4d7 100644 --- a/src/views/dashboard/LineChart.vue +++ b/src/views/dashboard/LineChart.vue @@ -61,18 +61,29 @@ export default { this.chart = echarts.init(this.$el, 'macarons') this.setOptions(this.chartData) }, - setOptions({ expectedData, actualData } = {}) { + setOptions(data={}) { + let series = [] + data.data.forEach((item,idx) => { + series.push({ + name: data.legend[idx], + smooth: true, + type: 'line', + data: item, + animationDuration: 2800, + animationEasing: idx%2 === 0 ? 'cubicInOut': 'quadraticOut' + }) + }) this.chart.setOption({ xAxis: { - data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + data: data.xAxis, boundaryGap: false, axisTick: { show: false } }, grid: { - left: 10, - right: 10, + left: 15, + right: 35, bottom: 20, top: 30, containLabel: true @@ -90,44 +101,9 @@ export default { } }, legend: { - data: ['expected', 'actual'] + data: data.legend }, - series: [{ - name: 'expected', itemStyle: { - normal: { - color: '#FF005A', - lineStyle: { - color: '#FF005A', - width: 2 - } - } - }, - smooth: true, - type: 'line', - data: expectedData, - animationDuration: 2800, - animationEasing: 'cubicInOut' - }, - { - name: 'actual', - smooth: true, - type: 'line', - itemStyle: { - normal: { - color: '#3888fa', - lineStyle: { - color: '#3888fa', - width: 2 - }, - areaStyle: { - color: '#f3f8ff' - } - } - }, - data: actualData, - animationDuration: 2800, - animationEasing: 'quadraticOut' - }] + series: series }) } } diff --git a/src/views/dashboard/OptionBar.vue b/src/views/dashboard/OptionBar.vue new file mode 100644 index 0000000..49c76b3 --- /dev/null +++ b/src/views/dashboard/OptionBar.vue @@ -0,0 +1,82 @@ + + + diff --git a/src/views/dashboard/PieChart.vue b/src/views/dashboard/PieChart.vue index 63f0d84..0b98565 100644 --- a/src/views/dashboard/PieChart.vue +++ b/src/views/dashboard/PieChart.vue @@ -21,6 +21,10 @@ export default { height: { type: String, default: '300px' + }, + chartData:{ + type: Object, + required: true } }, data() { @@ -42,32 +46,35 @@ export default { }, methods: { initChart() { + if(this.chart) this.chart.dispose() this.chart = echarts.init(this.$el, 'macarons') - + this.setOptions(this.chartData) + }, + setOptions(data={}) { + let seriesData = [] + data.data[0].forEach((item,idx) => { + seriesData.push({value: item, name: data.legend[idx]}) + }) this.chart.setOption({ + title: { + text: '交易类型图', + left: 'center' + }, tooltip: { trigger: 'item', - formatter: '{a}
{b} : {c} ({d}%)' + formatter: '{b} : {c} ({d}%)' }, legend: { left: 'center', bottom: '10', - data: ['Industries', 'Technology', 'Forex', 'Gold', 'Forecasts'] + data: data.legend }, series: [ { - name: 'WEEKLY WRITE ARTICLES', type: 'pie', - roseType: 'radius', radius: [15, 95], - center: ['50%', '38%'], - data: [ - { value: 320, name: 'Industries' }, - { value: 240, name: 'Technology' }, - { value: 149, name: 'Forex' }, - { value: 100, name: 'Gold' }, - { value: 59, name: 'Forecasts' } - ], + center: ['50%', '50%'], + data: seriesData, animationEasing: 'cubicInOut', animationDuration: 2600 } diff --git a/src/views/dashboard/commonChart.vue b/src/views/dashboard/commonChart.vue new file mode 100644 index 0000000..d9eff80 --- /dev/null +++ b/src/views/dashboard/commonChart.vue @@ -0,0 +1,146 @@ + + + diff --git a/src/views/index.vue b/src/views/index.vue index 83b651f..4837ba7 100644 --- a/src/views/index.vue +++ b/src/views/index.vue @@ -5,20 +5,149 @@

{{ $t('index.title') }}

- + + + + +
+ + + + +
+
+
+
+ + + + + + + + + + + + + + + + + + + +