图例中是否可以同时包含colorAxis和series?http://jsfiddle.net/6k17dojn/我看到在切换此设置时一次只能显示一个
colorAxis: {
showInLegend: true,
}
当前,要使用显示一个基本图例colorAxis
,您需要向Highcharts核心添加一些代码。colorAxis
如果showInLegend
属性设置为,则下面的此插件可让您添加图例false
:
(function(H) {
H.addEvent(H.Legend, 'afterGetAllItems', function(e) {
var colorAxisItems = [],
colorAxis = this.chart.colorAxis[0],
i;
if (colorAxis && colorAxis.options) {
if (colorAxis.options.dataClasses) {
colorAxisItems = colorAxis.getDataClassLegendSymbols();
} else {
colorAxisItems.push(colorAxis);
}
}
i = colorAxisItems.length;
while (i--) {
e.allItems.unshift(colorAxisItems[i]);
}
});
}(Highcharts))
现场演示: http : //jsfiddle.net/BlackLabel/hs1zeruy/
API参考: https : //api.highcharts.com/highcharts/colorAxis.showInLegend