Skip to content

fix(react-charting): Fix for lineOptions bug in Area chart #34298

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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
@@ -0,0 +1,7 @@
{

Choose a reason for hiding this comment

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

🕵🏾‍♀️ visual changes to review in the Visual Change Report

vr-tests/Callout 11 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/Callout.Left bottom edge.default.chromium.png 3123 Changed
vr-tests/Callout.Bottom right edge.default.chromium.png 1120 Changed
vr-tests/Callout.No callout width specified.default.chromium.png 2126 Changed
vr-tests/Callout.Beak 25.default.chromium.png 2185 Changed
vr-tests/Callout.Rendering callout attached to a rectangle.default.chromium.png 1832 Changed
vr-tests/Callout.Bottom left edge - RTL.default.chromium.png 2186 Changed
vr-tests/Callout.Bottom right edge - RTL.default.chromium.png 1114 Changed
vr-tests/Callout.Gap space 25.default.chromium.png 2181 Changed
vr-tests/Callout.Top auto edge.default.chromium.png 2196 Changed
vr-tests/Callout.Right bottom edge.default.chromium.png 3037 Changed
vr-tests/Callout.Top right edge.default.chromium.png 1134 Changed
vr-tests/Keytip 3 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/Keytip.Disabled.default.chromium.png 24 Changed
vr-tests/Keytip.Offset.default.chromium.png 86 Changed
vr-tests/Keytip.Root.default.chromium.png 51 Changed
vr-tests/react-charting-GaugeChart 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/react-charting-GaugeChart.Basic.default.chromium.png 2 Changed
vr-tests/react-charting-LineChart 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/react-charting-LineChart.Multiple.default.chromium.png 192 Changed
vr-tests/react-charting-MultiStackBarChart 1 screenshots
Image Name Diff(in Pixels) Image Type
vr-tests/react-charting-MultiStackBarChart.Basic_PartToWhole - Dark Mode.default.chromium.png 363 Changed

There were 1 duplicate changes discarded. Check the build logs for more information.

"type": "patch",
"comment": "fix(react-charting): Fix for lineOptions bug in Area chart",
"packageName": "@fluentui/react-charting",
"email": "120183316+srmukher@users.noreply.github.com",
"dependentChangeType": "patch"
}
Original file line number Diff line number Diff line change
@@ -736,82 +736,84 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
let lineColor: string;
// eslint-disable-next-line @typescript-eslint/no-explicit-any
this._data.forEach((singleStackedData: Array<any>, index: number) => {
const curveFactory = getCurveFactory(points[index].lineOptions?.curve, d3CurveBasis);
const area = d3Area()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.x((d: any) => xScale(d.xVal))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.y0((d: any) => yScale(d.values[0]))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.y1((d: any) => yScale(d.values[1]))
.curve(curveFactory);
const line = d3Line()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.x((d: any) => xScale(d.xVal))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.y((d: any) => yScale(d.values[1]))
.curve(curveFactory);
const layerOpacity = this.props.mode === 'tozeroy' ? 0.8 : this._opacity[index];
graph.push(
<React.Fragment key={`${index}-graph-${this._uniqueIdForGraph}`}>
{this.props.enableGradient && (
<defs>
<linearGradient id={`gradient_${index}`} x1="0%" x2="0%" y1="0%" y2="100%">
<stop offset="0" stopColor={this._colors[index]} />
<stop offset="100%" stopColor="transparent" />
</linearGradient>
</defs>
)}
<path
id={`${index}-line-${this._uniqueIdForGraph}`}
d={line(singleStackedData)!}
fill={'transparent'}
strokeWidth={points[index].lineOptions?.strokeWidth ?? 3}
stroke={this._colors[index]}
opacity={this._getLineOpacity(points[index]!.legend)}
onMouseMove={this._onRectMouseMove}
onMouseOut={this._onRectMouseOut}
onMouseOver={this._onRectMouseMove}
strokeDasharray={points[index].lineOptions?.strokeDasharray}
strokeDashoffset={points[index].lineOptions?.strokeDashoffset}
strokeLinecap={points[index].lineOptions?.strokeLinecap}
/>
{singleStackedData.length === 1 ? (
<circle
id={`${index}-graph-${this._uniqueIdForGraph}`}
cx={xScale(singleStackedData[0].xVal)}
cy={yScale(singleStackedData[0].values[1])}
r={6}
stroke={this._colors[index]}
strokeWidth={3}
fill={this._colors[index]}
opacity={layerOpacity}
fillOpacity={this._getOpacity(points[index]!.legend)}
onMouseMove={this._onRectMouseMove}
onMouseOut={this._onRectMouseOut}
onMouseOver={this._onRectMouseMove}
/>
) : (
if (points[index]) {
Copy link
Contributor

Choose a reason for hiding this comment

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

if (points[index]) {

how is it possible that index is out of bounds here. Is there a difference between length of this.props.data and this._data

const curveFactory = getCurveFactory(points[index].lineOptions?.curve, d3CurveBasis);
const area = d3Area()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.x((d: any) => xScale(d.xVal))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.y0((d: any) => yScale(d.values[0]))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.y1((d: any) => yScale(d.values[1]))
.curve(curveFactory);
const line = d3Line()
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.x((d: any) => xScale(d.xVal))
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.y((d: any) => yScale(d.values[1]))
.curve(curveFactory);
const layerOpacity = this.props.mode === 'tozeroy' ? 0.8 : this._opacity[index];
graph.push(
<React.Fragment key={`${index}-graph-${this._uniqueIdForGraph}`}>
{this.props.enableGradient && (
<defs>
<linearGradient id={`gradient_${index}`} x1="0%" x2="0%" y1="0%" y2="100%">
<stop offset="0" stopColor={this._colors[index]} />
<stop offset="100%" stopColor="transparent" />
</linearGradient>
</defs>
)}
<path
id={`${index}-graph-${this._uniqueIdForGraph}`}
d={area(singleStackedData)!}
fill={this.props.enableGradient ? `url(#gradient_${index})` : this._colors[index]}
opacity={layerOpacity}
fillOpacity={this._getOpacity(points[index]!.legend)}
id={`${index}-line-${this._uniqueIdForGraph}`}
d={line(singleStackedData)!}
fill={'transparent'}
strokeWidth={points[index].lineOptions?.strokeWidth ?? 3}
stroke={this._colors[index]}
opacity={this._getLineOpacity(points[index]!.legend)}
onMouseMove={this._onRectMouseMove}
onMouseOut={this._onRectMouseOut}
onMouseOver={this._onRectMouseMove}
{...(this.props.optimizeLargeData && {
'data-is-focusable': this._legendHighlighted(points[index]!.legend) || this._noLegendHighlighted(),
role: 'img',
'aria-label': `${points[index].legend}, series ${index + 1} of ${points.length} with ${
points[index].data.length
} data points.`,
})}
strokeDasharray={points[index].lineOptions?.strokeDasharray}
strokeDashoffset={points[index].lineOptions?.strokeDashoffset}
strokeLinecap={points[index].lineOptions?.strokeLinecap}
/>
)}
</React.Fragment>,
);
{singleStackedData.length === 1 ? (
<circle
id={`${index}-graph-${this._uniqueIdForGraph}`}
cx={xScale(singleStackedData[0].xVal)}
cy={yScale(singleStackedData[0].values[1])}
r={6}
stroke={this._colors[index]}
strokeWidth={3}
fill={this._colors[index]}
opacity={layerOpacity}
fillOpacity={this._getOpacity(points[index]!.legend)}
onMouseMove={this._onRectMouseMove}
onMouseOut={this._onRectMouseOut}
onMouseOver={this._onRectMouseMove}
/>
) : (
<path
id={`${index}-graph-${this._uniqueIdForGraph}`}
d={area(singleStackedData)!}
fill={this.props.enableGradient ? `url(#gradient_${index})` : this._colors[index]}
opacity={layerOpacity}
fillOpacity={this._getOpacity(points[index]!.legend)}
onMouseMove={this._onRectMouseMove}
onMouseOut={this._onRectMouseOut}
onMouseOver={this._onRectMouseMove}
{...(this.props.optimizeLargeData && {
'data-is-focusable': this._legendHighlighted(points[index]!.legend) || this._noLegendHighlighted(),
role: 'img',
'aria-label': `${points[index].legend}, series ${index + 1} of ${points.length} with ${
points[index].data.length
} data points.`,
})}
/>
)}
</React.Fragment>,
);
}
});

const circleRadius = pointOptions && pointOptions.r ? Number(pointOptions.r) : 8;
Loading
Oops, something went wrong.