Skip to content

Commit

Permalink
Adding example for legend multi select for VSBC
Browse files Browse the repository at this point in the history
  • Loading branch information
srmukher committed Dec 13, 2024
1 parent 216f82e commit 796309f
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
1 change: 1 addition & 0 deletions packages/charts/react-charting/etc/react-charting.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1476,6 +1476,7 @@ export interface IVerticalStackedBarChartProps extends ICartesianChartProps {
barMinimumHeight?: number;
barWidth?: number | 'default' | 'auto';
calloutProps?: Partial<ICalloutProps>;
canSelectMultipleLegends?: boolean;
chartTitle?: string;
// @deprecated
colors?: string[];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -651,7 +651,7 @@ export class VerticalStackedBarChartBase extends React.Component<
overflowText={this.props.legendsOverflowText}
{...this.props.legendProps}
onChange={this._onLegendChange}
canSelectMultipleLegends
canSelectMultipleLegends={this.props.canSelectMultipleLegends}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,12 @@ export interface IVerticalStackedBarChartProps extends ICartesianChartProps {
* The prop used to enable rounded corners for the chart.
*/
roundCorners?: boolean;

/**
* The prop used to enable multiple legend selection.
* @default false
*/
canSelectMultipleLegends?: boolean;
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ interface IVerticalStackedBarState {
margins: {};
enableGradient: boolean;
roundCorners: boolean;
legendMultiSelect: boolean;
}

export class VerticalStackedBarChartBasicExample extends React.Component<{}, IVerticalStackedBarState> {
Expand All @@ -41,6 +42,7 @@ export class VerticalStackedBarChartBasicExample extends React.Component<{}, IVe
},
enableGradient: false,
roundCorners: false,
legendMultiSelect: false,
};
}

Expand Down Expand Up @@ -94,6 +96,10 @@ export class VerticalStackedBarChartBasicExample extends React.Component<{}, IVe
this.setState({ roundCorners: checked });
};

private _onToggleLegendMultiSelect = (ev: React.MouseEvent<HTMLElement>, checked: boolean) => {
this.setState({ legendMultiSelect: checked });
};

private _basicExample(): JSX.Element {
const { showLine } = this.state;
const firstChartPoints: IVSChartDataPoint[] = [
Expand Down Expand Up @@ -307,6 +313,13 @@ export class VerticalStackedBarChartBasicExample extends React.Component<{}, IVe
<Toggle label="Enable Gradient" onText="ON" offText="OFF" onChange={this._onEnableGradientChange} />
&nbsp;&nbsp;
<Toggle label="Rounded Corners" onText="ON" offText="OFF" onChange={this._onRoundCornersChange} />
&nbsp;&nbsp;
<Toggle
label="Select Multiple Legends"
onText="ON"
offText="OFF"
onChange={this._onToggleLegendMultiSelect}
/>
</div>
{this.state.showAxisTitles && (
<div style={rootStyle}>
Expand All @@ -328,6 +341,7 @@ export class VerticalStackedBarChartBasicExample extends React.Component<{}, IVe
xAxisTitle={this.state.showAxisTitles ? 'Number of days' : undefined}
enableGradient={this.state.enableGradient}
roundCorners={this.state.roundCorners}
canSelectMultipleLegends={this.state.legendMultiSelect}
/>
</div>
)}
Expand Down

0 comments on commit 796309f

Please sign in to comment.