var hours = ['','塑料瓶', '其他', '玻璃瓶'];
var days = ['无','少量','中量', '微量','大量'];
var data = [[0,1,0.64],[0,2,0.08],[0,3,0.16],[3,1,0.03],[3,3,0.04]];
data = data.map(function (item) {
return [item[1], item[0], item[2]];
});
option = {
title: {
text: 'Labulabula',
link: 'https://github.com/pissang/echarts-next/graphs/punch-card'
},
legend: {
data: ['置信度'],
left: 'right'
},
tooltip: {
position: 'top',
formatter: function (params) {
return params.value[2] + ' commits in ' + hours[params.value[0]] + ' of ' + days[params.value[1]];
}
},
grid: {
left: 20,
bottom: 10,
right: 25,
containLabel: true
},
xAxis: {
type: 'category',
data: hours,
boundaryGap: false,
splitLine: {
show: true,
lineStyle: {
color: '#999',
type: 'dashed'
}
},
axisLine: {
show: true //显示坐标轴线
}
},
yAxis: {
type: 'category',
data: days,
axisLine: {
show: true //显示坐标轴线
}
},
series: [{
name: '置信度',
type: 'scatter',
symbolSize: function (val) {
return val[2] * 150;
},
data: data,
animationDelay: function (idx) {
return idx * 5;
},
label: { //显示数值的地方
normal: {
position:'top',
color:'#000000',
show: true,
formatter:function(params) {
return params.value[2];
}
}
}
}]
};
Echarts中的Demo:https://echarts.baidu.com/examples/editor.html?c=scatter-punchCard