This article shares the specific code of Vue importing Echarts to realize the line scatter chart for your reference. The specific content is as follows Effect picture: 1. Import echarts in vue-cli Download it to the project through the command: npm install echarts --save, then import it in the main.js of the project and save it on the prototype of vue. import Vue from 'vue' import App from './App.vue' const echarts = require("echarts") Vue.prototype.$echarts = echarts Vue.config.productionTip = false new Vue({ render: h => h(App), }).$mount('#app') The require used to import echarts here will fail if you use import echarts from 'echarts'. The specific reason is still unknown. Then write the following code in app.vue: <template> <div id="app"> </div> </template> <script> export default { name: 'App', mounted() { this.eachartsInit() }, methods: { eachartsInit() { let myEcharts = this.$echarts.init(document.getElementById("app")) let option = { legend: { data: ["Target 1", "Fixed Type", "Target 2", "Target 3"] //Show how many lines there are, corresponding one to one with the elements of the series array}, grid: { bottom: "20%", //Control the distance between the bottom of the entire chart and the external container width: 800, // height:500 }, tooltip: { trigger: "axis", //Set the mouse to hover over the line to display the X-axis data axisPointer: { type: "cross", //Control the display of Y-axis data label: { backgroundColor: "#6a7985" //When the mouse moves to this point, add a background color to the coordinates of the coordinate axis} } }, xAxis: type: "category", //The possible values are time, value, log, category. Category is used for this kind of scatter line chart //The coordinate value of the X-axis data: ["2021.10.28 09:17:34", "2021.10.28 09:20:35", "2021.10.28 09:20:50", "2021.10.28 09:21:05", "2021.10.28 09:22:34", "2021.10.28 09:25:34"], //Here controls the font rotation of the X-axis coordinate (counterclockwise) axisLabel: { rotate: 45, //Degree of rotation color: "red", //Control the font color of the X-axis coordinate fontWeight: 600 //Control the boldness of the font} }, //Configuration of the y-axis. Here, y only needs to display the value, and type uses value. yAxis: { type: "value" }, // series: [ //4 array elements are equivalent to 4 lines { data: [820, 750, 450, 560, 650, 660], //The value corresponding to each X coordinate type: "line", //Display type name: "Target 1", //The value of the name attribute is taken from the data array element in legend smooth: true //Whether to perform smoothing }, { data: [220, 450, 350, 760, 680, 560], type: "line", name: "Target 2", smooth: true }, { data: [352, 550, 370, 560, 420, 590], type: "line", name: "Fixed Type", smooth: true }, { data: [522, 345, 450, 458, 592, 485], type: "line", name: "Target 3", smooth: true } ] } myEcharts.setOption(option) // Pass the configuration option to the generated echarts instance } } } </script> <style> #app{ width: 850px; height: 600px; } </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:
|
<<: Tutorial on deploying springboot package in linux environment using docker
>>: 40+ Beautiful Web Form Design Examples
What is Nginx access restriction configuration Ng...
Chinese Tutorial https://www.ncnynl.com/category/...
Situation description: The database was started a...
This article example shares the specific code of ...
Problem to be solved Mainly for cross-level commu...
background On mobile devices, caching between pag...
1. About Registry The official Docker hub is a go...
Classification of website experience 1. Sensory e...
The first time I used the essay, I felt quite awkw...
nginx version 1.11.3 Using the following configur...
Table of contents Dynamically change themes The f...
Recently, I needed to test the zoom video confere...
The following two functions are used in the same ...
GitHub address, you can star it if you like it Pl...
This article example shares the specific code of ...