Chart.removeAllSeries

Syntax

removeAllSeries(redraw: Boolean);

Parameters

redraw. Indicates whether the chart should be redrawn. Available values:

Description

The removeAllSeries method removes all data series from the chart.

Example

To execute the example, the HTML page should contains the Chart component named chart (see Example of Creating a Histogram). Remove one of the chart data series:

// Get chart series
var series = chart.getSeries();
// Show the number of chart series to the browser console
console.log("Number of chart series: " + series.length);
// Check availability of data series in the chart
if (series.length > 0) {
    //Get the last data series of the chart
    var serie = chart.getSerie(chart.getSeries().length - 1);
    // Remove this series without redrawing the chart
    chart.removeSerie(serie, false);
    // Show the number of chart series after this series is removed to the browser console
    console.log("Number of chart series after the series is removed: " + chart.getSeries().length);
    // Redraw the chart
    chart.redraw(true);
}

After executing the example the last data series is removed from the array of chart series:

The browser console displays messages on the number of chart series before and after the series is removed:

Number of chart series: 5

Number of chart series after the series is removed: 4

 

Remove all data series from the chart:

// Remove all data series from the chart
chart.removeAllSeries();

After this a chart with no data series is displayed:

See also:

Chart