Problem record of using vue+echarts chart

Problem record of using vue+echarts chart

Preface

echarts is my most commonly used charting tool, and it also has a very complete ecosystem and content, which is enough for our daily use. I was recently working on a big data platform page and needed to use a lot of charts, so I used echarts. During the use process, I also encountered some difficult problems or some properties hidden deep in the configuration manual. I will record them today.

How to use

1. Cancel the grid of the chart and change the color of the grid

// Control whether the grid line is displayed splitLine: {
    show: false, //Whether the grid lines are displayed//Change style lineStyle: {
       color: '#ccc' // Change the grid line color}                            
},

2. Change the style of the coordinate axis

xAxis: [
              {
                  type: 'category',
                  boundaryGap: false,
                  data: ['January', 'February', 'March', 'April', 'May', 'June'],
                  axisLine:{
                      lineStyle:{color:"#ccc"}
                  },
                  axisTick: {
                    show: false // remove the scale},
                  axisLabel:{//Modify font styleshow: true,//Show and hidetextStyle:{color:"#ccc"}
                  },
                  // Control whether the grid line is displayed splitLine: {
                 show: false, //Whether the grid lines are displayed//Change style lineStyle: {
                     color: '#ccc' // Change the grid line color}                            
},
              }
          ],
          yAxis: [
              {
                  type: 'value',
                  name: '(times)',
                  axisLine:{
                      lineStyle:{color:"#ccc",fontSize:'16'}
                  },
                  axisTick: {
                    show: false // remove the scale},
              }
          ],

3. Some style modifications or configurations of the donut chart

//Modify the style of the text in the center of the circle title: {
          text: value.value+'times',
          subtext: value.name,
          x: 'center',
          y: 'center',
          itemGap: 0,
          textStyle: {
            fontSize: 26,
            fontWeight: 'bold',
            color: 'rgb(0,237,255)'
          },
          subtextStyle: {
            fontSize: 16,
            fontWeight: 'bold',
            color: '#fff'
          },
},
//Clear the floating effect of the circle when the mouse moves in series: [
            {
              hoverAnimation:false, //Add this attribute}
    ]

4. Switch between multiple charts and clear the last loaded data

Add true to setOption

option && myChart.setOption(option,true);

5. Use of gradient colors in charts

echarts.graphic.LinearGradient

series: [
          {
            type: 'pie',
            center: ['50%', '49%'],
            radius: ['45%', '73%'],
            // minAngle: 0,
            startAngle: 0, // gradient angle avoidLabelOverlap: true, //Whether to enable preventing label overlap emphasis: {
              label: {
                show: true,
                position: 'center'
              }
            },
            data: seriesData,
            itemStyle: {
              emphasis:
                shadowBlur: 10,
                shadowOffsetX: 0,
                shadowColor: 'rgba(0, 0, 0, 0.5)',
                label: {
                  show: true,
                }
              },
              normal: {
                color: function (params) { //Color gradient var colorList = [
                    {
                      c1: '#3288FC',
                      c2: '#36B4FD'
                    },
                    {
                      c1: '#CBA0FF',
                      c2: '#598EFE'
                    },
                  ]
                  return new echarts.graphic.LinearGradient(1, 0, 0, 0, [{ //The first four parameters of the color gradient function represent the four positions, left, bottom, right, and top, respectively. offset: 0,
                    color: colorList[params.dataIndex].c1
                  }, {
                    offset: 1,
                    color: colorList[params.dataIndex].c2
                  }])

                }
              }
            }
          }
        ]

Summarize

This is the end of this article about the use of vue+echarts charts. For more relevant content on the use of vue+echarts charts, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Basic tutorial for adding Echarts charts in vue
  • Vue+echarts realizes the method of dynamically drawing charts and asynchronously loading data
  • Vue.js+Echarts development chart zoom in and out function example
  • Implement loop rendering of multiple identical echarts charts in Vue
  • Detailed method of using echarts charts in Vue
  • Detailed explanation of using echarts chart example code in vue
  • Vue2 uses Echarts to create chart example code
  • Several solutions for vue to use echarts chart adaptation
  • Case of echarts chart size in vue adapting to window size and not needing to be refreshed

<<:  Alibaba Cloud Server Tomcat cannot be accessed

>>:  How to remotely connect to the cloud server database using Navicat

Recommend

Installation and configuration of MySQL 5.7.17 free installation version

MYSQL version: MySQL Community Server 5.7.17, ins...

ElementUI component el-dropdown (pitfall)

Select and change: click to display the current v...

Detailed explanation of commands to view linux files

How to view linux files Command to view file cont...

Solution to MySQL failure to start

Solution to MySQL failure to start MySQL cannot s...

Solution to high CPU usage of Tomcat process

Table of contents Case Context switching overhead...

An article to master MySQL index query optimization skills

Preface This article summarizes some common MySQL...

Vue-Router installation process and principle detailed

Table of contents 1. Front-end routing implementa...

Discussion on the browsing design method of web page content

<br />For an article on a content page, if t...

Write a simple calculator using JavaScript

The effect is as follows:Reference Program: <!...

MySQL character set garbled characters and solutions

Preface A character set is a set of symbols and e...