var symbolSize = 20; var data = [['周一',11], ['周二',11], ['周三',15], ['周四',13], ['周五',12], ['周六',13], ['周日',10]]; var thisNode ; option = { title: { text: 'Try Dragging these Points' }, tooltip: { triggerOn: 'none', }, xAxis: { type: 'category', boundaryGap: false, data: ['周一','周二','周三','周四','周五','周六','周日'] }, yAxis: { type: 'value', axisLabel: { formatter: '{value} °C' } }, series: [ { name: 'a', type: 'line', smooth: true, symbolSize: symbolSize, data: data } ] }; if (!app.inNode) { setTimeout(function () { // Add shadow circles (which is not visible) to enable drag. myChart.setOption({ graphic: echarts.util.map(data, function (item, dataIndex) { return { type: 'line', position: myChart.convertToPixel({seriesName: 'a'}, item), shape: { cx: 0, cy: 0, r: symbolSize / 2 }, invisible: true, draggable: true, ondrag: echarts.util.curry(onPointDragging, dataIndex), onmousemove: echarts.util.curry(showTooltip, dataIndex), onmouseout: echarts.util.curry(hideTooltip, dataIndex), z: 100 }; }) }); }, 0); window.addEventListener('resize', updatePosition); } myChart.on('dataZoom', updatePosition); function updatePosition() { myChart.setOption({ graphic: echarts.util.map(data, function (item, dataIndex) { return { position: myChart.convertToPixel({seriesName: 'a'}, item) }; }) }); } function showTooltip(dataIndex) { myChart.dispatchAction({ type: 'showTip', seriesIndex: 0, dataIndex: dataIndex }); } function hideTooltip(dataIndex) { myChart.dispatchAction({ type: 'hideTip' }); } function onPointDragging(dataIndex, dx, dy) { convert = myChart.convertFromPixel('grid', this.position); thisNode = convert[0]; data[thisNode] = convert; // Update data myChart.setOption({ series: [{ name: 'a', data: data }] }); }
世人的悲欢并不相通,我只是觉得他们吵闹。