UNPKG

scichart

Version:

Fast WebGL JavaScript Charting Library and Framework

112 lines (111 loc) 4.46 kB
import { EventHandler } from "../../Core/EventHandler"; import { EChart2DModifierType } from "../../types/ChartModifierType"; import { IThemeProvider } from "../Themes/IThemeProvider"; import { SciChartLegend } from "../Visuals/Legend/SciChartLegend"; import { ILegendOptionsBase } from "../Visuals/Legend/SciChartLegendBase"; import { IRenderableSeries } from "../Visuals/RenderableSeries/IRenderableSeries"; import { ChartModifierBase2D, IChartModifierBaseOptions } from "./ChartModifierBase2D"; /** * Optional parameters used to configure a {@link LegendModifier} at construct time */ export interface ILegendModifierOptions extends IChartModifierBaseOptions, ILegendOptionsBase { /** * Sets whether the legend has visibility checkboxes in it or not */ showCheckboxes?: boolean; /** * Sets whether Series markers are visible or not */ showSeriesMarkers?: boolean; /** * Callback when a legend item checkbox is checked or unchecked (by default, this corresponds to {@link IRenderableSeries.isVisible} * @param series * @param isChecked */ isCheckedChangedCallback?: (series: IRenderableSeries, isChecked: boolean, legend?: SciChartLegend) => void; /** * Set this only if you need to pass in a custom legend instance. * showCheckboxes, showSeriesMarkers and isCheckedChangedCallback will be set on the instance you pass if specified in the options. */ legend?: SciChartLegend; } /** * Type args for the {@link LegendModifier.isCheckedChanged} callback */ export declare type TCheckedChangedArgs = { /** * The series which was checked or unchecked */ series: IRenderableSeries; /** * Whether the corresponding legend item is checked or not (by default, this corresponds to {@link IRenderableSeries.isVisible}) */ isChecked: boolean; }; /** * The LegendModifier provides interactive legend behavior on a 2D {@link SciChartSurface} * within SciChart - High Performance {@link https://www.scichart.com/javascript-chart-features | JavaScript Charts} * @remarks * * To apply the LegendModifier to a {@link SciChartSurface} and add tooltip behavior, * use the following code: * * ```ts * const sciChartSurface: SciChartSurface; * sciChartSurface.chartModifiers.add(new LegendModifier()); * ``` * * --- * 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/chart-modifier-api/miscellaneous-modifiers/legend-modifier/} */ export declare class LegendModifier extends ChartModifierBase2D { private readonly _legendOptions; readonly type: EChart2DModifierType; /** * Gets the {@link SciChartLegend} control used to render the legend */ sciChartLegend: SciChartLegend | undefined; /** * An event handler raised when a {@link SciChartLegend} row checkbox is checked or unchecked */ readonly isCheckedChanged: EventHandler<TCheckedChangedArgs>; /** * Creates an instance of the LegendModifier * @param options Optional parameters {@link ILegendModifierOptions} used to configure the modifier * * --- * 📚 Docs: {@link https://www.scichart.com/documentation/js/v4/2d-charts/chart-modifier-api/miscellaneous-modifiers/legend-modifier/} */ constructor(options?: ILegendModifierOptions); private applyLegendOptions; /** @inheritDoc */ applyTheme(themeProvider: IThemeProvider): void; /** @inheritDoc */ onAttachSeries(rs: IRenderableSeries): void; /** @inheritDoc */ onDetachSeries(rs: IRenderableSeries): void; /** @inheritDoc */ onParentSurfaceRendered(): void; /** @inheritDoc */ onAttach(): void; /** @inheritDoc */ onDetach(): void; /** @inheritDoc */ includeSeries(series: IRenderableSeries, isIncluded: boolean): boolean; /** @inheritDoc */ testIsIncludedSeries(series: IRenderableSeries): boolean; /** @inheritDoc */ toJSON(): { type: string; options: Required<Omit<IChartModifierBaseOptions, never>>; }; /** @inheritDoc */ delete(): void; /** * Callback called from inner {@link SciChartLegend} when a checkbox is checked or unchecked * @param series * @param isChecked * @protected */ protected legendItemCheckedChanged(series: IRenderableSeries, isChecked: boolean): void; }