diff --git a/src/assets/echarts-macarons.js b/src/assets/echarts-macarons.js new file mode 100644 index 0000000000000000000000000000000000000000..0678ef830d0118d62410aa11e934ecb441ebdcf6 --- /dev/null +++ b/src/assets/echarts-macarons.js @@ -0,0 +1,199 @@ +/* eslint-disable */ +(function (root, factory) { + if (typeof define === 'function' && define.amd) { + // AMD. Register as an anonymous module. + define(['exports', 'echarts'], factory); + } else if (typeof exports === 'object' && typeof exports.nodeName !== 'string') { + // CommonJS + factory(exports, require('echarts')); + } else { + // Browser globals + factory({}, root.echarts); + } +}(this, function (exports, echarts) { + var log = function (msg) { + if (typeof console !== 'undefined') { + console && console.error && console.error(msg); + } + }; + if (!echarts) { + log('ECharts is not Loaded'); + return; + } + + var colorPalette = [ + '#2ec7c9','#b6a2de','#5ab1ef','#ffb980','#d87a80', + '#8d98b3','#e5cf0d','#97b552','#95706d','#dc69aa', + '#07a2a4','#9a7fd1','#588dd5','#f5994e','#c05050', + '#59678c','#c9ab00','#7eb00a','#6f5553','#c14089' + ]; + + + var theme = { + color: colorPalette, + + title: { + textStyle: { + fontWeight: 'normal', + color: '#008acd' + } + }, + + visualMap: { + itemWidth: 15, + color: ['#5ab1ef','#e0ffff'] + }, + + toolbox: { + iconStyle: { + normal: { + borderColor: colorPalette[0] + } + } + }, + + tooltip: { + backgroundColor: 'rgba(50,50,50,0.5)', + axisPointer : { + type : 'line', + lineStyle : { + color: '#008acd' + }, + crossStyle: { + color: '#008acd' + }, + shadowStyle : { + color: 'rgba(200,200,200,0.2)' + } + } + }, + + dataZoom: { + dataBackgroundColor: '#efefff', + fillerColor: 'rgba(182,162,222,0.2)', + handleColor: '#008acd' + }, + + grid: { + borderColor: '#eee' + }, + + categoryAxis: { + axisLine: { + lineStyle: { + color: '#008acd' + } + }, + splitLine: { + lineStyle: { + color: ['#eee'] + } + } + }, + + valueAxis: { + axisLine: { + lineStyle: { + color: '#008acd' + } + }, + splitArea : { + show : true, + areaStyle : { + color: ['rgba(250,250,250,0.1)','rgba(200,200,200,0.1)'] + } + }, + splitLine: { + lineStyle: { + color: ['#eee'] + } + } + }, + + timeline : { + lineStyle : { + color : '#008acd' + }, + controlStyle : { + normal : { color : '#008acd'}, + emphasis : { color : '#008acd'} + }, + symbol : 'emptyCircle', + symbolSize : 3 + }, + + line: { + smooth : true, + symbol: 'emptyCircle', + symbolSize: 3 + }, + + candlestick: { + itemStyle: { + normal: { + color: '#d87a80', + color0: '#2ec7c9', + lineStyle: { + color: '#d87a80', + color0: '#2ec7c9' + } + } + } + }, + + scatter: { + symbol: 'circle', + symbolSize: 4 + }, + + map: { + label: { + normal: { + textStyle: { + color: '#d87a80' + } + } + }, + itemStyle: { + normal: { + borderColor: '#eee', + areaColor: '#ddd' + }, + emphasis: { + areaColor: '#fe994e' + } + } + }, + + graph: { + color: colorPalette + }, + + gauge : { + axisLine: { + lineStyle: { + color: [[0.2, '#2ec7c9'],[0.8, '#5ab1ef'],[1, '#d87a80']], + width: 10 + } + }, + axisTick: { + splitNumber: 10, + length :15, + lineStyle: { + color: 'auto' + } + }, + splitLine: { + length :22, + lineStyle: { + color: 'auto' + } + }, + pointer : { + width : 5 + } + } + }; + + echarts.registerTheme('macarons', theme); +})); diff --git a/src/components/Charts/barPercent.vue b/src/components/Charts/barPercent.vue deleted file mode 100644 index e82422fe759c8d2ab0acef683c18c2293468995c..0000000000000000000000000000000000000000 --- a/src/components/Charts/barPercent.vue +++ /dev/null @@ -1,104 +0,0 @@ -<template> - <div :class="className" :id="id" :style="{height:height,width:width}"></div> -</template> -<script> - // 引入 ECharts ä¸»æ¨¡å— - const echarts = require('echarts/lib/echarts'); - // 引入柱状图 - require('echarts/lib/chart/bar'); - // 引入æç¤ºæ¡†å’Œæ ‡é¢˜ç»„ä»¶ - require('echarts/lib/component/tooltip'); - export default { - name: 'barPercent', - props: { - className: { - type: String, - default: 'bar-percent-chart' - }, - id: { - type: String, - default: 'bar-percent-chart' - }, - width: { - type: String, - default: '100px' - }, - height: { - type: String, - default: '80px' - }, - dataNum: { - type: Number, - default: 0 - } - }, - data() { - return { - chart: null - }; - }, - watch: { - dataNum() { - this.setOptions() - } - }, - mounted() { - this.initBar(); - }, - methods: { - initBar() { - this.chart = echarts.init(document.getElementById(this.id)); - this.setOptions(); - }, - setOptions() { - this.chart.setOption({ - tooltip: { - show: true, - formatter(params) { - return '已完æˆ' + params.value + '篇<br/>ç›®æ ‡90篇<br/>完æˆè¿›åº¦' + Math.round((params.value / 90) * 100) + '%' - } - }, - grid: { - left: 0, - right: 0, - bottom: 0, - top: 0, - containLabel: false - }, - xAxis: [{ - type: 'category', - data: ['æ–‡ç« å®Œæˆæ¯”例'] - }], - yAxis: [{ - type: 'value', - data: [], - show: false - }], - animationDelay: 1000, - series: [{ - type: 'bar', - name: 'åˆè¯Š', - itemStyle: { - normal: { - color: '#e5e5e5' - } - }, - silent: true, - barGap: '-100%', // Make series be overlap - data: [150] - }, { - type: 'bar', - name: 'app', - itemStyle: { - normal: { - color: '#30b08f' - } - }, - z: 10, - data: [this.dataNum] - }] - }) - } - } - } -</script> diff --git a/src/components/Charts/line.vue b/src/components/Charts/line.vue deleted file mode 100644 index ab416c76f94f6014e9e75c027aa4ebeb7ac880f1..0000000000000000000000000000000000000000 --- a/src/components/Charts/line.vue +++ /dev/null @@ -1,146 +0,0 @@ -<template> - <div :class="className" :id="id" :style="{height:height,width:width}"></div> -</template> -<script> - // 引入 ECharts ä¸»æ¨¡å— - const echarts = require('echarts/lib/echarts'); - // 引入图 - require('echarts/lib/chart/line'); - // 引入æç¤ºæ¡†å’Œæ ‡é¢˜ç»„ä»¶ - require('echarts/lib/component/markLine'); - require('echarts/lib/component/markPoint'); - require('echarts/lib/component/tooltip'); - export default { - name: 'lineChart', - props: { - className: { - type: String, - default: 'line-chart' - }, - id: { - type: String, - default: 'line-chart' - }, - width: { - type: String, - default: '100%' - }, - height: { - type: String, - default: '280px' - }, - listData: { - type: Array, - require: true - } - }, - data() { - return { - chart: null - }; - }, - watch: { - listData(dataList) { - this.setLine(dataList) - } - }, - mounted() { - this.chart = echarts.init(document.getElementById(this.id)); - this.setLine(this.listData); - }, - methods: { - setLine(dataList) { - const xAxisData = []; - const data = []; - for (let i = 0; i < dataList.length; i++) { - const item = dataList[i] - xAxisData.push(item.week.substring(item.week.length - 2) + '周'); - data.push(item.count) - } - const markLineData = []; - for (let i = 1; i < data.length; i++) { - markLineData.push([{ - xAxis: i - 1, - yAxis: data[i - 1], - value: data[i] - data[i - 1] - }, { - xAxis: i, - yAxis: data[i] - }]); - } - this.chart.setOption({ - title: { - text: 'Awesome Chart' - }, - grid: { - left: 0, - right: 0, - bottom: 20, - - containLabel: true - }, - tooltip: { - trigger: 'axis' - }, - animationDelay: 1000, - xAxis: { - data: xAxisData, - axisLine: { - show: false - }, - axisTick: { - show: false - } -// axisLabel:{ -// show:false -// }, - }, - - yAxis: { - splitLine: { - show: false - }, - show: false - // min: 90 - }, - series: [{ - name: '撸文数', - type: 'line', - data, - markPoint: { - data: [ - { type: 'max', name: '最大值' }, - { type: 'min', name: '最å°å€¼' } - ] - }, - itemStyle: { - normal: { - color: '#30b08f' - } - }, - markLine: { - silent: true, - smooth: true, - effect: { - show: true - }, - animationDuration(idx) { - return idx * 100; - }, - animationDelay: 1000, - animationEasing: 'quadraticInOut', - distance: 1, - label: { - normal: { - position: 'middle' - } - }, - symbol: ['none', 'none'], - data: markLineData - } - }] - }) - } - } - } -</script> diff --git a/src/styles/index.scss b/src/styles/index.scss index 5bf93a899e2afe5f34996126c60120dc2715dc3a..79fda7e9cd7d0cb6ed178b97ae0b042a2d29f64d 100644 --- a/src/styles/index.scss +++ b/src/styles/index.scss @@ -96,6 +96,7 @@ code { opacity: 0; } + //main-containerå…¨å±€æ ·å¼ .app-container { padding: 20px; @@ -112,6 +113,9 @@ code { height: 100%!important; } +.text-center{ + text-align: center +} .wscn-icon { width: 1em; height: 1em; diff --git a/src/views/dashboard/editor/articlesChart.vue b/src/views/dashboard/editor/articlesChart.vue deleted file mode 100644 index a62e19620ae77f50b8158f16cc80a4281682012b..0000000000000000000000000000000000000000 --- a/src/views/dashboard/editor/articlesChart.vue +++ /dev/null @@ -1,34 +0,0 @@ -<template> - <div class="articlesChart-container"> - <span class="articlesChart-container-title">æ¯å¤©æ’¸æ–‡</span> - <line-chart :listData='listData' ></line-chart> - </div> -</template> -<script> - import LineChart from 'components/Charts/line'; - export default { - name: 'articlesChart', - components: { LineChart }, - props: { - listData: { - type: Array, - default: [], - require: true - } - }, - data() { - return {} - } - } -</script> -<style> - .articlesChart-container { - width: 100%; - } - .articlesChart-container-title { - color: #7F8C8D; - font-size: 16px; - display: inline-block; - margin-top: 10px; - } -</style> diff --git a/src/views/dashboard/editor/barChart.vue b/src/views/dashboard/editor/barChart.vue new file mode 100644 index 0000000000000000000000000000000000000000..dcbb357ac64b5b2400267c4065499bd1b6a9f882 --- /dev/null +++ b/src/views/dashboard/editor/barChart.vue @@ -0,0 +1,88 @@ +<template> + <div :class="className" :style="{height:height,width:width}"></div> +</template> +<script> + import echarts from 'echarts'; + require('echarts/theme/macarons'); // echarts 主题 + + export default { + props: { + className: { + type: String, + default: 'chart' + }, + width: { + type: String, + default: '100%' + }, + height: { + type: String, + default: '300px' + } + }, + data() { + return { + chart: null + }; + }, + mounted() { + this.initChart(); + }, + beforeDestroy() { + if (!this.chart) { + return + } + this.chart.dispose(); + this.chart = null; + }, + methods: { + initChart() { + this.chart = echarts.init(this.$el, 'macarons'); + + this.chart.setOption({ + tooltip: { + trigger: 'axis', + axisPointer: { // åæ ‡è½´æŒ‡ç¤ºå™¨ï¼Œåæ ‡è½´è§¦å‘有效 + type: 'shadow' // 默认为直线,å¯é€‰ä¸ºï¼š'line' | 'shadow' + } + }, + grid: { + left: '3%', + right: '4%', + bottom: '3%', + containLabel: true + }, + xAxis: [{ + type: 'category', + data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'], + axisTick: { + alignWithLabel: true + } + }], + yAxis: [{ + type: 'value' + }], + series: [{ + name: 'pageA', + type: 'bar', + stack: 'vistors', + barWidth: '60%', + data: [79, 52, 200, 334, 390, 330, 220] + }, { + name: 'pageB', + type: 'bar', + stack: 'vistors', + barWidth: '60%', + data: [80, 52, 200, 334, 390, 330, 220] + }, { + name: 'pageC', + type: 'bar', + stack: 'vistors', + barWidth: '60%', + data: [30, 52, 200, 334, 390, 330, 220] + }] + }) + } + } +} +</script> diff --git a/src/views/dashboard/editor/index.vue b/src/views/dashboard/editor/index.vue index 452070ff25fbda2b7cadc0acabd9fb9bfefd4b87..9c05c97eb515e499d86e6dd33e1a5df7b3c1d5da 100644 --- a/src/views/dashboard/editor/index.vue +++ b/src/views/dashboard/editor/index.vue @@ -1,55 +1,91 @@ <template> <div class="dashboard-editor-container"> - <div class=" clearfix"> - <PanThumb style="float: left" :image="avatar"> ä½ çš„æƒé™: - <span class="pan-info-roles" v-for="item in roles">{{item}}</span> - </PanThumb> - <a href="https://github.com/PanJiaChen/vue-element-admin" target="_blank" class="github-corner" aria-label="View source on Github"> - <svg width="80" height="80" viewBox="0 0 250 250" style="fill:#4AB7BD; color:#fff; position: absolute; top: 50px; border: 0; right: 0;" + <a href="https://github.com/PanJiaChen/vue-element-admin" target="_blank" class="github-corner" aria-label="View source on Github"> + <svg width="80" height="80" viewBox="0 0 250 250" style="fill:#4AB7BD; color:#fff; position: absolute; top: 50px; border: 0; right: 0;" aria-hidden="true"> <path d="M0,0 L115,115 L130,115 L142,142 L250,250 L250,0 Z"></path> <path d="M128.3,109.0 C113.8,99.7 119.0,89.6 119.0,89.6 C122.0,82.7 120.5,78.6 120.5,78.6 C119.2,72.0 123.4,76.3 123.4,76.3 C127.3,80.9 125.5,87.3 125.5,87.3 C122.9,97.6 130.6,101.9 134.4,103.2" fill="currentColor" style="transform-origin: 130px 106px;" class="octo-arm"></path> - <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z"fill="currentColor" class="octo-body"></path> - </svg> - </a> - <div class="info-container"> - <span class="display_name">{{name}}</span> - <div class="info-wrapper"> + <path d="M115.0,115.0 C114.9,115.1 118.7,116.5 119.8,115.4 L133.7,101.6 C136.9,99.2 139.9,98.4 142.2,98.6 C133.8,88.0 127.5,74.4 143.8,58.0 C148.5,53.4 154.0,51.2 159.7,51.0 C160.3,49.4 163.2,43.6 171.4,40.1 C171.4,40.1 176.1,42.5 178.8,56.2 C183.1,58.6 187.2,61.8 190.9,65.4 C194.5,69.0 197.7,73.2 200.1,77.6 C213.8,80.2 216.3,84.9 216.3,84.9 C212.7,93.1 206.9,96.0 205.4,96.6 C205.1,102.4 203.0,107.8 198.3,112.5 C181.9,128.9 168.3,122.5 157.7,114.1 C157.9,116.9 156.7,120.9 152.7,124.9 L141.0,136.5 C139.8,137.7 141.6,141.9 141.8,141.8 Z" + fill="currentColor" class="octo-body"></path> + </svg> + </a> + <div class="btn-group"> + <el-row> + <el-col :span="4" class='text-center'> + <router-link class="pan-btn blue-btn" to="/components/index">Components</router-link> + </el-col> + <el-col :span="4" class='text-center'> + <router-link class="pan-btn light-blue-btn" to="/charts/index">Charts</router-link> + </el-col> + <el-col :span="4" class='text-center'> + <router-link class="pan-btn pink-btn" to="/excel/download">Export Excel</router-link> + </el-col> + <el-col :span="4" class='text-center'> + <router-link class="pan-btn green-btn" to="/example/table/table">Table</router-link> + </el-col> + <el-col :span="4" class='text-center'> + <router-link class="pan-btn tiffany-btn" to="/example/form/edit">Form</router-link> + </el-col> + <el-col :span="4" class='text-center'> + <router-link class="pan-btn yellow-btn" to="/example/form/edit">Theme</router-link> + </el-col> + </el-row> + + </div> + <el-row> + <el-col :span="6"> + + <el-card class="box-card"> + <div slot="header" class="clearfix"> + <pan-thumb style="float: left" :image="avatar"> ä½ çš„æƒé™: + <span class="pan-info-roles" v-for="item in roles">{{item}}</span> + </pan-thumb> + </div> + <span class="display_name">{{name}}</span> <div class="info-item" :to="'/article/wscnlist?uid='+uid"> - <countTo class="info-item-num" :startVal='0' :endVal='statisticsData.article_count' :duration='3400'></countTo> + <countTo class="info-item-num" :startVal='0' :endVal='statisticsData.article_count' :duration='3400'></countTo> <span class="info-item-text">æ–‡ç« </span> - <wscn-icon-svg icon-class="a" class="dashboard-editor-icon"/> + <wscn-icon-svg icon-class="a" class="dashboard-editor-icon" /> </div> <div class="info-item" style="cursor: auto"> - <countTo class="info-item-num" :startVal='0' :endVal='statisticsData.pageviews_count' :duration='3600'></countTo> + <countTo class="info-item-num" :startVal='0' :endVal='statisticsData.pageviews_count' :duration='3600'></countTo> <span class="info-item-text">æµè§ˆé‡</span> - <wscn-icon-svg icon-class="b" class="dashboard-editor-icon"/> + <wscn-icon-svg icon-class="b" class="dashboard-editor-icon" /> </div> <div class="info-item" :to="'/comment/commentslist?res_author_id='+uid"> - <countTo class="info-item-num" ref='countTo3' :startVal='0' :endVal='statisticsData.comment_count' :duration='3800'></countTo> + <countTo class="info-item-num" ref='countTo3' :startVal='0' :endVal='statisticsData.comment_count' :duration='3800'></countTo> <span class="info-item-text">评论</span> - <wscn-icon-svg icon-class="c" class="dashboard-editor-icon"/> + <wscn-icon-svg icon-class="c" class="dashboard-editor-icon" /> </div> - </div> + + </el-card> + + </el-col> + <el-col :span="8"> + <pie-chart></pie-chart> + </el-col> + + <el-col :span="10"> + <bar-chart></bar-chart> + </el-col> + + </el-row> + <el-row> + <el-col :span="16"> + <line-chart></line-chart> + </el-col> + </el-row> + + <div class="info-container"> + + <div class="info-wrapper"> + </div> </div> - <div class="btn-group"> - <router-link class="pan-btn blue-btn" to="/components/index">组件</router-link> - <router-link class="pan-btn light-blue-btn" to="/charts/index">图表</router-link> - <router-link class="pan-btn red-btn" to="/errorpage/404">错误页é¢</router-link> - <router-link class="pan-btn pink-btn" to="/excel/download">导出excel</router-link> - <router-link class="pan-btn green-btn" to="/example/table/table">Table</router-link> - <router-link class="pan-btn tiffany-btn" to="/example/form/edit">Form</router-link> - </div> + <!--<div class="clearfix main-dashboard-container"> - <div class="clearfix main-dashboard-container"> - <div class="chart-container"> - <MonthKpi style="border-bottom: 1px solid #DEE1E2;" - :articlesComplete='statisticsData.month_article_count'></MonthKpi> - <ArticlesChart :listData='statisticsData.week_article'></ArticlesChart> - </div> <div class="recent-articles-container"> <div class="recent-articles-title">最近撸了</div> <div class="recent-articles-wrapper"> @@ -67,20 +103,21 @@ </template> </div> </div> - </div> + </div>--> </div> </template> <script> import { mapGetters } from 'vuex'; import PanThumb from 'components/PanThumb'; - import MonthKpi from './monthKpi'; - import ArticlesChart from './articlesChart'; + import pieChart from './pieChart'; + import barChart from './barChart'; + import lineChart from './lineChart'; import { getList } from 'api/article'; import countTo from 'vue-count-to'; export default { name: 'dashboard-editor', - components: { PanThumb, MonthKpi, ArticlesChart, countTo }, + components: { PanThumb, countTo, pieChart, lineChart, barChart }, data() { return { chart: null, @@ -145,151 +182,7 @@ </script> <style rel="stylesheet/scss" lang="scss" scoped> - .recent-articles-emptyTitle { - font-size: 16px; - color: #95A5A6; - padding-top: 20px; - text-align: center; - } - - .dashboard-editor-container { - padding: 30px 50px; - .pan-info-roles { - font-size: 12px; - font-weight: 700; - color: #333; - display: block; - } - .info-container { - position: relative; - margin-left: 190px; - height: 150px; - line-height: 200px; - .display_name { - font-size: 48px; - line-height: 48px; - color: #212121; - position: absolute; - top: 25px; - } - .info-wrapper { - line-height: 40px; - position: absolute; - bottom: 0px; - .info-item { - cursor: pointer; - display: inline-block; - margin-right: 95px; - .info-item-num { - color: #212121; - font-size: 24px; - display: inline-block; - padding-right: 5px; - } - .info-item-text { - color: #727272; - font-size: 14px; - padding-right: 5px; - display: inline-block; - } - } - } - .dashboard-editor-icon { - width: 22px; - height: 22px; - } - } - - .btn-group { - margin: 30px 36px 30px 0; - } - .main-dashboard-container { - width: 100%; - position: relative; - border: 1px solid #DEE1E2; - padding: 0 10px; - } - .chart-container { - float: left; - position: relative; - padding-right: 10px; - width: 40%; - border-right: 1px solid #DEE1E2; - } - .recent-articles-container { - padding: 12px 12px 0px; - float: left; - width: 60%; - position: relative; - .recent-articles- { - &title { - font-size: 16px; - color: #95A5A6; - letter-spacing: 1px; - padding-left: 15px; - padding-bottom: 10px; - border-bottom: 1px solid #DEE1E2; - } - &more { - color: #2C3E50; - font-size: 12px; - float: right; - margin-right: 25px; - line-height: 40px; - &:hover { - color: #3A71A8; - } - } - &wrapper { - padding: 0 20px 0 22px; - .recent-articles- { - &item { - cursor: pointer; - padding: 16px 100px 16px 16px; - border-bottom: 1px solid #DEE1E2; - position: relative; - &:before { - content: ""; - height: 104%; - width: 0px; - background: #30B08F; - display: inline-block; - position: absolute; - opacity: 0; - left: 0px; - top: -2px; - transition: 0.3s ease all; - } - &:hover { - &:before { - opacity: 1; - width: 3px; - } - } - } - &status { - font-size: 12px; - display: inline-block; - color: #9B9B9B; - padding-right: 6px; - } - &content { - font-size: 13px; - color: #2C3E50; - &:hover { - color: #3A71A8; - } - } - &time { - position: absolute; - right: 16px; - top: 16px; - color: #9B9B9B; - } - } - } - } - - } - } +.dashboard-editor-container{ + margin: 30px; +} </style> diff --git a/src/views/dashboard/editor/lineChart.vue b/src/views/dashboard/editor/lineChart.vue new file mode 100644 index 0000000000000000000000000000000000000000..7ebd72b0a379d8416a3d11b3182204b053ec3477 --- /dev/null +++ b/src/views/dashboard/editor/lineChart.vue @@ -0,0 +1,93 @@ +<template> + <div :class="className" :style="{height:height,width:width}"></div> +</template> +<script> + import echarts from 'echarts'; + require('echarts/theme/macarons'); // echarts 主题 + + export default { + props: { + className: { + type: String, + default: 'chart' + }, + width: { + type: String, + default: '100%' + }, + height: { + type: String, + default: '300px' + } + }, + data() { + return { + chart: null + }; + }, + mounted() { + this.initChart(); + }, + beforeDestroy() { + if (!this.chart) { + return + } + this.chart.dispose(); + this.chart = null; + }, + methods: { + initChart() { + this.chart = echarts.init(this.$el, 'macarons'); + + this.chart.setOption({ + xAxis: { + data: ['Sunday', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday'], + boundaryGap: false + }, + grid: { + left: 0, + right: 0, + bottom: 20, + containLabel: true + }, + + tooltip: { + trigger: 'axis', + axisPointer: { + type: 'cross' + } + }, + yAxis: {}, + series: [{ + name: 'vistor', + itemStyle: { + normal: { + areaStyle: {} + } + }, + smooth: true, + type: 'line', + data: [100, 120, 161, 134, 105, 160, 165] + }, + { + name: 'buyer', + smooth: true, + type: 'line', + itemStyle: { + normal: { + color: 'rgba(2, 197, 233, 0.2)', + lineStyle: { + color: 'rgba(2, 197, 233, 0.2)' + }, + areaStyle: { + color: 'rgba(99,194,255, 0.6)' + } + } + }, + data: [120, 82, 91, 154, 162, 140, 130] + }] + }) + } + } +} +</script> diff --git a/src/views/dashboard/editor/monthKpi.vue b/src/views/dashboard/editor/monthKpi.vue deleted file mode 100644 index 7fdd75014ca715feff48b4eeae07c0639447fb22..0000000000000000000000000000000000000000 --- a/src/views/dashboard/editor/monthKpi.vue +++ /dev/null @@ -1,61 +0,0 @@ -<template> - <div class="monthKpi-container"> - <span class="monthKpi-container-title">{{month}}月</span> - <BarPercent class="monthKpi-container-chart" :dataNum='articlesComplete'></BarPercent> - <span class="monthKpi-container-text">æ–‡ç« å®Œæˆæ¯”例</span> - <span class="monthKpi-container-count">{{articlesComplete}}<b>篇</b></span> - </div> -</template> - -<script> - import BarPercent from 'components/Charts/barPercent'; - export default { - name: 'monthKpi', - components: { BarPercent }, - props: { - articlesComplete: { - type: Number - } - }, - data() { - return { - month: new Date().getMonth() + 1 - } - } - } -</script> -<style rel="stylesheet/scss" lang="scss" scoped> - .monthKpi-container{ - width: 100%; - } - .monthKpi-container-title { - color: #7F8C8D; - font-size: 16px; - display: inline-block; - margin-top: 10px; - } - - .monthKpi-container-chart { - margin-left: 100px; - margin-bottom: 4px; - } - - .monthKpi-container-text { - margin-left: 112px; - color: #9EA7B3; - font-size: 12px; - } - - .monthKpi-container-count { - color: #30B08F; - font-size: 34px; - position: absolute; - left: 260px; - top: 60px; - b { - padding-left: 10px; - color: #9EA7B3; - font-size: 12px; - } - } -</style> diff --git a/src/views/dashboard/editor/pieChart.vue b/src/views/dashboard/editor/pieChart.vue new file mode 100644 index 0000000000000000000000000000000000000000..2b02a5d75fb37960f76c636777a6424fc1f8a880 --- /dev/null +++ b/src/views/dashboard/editor/pieChart.vue @@ -0,0 +1,76 @@ +<template> + <div :class="className" :style="{height:height,width:width}"></div> +</template> +<script> + import echarts from 'echarts'; + require('echarts/theme/macarons'); // echarts 主题 + + export default { + props: { + className: { + type: String, + default: 'chart' + }, + width: { + type: String, + default: '100%' + }, + height: { + type: String, + default: '300px' + } + }, + data() { + return { + chart: null + }; + }, + mounted() { + this.initChart(); + }, + beforeDestroy() { + if (!this.chart) { + return + } + this.chart.dispose(); + this.chart = null; + }, + methods: { + initChart() { + this.chart = echarts.init(this.$el, 'macarons'); + + this.chart.setOption({ + title: { + text: 'WEEKLY WRITE ARTICLES', + x: 'center' + }, + tooltip: { + trigger: 'item', + formatter: '{a} <br/>{b} : {c} ({d}%)' + }, + legend: { + x: 'center', + y: 'bottom', + data: ['industries', 'technology', 'gold', 'forex', 'forecasts', 'markets'] + }, + calculable: true, + series: [ + { + name: 'WEEKLY WRITE ARTICLES', + type: 'pie', + roseType: 'radius', + data: [ + { value: 320, name: 'industries' }, + { value: 240, name: 'technology' }, + { value: 149, name: 'forex' }, + { value: 100, name: 'gold' }, + { value: 59, name: 'forecastsx' }, + { value: 49, name: 'markets' } + ] + } + ] + }) + } + } +} +</script>