vue-echarts画深度图

vue-echarts画深度图安装vue-echarts依赖cnpminstallvue-echarts–save按需引入vue-echarts绘制深度图全局引入会将所有的echarts图表打包,导致体积过大,这里推荐按需引入。<template><div><h2>深度图</h2><e-chartsauto-res…

大家好,又见面了,我是你们的朋友全栈君。

安装vue-echarts依赖

cnpm install vue-echarts --save

按需引入vue-echarts绘制深度图

全局引入会将所有的echarts图表打包,导致体积过大,这里推荐按需引入。

<template>
  <div>
    <h2>深度图</h2>
    <e-charts auto-resize :options="deptChartOption" @legendselectchanged="legendSelectChanged"></e-charts>
  </div>
</template>

<script> import ECharts from 'vue-echarts/components/ECharts'; require('echarts/lib/chart/line'); require('echarts/lib/component/tooltip'); require('echarts/lib/component/legendScroll'); export default { components: {ECharts}, data() { return { deptChartOption: { grid: {left: 10, top: 30, right: 10, bottom: 10}, tooltip: { confine: true, trigger: 'axis', axisPointer: {type: 'line', lineStyle: {color: 'rgba(0, 0, 0, 0)'}}, backgroundColor: '#355475', textStyle: {color: '#fff', fontSize: '14px'}, extraCssText: 'box-shadow: 0 0 16px 0 rgba(0, 0, 0, .2);border-radius: 4px;' }, legend: { data: [ {name: '买单', icon: 'rect'}, {name: '卖单', icon: 'rect'} ], selected: { '买单': true, '卖单': true }, itemWidth: 10, itemHeight: 10, textStyle: {color: '#fff'}, pageIconColor: '#4CC453' }, xAxis: { type: 'category', axisLine: {show: false}, axisTick: {show: false}, axisLabel: {show: false}, boundaryGap: false, data: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] }, yAxis: [{ type: 'value', axisLine: {show: false}, axisTick: {show: false}, axisLabel: {show: false}, splitLine: {show: false} }], series: [ { name: '买单', type: 'line', smooth: true, symbol: 'circle', showSymbol: false, symbolSize: 3, sampling: 'average', itemStyle: {normal: {color: '#4cc453'}}, lineStyle: {normal: {color: '#243235'}}, areaStyle: {color: '#243235'}, data: [10, 9, 8, 5, 1, '', '', '', '', ''] }, { name: '卖单', type: 'line', smooth: true, symbol: 'circle', showSymbol: false, symbolSize: 3, sampling: 'average', itemStyle: {normal: {color: '#e94c4c'}}, lineStyle: {normal: {color: '#392332'}}, areaStyle: {color: '#392332'}, data: ['', '', '', '', '', 0, 2, 3, 6, 8] } ] } }; }, mounted() { this.deptChartOption.tooltip.formatter = this.deptChartHover; }, methods: { legendSelectChanged(obj) { const selected = obj.selected; if (selected) { this.deptChartOption.legend.selected[obj.name] = selected[obj.name]; } }, deptChartHover(value) { let result = ''; value.map(item => { if (item.value !== '') { result = value[0].axisValue + item.value; } }); return result; } } }; </script>

其它样式调整可详见echarts官网的配置项手册。 —— [ echarts配置项手册 ]

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/144782.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号