Skip to content

Commit 00d3bc7

Browse files
authored
Merge pull request #2289 from visualize-admin/feat/smaller-improvements-2
feat: Smaller improvements
2 parents dac3687 + 5253c55 commit 00d3bc7

File tree

5 files changed

+44
-16
lines changed

5 files changed

+44
-16
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ You can also check the
1818
- Fixes on
1919
- Nested layers appear on the map
2020
- Attributions are no longer coming from all layers of the endpoint
21+
- Other features
22+
- Value labels in bar and column charts are now centered both horizontally and
23+
vertically
24+
- ODS iframe dataset preview now uses official ODS color for new chart button
2125

2226
# 5.7.4 - 2025-04-29
2327

app/browser/select-dataset-step.tsx

+14-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ContentWrapper } from "@interactivethings/swiss-federal-ci/dist/components";
22
import { Trans } from "@lingui/macro";
3-
import { Box, Button, Theme, Typography } from "@mui/material";
3+
import { Box, Button, darken, Theme, Typography } from "@mui/material";
44
import { makeStyles } from "@mui/styles";
55
import { AnimatePresence } from "framer-motion";
66
import sortBy from "lodash/sortBy";
@@ -472,6 +472,19 @@ const SelectDatasetStepContent = ({
472472
<Icon name="arrowRight" size={20} />
473473
)
474474
}
475+
sx={
476+
// Could be extracted in case we have more
477+
// openData.swiss dependencies
478+
odsIframe
479+
? {
480+
backgroundColor: "#009688",
481+
482+
"&:hover": {
483+
backgroundColor: darken("#009688", 0.2),
484+
},
485+
}
486+
: null
487+
}
475488
>
476489
{!odsIframe ? (
477490
<Trans id="browse.dataset.create-visualization">

app/charts/bar/rendering-utils.ts

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

3-
import { setSegmentValueLabelProps } from "@/charts/shared/render-value-labels";
3+
import {
4+
setSegmentValueLabelProps,
5+
setSegmentWrapperValueLabelProps,
6+
} from "@/charts/shared/render-value-labels";
47
import {
58
maybeTransition,
69
RenderOptions,
@@ -66,14 +69,9 @@ export const renderBars = (
6669
})
6770
)
6871
.append("xhtml:div")
69-
.style("display", "flex")
70-
.style("align-items", "center")
71-
.style("width", "100%")
72-
.style("height", "100%")
72+
.call(setSegmentWrapperValueLabelProps)
7373
.append("xhtml:p")
7474
.call(setSegmentValueLabelProps)
75-
.style("padding-left", "2px")
76-
.style("padding-right", "2px")
7775
.style("color", function (d) {
7876
return d.valueLabelColor ?? select(this).style("color");
7977
})

app/charts/column/rendering-utils.ts

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

3-
import { setSegmentValueLabelProps } from "@/charts/shared/render-value-labels";
3+
import {
4+
setSegmentValueLabelProps,
5+
setSegmentWrapperValueLabelProps,
6+
} from "@/charts/shared/render-value-labels";
47
import {
58
maybeTransition,
69
RenderOptions,
@@ -61,11 +64,10 @@ export const renderColumns = (
6164
s: (g) => g.attr("y", (d) => d.y),
6265
})
6366
)
67+
.append("xhtml:div")
68+
.call(setSegmentWrapperValueLabelProps)
6469
.append("xhtml:p")
6570
.call(setSegmentValueLabelProps)
66-
.style("padding-top", "4px")
67-
.style("padding-left", "2px")
68-
.style("padding-right", "2px")
6971
.style("color", function (d) {
7072
return d.valueLabelColor ?? select(this).style("color");
7173
})

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

+15-4
Original file line numberDiff line numberDiff line change
@@ -117,17 +117,28 @@ const getValueLabelTextAnchor = (rotate: boolean) => {
117117
return rotate ? "start" : "middle";
118118
};
119119

120-
export const setSegmentValueLabelProps = <
120+
export const setSegmentWrapperValueLabelProps = <
121121
T extends { valueLabel?: string; valueLabelColor?: string },
122122
>(
123123
g: Selection<BaseType, T, SVGGElement, null>
124124
) => {
125125
return g
126126
.attr(DISABLE_SCREENSHOT_COLOR_WIPE_KEY, true)
127-
.style("overflow", "hidden")
127+
.style("display", "flex")
128+
.style("justify-content", "center")
129+
.style("align-items", "center")
128130
.style("width", "100%")
129-
.style("margin", 0)
130-
.style("text-align", "center")
131+
.style("height", "100%")
132+
.style("padding", "2px");
133+
};
134+
135+
export const setSegmentValueLabelProps = <
136+
T extends { valueLabel?: string; valueLabelColor?: string },
137+
>(
138+
g: Selection<BaseType, T, SVGGElement, null>
139+
) => {
140+
return g
141+
.style("overflow", "hidden")
131142
.style("font-size", "12px")
132143
.style("white-space", "nowrap")
133144
.style("text-overflow", "ellipsis");

0 commit comments

Comments
 (0)