In this section we will introduce you to some of the configurations that useECharts to generate charts. Create a HTML page and introduce Id in the instance is ECharts library usage Here Title Configure the title for the chart: Prompt information Configuration tips: Legend component The legend component shows a different series of tags (symbol), colors and names. You can control which series are not displayed by clicking on the legend. X axis Configure the items to display on the X axis: Y axis Configure the items to display on the Y axis. Series list Each series passes through Each series passes through Type: ‘bar’:Column/bar chart Type: ‘line’:Line/Area Chart Type: ‘pie’:Pie Type: ‘scatter’:Scatter (bubble) plot Type: ‘effectScatter’:Scatter (Bubble) with Ripple Effect Animation Type: ‘radar’:Radar chart Type: ‘tree’:Tree Map Type: ‘treemap’:Tree Map Type: ‘sunburst’:Sunrise chart Type: ‘boxplot’:Box plot Type: ‘candlestick’:Candlestick chart Type: ‘heatmap’:heat map Type: ‘map’:Map Type: ‘parallel’:Series of parallel coordinate systems Type: ‘lines’:diagram Type: ‘graph’:Relationship diagram Type: ‘sankey’:Sankey Type: ‘funnel’:Funnel plot Type: ‘gauge’:Dashboard Type: ‘pictorialBar’:Pictogram Type: ‘themeRiver’:Theme River Type: ‘custom’:Custom series The following is a complete example: Example For more configuration items, please see: https://echarts.apache.org/zh/option.html 9.3.1. Step 1: create a HTML page ¶
echarts.min.js
:<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<!-- Introducing ECharts files -->
<script src="echarts.min.js"></script>
</head>
</html>
9.3.2. Step 2: prepare a DOM container with height and width for ECharts ¶
main
of
div
used to include charts drawn by ECharts:<body>
<!-- Prepare a DOM with size (width and height) for ECharts -->
<div id="main" style="width: 600px;height:400px;"></div>
</body>
9.3.3. Step 3: set configuration information ¶
json
format to configure.echarts.init(document.getElementById('main')).setOption(option);
option
indicates the use of
json
the configuration of the data format to draw the chart. The steps are as follows:title: {
text: 'First ECharts instance'
}
tooltip: {},
legend: {
data: [{
name: 'series 1',
// Force the shape to be a circle.
icon: 'circle',
// Set text to red
textStyle: {
color: 'red'
}
}]
}
xAxis: {
data: ["Shirts", "woolen sweaters", "chiffon shirts", "pants", "high heels", "socks"]
}
yAxis: {}
type
decide your own chart type:series: [{
name: 'sales volume', // Series Name
type: 'bar', // Series chart types
data: [5, 20, 36, 10, 10, 20] // Data content in the series
}]
type
decide your own chart type: 9.3.4. Example ¶
<!DOCTYPEhtml><html><head><metacharset="utf-8"><title>The first one ECharts
example</title><!--introduce
echarts.js--><scriptsrc="https://cdn.staticfile.org/echarts/4.3.0/echarts.min.js"></script>
</head><body><!--Prepare a Dom with size (width and height) for ECharts--><divid="main"style="width:
600px;height:400px;"></div><scripttype="text/javascript">//
Based on the prepared dom, initialize the echarts instance var myChart =
echarts.init(document.getElementById('main')); // Specify configuration items and data for the chart
var option = { title: { text: 'First ECharts instance' }, tooltip: {},
legend: { data:['sales volume'] }, xAxis: { data:
["Shirts", "woolen sweaters", "chiffon shirts", "pants", "high heels", "socks"] }, yAxis: {}, series:
[{ name: 'sales volume', type: 'bar', data: [5, 20, 36, 10, 10, 20] }] }; //
Use the newly specified configuration items and data to display charts.
myChart.setOption(option);</script></body></html>