更新 colorAxis 后的 Highcharts 导出

Highcharts Export after updating colorAxis

使用 Highcharts heapmap 模块时,在 colorAxis 更新后导出图表时出现问题。

我使用

创建图表
var chart = new Highcharts.Chart({
    ...
    colorAxis: {
        min: 0,
        max: 100,
        minColor: '#FFFFFF',
        maxColor: Highcharts.getOptions().colors[0]
    },
    ...
})

colorAxis 上的 update 之后,其中 max 被更改,图表的导出显示原始比例。

有什么我应该做的不同的事情吗?

Example jsfiddle

在图表回调中调用您的操作,并将导出包装到 setTimeout() 中,然后就可以了。

    chart.colorAxis[0].update({
        max: 200
    }, true);
    setTimeout(function () {
        chart.exportChart();
    }, 1);

示例:http://jsfiddle.net/rje8y2sw/6/

解决了问题。看起来这是 Highcharts 如何处理 colorAxis 更新的问题。它没有正确设置 chart.options.colorAxis 值。

在更新调用中,以下行(highcharts.src.js 中的第 15467 行)应该更新正确的 chart.options 值。

newOptions = chart.options[this.coll][this.options.index] = merge(this.userOptions, newOptions);

但是,chart.options.colorAxis 不是数组,也没有 this.options.index。因此,这条线没有按预期工作。如果您稍微修改以检查索引是否存在并根据需要更新对象或索引对象,则可以解决此问题。

newOptions = this.options.index ? chart.options[this.coll][this.options.index] : chart.options[this.coll] = merge(this.userOptions, newOptions);