File tree Expand file tree Collapse file tree 2 files changed +16
-6
lines changed
lib/components/data-vis/line-chart
routes/playground/create-a-reactive-line-chart/local-lib Expand file tree Collapse file tree 2 files changed +16
-6
lines changed Original file line number Diff line number Diff line change 25
25
defaultLineParams,
26
26
globalTierRules,
27
27
chartBackgroundColor,
28
+ nothingSelected,
28
29
} = $props ();
29
30
30
31
let bounds = $state ([0 , chartHeight]);
31
32
32
33
let transformed = $derived (
33
- tieredDataObject[lineHovered ? " hover" : " primary" ].map ((item ) => {
34
- let lastY = yFunction (item .data [0 ].y );
35
- return { areaCode: item .areaCode , lastY };
36
- }),
34
+ (nothingSelected
35
+ ? tieredDataObject .primary
36
+ : [... (tieredDataObject .hover || []), ... (tieredDataObject .clicked || [])]
37
+ )
38
+ .filter (
39
+ (item , index , self ) =>
40
+ self .findIndex ((other ) => other .areaCode === item .areaCode ) === index,
41
+ )
42
+ .map ((item ) => ({
43
+ areaCode: item .areaCode ,
44
+ lastY: yFunction (item .data [0 ].y ),
45
+ })),
37
46
);
38
47
39
48
let labelsPlaced = $derived (
111
120
112
121
< g>
113
122
{#each tieredDataObject[tier] as line, i}
114
- {#if (! lineHovered && tier === " primary" ) || (lineHovered && tier === " hover " ) || ( line . areaCode == lineClicked && [ " primary " , " hover " ].includes (tier) )}
123
+ {#if (tier == " primary" && nothingSelected ) || [ " hover " , " clicked " ].includes (tier)}
115
124
{@render categoryLabelSnippet (
116
125
line,
117
- labelsPlaced .find ((el ) => el .datum .areaCode === line .areaCode ).y ,
126
+ labelsPlaced .find ((el ) => el .datum .areaCode === line .areaCode )? .y ,
118
127
)}
119
128
{/ if }
120
129
{/ each}
Original file line number Diff line number Diff line change 312
312
{showAllData}
313
313
{globalTierRules}
314
314
{chartBackgroundColor}
315
+ {nothingSelected}
315
316
>< / Lines>
316
317
< / g>
317
318
< g data- role= " y-axis" >
You can’t perform that action at this time.
0 commit comments