|
10 | 10 | import ValueLabel from "./ValueLabel.svelte";
|
11 | 11 |
|
12 | 12 | let {
|
13 |
| - // Required |
14 | 13 | series,
|
15 | 14 | y,
|
16 | 15 | x,
|
17 | 16 | lineChartData,
|
18 | 17 |
|
19 | 18 | tooltipSnippet = undefined,
|
20 |
| - tooltipContent = "tooltipContent", |
| 19 | + tooltipContent = "default", |
21 | 20 |
|
22 |
| - // ask |
23 | 21 | xFunction = (number) => {
|
24 | 22 | return scaleLinear()
|
25 | 23 | .domain([2015, 2022])
|
|
37 | 35 | labelText = "labelText",
|
38 | 36 |
|
39 | 37 | onClickSeries = (series, tier) => {
|
40 |
| - if (clickedSeries === dataId) { |
| 38 | + if (clickedSeries === series) { |
41 | 39 | clickedSeries = null;
|
| 40 | + hoveredSeries = null; |
42 | 41 | } else {
|
43 | 42 | clickedSeries = series;
|
44 | 43 | clickedTier = tier;
|
| 44 | + hoveredSeries = series; |
| 45 | + hoveredTier = tier; |
45 | 46 | }
|
46 | 47 | },
|
47 | 48 | onMouseLeaveSeries = (series, tier) => {
|
|
91 | 92 | currentMousePosition = undefined,
|
92 | 93 | markerRect = undefined,
|
93 | 94 | clickedSeries = $bindable(undefined),
|
94 |
| - hoveredSeries = undefined, |
95 |
| - hoveredTier = undefined, |
| 95 | + hoveredSeries = $bindable(undefined), |
| 96 | + hoveredTier = $bindable(undefined), |
| 97 | + clickedTier = $bindable(undefined), |
96 | 98 | overrideLineParams = () => ({}),
|
97 |
| - getLine = (key, el) => { |
| 99 | + getLine = (tier, el) => { |
98 | 100 | return true;
|
99 | 101 | },
|
100 | 102 | nothingSelected = true,
|
|
142 | 144 |
|
143 | 145 | let chartWidth = $derived(svgWidth - paddingLeft - paddingRight);
|
144 | 146 | let chartHeight = $derived(svgHeight - paddingTop - paddingBottom);
|
145 |
| - // let areaFunction = $derived( |
146 |
| - // area() |
147 |
| - // .y0((d) => yFunction(0)) |
148 |
| - // .x((d) => xFunction(d.x)) |
149 |
| - // .y1((d) => yFunction(d.y)) |
150 |
| - // .curve(curveLinear), |
151 |
| - // ); |
| 147 | + let areaFunction = $derived( |
| 148 | + area() |
| 149 | + .y0((d) => yFunction(0)) |
| 150 | + .x((d) => xFunction(d.x)) |
| 151 | + .y1((d) => yFunction(d.y)) |
| 152 | + .curve(curveLinear), |
| 153 | + ); |
152 | 154 |
|
153 | 155 | let selectedLine = $derived([hoveredSeries, clickedSeries]);
|
154 | 156 |
|
|
240 | 242 | {tieredDataObject}
|
241 | 243 | dataArray={lineChartData.lines}
|
242 | 244 | {lineFunction}
|
| 245 | + {areaFunction} |
243 | 246 | {chartWidth}
|
244 | 247 | {xFunction}
|
245 | 248 | {yFunction}
|
246 | 249 | {hoveredSeries}
|
247 | 250 | {clickedSeries}
|
| 251 | + {clickedTier} |
| 252 | + {hoveredTier} |
248 | 253 | {chartHeight}
|
249 | 254 | {globalTierRules}
|
250 | 255 | {chartBackgroundColor}
|
|
282 | 287 | {#if activeMarkerId}
|
283 | 288 | <ValueLabel
|
284 | 289 | {activeMarkerId}
|
285 |
| - labelColor="grey" |
| 290 | + labelColor="lightgrey" |
286 | 291 | labelTextColor="black"
|
287 | 292 | {tooltipContent}
|
288 | 293 | {xFunction}
|
|
0 commit comments