In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/02 Report--
This article mainly introduces Vue into Echarts how to achieve broken line scatter chart, has a certain reference value, interested friends can refer to, I hope you can learn a lot after reading this article, the following let the editor take you to understand it.
Effect picture:
Import echarts into vue-cli
Download it to the project with the command: npm install echarts-- save, then import it in the main.js in the project and save it on the prototype of vue.
The main.js code is as follows:
Import Vue from 'vue'import App from'. / App.vue'const echarts = require ("echarts") Vue.prototype.$echarts = echartsVue.config.productionTip = falsenew Vue ({render: h = > h (App),}). $mount ('# app')
The require used to import echarts here, but the import will fail with import echarts from 'echarts'. The exact reason is not known.
Then write the code in app.vue as follows:
Export default {name: 'App', mounted () {this.eachartsInit ()}, methods: {eachartsInit () {let myEcharts = this.$echarts.init (document.getElementById ("app")) let option = {legend: {data: ["goal 1", "fixed type", "goal 2", "goal 3"] / / shows several lines One-to-one correspondence with the elements of the series array}, grid: {bottom: "20%", / / controls the distance between the bottom of the whole chart and the external container width: 800,/ / height:500}, tooltip: {trigger: "axis" / / set the mouse hover to the broken line to display the X-axis data axisPointer: {type: "cross", / / control the simultaneous display of Y-axis data label: {backgroundColor: "# 6a7985" / / when the mouse is moved to this point Add background color to the coordinates of the axis}, xAxis: {type: "category", / / available values time, value, log, category The coordinate values used by category for this scatter line chart / / 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"] / / the font that controls the X-axis coordinates here rotates (rotates counterclockwise) axisLabel: {rotate: 45, / / the degree of rotation color: "red", / / controls the font color of the X-axis coordinates fontWeight: 600 / / controls the font bold}}, / / the 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 type: "line" corresponding to each X coordinate / / the displayed type name: "goal 1", / / the value of the name attribute is taken from the data array element smooth: true / / in legend}, {data: [220,450,350,760,680,560], type: "line", name: "goal 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: "goal 3", smooth: true}]} myEcharts.setOption (option) / / pass configuration item option} # app {width: 850px to the generated echarts instance Height: 600px;} Thank you for reading this article carefully. I hope the article "how to achieve a broken line scatter chart by importing Vue into Echarts" shared by the editor will be helpful to everyone. At the same time, I also hope that you will support us and pay attention to the industry information channel. More related knowledge is waiting for you to learn!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.