在百度echarts中添加標識線,打開如下網址複製代碼到輸入框,繪製一條直線。html
http://echarts.baidu.com/echarts2/doc/example/line3.htmlecharts
option = { title : { text: '某樓盤銷售狀況', subtext: '純屬虛構' }, tooltip : { trigger: 'axis' }, legend: { data:['意向','預購','成交'] }, toolbox: { show : true, 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', boundaryGap : false, data : ['週一','週二','週三','週四','週五','週六','週日'] } ], yAxis : [ { type : 'value' } ], series : [ { name:'成交', type:'line', smooth:true, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data:[10, 12, 21, 54, 260, 830, 710], markLine:{ itemStyle:{ normal:{lineStyle:{type:'solid',color:'#000'},label:{show:true,position:'left'}} }, large:true, effect:{ show: false, loop: true, period: 0, scaleSize : 2, color : null, shadowColor : null, shadowBlur : null }, data:[ [ {name: '標線1起點', value: 400, xAxis: -1, yAxis: 400}, // 當xAxis爲類目軸時,數值1會被理解爲類目軸的index,經過xAxis:-1|MAXNUMBER可讓線到達grid邊緣 {name: '標線1終點', xAxis: '週日', yAxis: 400}, // 當xAxis爲類目軸時,字符串'週三'會被理解爲與類目軸的文本進行匹配 ], ] } }, { name:'預購', type:'line', smooth:true, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data:[30, 182, 434, 791, 390, 30, 10] }, { name:'意向', type:'line', smooth:true, itemStyle: {normal: {areaStyle: {type: 'default'}}}, data:[1320, 1132, 601, 234, 120, 90, 20] } ] };