isDirtyBox和isDirtyLegend

时间:2013-02-19 05:52:08

标签: highcharts highstock

我在here中的一些帖子中发现,使用了 chart.isDirtyBox chart.isDirtyLegend 属性。我也无法在highcharts API中找到它们。

他们究竟做了什么?有人可以帮助我获取这些属性的文档或帮助我解释这些属性的使用,可能还有例子吗?

1 个答案:

答案 0 :(得分:2)

这不是文档,它只是用于了解哪些元素已被更改并且必须重绘。

Highstock v1.2.4

isDirtyBox - 相关代码。

var chart = this,
    ...
    isDirtyBox = chart.isDirtyBox;

// redraw axes
each(axes, function (axis) {

    // Fire 'afterSetExtremes' only if extremes are set
    if (axis.isDirtyExtremes) { // #821
        axis.isDirtyExtremes = false;
        afterRedraw.push(function () { // prevent a recursive call to chart.redraw() (#1119)
            fireEvent(axis, 'afterSetExtremes', axis.getExtremes()); // #747, #751
        });
    }

    if (axis.isDirty || isDirtyBox || hasStackedSeries) {
        axis.redraw();
        isDirtyBox = true; // #792
    }
});

// the plot areas size has changed
if (isDirtyBox) {
    chart.drawChartBox();
}

isDirtyLegend - 相关代码。

var chart = this,
    ...
    redrawLegend = chart.isDirtyLegend,
    ...

// handle updated data in the series
each(series, function (serie) {
    if (serie.isDirty) { // prepare the data so axis can read it
        if (serie.options.legendType === 'point') {
            redrawLegend = true;
        }
    }
});

// handle added or removed series
if (redrawLegend && legend.options.enabled) { // series or pie points are added or removed
    // draw legend graphics
    legend.render();

    chart.isDirtyLegend = false;
}

isDirtyLegend也在chart.resizeseries.removechart.addSeries中使用以下行。

chart.isDirtyLegend = true; // force legend redraw