<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">
<!--引入ECharts脚本-->
<script src="js/echarts.min.js"></script>
</head>
<body>
<!---为ECharts准备一个具备大小(宽高)的DOM-->
<div id="main" style="width: 600px; height: 400px"></div>
<script type="text/javascript">
//基于准备好的DOM,初始化ECharts图表
var myChart = echarts.init(document.getElementById("main"));
//指定图表的配置项和数据
var option = {
title: {
text:"销售统计表",
},
tooltip: {
// 提示框是一个还是整个x轴的数据,靠近x轴的时候就会触发还是靠近点才会触发
trigger: 'axis',
// 这个是标杆
axisPointer: { //设置坐标轴指示器,坐标轴触发有效
type: 'shadow' //设置坐标轴默认为直线,可选为:'line'|'shadow'
}
},
// tooltip由axisPointer和trigger组成
legend: {
data: ['衬衫', '羊毛衫', '雪纺衫', '裤子',
'高跟鞋', '袜子', '其他']
},
toolbox: {
show: true,
// 朝向方向
orient: 'vertical',
x: 'right',
y: 'center',
feature: {
mark: { show: true },
dataView: { show: true, readOnly: false },
magicType: { show: true, type: ['line', 'bar', 'stack', 'tiled'] },
restore: { show: true },
saveAsImage: { show: true }
}
},
calculable: true,
xAxis: [{
type: "category",
data: ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"]
}],
yAxis: [
{
type: 'value'
}
],
series: [
{
name: '衬衫',
type: 'bar',
data: [5, 6, 12, 20, 21, 21, 21, 15, 17, 8, 7, 22, 12]
},
{
name: '羊毛衫',
type: 'bar',
data: [20, 18, 30, 22, 22, 24, 9, 12, 21, 24, 22, 12]
},
{
name: '雪纺衫',
type: 'bar',
data: [36, 20, 20, 23, 28, 21, 13, 16, 12, 28, 21, 22]
},
{
name: '裤子',
type: 'bar',
data: [10, 12, 18, 21, 25, 22, 12, 14, 32, 21, 18, 21]
},
{
name: '高跟鞋',
type: 'bar',
data: [10, 11, 17, 18, 13, 12, 14, 21, 12, 31, 21, 18]
},
{
name: '袜子',
type: 'bar',
data: [20, 19, 22, 21, 23, 21, 19, 24, 32, 21, 24, 21],
// start
markLine: {
data: [
[
{
name: '两个坐标之间的标线',
coord: [10, 10]
},
{
coord: [20, 30]
}
],
]
}
},
]
};
//使用刚指定的配置项和数据显示图表
myChart.setOption(option);
</script>
<!-- jQuery (Bootstrap 的所有 JavaScript 插件都依赖 jQuery,所以必须放在前边-->
<script src="https://fastly.jsdelivr.net/npm/jquery@1.12.4/dist/jquery.min.js" integrity="sha384-nvAa0+6Qg9clwYCGGPpDQLVpLNn0fRaROjHqs13t4Ggj3Ez50XnGQqc/r8MhnRDZ" crossorigin="anonymous"></script>
<!-- 加载 Bootstrap 的所有 JavaScript 插件。你也可以根据需要只加载单个插件。 -->
<script src="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/js/bootstrap.min.js" integrity="sha384-aJ21OjlMXNL5UyIl/XNwTMqvzeRMZH2w8c5cRVpzpU8Y5bApTppSuUkhZXN0VxHd" crossorigin="anonymous"></script>
</body>
</html>
boot作业
最新推荐文章于 2024-04-11 14:41:09 发布