Skip to content

Commit ea5b41f

Browse files
authored
fix: hide data labels for rangeSlider (#373)
1 parent f6c591a commit ea5b41f

File tree

4 files changed

+9
-3
lines changed

4 files changed

+9
-3
lines changed

src/hooks/useShapes/area/prepare-data.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ export const prepareAreaData = async (args: {
115115
boundsHeight: number;
116116
split: PreparedSplit;
117117
isOutsideBounds: (x: number, y: number) => boolean;
118+
isRangeSlider?: boolean;
118119
}): Promise<PreparedAreaData[]> => {
119120
const {
120121
series,
@@ -125,6 +126,7 @@ export const prepareAreaData = async (args: {
125126
boundsHeight: plotHeight,
126127
split,
127128
isOutsideBounds,
129+
isRangeSlider,
128130
} = args;
129131
const [_xMin, xRangeMax] = xScale.range();
130132
const xMax = xRangeMax;
@@ -217,7 +219,7 @@ export const prepareAreaData = async (args: {
217219
const labels: LabelData[] = [];
218220
const htmlElements: HtmlItem[] = [];
219221

220-
if (s.dataLabels.enabled) {
222+
if (s.dataLabels.enabled && !isRangeSlider) {
221223
const labelsData = await prepareDataLabels({series: s, points, xMax, yAxisTop});
222224
labels.push(...labelsData.svgLabels);
223225
htmlElements.push(...labelsData.htmlLabels);

src/hooks/useShapes/bar-x/prepare-data.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ export const prepareBarXData = async (args: {
7575
yScale: (ChartScale | undefined)[];
7676
boundsHeight: number;
7777
split: PreparedSplit;
78+
isRangeSlider?: boolean;
7879
}): Promise<PreparedBarXData[]> => {
7980
const {
8081
series,
@@ -85,6 +86,7 @@ export const prepareBarXData = async (args: {
8586
yScale,
8687
boundsHeight: plotHeight,
8788
split,
89+
isRangeSlider,
8890
} = args;
8991
const stackGap: number = seriesOptions['bar-x'].stackGap;
9092
const categories = xAxis?.categories ?? [];
@@ -263,7 +265,7 @@ export const prepareBarXData = async (args: {
263265
for (let i = 0; i < result.length; i++) {
264266
const barData = result[i];
265267

266-
if (barData.series.dataLabels.enabled) {
268+
if (barData.series.dataLabels.enabled && !isRangeSlider) {
267269
const label = await getLabelData(barData);
268270
if (barData.series.dataLabels.html && label) {
269271
barData.htmlElements.push({

src/hooks/useShapes/index.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ export const useShapes = (args: Args) => {
153153
yScale,
154154
boundsHeight,
155155
split,
156+
isRangeSlider,
156157
});
157158
shapes.push(
158159
<BarXSeriesShapes
@@ -255,6 +256,7 @@ export const useShapes = (args: Args) => {
255256
boundsHeight,
256257
split,
257258
isOutsideBounds,
259+
isRangeSlider,
258260
});
259261
shapes.push(
260262
<AreaSeriesShapes

src/hooks/useShapes/line/prepare-data.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ export const prepareLineData = async (args: {
6969

7070
const htmlElements: HtmlItem[] = [];
7171
const labels: LabelData[] = [];
72-
if (s.dataLabels.enabled) {
72+
if (s.dataLabels.enabled && !isRangeSlider) {
7373
if (s.dataLabels.html) {
7474
const list = await Promise.all(
7575
points.reduce<Promise<HtmlItem>[]>((result, p) => {

0 commit comments

Comments
 (0)