最近須要作個極座標圖,顯示時間與對應的壓力數值,而且有多個點,查看echart雙數值軸中能夠作到多個點,可是外圍顯示的是角度,咱們須要把角度格式化成時間,而且tooltip也要對應顯示時間與壓力javascript
下面爲完整的option代碼java
var option2 = { //title: { //text: '極座標雙數值軸' //}, legend: { data: ['line'] }, polar: {}, tooltip: { trigger: 'axis', axisPointer: { // 座標軸指示器,座標軸觸發有效 type: 'line' // 默認爲直線,可選爲:'line' | 'shadow' }, formatter: function(params) { var value1 var value = (params[0].value[1] / 15 + 8) >= 24 ? params[0].value[1] / 15 + 8 - 24 : params[0].value[1] / 15 + 8; if (value % 1 === 0) { value1 = value + ":00"; } else { value1 = value.toString().replace(".5", ":30"); } return params[0].value[0] + "<br>" + value1; } }, angleAxis: { type: 'value', min: 0, max: 360, interval: 15, startAngle: 0, axisLabel: { formatter: function(value, index) { var value = value / 15 + 8; if (value >= 24) { value = value - 24; } return value + ":00"; } }, }, radiusAxis: {}, series: [{ coordinateSystem: 'polar', name: 'ok', type: 'line', //showSymbol:false, data: data }] }; // console.log(option2); var myChart = echarts.init(document.getElementById('chart2'), theme); myChart.setOption(option2);