2

我在之前的几篇文章中找到了,比如在这里,使用了chart.isDirtyBoxandchart.isDirtyLegend属性。我也无法在 highcharts API 中找到它们。

他们实际上是做什么的?那里的任何人都可以帮助我获取这些属性的文档或帮助我解释这些属性的使用,可能带有示例吗?

4

1 回答 1

3

它不在文档中,它只是在内部用于知道哪些元素已更改并且必须重绘。

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.resize,series.removechart.addSeries下面的行。

chart.isDirtyLegend = true; // force legend redraw
于 2013-02-19T17:20:51.073 回答