<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<script src="./echarts.min.js"></script>
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Document</title>
</head>
<body>
<div id="main1" style="width: 600px; height: 400px"></div>
<script>
var chartDom = document.getElementById('main1');
var myChart = echarts.init(chartDom);
var option;
option = {
tooltip: {
trigger: 'axis',
axisPointer: {
type: 'cross',
crossStyle: {
color: '#999'
}
}
},
toolbox: {
feature: {
dataView: { show: true, readOnly: false },
magicType: { show: true, type: ['line', 'bar'] },
restore: { show: true },
saveAsImage: { show: true }
}
},
// legend: {
// data: ['Evaporation', 'Precipitation', 'Temperature']
// },
xAxis: [
{
type: 'category',
data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'],
axisPointer: {
type: 'shadow'
}
}
],
yAxis: [
{
type: 'value',
name: 'Precipitation',
min: 0,
max: 2000,
interval: 500,
axisLabel: {
formatter: '{value}'
}
},
{
type: 'value',
name: 'Temperature',
min: -10000,
max: 40000,
interval: 10000,
axisLabel: {
formatter: '{value}'
}
}
],
series: [
{
name: 'Evaporation',
type: 'bar',
tooltip: {
valueFormatter: function (value) {
return value;
}
},
data: [
500,800,1700,1900,1000,900,400,500,400,50,30
]
},
{
name: 'Precipitation',
type: 'bar',
tooltip: {
valueFormatter: function (value) {
return value ;
}
},
data: [
600,1200,900,1000,600,500,400,350,600,30,0
]
},
{
name: 'Precipitation',
type: 'bar',
tooltip: {
valueFormatter: function (value) {
return value;
}
},
data: [
500,800,600,900,600,500,400,500,800,600,10
]
},
{
name: 'Temperature',
type: 'line',
yAxisIndex: 1,
tooltip: {
valueFormatter: function (value) {
return value;
}
},
data: [0,1000,8000,9000,0,0,1000,0,1000,0,0]
},
{
name: 'Temperature',
type: 'line',
yAxisIndex: 1,
tooltip: {
valueFormatter: function (value) {
return value;
}
},
data: [0,1000,8000,20000,5000, 8000,1000,0,1000,0,0]
},
{
name: 'Temperature',
type: 'line',
yAxisIndex: 1,
tooltip: {
valueFormatter: function (value) {
return value;
}
},
data: [0,1000,5000,7000,5000, 8000,1000,0,1000,0,0]
}
]
};
myChart.setOption(option);
</script>
</body>
</html>