echarts幾種騷圖
阿新 • • 發佈:2020-08-19
第一種:
let num = 0; option = { backgroundColor: '#111', title: [{ text: 'SPEED', x: 'center', top: '52%', textStyle: { color: '#fdf914', fontSize: 20, fontWeight: '100', } }, { text: '60%', x: 'center', top:View Code'42%', textStyle: { fontSize: '50', color: '#fdf914', fontFamily: 'Lato', foontWeight: '600', }, }], polar: { radius: ['40%', '50%'], center: ['50%', '50%'], }, angleAxis: { max: 100, show: false, }, radiusAxis: { type:'category', show: true, axisLabel: { show: false, }, axisLine: { show: false, }, axisTick: { show: false }, }, series: [ { name: '', type: 'bar', roundCap:true, barWidth: 60, showBackground: true, backgroundStyle: { color: 'rgba(66, 66, 66, .3)', }, data: [60], coordinateSystem: 'polar', itemStyle: { normal: { color: new echarts.graphic.LinearGradient(0, 1, 0, 0, [{ offset: 0, color: '#fdf914' }, { offset: 1, color: '#38a700' }]), } } }, ] }; function numb(){ num = num+5 myChart.setOption(option, true) } setInterval(function() { numb() }, 100);
第二種:條形圖
程式碼:
option = { yAxis: { type: 'category', axisLabel: { inside: true, verticalAlign:'bottom', lineHeight:'45', textStyle: { color: '#f00', fontSize:'20' } }, axisLine:{ show:false }, axisTick:{ show:false }, z:10, data: ['Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat', 'Sun'] }, xAxis: { type: 'value', splitLine:{ show:false } }, series: [{ data: [120, 200, 150, 80, 70, 110, 130], type: 'bar', barWidth:'30px', showBackground: true, backgroundStyle: { color: 'rgba(220, 220, 220, 0.8)' }, label: { show: true, position: [70,-16], fontSize:20, color:'#f00' }, markPoint:{ symbol:'path:// M 100 100 L 300 100 L 200 300 z',//箭頭svg,echart內建 symbolSize : 15, //symbolRotate:180, symbolOffset:[0,'-20px'], itemStyle:{ color:'#f00' }, data:[ {xAxis:120,yAxis:'Mon'}, {xAxis:200,yAxis:'Tue'}, {xAxis:150,yAxis:'Wed'}, {xAxis:80,yAxis:'Thu'}, {xAxis:70,yAxis:'Fri'}, {xAxis:110,yAxis:'Sat'}, {xAxis:130,yAxis:'Sun'}, ] }, itemStyle: { color: new echarts.graphic.LinearGradient( 1, 0, 0, 0, [ {offset: 0, color: '#83bff6'}, {offset: 0.5, color: '#188df0'}, {offset: 1, color: '#188df0'} ] ) }, }] };View Code