示例图
<div id="chart2" style="width:600px; height: 400px;"></div>
<!-- js部分 -->
<script src="./js/jquery.min.js"></script>
<script src="./js/echarts.min.js"></script>
<script type="text/javascript">
var data = [21,25,27,12,22,21,25,27,12,22,42,32];
var option = {
xAxis: {
data:['01','02','03','04','05','06','07','08','09','10','11','12 (月)'],
type: 'category',
axisTick:{
show:false,//去掉刻度值
},
boundaryGap: false,//设置为false后,x轴的起始点01和y轴的起始点0是同一个位置
},
yAxis: {
type: 'value',
axisTick:{
show:false,
},
},
series: [
{
type:'line',//必须有,代表是line图
symbol: 'none',//去掉点
smooth:true,//平滑的曲线,不再是折线
itemStyle: {
normal: {
color: '#41b1de',
}
},
//data:data 赋值方法1
}
]
};
option.series[0].data = data;//赋值方法2,两种方法等效
var chart2 = echarts.init(document.getElementById('chart2'));
chart2.setOption(option);
</script>