Echarts is an open source visual chart library based on JavaScript, which has a variety of ICONS, to meet our daily development needs, for the first contact with VUE white, Echarts is more commonly used, documentation is clear
- Download Echarts in the VUE project
npm i echarts -S
Copy the code
- The introduction of echarts
var echarts = require("echarts");
Copy the code
- In the HTML
<div id="box" style="width: 800px; height: 400px"></div>
Copy the code
- Initialize echarts
var myChart = echarts.init(document.getElementById("box"));
Copy the code
- Specify the configuration items for the diagram
var option = {
title: {
text: "Getting started with ECharts",},tooltip: {},
legend: {
data: ["Sales"],},xAxis: {
data: ["Shirt"."Cardigan"."Chiffon shirt."."Pants"."High heels"."Socks"],},yAxis: {},
series: [{name: "Sales".type: "bar".data: [5.20.36.10.10.20],},]};Copy the code
- Display the chart using the configuration items and data you just specified
myChart.setOption(option);
Copy the code