How to realize three-dimensional histogram with vue3.0+echarts
This article mainly explains "how to use vue3.0+echarts to achieve three-dimensional bar chart", the content of the article is simple and clear, easy to learn and understand, the following please follow the editor's ideas slowly in depth, together to study and learn "how to use vue3.0+echarts to achieve three-dimensional bar chart" bar!
Foreword:
Realization of echarts Stereo histogram by vue3.0
Achieve results:
Implementation steps:
1. Install echarts
Cnpm I-- save echarts
2. Page definition container
3. Introducing echarts into js
Export default {setup () {let state = reactive ({xAxisData: ['Hao Xing', 'Yan Zai', 'Doraemon','Li Qiang', 'Wang Ying', 'Lao Wang'), yAxisData: [4 var myChart 22, 11], yAxisData1: [1], echart: ref (),}) const echartInit = () = > {var myChart = echarts.init (state.echart) / / specify the configuration items and data of the chart var option = {tooltip: {trigger: "axis", axisPointer: {type: "shadow", / / default is straight line Optional: 'line' |' shadow'}, formatter: function (parms) {var str = parms [0] .axisValue + "" + parms [0] .value + "Login today:" + parms [0] .value + 'times' return str },}, textStyle: {color: "# 333",}, color: ["# 7BA9FA", "# 4690FA"], grid: {containLabel: true, left: "10%", top: "20%", bottom: "10%", right: "10%" }, xAxis: {type: "category", data: state.xAxisData, axisLine: {lineStyle: {color: "# 333",},}, axisTick: {show: false,}, axisLabel: {margin: 20 / / the distance between the scale label and the axis. TextStyle: {color: "# 000",}, yAxis: {type: "value", axisLine: {show: true, lineStyle: {color: "# B5B5B5",},} SplitLine: {lineStyle: {/ / use interval colors color: ["# B5B5B5"], type: "dashed", opacity: 0.5,},}, axisLabel: {},} Series: [{data: state.yAxisData, stack: "zs", type: "bar", barMaxWidth: "auto", barWidth: 60, itemStyle: {color: {x: 0, y: 0, x2: 0, y2: 1 Type: "linear", global: false, colorStops: [{offset: 0, color: "# 5EA1FF",}, {offset: 1, color: "# 90BEFF",},] }, / / the solid below, the color control is color's first {data: state.yAxisData1, type: "pictorialBar", barMaxWidth: "20", symbol: "diamond", symbolOffset: [0,50% "], symbolSize: [60 15], zlevel: 2,}, / / the solid above, the control color is color's second {data: state.yAxisData, type: "pictorialBar", barMaxWidth: "20", symbolPosition: "end", symbol: "diamond", symbolOffset: [0, "- 50%"] SymbolSize: [60, 12], zlevel: 2,}],} / / display the chart using the configuration items and data you just specified. MyChart.setOption (option);} / Mount onMounted (() = > {echartInit ()}) return {... toRefs (state), echartInit};}} .echartDiv {width: 100%; height: 400px Thank you for your reading, the above is the content of "how to use vue3.0+echarts to achieve three-dimensional histogram". After the study of this article, I believe you have a deeper understanding of how to use vue3.0+echarts to achieve three-dimensional histogram, and the specific use needs to be verified in practice. Here is, the editor will push for you more related knowledge points of the article, welcome to follow!