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

JavaScript data structure bidirectional linked list

A singly linked list can only be traversed from t...

MySQL complete collapse: detailed explanation of query filter conditions

Overview In actual business scenario applications...

Reasons and solutions for not being able to detect array changes in Vue2

Table of contents Workaround Why can't I moni...

Three ways to share component logic in React

Without further ado, these three methods are: ren...

HTML sub tag and sup tag

Today I will introduce two HTML tags that I don’t...

Does the website's text still need to be designed?

Many people may ask, does the text on the website...

How to use lodop print control in Vue to achieve browser compatible printing

Preface This control will have a watermark at the...

Example code for implementing equal width layout in multiple ways using CSS

The equal-width layout described in this article ...

Vue implements a shopping cart that can change the shopping quantity

This article shares with you how to use Vue to ch...