vue3.0+echarts realizes three-dimensional column chart

vue3.0+echarts realizes three-dimensional column chart

Preface:

Vue3.0 implements echarts three-dimensional column chart

Result:

Implementation steps:

1. Install echarts

cnpm i --save echarts

2. Page definition container

<template>
  <div ref="echart" class="echartDiv"></div>
</template>

3. Introducing echarts into js

import * as echarts from 'echarts';

Component complete source code:

<template>
  <div ref="echart" class="echartDiv"></div>
</template>
 
<script>
import * as echarts from 'echarts';
import { onMounted,toRefs, ref,reactive } from 'vue';
export default {
  setup(){
    let state = reactive({
      xAxisData:['Haoxing', 'Yanzi', 'Doraemon', 'Li Qiang', 'Wang Ying', 'Lao Wang'],
      yAxisData:[4,22,1,11,23,11],
      yAxisData1:[1,1,1,1,1,1],
      echart: ref(),
    })
    const echartInit = () => {
      var myChart = echarts.init(state.echart);
      //Specify the chart's configuration items and data var option = {
        tooltip: {
          trigger: "axis",
          axisPointer:
            type: "shadow", // Default is a straight line, optional: 'line' | 'shadow'
          },
          formatter: function(parms) {
            var str =
              parms[0].axisValue +
              "</br>" +
              parms[0].marker +
              "Login today:" +
              parms[0].value + 'times'
            return str;
          },
 
        },
        textStyle: {
          color: "#333",
        },
        color: ["#7BA9FA", "#4690FA"],
        grid: {
          containLabel: true,
          left: "10%",
          top: "20%",
          bottom: "10%",
          right: "10%",
        },
        xAxis:
          type: "category",
          data: state.xAxisData,
          axisLine: {
            lineStyle:
              color: "#333",
            },
          },
          axisTick: {
            show: false,
          },
          axisLabel: {
            margin: 20, //The distance between the scale label and the axis line.
            textStyle: {
              color: "#000",
            },
          },
        },
        yAxis: {
          type: "value",
          axisLine: {
            show: true,
            lineStyle:
              color: "#B5B5B5",
            },
          },
          splitLine: {
            lineStyle:
              // Use light and dark interval colors color: ["#B5B5B5"],
              type: "dashed",
              opacity: 0.5,
            },
          },
          axisLabel: {},
        },
        series: [{
          data: state.yAxisData,
          stack: "zs",
          type: "bar",
          barMaxWidth: "auto",
          barWidth: 60,
          itemStyle: {
            color:
              x: 0,
              y: 0,
              x2: 0,
              y2: 1,
              type: "linear",
              global: false,
              colorStops: [{
                offset: 0,
                color: "#5EA1FF",
              },
                {
                  offset: 1,
                  color: "#90BEFF",
                },
              ],
            },
          },
        },
 
          //The following three-dimensional, control color is the first color {
            data: state.yAxisData1,
            type: "pictorialBar",
            barMaxWidth: "20",
            symbol: "diamond",
            symbolOffset: [0, "50%"],
            symbolSize: [60, 15],
            zlevel: 2,
          },
          //The above three-dimensional, the control color is the second color {
            data: state.yAxisData,
            type: "pictorialBar",
            barMaxWidth: "20",
            symbolPosition: "end",
            symbol: "diamond",
            symbolOffset: [0, "-50%"],
            symbolSize: [60, 12],
            zlevel: 2,
          }
        ],
      };
      // Display the chart using the configuration items and data just specified.
      myChart.setOption(option);
    }
 
    //Mount onMounted(()=>{
      echartInit()
    })
 
    return {
      ...toRefs(state),
      echartInit
    };
  }
}
</script>
 
<style lang='scss' scoped>
  .echartDiv{
    width: 100%;
    height: 400px;
  }
</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:
  • Vue+echarts realizes 3D column chart
  • Vue+Echarts implements columnar line chart
  • Vue+echarts realizes striped columnar horizontal chart
  • Detailed explanation of vue using Echarts to draw a bar chart
  • Vue echarts realizes horizontal bar chart
  • Vue echarts realizes dynamic display of bar chart
  • Vue+echarts realizes stacked bar chart
  • Vue+echarts realizes progress bar histogram
  • Vue implements three-dimensional column chart based on echarts
  • Vue Echarts implements column chart with scrolling effect

<<:  Detailed tutorial on how to deploy Springboot project using Nginx on the server (jar package)

>>:  MySQL master-slave replication principle and practice detailed explanation

Recommend

Introduction to the use of base link tag base

<br />When you click the link, the web page ...

Implementation steps for installing Redis container in Docker

Table of contents Install Redis on Docker 1. Find...

How to allow remote access to open ports in Linux

1. Modify the firewall configuration file # vi /e...

How to write HTML head in mobile device web development

Copy code The code is as follows: <head> &l...

A detailed introduction to the basics of Linux scripting

Table of contents 1. Script vim environment 2. Ho...

In-depth understanding of Vue's plug-in mechanism and installation details

Preface: When we use Vue, we often use and write ...

In-depth understanding of Linux load balancing LVS

Table of contents 1. LVS load balancing 2. Basic ...

Instructions for using the --rm option of docker run

When the Docker container exits, the file system ...

Steps to modify the MySQL database data file path under Linux

After installing the MySQL database using the rpm...

MySQL 5.7.23 installation and configuration graphic tutorial

This article records the detailed installation pr...

Detailed explanation of several examples of insert and batch statements in MySQL

Table of contents Preface 1.insert ignore into 2....

Basic Implementation of AOP Programming in JavaScript

Introduction to AOP The main function of AOP (Asp...

JavaScript to achieve simple provincial and municipal linkage

This article shares the specific code for JavaScr...

MySQL 8.0.18 installation and configuration method graphic tutorial (linux)

This article records the installation and configu...