87,990
社区成员
发帖
与我相关
我的任务
分享
myChart = echarts.init(document.getElementById('echartsMain'));
//
option = {
title: {
text: '风区70米风速',
subtext: ''
},
tooltip: {
trigger: 'axis'
},
grid: {
},
legend: {
data:['风速']
},
toolbox: {
show: true,
feature: {
dataZoom : {show: true},
restore : {show: true},
saveAsImage: {}
}
},
xAxis: {
type: 'category',
boundaryGap: false,
//data: ['周一','周二','周三','周四','周五','周六','周日']
data: []
},
yAxis: {
type: 'value',
axisLabel: {
formatter: '{value} m/s'
}
},
dataZoom: [
{
type: 'slider',
xAxisIndex: 0,
filterMode: 'empty'
},
{
type: 'slider',
yAxisIndex: 0,
filterMode: 'empty'
},
{
type: 'inside',
xAxisIndex: 0,
filterMode: 'empty'
},
{
type: 'inside',
yAxisIndex: 0,
filterMode: 'empty'
}
],
series: [
{
name:'风速',
id: 'a',
type:'line',
//data:[11, 11, 15, 13, 12, 13, 10],
data:[],
markPoint: {
data: [
{type: 'max', name: '最大值'},
{type: 'min', name: '最小值'}
]
},
markLine: {
data: [
{type: 'average', name: '平均值'}
]
}
}
]
};
//
myChart.on('dataZoom', updatePosition);
myChart.setOption(option);
myChart.hideLoading();
myChart.setOption({
graphic: echarts.util.map(windv70, function (item, dataIndex) {
return {
type: 'circle',
position: myChart.convertToPixel('grid', 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
};
})
});
window.addEventListener('resize', updatePosition);
function updatePosition() {
myChart.setOption({
graphic: echarts.util.map(windv70, function (item, dataIndex) {
return {
position: myChart.convertToPixel('grid', item)
};
})
});
}
function showTooltip(dataIndex) {
myChart.dispatchAction({
type: 'showTip',
seriesIndex: 0,
dataIndex: dataIndex
});
}
function hideTooltip(dataIndex) {
myChart.dispatchAction({
type: 'hideTip'
});
}
function onPointDragging(dataIndex, dx, dy) {
windv70[dataIndex] = myChart.convertFromPixel('grid', this.position);
// Update data
myChart.setOption({
series: [{
id: 'a',
data: windv70
}]
});
}