// 先初始化日历坐标系。
chart.setOption({
calendar: {
...
}
});
var option2 = {
xAxis: [],
yAxis: [],
grid: [],
series: []
};
dateList.each(function (date) {
// 对每日,计算其在日历坐标系上的像素位置。
var gridCenter = chart.convertToPixel(
'calendar', date
);
// 对每日,做一个直角坐标系。
option2.grid.push({
left: gridCenter[0] - cellWidth / 2,
top: gridCenter[1] - cellHeight / 2,
width: cellWidth,
height: cellHeight,
...
});
option2.xAxis.push({...});
option2.yAxis.push({...});
// 直角坐标系里的柱状图。
option2.series.push({
type: 'bar',
data: ...
});
});
// 将所有直角坐标系和柱状图设置进 chart。
chart.setOption(option2);