Vue use echarts data dynamic update, y-axis scaling fixed or adaptive

Source: Internet
Author: User

Use the Echarts in the Vue project a few days ago, so write a simple demo The effect you want to implement data dynamic generation (real-time change) time point 1
Time point 2
code file (Echarts.vue)

<template> <div class= "Echarts" > <i-echarts:option= "Options" ></i-echarts> </div> &L
    t;/template> <script> import iecharts from ' Vue-echarts-v3/src/full.vue ' export default {name: ' table ', Components: {iecharts}, data () {return {options: {title: {text : ' Timesky '}, tooltip: {trigger: ' item '}, Legend: {dat A: [' Sales ']}, Xaxis: {name: ' goods ', namelocation: ' Start ', Namegap: ' $ ', boundarygap:true, data: [' shirts ', ' sweaters ', ' chiffon shirts ', ' trousers ', ' heels ', ' socks ']},//Y
              Axis: {}, longitudinal axis adaptive yaxis: {//Vertical axis ruler fixed type: ' Value ', Scale:true,
          Name: ' Sales ', max:100, min:0, Boundarygap: [0.2, 0.2]},
          Series: [{  Name: ' Sales ', type: ' Bar ', data: [5, 20, 36, 60, 10, 55]}}},  Mounted () {This.changedata ()}, methods: {Changedata () {Let data = [] for (Let i = 0, min = 5, max = 99; I < 6; i++) {Data.push (Math.floor (Math.random () * (max + 1-min) + min)} this.options.series[0].dat  A = Data settimeout (this.changedata)}} </script> <style>. echarts {width:
    800px;
  height:400px; } </style>
The y-axis scale is adaptive and fixed as shown in the comments in the previous paragraph, which is adaptive by default and has the following effect

If you want to fix the longitudinal axis only need to configure Min and Max values, you can configure the Splitnumber property if you want to divide more ticks
YAxis: {},      //longitudinal axis adaptive
 yaxis: {          //Vertical axis ruler fixed
      type: ' Value ',
      scale:true,
      name: ' Sales ',
      max:100,
      min:0,
      splitnumber:10,
      boundarygap: [0.2, 0.2]
  },

The effect is as follows


This article refers to the blog JavaScript echart yaxis fixed value change value Echarts Official website example

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.