Skip to content

Commit 1682a14

Browse files
committed
fix: Persist value label colors when downloading images
1 parent 42b82da commit 1682a14

File tree

5 files changed

+10
-6
lines changed

5 files changed

+10
-6
lines changed

CHANGELOG.md

+1
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ You can also check the
2727
- Interactive 100% mode switch doesn't overlap with Y axis label anymore
2828
- Chart preview using hash parameters now correctly deals with spacial
2929
characters
30+
- Value labels are not gray anymore when downloading an image
3031

3132
# [5.7.0] - 2025-04-16
3233

app/charts/bar/rendering-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { select, Selection } from "d3-selection";
22

3-
import { setSegmentValueLabelStyles } from "@/charts/shared/render-value-labels";
3+
import { setSegmentValueLabelProps } from "@/charts/shared/render-value-labels";
44
import {
55
maybeTransition,
66
RenderOptions,
@@ -71,7 +71,7 @@ export const renderBars = (
7171
.style("width", "100%")
7272
.style("height", "100%")
7373
.append("xhtml:p")
74-
.call(setSegmentValueLabelStyles)
74+
.call(setSegmentValueLabelProps)
7575
.style("padding-left", "2px")
7676
.style("padding-right", "2px")
7777
.style("color", function (d) {

app/charts/column/rendering-utils.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { select, Selection } from "d3-selection";
22

3-
import { setSegmentValueLabelStyles } from "@/charts/shared/render-value-labels";
3+
import { setSegmentValueLabelProps } from "@/charts/shared/render-value-labels";
44
import {
55
maybeTransition,
66
RenderOptions,
@@ -62,7 +62,7 @@ export const renderColumns = (
6262
})
6363
)
6464
.append("xhtml:p")
65-
.call(setSegmentValueLabelStyles)
65+
.call(setSegmentValueLabelProps)
6666
.style("padding-top", "4px")
6767
.style("padding-left", "2px")
6868
.style("padding-right", "2px")

app/charts/shared/render-value-labels.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
maybeTransition,
55
RenderOptions,
66
} from "@/charts/shared/rendering-utils";
7+
import { DISABLE_SCREENSHOT_COLOR_WIPE_KEY } from "@/components/chart-shared";
78

89
export type RenderTotalValueLabelDatum = {
910
key: string;
@@ -116,12 +117,13 @@ const getValueLabelTextAnchor = (rotate: boolean) => {
116117
return rotate ? "start" : "middle";
117118
};
118119

119-
export const setSegmentValueLabelStyles = <
120+
export const setSegmentValueLabelProps = <
120121
T extends { valueLabel?: string; valueLabelColor?: string },
121122
>(
122123
g: Selection<BaseType, T, SVGGElement, null>
123124
) => {
124125
return g
126+
.attr(DISABLE_SCREENSHOT_COLOR_WIPE_KEY, true)
125127
.style("overflow", "hidden")
126128
.style("width", "100%")
127129
.style("margin", 0)

app/components/chart-shared.tsx

+2-1
Original file line numberDiff line numberDiff line change
@@ -504,7 +504,8 @@ const useModifyNode = (configKey?: string) => {
504504
);
505505
};
506506

507-
const DISABLE_SCREENSHOT_COLOR_WIPE_KEY = "data-disable-screenshot-color";
507+
export const DISABLE_SCREENSHOT_COLOR_WIPE_KEY =
508+
"data-disable-screenshot-color";
508509
export const DISABLE_SCREENSHOT_COLOR_WIPE_ATTR = {
509510
[DISABLE_SCREENSHOT_COLOR_WIPE_KEY]: true,
510511
};

0 commit comments

Comments
 (0)