SciChart.js JavaScript 2D Charts API > 2D Chart Types > Series isVisible and isVisibleChanged API
Series isVisible and isVisibleChanged API

Each RenderableSeries has an isVisible property. This defines whether the series is included in rendering or not.

isVisible can be set programmatically, or is also set by SciChart.js when checking or unchecking a Legend row checkbox (see LegendModifier API).

You can listen to isVisible changes via the BaseRenderableSeries.isVisibleChanged event. Listen to the event (get a callback) using the following code:

import { FastLineRenderableSeries } from "scichart/Charting/Visuals/RenderableSeries/FastLineRenderableSeries";

// Subscribe to onIsVisibleChanged on instantiation
const lineSeries = new FastLineRenderableSeries(wasmContext, {
    stroke: "Red",
    strokeThickness: 3,
    isVisible: true,
    onIsVisibleChanged: (sourceSeries, isVisible) => {
        console.log(`Series ${sourceSeries.type} was set to isVisible=${isVisible}`);
    }
});
// Alternatiely you can subscribe to (or unsubscribe from) isVisibleChanged after instantiation
lineSeries.isVisibleChanged.subscribe((sourceSeries, isVisible) => {
    console.log(`Option 2: Series ${sourceSeries.type} was set to isVisible=${isVisible}`);
});
import { FastLineRenderableSeries } from "scichart/Charting/Visuals/RenderableSeries/FastLineRenderableSeries";

// Subscribe to onIsVisibleChanged on instantiation
const lineSeries = new FastLineRenderableSeries(wasmContext, {
    stroke: "Red",
    strokeThickness: 3,
    isVisible: true,
    onIsVisibleChanged: (sourceSeries: IRenderableSeries, isVisible: boolean) => {
        console.log(`Series ${sourceSeries.type} was set to isVisible=${isVisible}`);
    }
});
// Alternatiely you can subscribe to (or unsubscribe from) isVisibleChanged after instantiation
lineSeries.isVisibleChanged.subscribe((sourceSeries: IRenderableSeries, isVisible: boolean) => {
    console.log(`Option 2: Series ${sourceSeries.type} was set to isVisible=${isVisible}`);
});