@@ -17,6 +17,7 @@ function convertSankeyDataToPlotly(links: SankeyLink[]): Partial<SankeyData> {
17
17
const targets = links . map ( link => uniqueNodeStrings . indexOf ( link . target ) )
18
18
const values = links . map ( link => link . value )
19
19
const labels = links . map ( link => link . label || null )
20
+ // const linkLabelColors = links.map(link => getColorByNodeName(link.source))
20
21
const linkColors = links . map ( link => chroma ( getColorByNodeName ( link . source ) ) . alpha ( .5 ) . hex ( ) )
21
22
22
23
return {
@@ -50,13 +51,29 @@ function convertSankeyDataToPlotly(links: SankeyLink[]): Partial<SankeyData> {
50
51
} ,
51
52
label : uniqueNodeStrings ,
52
53
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>" ,
54
64
// todo add to typescript definitions
55
65
// align: "right",
56
66
} ,
57
67
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>" ,
60
77
source : sources ,
61
78
target : targets ,
62
79
value : values ,
@@ -74,7 +91,7 @@ const plotlySankeyLayout: Partial<Plotly.Layout> = {
74
91
size : 14 ,
75
92
} ,
76
93
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
78
95
}
79
96
80
97
const transitionTimeMs = 400
@@ -123,7 +140,7 @@ export const IronPowderSankey: FunctionComponent<{
123
140
svgHeight ?: number ,
124
141
} > = ( {
125
142
links,
126
- maxWidth = "45rem " ,
143
+ maxWidth = "50rem " ,
127
144
svgHeight = 600 ,
128
145
} ) => {
129
146
const divId = "sankey" + useRandomInt ( )
0 commit comments