Preface:Vue3.0 implements echarts three-dimensional column chart Result:Implementation steps:1. Install echarts cnpm i --save echarts 2. Page definition container <template> <div ref="echart" class="echartDiv"></div> </template> 3. Introducing echarts into js import * as echarts from 'echarts'; Component complete source code:<template> <div ref="echart" class="echartDiv"></div> </template> <script> import * as echarts from 'echarts'; import { onMounted,toRefs, ref,reactive } from 'vue'; export default { setup(){ let state = reactive({ xAxisData:['Haoxing', 'Yanzi', 'Doraemon', 'Li Qiang', 'Wang Ying', 'Lao Wang'], yAxisData:[4,22,1,11,23,11], yAxisData1:[1,1,1,1,1,1], echart: ref(), }) const echartInit = () => { var myChart = echarts.init(state.echart); //Specify the chart's configuration items and data var option = { tooltip: { trigger: "axis", axisPointer: type: "shadow", // Default is a straight line, optional: 'line' | 'shadow' }, formatter: function(parms) { var str = parms[0].axisValue + "</br>" + parms[0].marker + "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 line. textStyle: { color: "#000", }, }, }, yAxis: { type: "value", axisLine: { show: true, lineStyle: color: "#B5B5B5", }, }, splitLine: { lineStyle: // Use light and dark 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 following three-dimensional, control color is the first color { data: state.yAxisData1, type: "pictorialBar", barMaxWidth: "20", symbol: "diamond", symbolOffset: [0, "50%"], symbolSize: [60, 15], zlevel: 2, }, //The above three-dimensional, the control color is the second color { 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 just specified. myChart.setOption(option); } //Mount onMounted(()=>{ echartInit() }) return { ...toRefs(state), echartInit }; } } </script> <style lang='scss' scoped> .echartDiv{ width: 100%; height: 400px; } </style> The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM. You may also be interested in:
|
<<: Detailed tutorial on how to deploy Springboot project using Nginx on the server (jar package)
>>: MySQL master-slave replication principle and practice detailed explanation
<br />When you click the link, the web page ...
Table of contents Install Redis on Docker 1. Find...
1. Modify the firewall configuration file # vi /e...
Copy code The code is as follows: <head> &l...
Table of contents 1. Script vim environment 2. Ho...
Preface: When we use Vue, we often use and write ...
Table of contents 1. LVS load balancing 2. Basic ...
When the Docker container exits, the file system ...
After installing the MySQL database using the rpm...
This article records the detailed installation pr...
Table of contents Preface 1.insert ignore into 2....
Introduction to AOP The main function of AOP (Asp...
Table of contents 1. The writing order of a compl...
This article shares the specific code for JavaScr...
This article records the installation and configu...