71 lines
1.7 KiB
HTML
71 lines
1.7 KiB
HTML
<!DOCTYPE html>
|
|
<html lang="en">
|
|
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
|
<title>折线图</title>
|
|
<script src="js/echarts.min.js"></script>
|
|
|
|
|
|
</head>
|
|
|
|
<body>
|
|
<div id="main" style="width:800px;height:800px;"></div>
|
|
<script type="text/javascript">
|
|
var myChart = echarts.init(document.getElementById('main'));
|
|
|
|
var chartDom = document.getElementById('main');
|
|
var myChart = echarts.init(chartDom);
|
|
var option;
|
|
|
|
option = {
|
|
title: {
|
|
text: '一周天气变化'
|
|
},
|
|
tooltip: {
|
|
trigger: 'axis'
|
|
},
|
|
legend: {
|
|
data: ['最高气温', '最低气温']
|
|
},
|
|
grid: {
|
|
left: '3%',
|
|
right: '4%',
|
|
bottom: '3%',
|
|
containLabel: true
|
|
},
|
|
toolbox: {
|
|
feature: {
|
|
saveAsImage: {}
|
|
}
|
|
},
|
|
xAxis: {
|
|
type: 'category',
|
|
boundaryGap: false,
|
|
data: ['周一', '周二', '周三', '周四', '周五', '周六', '周日']
|
|
},
|
|
yAxis: {
|
|
type: 'value'
|
|
},
|
|
series: [
|
|
{
|
|
name: '最高气温',
|
|
type: 'line',
|
|
data: [21, 21, 25, 23, 22, 23, 20]
|
|
},
|
|
{
|
|
name: '最低气温',
|
|
type: 'line',
|
|
data: [10, 12, 12, 15, 13, 12, 10]
|
|
}
|
|
]
|
|
};
|
|
|
|
option && myChart.setOption(option);
|
|
|
|
|
|
</script>
|
|
</body>
|
|
|
|
</html> |