引入了dist文件夹
还有echarts.js文件
<!DOCTYPE html>
<head></body>
<!DOCTYPE html>
<head>
<meta charset="utf-8">
<title>ECharts - 折线图</title>
</head>
<body>
<!-- 为ECharts准备一个具备大小(宽高)的Dom -->
<div id="main" style="height: 400px; width: 600px"></div>
<!-- ECharts单文件引入 -->
<script src="http://echarts.baidu.com/build/dist/echarts.js"></script>
<script type="text/javascript">
// 路径配置
require.config({
paths : {
echarts : 'http://echarts.baidu.com/build/dist'
}
});
// 使用
require([ 'echarts', 'echarts/chart/line' // 使用折线图就加载line模块,按需加载
], function(ec) {
// 基于准备好的dom,初始化echarts图表
var myChart = ec.init(document.getElementById('main'));
var option = {
// color:['rgba(254,0,0,0.5)'],
title : {
text : '未来一周气温变化',
subtext : '纯属虚构'
},
//数据提示框配置
tooltip : {
trigger: "item"//可选item和axis axis会有线的~~默认蓝色详细看文档更改
},
//图例配置
legend : {
show:false,
data : [ '最高气温', '最低气温' ]
},
//工具箱配置
toolbox : {
show : false,
feature : {
mark : {
show : true
},
dataView : {
show : true,
readOnly : false
},
magicType : {
show : true,
type : [ 'line', 'bar' ]
},
restore : {
show : true
},
saveAsImage : {
show : true
}
}
},
calculable : true,
xAxis : [ {
axisLine:{lineStyle:{color: 'rgba(254,0,0,0.5)',width: '2',type: 'solid'}},
type : 'category',
boundaryGap : false,
data : [ '周一', '周二', '周三', '周四', '周五', '周六', '周日' ]
} ],
yAxis : [ {
axisLine:{lineStyle:{color: 'rgba(254,0,0,0.5)',width: '2',type: 'solid'}},
type : 'value',
axisLabel : {
formatter : '{value} °C'
}
} ],
//图表Series数据序列配置
series : [ {
type : 'line',
itemStyle : {
normal : { color : '#f00', lineStyle : { width : 2 }, label : { show : true, position : 'top', textStyle : { fontStyle : 'bolder', fontSize : 15 } } }
},
data : [ 11, 11, 15, 13, 12, 13, 10 ],
symbol : 'emptyCircle'
// markPoint : {
// data : [ {name: '标注1', value: 100, xAxis: 0, yAxis: 11},{name: '标注1', value: 100, xAxis: 1, yAxis: 11}, {name: '标注1', value: 100, xAxis: 2, yAxis: 20}, {name: '标注1', value: 100, xAxis: 3, yAxis: 20}, {name: '标注1', value: 100, xAxis: 4, yAxis: 20}, {name: '标注1', value: 100, xAxis: 5, yAxis: 20}, {name: '标注1', value: 100, xAxis: 6, yAxis: 20}],
// itemStyle:{normal:{color:'yellow'}}
// }
// markLine : {
// data : [ {
// type : 'average',
// name : '平均值'
// } ]}
}
]
};
// 为echarts对象加载数据
myChart.setOption(option);
});
</script>
</body>