Skip to content

Commit b106a27

Browse files
committed
WIP don't use id for non-unique elements
1 parent ff86afd commit b106a27

File tree

5 files changed

+70
-46
lines changed

5 files changed

+70
-46
lines changed

src/lib/components/data-vis/line-chart/Line.svelte

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
activeMarkerId,
4949
series,
5050
y,
51-
id,
51+
element,
5252
x,
5353
markers,
5454
markerFill,
@@ -86,53 +86,53 @@
8686
</marker>
8787
</defs>
8888

89-
<g
90-
data-id={dataId}
91-
{id}
92-
onclick={interactiveLines ? (e) => onClickSeries(dataId, tier) : null}
93-
onmouseenter={interactiveLines
94-
? (e) => onMouseEnterSeries(dataId, tier)
95-
: null}
96-
onmouseleave={interactiveLines
97-
? (e) => onMouseLeaveSeries(dataId, tier)
98-
: null}
99-
role="button"
100-
tabindex="0"
101-
onkeydown={interactiveLines
102-
? (e) => e.key === "Enter" && onClickSeries(e, dataArray)
103-
: null}
104-
{opacity}
105-
pointer-events={interactiveMarkers ? null : "none"}
106-
>
107-
{#if includeArea}
108-
<path d={areaFunction(dataArray)} fill={areaFillColor}></path>
109-
{/if}
110-
<path
111-
d={linePath}
112-
fill="none"
113-
stroke="invisible"
114-
stroke-width={invisibleStrokeWidth}
115-
pointer-events={interactiveLines ? "stroke" : "none"}
116-
></path>
117-
{#if halo}
89+
<g data-id={dataId} {element} {opacity}>
90+
<g
91+
onclick={interactiveLines ? (e) => onClickSeries(dataId, tier) : null}
92+
onmouseenter={interactiveLines
93+
? (e) => onMouseEnterSeries(dataId, tier)
94+
: null}
95+
onmouseleave={interactiveLines
96+
? (e) => onMouseLeaveSeries(dataId, tier)
97+
: null}
98+
role="button"
99+
tabindex="0"
100+
onkeydown={interactiveLines
101+
? (e) => e.key === "Enter" && onClickSeries(e, dataArray)
102+
: null}
103+
pointer-events={interactiveLines ? null : "none"}
104+
>
105+
{#if includeArea}
106+
<path d={areaFunction(dataArray)} fill={areaFillColor}></path>
107+
{/if}
108+
<path
109+
d={linePath}
110+
fill="none"
111+
stroke="invisible"
112+
stroke-width={invisibleStrokeWidth}
113+
pointer-events={interactiveLines ? "stroke" : "none"}
114+
></path>
115+
{#if halo}
116+
<path
117+
d={linePath}
118+
fill={pathFillColor}
119+
stroke={chartBackgroundColor}
120+
stroke-width={pathStrokeWidth * 1.2}
121+
stroke-dasharray={pathStrokeDashArray}
122+
pointer-events="none"
123+
></path>
124+
{/if}
118125
<path
119126
d={linePath}
120127
fill={pathFillColor}
121-
stroke={chartBackgroundColor}
122-
stroke-width={pathStrokeWidth * 1.2}
128+
stroke={pathStrokeColor}
129+
stroke-width={pathStrokeWidth}
123130
stroke-dasharray={pathStrokeDashArray}
124131
pointer-events="none"
132+
marker-start={`url(#${lineEnding}-${pathStrokeColor})`}
125133
></path>
126-
{/if}
127-
<path
128-
d={linePath}
129-
fill={pathFillColor}
130-
stroke={pathStrokeColor}
131-
stroke-width={pathStrokeWidth}
132-
stroke-dasharray={pathStrokeDashArray}
133-
pointer-events="none"
134-
marker-start={`url(#${lineEnding}-${pathStrokeColor})`}
135-
></path>
134+
</g>
135+
136136
{#if markers}
137137
<Marker
138138
{dataArray}

src/lib/components/data-vis/line-chart/LineChart.svelte

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -198,9 +198,12 @@
198198
let selectedLine = $derived([hoveredSeries, clickedSeries]);
199199
200200
function handleClickOutside(event) {
201+
{
202+
console.log(event.target.closest());
203+
}
201204
if (
202205
clickedSeries &&
203-
!event.target.closest('[id^="line"]') &&
206+
!event.target.closest('[id^="line"]') && //make this respond to the new element attribute
204207
!event.target.closest('[id^="label"]')
205208
) {
206209
clickedSeries = null;

src/lib/components/data-vis/line-chart/Lines.svelte

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,10 @@
6666
{#each Object.keys(tieredDataObject) as tier}
6767
<g id={tier}>
6868
<g {...globalTierRules[tier]}>
69-
{console.log(globalTierRules[tier])}
7069
{#each tieredDataObject[tier] as line, i}
7170
<Line
7271
{...line}
73-
id={`line-${line[series]}`}
72+
element={`line-${line[series]}`}
7473
{tier}
7574
{chartBackgroundColor}
7675
{lineFunction}

src/lib/components/data-vis/line-chart/Marker.svelte

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,21 @@
4545
onkeydown={interactiveMarkers
4646
? (e) => e.key === "Enter" && onClickMarker(e, marker)
4747
: null}
48+
pointer-events={interactiveMarkers ? null : "none"}
4849
>
50+
<circle
51+
r={markerRadius + 6}
52+
fill="transparent"
53+
stroke="none"
54+
pointer-events="all"
55+
></circle>
4956
{#if markerShape === "circle"}
5057
<circle
5158
r={markerRadius}
5259
stroke={markerStroke}
5360
fill={markerFill}
5461
stroke-width={markerStrokeWidth}
62+
pointer-events="none"
5563
></circle>
5664
{:else if ["square", "diamond"].includes(markerShape)}
5765
<rect
@@ -63,6 +71,7 @@
6371
stroke={markerStroke}
6472
fill={markerFill}
6573
stroke-width={markerStrokeWidth}
74+
pointer-events="none"
6675
></rect>
6776
{:else if markerShape === "triangle"}
6877
<polygon
@@ -71,6 +80,7 @@
7180
stroke={markerStroke}
7281
fill={markerFill}
7382
stroke-width={markerStrokeWidth}
83+
pointer-events="none"
7484
></polygon>
7585
{/if}
7686
</g>

src/wrappers/components/data-vis/line-chart/LineChartWrapper.svelte

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@
333333
functionAsString: ``,
334334
},
335335
value: function (series, tier) {
336+
{
337+
console.log("ENTERING SERIES");
338+
}
336339
if (hoveredSeries !== series) {
337340
hoveredSeries = series;
338341
hoveredTier = tier;
@@ -346,6 +349,9 @@
346349
functionAsString: ``,
347350
},
348351
value: function (series, tier) {
352+
{
353+
console.log("LEAVING SERIES");
354+
}
349355
if (hoveredSeries === series) {
350356
hoveredSeries = null;
351357
hoveredTier = null;
@@ -361,6 +367,9 @@
361367
}`,
362368
},
363369
value: function (event, marker, markerId, rect) {
370+
{
371+
console.log("ENTERING MARKER");
372+
}
364373
activeMarkerId = marker;
365374
if (container) {
366375
const bounds = container.getBoundingClientRect();
@@ -391,6 +400,9 @@
391400
}`,
392401
},
393402
value: function (event, marker, dataId) {
403+
{
404+
console.log("LEAVING MARKER");
405+
}
394406
activeMarkerId = null;
395407
},
396408
},
@@ -609,7 +621,7 @@
609621
pathStrokeColor: colors.black,
610622
pathStrokeWidth: 1,
611623
opacity: 0.05,
612-
interactiveLines: true,
624+
interactiveLines: false,
613625
markers: false,
614626
showLabel: false,
615627
},

0 commit comments

Comments
 (0)