This article shares the specific code of vue echarts to realize the dynamic display of bar chart for your reference. The specific content is as follows Display in the form of a carousel <template> <div class="dan"> <div id="scalesize" :style="{width: '100%', height: '100%'}"></div> </div> </template> <script> import echarts from "echarts"; export default { data() { return { texts: 111 }; }, mounted() { this.drawLine(); }, methods: { drawLine() { // Initialize the echarts instance based on the prepared dom let myChart = this.$echarts.init(document.getElementById("scalesize")); var fanfa = [ { name: "Seedling Base", type: "bar", barWidth: "15%", itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#fccb05" }, { offset: 1, color: "#f5804d" } ]), barBorderRadius: 12 } }, data: [100, 120, 160, 180, 220, 400] }, { name: "Planting Base", type: "bar", barWidth: "15%", itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#8bd46e" }, { offset: 1, color: "#09bcb7" } ]), barBorderRadius: 11 } }, data: [270, 320, 420, 650, 821,907] }, { name: "Hosted Area", type: "bar", barWidth: "15%", itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#248ff7" }, { offset: 1, color: "#6851f1" } ]), barBorderRadius: 11 } }, data: [140, 180, 215, 320, 396, 520] }, { name: "Joint Construction Base", type: "bar", barWidth: "15%", itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [ { offset: 0, color: "#B88080" }, { offset: 1, color: "#983A3A" } ]), barBorderRadius: 11 } }, data: [140, 180, 215, 320, 396, 420] } ]; myChart.setOption({ tooltip: { trigger: "axis", axisPointer: // Axis indicator, axis trigger valid type: "shadow" // Default is a straight line, optional: 'line' | 'shadow' } }, grid: { left: "2%", right: "4%", bottom: "14%", top: "16%", containLabel: true }, legend: { data: ["seedling base", "planting base", "trusteeship area", "joint construction base"], right: 10, top: 12, textStyle: { color: "#fff" }, itemWidth: 12, itemHeight: 10 //itemGap: 35 }, xAxis: type: "category", data: [ "2014", "2015", "2016", "2017", "2018", "2019" ], axisLine: { lineStyle: color: "white" } }, axisLabel: { // interval: 0, // rotate: 40, textStyle: { fontFamily: "Microsoft YaHei" } } }, yAxis: { type: "value", axisLine: { show: false, lineStyle: color: "white" } }, splitLine: { show: true, lineStyle: color: "rgba(255,255,255,0.3)" } }, axisLabel: {} }, dataZoom: [ { show: true, height: 12, xAxisIndex: [0], bottom: "8%", handleIcon: "path://M306.1,413c0,2.2-1.8,4-4,4h-59.8c-2.2,0-4-1.8-4-4V200.8c0-2.2,1.8-4,4-4h59.8c2.2,0,4,1.8,4,4V413z", handleSize: "110%", handleStyle: { color: "#d3dee5" }, textStyle: { color: "#fff" }, borderColor: "#90979c" }, { type: "inside", show: true, height: 15, start: 1, end: 35 } ], series: fanfa }); let app = { currentIndex: -1 }; setInterval(function() { let dataLen = fanfa[1].data.length; // Cancel the previously highlighted graph myChart.dispatchAction({ type: "downplay", seriesIndex: 0, dataIndex: app.currentIndex }); app.currentIndex = (app.currentIndex + 1) % dataLen; //console.log(app.currentIndex); //Highlight the current graphmyChart.dispatchAction({ type: "highlight", seriesIndex: 0, dataIndex: app.currentIndex }); // Display tooltip myChart.dispatchAction({ type: "showTip", seriesIndex: 0, dataIndex: app.currentIndex }); }, 1000); window.onresize = myChart.resize; } } }; </script> <style lang="less" scoped> .dan { height: 90%; } </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:
|
<<: MySQL 8.0.20 installation and configuration detailed tutorial
>>: How to connect Xshell5 to Linux in a virtual machine and how to solve the failure
1. Delete folders Example: rm -rf /usr/java The /...
MySQL Introduction to MySQL MySQL was originally ...
1. Requirements description For a certain element...
After entering the Docker container, if you exit ...
Table of contents Preface Static scope vs. dynami...
Basic Introduction Features Flexbox is a CSS disp...
Table of contents 1. Integrate Ant Design Vue 2. ...
Get the number of connections --- Get the maximum...
Preface This article mainly introduces the releva...
Preface Everyone should be familiar with the watc...
1. Overflow content overflow settings (set whether...
1. Get the image #Specify the version that includ...
question I encountered a problem when writing dat...
Table of contents Query Background 1. Like query ...
Table of contents vue - Use swiper plugin to impl...