svelte-plots-basic 1.0.4 → 1.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -512,7 +512,7 @@
512
512
  const get_xaxis_slot_changes = dirty => ({});
513
513
  const get_xaxis_slot_context = ctx => ({});
514
514
 
515
- // (330:3) {#if title !== ""}
515
+ // (338:3) {#if title !== ""}
516
516
  function create_if_block_3(ctx) {
517
517
  let div;
518
518
 
@@ -533,7 +533,7 @@
533
533
  };
534
534
  }
535
535
 
536
- // (331:3) {#if yLabel !== ""}
536
+ // (339:3) {#if yLabel !== ""}
537
537
  function create_if_block_2(ctx) {
538
538
  let div;
539
539
  let span;
@@ -557,7 +557,7 @@
557
557
  };
558
558
  }
559
559
 
560
- // (332:3) {#if xLabel !== ""}
560
+ // (340:3) {#if xLabel !== ""}
561
561
  function create_if_block_1(ctx) {
562
562
  let div;
563
563
  let span;
@@ -581,7 +581,7 @@
581
581
  };
582
582
  }
583
583
 
584
- // (360:3) {#if !$isOk}
584
+ // (368:3) {#if !$isOk}
585
585
  function create_if_block$9(ctx) {
586
586
  let p;
587
587
 
@@ -1141,17 +1141,27 @@
1141
1141
  });
1142
1142
 
1143
1143
  // handle click on plot elements and dispatch manual events
1144
+ function dispatchClickEvent(eventName, el) {
1145
+ dispatch(eventName, {
1146
+ seriesTitle: el.parentNode.getAttribute('title'),
1147
+ elementID: el.dataset.id
1148
+ });
1149
+ }
1150
+
1144
1151
  function handleClick(e) {
1152
+ // scatter plot markers
1145
1153
  if (e.target.tagName === "text" && e.target.parentNode.classList.contains("series_scatter")) {
1146
- dispatch("markerclick", { markerid: e.target.dataset.id });
1154
+ dispatchClickEvent("markerclick", e.target);
1147
1155
  return;
1148
1156
  }
1149
1157
 
1158
+ // bar plot bars
1150
1159
  if (e.target.tagName === "rect" && e.target.parentNode.classList.contains("series_bar")) {
1151
- dispatch("barclick", { markerid: e.target.dataset.id });
1160
+ dispatchClickEvent("barclick", e.target);
1152
1161
  return;
1153
1162
  }
1154
1163
 
1164
+ // outside any plot element
1155
1165
  dispatch("axesclick");
1156
1166
  }
1157
1167
 
package/dist/index.mjs CHANGED
@@ -506,7 +506,7 @@ const get_yaxis_slot_context = ctx => ({});
506
506
  const get_xaxis_slot_changes = dirty => ({});
507
507
  const get_xaxis_slot_context = ctx => ({});
508
508
 
509
- // (330:3) {#if title !== ""}
509
+ // (338:3) {#if title !== ""}
510
510
  function create_if_block_3(ctx) {
511
511
  let div;
512
512
 
@@ -527,7 +527,7 @@ function create_if_block_3(ctx) {
527
527
  };
528
528
  }
529
529
 
530
- // (331:3) {#if yLabel !== ""}
530
+ // (339:3) {#if yLabel !== ""}
531
531
  function create_if_block_2(ctx) {
532
532
  let div;
533
533
  let span;
@@ -551,7 +551,7 @@ function create_if_block_2(ctx) {
551
551
  };
552
552
  }
553
553
 
554
- // (332:3) {#if xLabel !== ""}
554
+ // (340:3) {#if xLabel !== ""}
555
555
  function create_if_block_1(ctx) {
556
556
  let div;
557
557
  let span;
@@ -575,7 +575,7 @@ function create_if_block_1(ctx) {
575
575
  };
576
576
  }
577
577
 
578
- // (360:3) {#if !$isOk}
578
+ // (368:3) {#if !$isOk}
579
579
  function create_if_block$9(ctx) {
580
580
  let p;
581
581
 
@@ -1135,17 +1135,27 @@ function instance$b($$self, $$props, $$invalidate) {
1135
1135
  });
1136
1136
 
1137
1137
  // handle click on plot elements and dispatch manual events
1138
+ function dispatchClickEvent(eventName, el) {
1139
+ dispatch(eventName, {
1140
+ seriesTitle: el.parentNode.getAttribute('title'),
1141
+ elementID: el.dataset.id
1142
+ });
1143
+ }
1144
+
1138
1145
  function handleClick(e) {
1146
+ // scatter plot markers
1139
1147
  if (e.target.tagName === "text" && e.target.parentNode.classList.contains("series_scatter")) {
1140
- dispatch("markerclick", { markerid: e.target.dataset.id });
1148
+ dispatchClickEvent("markerclick", e.target);
1141
1149
  return;
1142
1150
  }
1143
1151
 
1152
+ // bar plot bars
1144
1153
  if (e.target.tagName === "rect" && e.target.parentNode.classList.contains("series_bar")) {
1145
- dispatch("barclick", { markerid: e.target.dataset.id });
1154
+ dispatchClickEvent("barclick", e.target);
1146
1155
  return;
1147
1156
  }
1148
1157
 
1158
+ // outside any plot element
1149
1159
  dispatch("axesclick");
1150
1160
  }
1151
1161
 
package/package.json CHANGED
@@ -25,7 +25,7 @@
25
25
  "dist"
26
26
  ],
27
27
  "description": "Svelte components for creating simple plots",
28
- "version": "1.0.4",
28
+ "version": "1.0.5",
29
29
  "repository": {
30
30
  "type": "git",
31
31
  "url": "svkucheryavski/svelte-plots-basic"
package/src/Axes.svelte CHANGED
@@ -277,19 +277,27 @@
277
277
  ro.observe(axesWrapper);
278
278
  });
279
279
 
280
+
280
281
  // handle click on plot elements and dispatch manual events
282
+ function dispatchClickEvent(eventName, el) {
283
+ dispatch(eventName, {seriesTitle: el.parentNode.getAttribute('title'), elementID: el.dataset.id});
284
+ }
285
+
281
286
  function handleClick(e) {
282
287
 
288
+ // scatter plot markers
283
289
  if (e.target.tagName === "text" && e.target.parentNode.classList.contains("series_scatter")) {
284
- dispatch("markerclick", {markerid: e.target.dataset.id})
290
+ dispatchClickEvent("markerclick", e.target);
285
291
  return;
286
292
  }
287
293
 
294
+ // bar plot bars
288
295
  if (e.target.tagName === "rect" && e.target.parentNode.classList.contains("series_bar")) {
289
- dispatch("barclick", {markerid: e.target.dataset.id})
296
+ dispatchClickEvent("barclick", e.target);
290
297
  return;
291
298
  }
292
299
 
300
+ // outside any plot element
293
301
  dispatch("axesclick")
294
302
  }
295
303