Skip to content

Commit 6d1f1a9

Browse files
author
Erik van Velzen
committedMar 25, 2025
Round sankey label values
1 parent f4426dc commit 6d1f1a9

File tree

3 files changed

+26
-9
lines changed

3 files changed

+26
-9
lines changed
 

‎frontend/components/Blocks/ContentBlocks.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ const ContentBlocks = ({
360360
/>
361361
)
362362
default:
363-
return <ContentBlocks content={[section]} />
363+
return <ContentBlocks content={[section]} key={`section ${section.id}`} />
364364
}
365365
})}
366366
</StepIndicatorWrapper>

‎frontend/components/IJzerboeren/Sankey/Sankey.tsx

+22-5
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ function convertSankeyDataToPlotly(links: SankeyLink[]): Partial<SankeyData> {
1717
const targets = links.map(link => uniqueNodeStrings.indexOf(link.target))
1818
const values = links.map(link => link.value)
1919
const labels = links.map(link => link.label || null)
20+
// const linkLabelColors = links.map(link => getColorByNodeName(link.source))
2021
const linkColors = links.map(link => chroma(getColorByNodeName(link.source)).alpha(.5).hex())
2122

2223
return {
@@ -50,13 +51,29 @@ function convertSankeyDataToPlotly(links: SankeyLink[]): Partial<SankeyData> {
5051
},
5152
label: uniqueNodeStrings,
5253
color: nodeColors,
53-
hovertemplate: "%{label}",
54+
hoverlabel: {
55+
font: {
56+
weight: "bold",
57+
color: "white",
58+
},
59+
},
60+
/**
61+
* d = whole numbers
62+
*/
63+
hovertemplate: "%{label} <extra>%{value:d} %{fullData.valuesuffix}</extra>",
5464
// todo add to typescript definitions
5565
// align: "right",
5666
},
5767
link: {
58-
hoverinfo: "all",
59-
hovertemplate: "%{source.label} ➔ %{target.label}",
68+
hoverlabel: {
69+
font: {
70+
weight: "bold",
71+
color: "white",
72+
},
73+
// I would like to set the opaclabels from .65 opacity to 1 but it seems not possible.
74+
// property "bgcolor" only changes the color
75+
},
76+
hovertemplate: "%{source.label} ➔ %{target.label} <extra>%{value:d} %{fullData.valuesuffix}</extra>",
6077
source: sources,
6178
target: targets,
6279
value: values,
@@ -74,7 +91,7 @@ const plotlySankeyLayout: Partial<Plotly.Layout> = {
7491
size: 14,
7592
},
7693
height: 600,
77-
// I would like to set Y size option here but it seems not possible
94+
// I would like to set Y scale here but it seems not possible
7895
}
7996

8097
const transitionTimeMs = 400
@@ -123,7 +140,7 @@ export const IronPowderSankey: FunctionComponent<{
123140
svgHeight?: number,
124141
}> = ({
125142
links,
126-
maxWidth = "45rem",
143+
maxWidth = "50rem",
127144
svgHeight = 600,
128145
}) => {
129146
const divId = "sankey" + useRandomInt()

‎frontend/components/KPIDashboard/KpiItems/number-format.ts

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
export function formatPreviousKpiNumber(value: number | null | undefined, fractionDigits: number = 1) {
1+
export function formatPreviousKpiNumber(value: number | null | undefined, fractionDigits = 1) {
22
return formatKpiNumber(value, "", fractionDigits)
33
}
44

5-
export function formatCurrentKpiNumber(value: number | null | undefined, fractionDigits: number = 1) {
5+
export function formatCurrentKpiNumber(value: number | null | undefined, fractionDigits = 1) {
66
return formatKpiNumber(value, "-", fractionDigits)
77
}
88

9-
export function formatKpiNumber(value: number | null | undefined, empty = "-", fractionDigits: number = 1): string {
9+
export function formatKpiNumber(value: number | null | undefined, empty = "-", fractionDigits = 1): string {
1010
if (value == undefined) {
1111
return empty
1212
} else if (typeof value == "number") {

0 commit comments

Comments
 (0)