单轴散点图 js代码
import * as echarts from 'echarts';
var chartDom = document.getElementById('main');
var myChart = echarts.init(chartDom);
var option;
var hours = [ 'A'];
var days = ['1'];
var data = [数据集];
option = {
tooltip: {
position: 'top'
},
title: [],
singleAxis: [],
series: []
};
days.forEach(function (day, idx) {
option.title.push({
textBaseline: 'middle',
top: (idx + 1) * 99 / 21 + '%',
text: day
});
option.singleAxis.push({
left: 70,
type: 'category',
boundaryGap: false,
data: hours,
top: (idx * 93 / 20 + 5) + '%',
height: (100 / 20 - 5) + '%',
axisLabel: {
interval:0
}
});
option.series.push({
singleAxisIndex: idx,
coordinateSystem: 'singleAxis',
type: 'scatter',
data: [],
symbolSize: function (dataItem) {
return dataItem[1] * 0.8;
}
});
});
data.forEach(function (dataItem) {
option.series[dataItem[0]].data.push([dataItem[1], dataItem[2]]);
});
option && myChart.setOption(option);