Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edit line chart based on legend selection in Text box #33517

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react';
import { Axis as D3Axis } from 'd3-axis';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🕵🏾‍♀️ visual regressions to review in the fluentuiv8 Visual Regression Report

Callout 4 screenshots
Image Name Diff(in Pixels) Image Type
Callout.Left top edge.chromium.png 1949 Changed
Callout.Bottom Left Edge RTL.chromium.png 2178 Changed
Callout.No callout width specified.chromium.png 2319 Changed
Callout.No beak.chromium.png 2306 Changed
react-charting-AreaChart 1 screenshots
Image Name Diff(in Pixels) Image Type
react-charting-AreaChart.Custom Accessibility.chromium.png 11 Changed
react-charting-GaugeChart 1 screenshots
Image Name Diff(in Pixels) Image Type
react-charting-GaugeChart.Basic.chromium.png 2 Changed

import { select as d3Select, pointer } from 'd3-selection';
import { bisector } from 'd3-array';
import { ILegend, Legends } from '../Legends/index';
import { ILegend, ILegendsProps, Legends } from '../Legends/index';
import { line as d3Line, curveLinear as d3curveLinear } from 'd3-shape';
import {
classNamesFunction,
Expand Down Expand Up @@ -188,6 +188,29 @@ export class LineChartBase extends React.Component<ILineChartProps, ILineChartSt
private _isRTL: boolean = getRTL();
private _cartesianChartRef: React.RefObject<IChart>;

public static getDerivedStateFromProps(
nextProps: Readonly<ILineChartProps>,
prevState: Readonly<ILineChartState>,
): Partial<ILineChartState> | null {
if (nextProps.legendProps?.selectedLegends?.length! > 0) {
const { selectedLegends = [] } = (nextProps.legendProps! as ILegendsProps) || {};
return {
...prevState,
selectedLegendPoints: new LineChartBase(nextProps)._injectIndexPropertyInLineChartData(
nextProps.data.lineChartData,
Array.isArray(selectedLegends) && selectedLegends?.some(legend => legend.trim().length > 0),
),
};
} else if (nextProps.legendProps?.selectedLegend !== undefined) {
const { selectedLegend = undefined } = (nextProps.legendProps! as ILegendsProps) || {};
return {
...prevState,
selectedLegend,
};
}
return prevState;
}

constructor(props: ILineChartProps) {
super(props);

Expand Down
Loading