diff --git a/change/@fluentui-react-charting-48ec930a-4a1f-4ee2-bd2d-bdaf4b06fbb0.json b/change/@fluentui-react-charting-48ec930a-4a1f-4ee2-bd2d-bdaf4b06fbb0.json new file mode 100644 index 00000000000000..4f0a25871f99e6 --- /dev/null +++ b/change/@fluentui-react-charting-48ec930a-4a1f-4ee2-bd2d-bdaf4b06fbb0.json @@ -0,0 +1,7 @@ +{ + "type": "patch", + "comment": "Enable chart selection based on legends in declarative charts", + "packageName": "@fluentui/react-charting", + "email": "74965306+Anush2303@users.noreply.github.com", + "dependentChangeType": "patch" +} diff --git a/packages/charts/react-charting/src/components/AreaChart/AreaChart.base.tsx b/packages/charts/react-charting/src/components/AreaChart/AreaChart.base.tsx index fef7e6965c59d7..686fe0babe863b 100644 --- a/packages/charts/react-charting/src/components/AreaChart/AreaChart.base.tsx +++ b/packages/charts/react-charting/src/components/AreaChart/AreaChart.base.tsx @@ -124,7 +124,7 @@ export class AreaChartBase extends React.Component this._createNewDataSet(data, xDate, xNum, yDate, yNum), ); this.state = { - selectedLegend: '', + selectedLegend: props.legendProps?.selectedLegend ?? '', activeLegend: '', isCalloutVisible: false, target: null, diff --git a/packages/charts/react-charting/src/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.tsx b/packages/charts/react-charting/src/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.tsx index 8e5562ebe55bbf..10246111177c29 100644 --- a/packages/charts/react-charting/src/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.tsx +++ b/packages/charts/react-charting/src/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.tsx @@ -87,7 +87,7 @@ export class HorizontalBarChartWithAxisBase extends React.Component< isLegendSelected: false, isLegendHovered: false, refSelected: null, - selectedLegendTitle: '', + selectedLegendTitle: props.legendProps?.selectedLegend ?? '', xCalloutValue: '', yCalloutValue: '', activeXdataPoint: null, diff --git a/packages/charts/react-charting/src/components/LineChart/LineChart.base.tsx b/packages/charts/react-charting/src/components/LineChart/LineChart.base.tsx index 846ce2c3764ac6..0e55be45edac90 100644 --- a/packages/charts/react-charting/src/components/LineChart/LineChart.base.tsx +++ b/packages/charts/react-charting/src/components/LineChart/LineChart.base.tsx @@ -186,7 +186,7 @@ export class LineChartBase extends React.Component `translate(${this._xAxisScale(pointToHighlight.x)}, ${this._yAxisScale(pointToHighlight.y)})`, ) .attr('visibility', 'visibility') - .attr('y2', `${lineHeight - 5 - this._yAxisScale(pointToHighlight.y)}`); + .attr('y2', `${lineHeight - this._yAxisScale(pointToHighlight.y)}`); this.setState({ nearestCircleToHighlight: pointToHighlight, @@ -1278,7 +1278,7 @@ export class LineChartBase extends React.Component `translate(${_this._xAxisScale(x)}, ${_this._yAxisScale(y)})`) .attr('visibility', 'visibility') - .attr('y2', `${lineHeight - 5 - _this._yAxisScale(y)}`); + .attr('y2', `${lineHeight - _this._yAxisScale(y)}`); if (this._uniqueCallOutID !== circleId) { this._uniqueCallOutID = circleId; this.setState({ diff --git a/packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx b/packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx index 8a0c7585df3416..9e793a25b87c60 100644 --- a/packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx +++ b/packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx @@ -110,7 +110,7 @@ export class VerticalBarChartBase extends React.Component