How to use vue to implement column chart

藏色散人
Release: 2023-01-29 14:13:29
Original
2450 people have browsed it

How to use vue to implement a column chart: 1. Create a div attribute as "

"; 2. Pass "mounted(){this.fetchData()window.addEventListener('resize',()=>{if (this.chart){...}" Just implement a three-dimensional histogram.

How to use vue to implement column chart

The operating environment of this tutorial: Windows 10 system, vue3 version, DELL G3 computer

How to use vue to implement a column chart?

vue implements a three-dimensional histogram

The style is as shown in the figure below:
How to use vue to implement column chart

The three-dimensional histogram can be regarded as the bottom and top of yData The composition, the corresponding code is as follows:

Copy after login
Copy after login

In the above js code, there are the following precautions:

  • Color selection: You can colors[params.dataIndex % 4]Replace with this.colorOptions[params.dataIndex % 4], that is, use the colorOptions defined in the code for color filling
  • colorStops ensures a three-dimensional effect
  • In the code colors[params.dataIndex % 4]The selection of 4 in is variable, ensuring that the index value is within the length range of the colors variable. For example: in this example, the length of colors is 4, params. dataIndex % 4can be no more than 4

To quote the above barchart, the following code can be applied:

Copy after login
Copy after login

Recommended learning: "vue video tutorial

The above is the detailed content of How to use vue to implement column chart. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
vue
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!