Skip to content

Commit b5d571f

Browse files
authored
Enable chart selection based on legends in declarative charts (#33460)
1 parent ed3876a commit b5d571f

File tree

10 files changed

+18
-11
lines changed

10 files changed

+18
-11
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"type": "patch",
3+
"comment": "Enable chart selection based on legends in declarative charts",
4+
"packageName": "@fluentui/react-charting",
5+
"email": "[email protected]",
6+
"dependentChangeType": "patch"
7+
}

Diff for: packages/charts/react-charting/src/components/AreaChart/AreaChart.base.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,7 @@ export class AreaChartBase extends React.Component<IAreaChartProps, IAreaChartSt
124124
super(props);
125125
this._createSet = memoizeFunction(this._createDataSet);
126126
this.state = {
127-
selectedLegend: '',
127+
selectedLegend: props.legendProps?.selectedLegend ?? '',
128128
activeLegend: '',
129129
hoverXValue: '',
130130
isCalloutVisible: false,

Diff for: packages/charts/react-charting/src/components/DonutChart/DonutChart.base.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export class DonutChartBase extends React.Component<IDonutChartProps, IDonutChar
7373
color: '',
7474
xCalloutValue: '',
7575
yCalloutValue: '',
76-
selectedLegend: '',
76+
selectedLegend: props.legendProps?.selectedLegend ?? '',
7777
focusedArcId: '',
7878
};
7979
this._hoverCallback = this._hoverCallback.bind(this);

Diff for: packages/charts/react-charting/src/components/GaugeChart/GaugeChart.base.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ export class GaugeChartBase extends React.Component<IGaugeChartProps, IGaugeChar
141141

142142
this.state = {
143143
hoveredLegend: '',
144-
selectedLegend: '',
144+
selectedLegend: props.legendProps?.selectedLegend ?? '',
145145
focusedElement: '',
146146
calloutTarget: null,
147147
isCalloutVisible: false,

Diff for: packages/charts/react-charting/src/components/GroupedVerticalBarChart/GroupedVerticalBarChart.base.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ export class GroupedVerticalBarChartBase extends React.Component<
109109
dataForHoverCard: 0,
110110
isCalloutVisible: false,
111111
refSelected: null,
112-
selectedLegend: '',
112+
selectedLegend: props.legendProps?.selectedLegend ?? '',
113113
xCalloutValue: '',
114114
yCalloutValue: '',
115115
YValueHover: [],

Diff for: packages/charts/react-charting/src/components/HeatMapChart/HeatMapChart.base.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ export class HeatMapChartBase extends React.Component<IHeatMapChartProps, IHeatM
133133
): DataSet => this._createNewDataSet(data, xDate, xNum, yDate, yNum),
134134
);
135135
this.state = {
136-
selectedLegend: '',
136+
selectedLegend: props.legendProps?.selectedLegend ?? '',
137137
activeLegend: '',
138138
isCalloutVisible: false,
139139
target: null,

Diff for: packages/charts/react-charting/src/components/HorizontalBarChartWithAxis/HorizontalBarChartWithAxis.base.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@ export class HorizontalBarChartWithAxisBase extends React.Component<
8787
isLegendSelected: false,
8888
isLegendHovered: false,
8989
refSelected: null,
90-
selectedLegendTitle: '',
90+
selectedLegendTitle: props.legendProps?.selectedLegend ?? '',
9191
xCalloutValue: '',
9292
yCalloutValue: '',
9393
activeXdataPoint: null,

Diff for: packages/charts/react-charting/src/components/LineChart/LineChart.base.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -186,7 +186,7 @@ export class LineChartBase extends React.Component<ILineChartProps, ILineChartSt
186186
activeLegend: '',
187187
YValueHover: [],
188188
refSelected: '',
189-
selectedLegend: '',
189+
selectedLegend: props.legendProps?.selectedLegend ?? '',
190190
isCalloutVisible: false,
191191
selectedLegendPoints: [],
192192
selectedColorBarLegend: [],
@@ -1192,7 +1192,7 @@ export class LineChartBase extends React.Component<ILineChartProps, ILineChartSt
11921192
() => `translate(${this._xAxisScale(pointToHighlight.x)}, ${this._yAxisScale(pointToHighlight.y)})`,
11931193
)
11941194
.attr('visibility', 'visibility')
1195-
.attr('y2', `${lineHeight - 5 - this._yAxisScale(pointToHighlight.y)}`);
1195+
.attr('y2', `${lineHeight - this._yAxisScale(pointToHighlight.y)}`);
11961196

11971197
this.setState({
11981198
nearestCircleToHighlight: pointToHighlight,
@@ -1278,7 +1278,7 @@ export class LineChartBase extends React.Component<ILineChartProps, ILineChartSt
12781278
d3Select(`#${this._verticalLine}`)
12791279
.attr('transform', () => `translate(${_this._xAxisScale(x)}, ${_this._yAxisScale(y)})`)
12801280
.attr('visibility', 'visibility')
1281-
.attr('y2', `${lineHeight - 5 - _this._yAxisScale(y)}`);
1281+
.attr('y2', `${lineHeight - _this._yAxisScale(y)}`);
12821282
if (this._uniqueCallOutID !== circleId) {
12831283
this._uniqueCallOutID = circleId;
12841284
this.setState({

Diff for: packages/charts/react-charting/src/components/VerticalBarChart/VerticalBarChart.base.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -110,7 +110,7 @@ export class VerticalBarChartBase extends React.Component<IVerticalBarChartProps
110110
dataForHoverCard: 0,
111111
isCalloutVisible: false,
112112
refSelected: null,
113-
selectedLegend: '',
113+
selectedLegend: props.legendProps?.selectedLegend ?? '',
114114
activeLegend: '',
115115
xCalloutValue: '',
116116
yCalloutValue: '',

Diff for: packages/charts/react-charting/src/components/VerticalStackedBarChart/VerticalStackedBarChart.base.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ export class VerticalStackedBarChartBase extends React.Component<
128128
super(props);
129129
this.state = {
130130
isCalloutVisible: false,
131-
selectedLegend: '',
131+
selectedLegend: props.legendProps?.selectedLegend ?? '',
132132
activeLegend: '',
133133
refSelected: null,
134134
dataForHoverCard: 0,

0 commit comments

Comments
 (0)