Skip to content

Commit 44163b8

Browse files
committed
addressed ghost points in large series bug bash finding
1 parent 80a1d9d commit 44163b8

File tree

2 files changed

+26
-26
lines changed

2 files changed

+26
-26
lines changed

src/core/__tests__/chart-core-legend.test.tsx

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -144,15 +144,15 @@ describe("CoreChart: legend", () => {
144144

145145
act(() => mouseOver(getItem(0).getElement()));
146146
expect(getItems({ dimmed: false, active: true }).map((w) => w.getElement().textContent)).toEqual(["L1"]);
147-
expect(hc.getChartSeries(0).state).toBe("normal");
147+
expect(hc.getChartSeries(0).state).toBe("");
148148
expect(hc.getChartSeries(2).state).toBe("inactive");
149149
expect(hc.getPlotLinesById("L3").map((l) => l.svgElem.opacity)).toEqual([0.4, 0.4]);
150150

151151
act(() => mouseOut(getItem(0).getElement()));
152152
act(() => mouseOver(getItem(2).getElement()));
153153
expect(getItems({ dimmed: false, active: true }).map((w) => w.getElement().textContent)).toEqual(["Line 3"]);
154154
expect(hc.getChartSeries(0).state).toBe("inactive");
155-
expect(hc.getChartSeries(2).state).toBe("normal");
155+
expect(hc.getChartSeries(2).state).toBe("");
156156
expect(hc.getPlotLinesById("L3").map((l) => l.svgElem.opacity)).toEqual([1, 1]);
157157

158158
act(() => mouseOut(getItem(0).getElement()));
@@ -161,8 +161,8 @@ describe("CoreChart: legend", () => {
161161
"L1",
162162
"Line 3",
163163
]);
164-
expect(hc.getChartSeries(0).state).toBe("normal");
165-
expect(hc.getChartSeries(2).state).toBe("normal");
164+
expect(hc.getChartSeries(0).state).toBe("");
165+
expect(hc.getChartSeries(2).state).toBe("");
166166
expect(hc.getPlotLinesById("L3").map((l) => l.svgElem.opacity)).toEqual([1, 1]);
167167
},
168168
);
@@ -191,20 +191,20 @@ describe("CoreChart: legend", () => {
191191
act(() => mouseOut(getItem(0).getElement()));
192192
await clearHighlightPause();
193193
expect(getItems({ dimmed: false, active: true }).map((w) => w.getElement().textContent)).toEqual(["P1", "Pie 3"]);
194-
expect(hc.getChartPoint(0, 0).state).toBe("normal");
195-
expect(hc.getChartPoint(0, 2).state).toBe("normal");
194+
expect(hc.getChartPoint(0, 0).state).toBe("");
195+
expect(hc.getChartPoint(0, 2).state).toBe("");
196196

197197
act(() => mouseOver(getItem(2).getElement()));
198198
expect(getItems({ dimmed: true, active: true }).map((w) => w.getElement().textContent)).toEqual(["P1"]);
199199
expect(getItems({ dimmed: false, active: true }).map((w) => w.getElement().textContent)).toEqual(["Pie 3"]);
200-
expect(hc.getChartPoint(0, 0).state).toBe("normal");
200+
expect(hc.getChartPoint(0, 0).state).toBe("");
201201
expect(hc.getChartPoint(0, 2).state).toBe("hover");
202202

203203
act(() => mouseOut(getItem(2).getElement()));
204204
await clearHighlightPause();
205205
expect(getItems({ dimmed: false, active: true }).map((w) => w.getElement().textContent)).toEqual(["P1", "Pie 3"]);
206-
expect(hc.getChartPoint(0, 0).state).toBe("normal");
207-
expect(hc.getChartPoint(0, 2).state).toBe("normal");
206+
expect(hc.getChartPoint(0, 0).state).toBe("");
207+
expect(hc.getChartPoint(0, 2).state).toBe("");
208208
},
209209
);
210210

@@ -315,20 +315,20 @@ describe("CoreChart: legend", () => {
315315

316316
getItem(2).keydown({ keyCode: KeyCode.right });
317317
expect(getItem(0).getElement()).toHaveFocus();
318-
expect(hc.getChartSeries(0).state).toBe("normal");
318+
expect(hc.getChartSeries(0).state).toBe("");
319319
expect(hc.getChartSeries(1).state).toBe("inactive");
320320
expect(hc.getChartSeries(2).state).toBe("inactive");
321321

322322
getItem(0).keydown({ keyCode: KeyCode.escape });
323323
expect(getItem(0).getElement()).toHaveFocus();
324-
expect(hc.getChartSeries(0).state).toBe("normal");
325-
expect(hc.getChartSeries(1).state).toBe("normal");
326-
expect(hc.getChartSeries(2).state).toBe("normal");
324+
expect(hc.getChartSeries(0).state).toBe("");
325+
expect(hc.getChartSeries(1).state).toBe("");
326+
expect(hc.getChartSeries(2).state).toBe("");
327327

328328
getItem(0).keydown({ keyCode: KeyCode.right });
329329
expect(getItem(1).getElement()).toHaveFocus();
330330
expect(hc.getChartSeries(0).state).toBe("inactive");
331-
expect(hc.getChartSeries(1).state).toBe("normal");
331+
expect(hc.getChartSeries(1).state).toBe("");
332332
expect(hc.getChartSeries(2).state).toBe("inactive");
333333
},
334334
);

src/core/chart-api/chart-extra-highlight.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,8 @@ export class ChartExtraHighlight {
2323
// We keep track of the previously highlighted series and points to recover highlight state if needed.
2424
// The recover is necessary if the chart was re-rendered while the highlighting is set. For example,
2525
// when triggered a state update from the consumer-provided tooltip footer action.
26-
private seriesState = new Map<string, Highcharts.SeriesStateValue>();
27-
private pointState = new Map<string, Map<string, Highcharts.SeriesStateValue>>();
26+
private seriesState = new Map<string, "" | Highcharts.SeriesStateValue>();
27+
private pointState = new Map<string, Map<string, "" | Highcharts.PointStateValue>>();
2828

2929
public onChartRender() {
3030
this.overrideStateSetters();
@@ -42,7 +42,7 @@ export class ChartExtraHighlight {
4242
}
4343
}
4444
} else {
45-
this.setSeriesState(s, itemIds.includes(getSeriesId(s)) ? "normal" : "inactive");
45+
this.setSeriesState(s, itemIds.includes(getSeriesId(s)) ? "" : "inactive");
4646
}
4747
}
4848
setPlotLinesState(this.context.chart(), (lineId) => itemIds.includes(lineId));
@@ -61,12 +61,12 @@ export class ChartExtraHighlight {
6161
includedSeriesIds.add(getSeriesId(point.series));
6262
});
6363
for (const s of this.context.chart().series) {
64-
this.setSeriesState(s, includedSeries.has(s) ? "normal" : "inactive");
64+
this.setSeriesState(s, includedSeries.has(s) ? "" : "inactive");
6565
// We use special handling for column- series to make stacks or groups of columns that have a shared X highlighted.
6666
// See: https://github.com/highcharts/highcharts/issues/23076.
6767
if (s.type === "column") {
6868
for (const d of s.data) {
69-
this.setPointState(d, includedPoints.has(d) ? "normal" : "inactive");
69+
this.setPointState(d, includedPoints.has(d) ? "" : "inactive");
7070
}
7171
}
7272
}
@@ -89,7 +89,7 @@ export class ChartExtraHighlight {
8989
// We override point state that could have been set for columns using this.highlightChartGroup().
9090
else if (s.type === "column") {
9191
for (const d of s.data) {
92-
this.setPointState(d, "normal");
92+
this.setPointState(d, "");
9393
}
9494
}
9595
}
@@ -99,24 +99,24 @@ export class ChartExtraHighlight {
9999
// Removes dimmed state from all series and points.
100100
public clearChartItemsHighlight = () => {
101101
for (const s of this.context.chart().series ?? []) {
102-
this.setSeriesState(s, "normal");
102+
this.setSeriesState(s, "");
103103
for (const p of s.data) {
104-
this.setPointState(p, "normal");
104+
this.setPointState(p, "");
105105
}
106106
}
107107
setPlotLinesState(this.context.chart(), () => true);
108108
};
109109

110110
// Makes the specified series active or dimmed.
111-
private setSeriesState(series: Highcharts.Series, state: Highcharts.SeriesStateValue) {
111+
private setSeriesState(series: Highcharts.Series, state: "" | Highcharts.SeriesStateValue) {
112112
(series.setState as SeriesSetStateWithLock)[SET_STATE_LOCK] = false;
113113
series.setState(state, false);
114114
this.updateStoredSeriesState(series, state);
115115
(series.setState as SeriesSetStateWithLock)[SET_STATE_LOCK] = true;
116116
}
117117

118118
// Makes the specified point active or dimmed.
119-
private setPointState(point: Highcharts.Point, state: Highcharts.PointStateValue) {
119+
private setPointState(point: Highcharts.Point, state: "" | Highcharts.PointStateValue) {
120120
(point.setState as PointSetStateWithLock)[SET_STATE_LOCK] = false;
121121
point.setState(state, true);
122122
this.updateStoredPointState(point, state);
@@ -144,11 +144,11 @@ export class ChartExtraHighlight {
144144
setPlotLinesState(this.context.chart(), (lineId) => !inactiveSeriesIds.has(lineId));
145145
}
146146

147-
private updateStoredSeriesState(series: Highcharts.Series, state: Highcharts.SeriesStateValue) {
147+
private updateStoredSeriesState(series: Highcharts.Series, state: "" | Highcharts.SeriesStateValue) {
148148
this.seriesState.set(getSeriesId(series), state);
149149
}
150150

151-
private updateStoredPointState(point: Highcharts.Point, state: Highcharts.PointStateValue) {
151+
private updateStoredPointState(point: Highcharts.Point, state: "" | Highcharts.PointStateValue) {
152152
const pointStateInSeries = this.pointState.get(getSeriesId(point.series)) ?? new Map();
153153
pointStateInSeries.set(this.getPointKey(point), state);
154154
this.pointState.set(getSeriesId(point.series), pointStateInSeries);

0 commit comments

Comments
 (0)