diff --git a/package.json b/package.json index 7ba8a51..096b8eb 100644 --- a/package.json +++ b/package.json @@ -67,6 +67,7 @@ "node-sass": "^4.14.1", "sass-loader": "8.0.0", "vue-axios": "2.1.4", + "vue-seamless-scroll": "^1.1.23", "vue-template-compiler": "2.6.10" }, "eslintConfig": { diff --git a/src/components/block/index.scss b/src/components/block/index.scss index 8d9d99b..67e7918 100644 --- a/src/components/block/index.scss +++ b/src/components/block/index.scss @@ -7,7 +7,7 @@ .icon { width: 80px; - height: 90px; + height: 100px; } .right { diff --git a/src/components/charts/line/index.html b/src/components/charts/line/index.html new file mode 100644 index 0000000..d60fced --- /dev/null +++ b/src/components/charts/line/index.html @@ -0,0 +1 @@ +
diff --git a/src/components/charts/line/index.js b/src/components/charts/line/index.js new file mode 100644 index 0000000..7a4df22 --- /dev/null +++ b/src/components/charts/line/index.js @@ -0,0 +1,184 @@ +import * as echarts from 'echarts'; +import elementResizeDetectorMaker from 'element-resize-detector'; +export default { + props: { + id: { + type: String, + default: 'line' + }, + data: { + type: Array, + default: function () { + return [ + { + name: '1月', + value: '10' + }, + { + name: '2月', + value: '19' + } + ]; + } + } + }, + data () { + return { + chart: null + }; + }, + mounted () { + this.initChart(); + }, + computed: { + }, + methods: { + // 设置监听器 页面尺寸变化重新绘制图表 + initResizeCallBack () { + const erd = elementResizeDetectorMaker(); + erd.listenTo(document.getElementById(this.id), () => { + this.$nextTick(() => { + this.chart.resize(); + }); + }); + }, + initChart () { + this.chart = echarts.init(document.getElementById(this.id)); + this.chartSetOption(); + }, + chartSetOption () { + let xAxisData = []; + let data = []; + this.data.forEach(item => { + xAxisData.push(item.name) + data.push(item.value) + }); + const option = { + grid: { + left: "5%", + right: "10%", + top: "15%", + bottom: "10%", + containLabel: true, + }, + tooltip: { + show: true, + trigger: "item", + }, + legend: { + show: false + }, + color: { + color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [ + { + offset: 1, + color: "rgba(134, 91, 252, 1)", + }, + { + offset: 0.5, + color: "rgba(26, 106, 226, 0.5)", + }, + { + offset: 0, + color: "rgba(26, 106, 226, 0)", + }, + ]), + }, + xAxis: [ + { + type: "category", + boundaryGap: false, + axisLabel: { + color: 'rgba(185, 211, 235, 1)', + }, + axisLine: { + show: false + }, + axisTick: { + show: false + }, + splitLine: { + show: false + }, + data: xAxisData + }, + ], + yAxis: [ + { + type: "value", + name: "单位:万元", + nameTextStyle: { + color: 'rgba(185, 211, 235, 1)' + }, + axisLabel: { + formatter: "{value}", + textStyle: { + color: "rgba(185, 211, 235, 1)", + }, + }, + axisLine: { + lineStyle: { + color: "#27b4c2", + }, + }, + axisTick: { + show: false, + }, + splitLine: { + show: true, + lineStyle: { + color: "#11366e", + }, + }, + } + ], + series: [ + { + + name: "", + type: "line", + smooth: true, + // symbol: "circle", + symbolSize: 12, + itemStyle: { + normal: { + color: "#0092f6", + lineStyle: { + color: "#0092f6", + width: 1, + }, + areaStyle: { + color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [ + { + offset: 1, + color: "rgba(134, 91, 252, 1)", + }, + { + offset: 0.5, + color: "rgba(26, 106, 226, 0.5)", + }, + { + offset: 0, + color: "rgba(26, 106, 226, 0)", + }, + ]), + }, + }, + }, + markPoint: { + itemStyle: { + normal: { + color: "red", + }, + }, + }, + data: data + } + ], + };; + this.chart.setOption(option); + this.initResizeCallBack(); + + } + } +}; diff --git a/src/components/charts/line/index.scss b/src/components/charts/line/index.scss new file mode 100644 index 0000000..b89d9dc --- /dev/null +++ b/src/components/charts/line/index.scss @@ -0,0 +1,6 @@ +.chart { + overflow: visible; + width: 100%; + height: 100%; + z-index: 2; +} \ No newline at end of file diff --git a/src/components/charts/line/index.vue b/src/components/charts/line/index.vue new file mode 100644 index 0000000..5ca257a --- /dev/null +++ b/src/components/charts/line/index.vue @@ -0,0 +1,3 @@ +