svelte-plots-basic 1.0.6 → 1.1.1
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/README.md +18 -16
- package/dist/index.js +123 -107
- package/dist/index.mjs +123 -107
- package/package.json +2 -2
- package/src/Axes.svelte +23 -19
- package/src/TextLabels.svelte +1 -1
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
## Description
|
|
4
4
|
|
|
5
|
-
`svelte-plots-basic` is a [Svelte](https://svelte.dev) component library for creating very simple 2D plots/charts. It is currently under active development and breaking changes may occur. In its current state (v.
|
|
5
|
+
`svelte-plots-basic` is a [Svelte](https://svelte.dev) component library for creating very simple 2D plots/charts. It is currently under active development and breaking changes may occur. In its current state (v. 1.1.1) it allows to create bar, scatter, area and line charts as well as any combination of the four. The charts are created using [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics) and are re-scalable.
|
|
6
6
|
|
|
7
7
|
The description is not complete yet and will be updated during February-March of 2022.
|
|
8
8
|
|
|
@@ -44,9 +44,9 @@ Just create a new Svelte app following the [quick start guide](https://svelte.de
|
|
|
44
44
|
showLabels="no"
|
|
45
45
|
faceColor="#e0e0e0"
|
|
46
46
|
edgeColor="#e0e0e0"
|
|
47
|
-
labels=
|
|
48
|
-
xValues=
|
|
49
|
-
yValues=
|
|
47
|
+
labels={years}
|
|
48
|
+
xValues={years}
|
|
49
|
+
yValues={amount}
|
|
50
50
|
/>
|
|
51
51
|
</Axes>
|
|
52
52
|
</div>
|
|
@@ -67,35 +67,36 @@ Example below shows how to create a plot with axis, box and grid as well as how
|
|
|
67
67
|
|
|
68
68
|
<div class="plot">
|
|
69
69
|
<Axes>
|
|
70
|
-
// x and y axis with automatic ticks and grid lines
|
|
71
|
-
<XAxis showGrid="{true}"></XAxis>
|
|
72
|
-
<YAxis showGrid="{true}"></YAxis>
|
|
73
70
|
|
|
74
71
|
// bar, line and marker series with the same data values
|
|
75
72
|
<BarSeries
|
|
76
73
|
showLabels="no"
|
|
77
74
|
faceColor="#eee"
|
|
78
75
|
edgeColor="#eee"
|
|
79
|
-
xValues=
|
|
80
|
-
yValues=
|
|
76
|
+
xValues={years}
|
|
77
|
+
yValues={amount}
|
|
81
78
|
/>
|
|
82
79
|
<LineSeries
|
|
83
80
|
lineColor="blue"
|
|
84
|
-
lineWidth=
|
|
85
|
-
xValues=
|
|
86
|
-
yValues=
|
|
81
|
+
lineWidth={2}
|
|
82
|
+
xValues={years}
|
|
83
|
+
yValues={amount}
|
|
87
84
|
/>
|
|
88
85
|
<ScatterSeries
|
|
89
86
|
marker="✺"
|
|
90
87
|
showLabels="hover"
|
|
91
88
|
markerColor="blue"
|
|
92
|
-
labels=
|
|
93
|
-
xValues=
|
|
94
|
-
yValues=
|
|
89
|
+
labels={years}
|
|
90
|
+
xValues={years}
|
|
91
|
+
yValues={amount}
|
|
95
92
|
/>
|
|
96
93
|
|
|
94
|
+
// x and y axis with automatic ticks and grid lines
|
|
95
|
+
<XAxis showGrid={true} slot="xaxis" />
|
|
96
|
+
<YAxis showGrid={true} slot="yaxis" />
|
|
97
|
+
|
|
97
98
|
// box around the axes
|
|
98
|
-
<Box />
|
|
99
|
+
<Box slot="box" />
|
|
99
100
|
</Axes>
|
|
100
101
|
</div>
|
|
101
102
|
```
|
|
@@ -125,6 +126,7 @@ Each component is responsible for visualization of the corresponding axis. The a
|
|
|
125
126
|
* `ticks` — vector with ticks
|
|
126
127
|
* `tickLabels` — vector with values to be shown as labels beside each tick
|
|
127
128
|
* `showGrid` — a logical parameter, which allows to show grid lines on the plot
|
|
129
|
+
* `slot` — name of the slot, `"xaxis"` or `"yaxis"`
|
|
128
130
|
|
|
129
131
|
The components must be placed in a particular slot of the parent `Axes` component.
|
|
130
132
|
|
package/dist/index.js
CHANGED
|
@@ -165,9 +165,9 @@
|
|
|
165
165
|
function toggle_class(element, name, toggle) {
|
|
166
166
|
element.classList[toggle ? 'add' : 'remove'](name);
|
|
167
167
|
}
|
|
168
|
-
function custom_event(type, detail, bubbles = false) {
|
|
168
|
+
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|
169
169
|
const e = document.createEvent('CustomEvent');
|
|
170
|
-
e.initCustomEvent(type, bubbles,
|
|
170
|
+
e.initCustomEvent(type, bubbles, cancelable, detail);
|
|
171
171
|
return e;
|
|
172
172
|
}
|
|
173
173
|
|
|
@@ -185,20 +185,23 @@
|
|
|
185
185
|
}
|
|
186
186
|
function createEventDispatcher() {
|
|
187
187
|
const component = get_current_component();
|
|
188
|
-
return (type, detail) => {
|
|
188
|
+
return (type, detail, { cancelable = false } = {}) => {
|
|
189
189
|
const callbacks = component.$$.callbacks[type];
|
|
190
190
|
if (callbacks) {
|
|
191
191
|
// TODO are there situations where events could be dispatched
|
|
192
192
|
// in a server (non-DOM) environment?
|
|
193
|
-
const event = custom_event(type, detail);
|
|
193
|
+
const event = custom_event(type, detail, { cancelable });
|
|
194
194
|
callbacks.slice().forEach(fn => {
|
|
195
195
|
fn.call(component, event);
|
|
196
196
|
});
|
|
197
|
+
return !event.defaultPrevented;
|
|
197
198
|
}
|
|
199
|
+
return true;
|
|
198
200
|
};
|
|
199
201
|
}
|
|
200
202
|
function setContext(key, context) {
|
|
201
203
|
get_current_component().$$.context.set(key, context);
|
|
204
|
+
return context;
|
|
202
205
|
}
|
|
203
206
|
function getContext(key) {
|
|
204
207
|
return get_current_component().$$.context.get(key);
|
|
@@ -499,7 +502,7 @@
|
|
|
499
502
|
return { set, update, subscribe };
|
|
500
503
|
}
|
|
501
504
|
|
|
502
|
-
/* src/Axes.svelte generated by Svelte v3.
|
|
505
|
+
/* src/Axes.svelte generated by Svelte v3.48.0 */
|
|
503
506
|
|
|
504
507
|
function add_css$3(target) {
|
|
505
508
|
append_styles(target, "svelte-n80kcc", ".plot{font-family:Arial, Helvetica, sans-serif;display:grid;grid-template-columns:min-content 1fr;grid-template-rows:auto 1fr auto;grid-template-areas:\". title\"\n \"ylab axes\"\n \". xlab\";box-sizing:border-box;background:#fefefe;min-width:100px;min-height:50px;width:100%;height:100%;padding:0;margin:0}.plot_small{font-size:11px}.plot_medium{font-size:13px}.plot_large{font-size:16px}.plot_error{display:flex}.plot_error > .axes-wrapper{display:none}.message_error{font-size:1.2em;color:crimson;padding:20px;text-align:center}.axes-wrapper.svelte-n80kcc{grid-area:axes;position:relative;box-sizing:border-box;display:flex;width:100%;height:100%;padding:0;margin:0}.axes{display:block;box-sizing:border-box;position:absolute;padding:0;margin:0;height:100%;width:100%;max-height:100%;max-width:100%;min-height:100%;min-width:100%}.axes__xlabel{grid-area:xlab;font-size:1.0em;font-weight:600;padding:0.25em;text-align:center}.axes__ylabel{grid-area:ylab;font-size:1.0em;font-weight:600;padding:0.25em;text-align:center;vertical-align:middle;display:flex}.axes__ylabel > span{width:1.5em;line-height:1.5em;display:inline-block;writing-mode:vertical-rl;transform:rotate(180deg)}.axes__title{background:transparent;grid-area:title;font-size:1.3em;font-weight:bold;line-height:1.2em;padding:0.5em 0;text-align:center}.axis-labels{fill:#303030;font-size:0.95em}.labels{fill:#606060;font-size:0.90em}.labels{visibility:hidden;transition:visibility 0.25s linear, opacity 0.25s linear;opacity:0}");
|
|
@@ -512,7 +515,7 @@
|
|
|
512
515
|
const get_xaxis_slot_changes = dirty => ({});
|
|
513
516
|
const get_xaxis_slot_context = ctx => ({});
|
|
514
517
|
|
|
515
|
-
// (
|
|
518
|
+
// (342:3) {#if title !== ""}
|
|
516
519
|
function create_if_block_3(ctx) {
|
|
517
520
|
let div;
|
|
518
521
|
|
|
@@ -533,7 +536,7 @@
|
|
|
533
536
|
};
|
|
534
537
|
}
|
|
535
538
|
|
|
536
|
-
// (
|
|
539
|
+
// (343:3) {#if yLabel !== ""}
|
|
537
540
|
function create_if_block_2(ctx) {
|
|
538
541
|
let div;
|
|
539
542
|
let span;
|
|
@@ -557,7 +560,7 @@
|
|
|
557
560
|
};
|
|
558
561
|
}
|
|
559
562
|
|
|
560
|
-
// (
|
|
563
|
+
// (344:3) {#if xLabel !== ""}
|
|
561
564
|
function create_if_block_1(ctx) {
|
|
562
565
|
let div;
|
|
563
566
|
let span;
|
|
@@ -581,7 +584,7 @@
|
|
|
581
584
|
};
|
|
582
585
|
}
|
|
583
586
|
|
|
584
|
-
// (
|
|
587
|
+
// (372:3) {#if !$isOk}
|
|
585
588
|
function create_if_block$9(ctx) {
|
|
586
589
|
let p;
|
|
587
590
|
|
|
@@ -626,14 +629,14 @@
|
|
|
626
629
|
let if_block0 = /*title*/ ctx[0] !== "" && create_if_block_3(ctx);
|
|
627
630
|
let if_block1 = /*yLabel*/ ctx[2] !== "" && create_if_block_2(ctx);
|
|
628
631
|
let if_block2 = /*xLabel*/ ctx[1] !== "" && create_if_block_1(ctx);
|
|
629
|
-
const xaxis_slot_template = /*#slots*/ ctx[
|
|
630
|
-
const xaxis_slot = create_slot(xaxis_slot_template, ctx, /*$$scope*/ ctx[
|
|
631
|
-
const yaxis_slot_template = /*#slots*/ ctx[
|
|
632
|
-
const yaxis_slot = create_slot(yaxis_slot_template, ctx, /*$$scope*/ ctx[
|
|
633
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
634
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
635
|
-
const box_slot_template = /*#slots*/ ctx[
|
|
636
|
-
const box_slot = create_slot(box_slot_template, ctx, /*$$scope*/ ctx[
|
|
632
|
+
const xaxis_slot_template = /*#slots*/ ctx[27].xaxis;
|
|
633
|
+
const xaxis_slot = create_slot(xaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_xaxis_slot_context);
|
|
634
|
+
const yaxis_slot_template = /*#slots*/ ctx[27].yaxis;
|
|
635
|
+
const yaxis_slot = create_slot(yaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_yaxis_slot_context);
|
|
636
|
+
const default_slot_template = /*#slots*/ ctx[27].default;
|
|
637
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], null);
|
|
638
|
+
const box_slot_template = /*#slots*/ ctx[27].box;
|
|
639
|
+
const box_slot = create_slot(box_slot_template, ctx, /*$$scope*/ ctx[26], get_box_slot_context);
|
|
637
640
|
let if_block3 = !/*$isOk*/ ctx[3] && create_if_block$9();
|
|
638
641
|
|
|
639
642
|
return {
|
|
@@ -658,12 +661,12 @@
|
|
|
658
661
|
t3 = space();
|
|
659
662
|
if (if_block3) if_block3.c();
|
|
660
663
|
set_style(rect, "pointer-events", "none");
|
|
661
|
-
attr(rect, "x", rect_x_value = /*cpx*/ ctx[
|
|
662
|
-
attr(rect, "y", rect_y_value = /*cpy*/ ctx[
|
|
663
|
-
attr(rect, "width", rect_width_value = /*cpx*/ ctx[
|
|
664
|
-
attr(rect, "height", rect_height_value = /*cpy*/ ctx[
|
|
665
|
-
attr(clipPath, "id", /*clipPathID*/ ctx[
|
|
666
|
-
attr(g, "clip-path", "url(#" + /*clipPathID*/ ctx[
|
|
664
|
+
attr(rect, "x", rect_x_value = /*cpx*/ ctx[8][0]);
|
|
665
|
+
attr(rect, "y", rect_y_value = /*cpy*/ ctx[7][1]);
|
|
666
|
+
attr(rect, "width", rect_width_value = /*cpx*/ ctx[8][1] - /*cpx*/ ctx[8][0]);
|
|
667
|
+
attr(rect, "height", rect_height_value = /*cpy*/ ctx[7][0] - /*cpy*/ ctx[7][1]);
|
|
668
|
+
attr(clipPath, "id", /*clipPathID*/ ctx[9]);
|
|
669
|
+
attr(g, "clip-path", "url(#" + /*clipPathID*/ ctx[9] + ")");
|
|
667
670
|
attr(svg, "preserveAspectRatio", "none");
|
|
668
671
|
attr(svg, "class", "axes");
|
|
669
672
|
attr(div0, "class", "axes-wrapper svelte-n80kcc");
|
|
@@ -702,13 +705,14 @@
|
|
|
702
705
|
box_slot.m(svg, null);
|
|
703
706
|
}
|
|
704
707
|
|
|
705
|
-
/*div0_binding*/ ctx[
|
|
708
|
+
/*div0_binding*/ ctx[28](div0);
|
|
706
709
|
append(div1, t3);
|
|
707
710
|
if (if_block3) if_block3.m(div1, null);
|
|
711
|
+
/*div1_binding*/ ctx[29](div1);
|
|
708
712
|
current = true;
|
|
709
713
|
|
|
710
714
|
if (!mounted) {
|
|
711
|
-
dispose = listen(svg, "click", /*handleClick*/ ctx[
|
|
715
|
+
dispose = listen(svg, "click", /*handleClick*/ ctx[16]);
|
|
712
716
|
mounted = true;
|
|
713
717
|
}
|
|
714
718
|
},
|
|
@@ -752,77 +756,77 @@
|
|
|
752
756
|
if_block2 = null;
|
|
753
757
|
}
|
|
754
758
|
|
|
755
|
-
if (!current || dirty[0] & /*cpx*/
|
|
759
|
+
if (!current || dirty[0] & /*cpx*/ 256 && rect_x_value !== (rect_x_value = /*cpx*/ ctx[8][0])) {
|
|
756
760
|
attr(rect, "x", rect_x_value);
|
|
757
761
|
}
|
|
758
762
|
|
|
759
|
-
if (!current || dirty[0] & /*cpy*/
|
|
763
|
+
if (!current || dirty[0] & /*cpy*/ 128 && rect_y_value !== (rect_y_value = /*cpy*/ ctx[7][1])) {
|
|
760
764
|
attr(rect, "y", rect_y_value);
|
|
761
765
|
}
|
|
762
766
|
|
|
763
|
-
if (!current || dirty[0] & /*cpx*/
|
|
767
|
+
if (!current || dirty[0] & /*cpx*/ 256 && rect_width_value !== (rect_width_value = /*cpx*/ ctx[8][1] - /*cpx*/ ctx[8][0])) {
|
|
764
768
|
attr(rect, "width", rect_width_value);
|
|
765
769
|
}
|
|
766
770
|
|
|
767
|
-
if (!current || dirty[0] & /*cpy*/
|
|
771
|
+
if (!current || dirty[0] & /*cpy*/ 128 && rect_height_value !== (rect_height_value = /*cpy*/ ctx[7][0] - /*cpy*/ ctx[7][1])) {
|
|
768
772
|
attr(rect, "height", rect_height_value);
|
|
769
773
|
}
|
|
770
774
|
|
|
771
775
|
if (xaxis_slot) {
|
|
772
|
-
if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
776
|
+
if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
773
777
|
update_slot_base(
|
|
774
778
|
xaxis_slot,
|
|
775
779
|
xaxis_slot_template,
|
|
776
780
|
ctx,
|
|
777
|
-
/*$$scope*/ ctx[
|
|
781
|
+
/*$$scope*/ ctx[26],
|
|
778
782
|
!current
|
|
779
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
780
|
-
: get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[
|
|
783
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
784
|
+
: get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_xaxis_slot_changes),
|
|
781
785
|
get_xaxis_slot_context
|
|
782
786
|
);
|
|
783
787
|
}
|
|
784
788
|
}
|
|
785
789
|
|
|
786
790
|
if (yaxis_slot) {
|
|
787
|
-
if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
791
|
+
if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
788
792
|
update_slot_base(
|
|
789
793
|
yaxis_slot,
|
|
790
794
|
yaxis_slot_template,
|
|
791
795
|
ctx,
|
|
792
|
-
/*$$scope*/ ctx[
|
|
796
|
+
/*$$scope*/ ctx[26],
|
|
793
797
|
!current
|
|
794
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
795
|
-
: get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[
|
|
798
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
799
|
+
: get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_yaxis_slot_changes),
|
|
796
800
|
get_yaxis_slot_context
|
|
797
801
|
);
|
|
798
802
|
}
|
|
799
803
|
}
|
|
800
804
|
|
|
801
805
|
if (default_slot) {
|
|
802
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
806
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
803
807
|
update_slot_base(
|
|
804
808
|
default_slot,
|
|
805
809
|
default_slot_template,
|
|
806
810
|
ctx,
|
|
807
|
-
/*$$scope*/ ctx[
|
|
811
|
+
/*$$scope*/ ctx[26],
|
|
808
812
|
!current
|
|
809
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
810
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
813
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
814
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, null),
|
|
811
815
|
null
|
|
812
816
|
);
|
|
813
817
|
}
|
|
814
818
|
}
|
|
815
819
|
|
|
816
820
|
if (box_slot) {
|
|
817
|
-
if (box_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
821
|
+
if (box_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
818
822
|
update_slot_base(
|
|
819
823
|
box_slot,
|
|
820
824
|
box_slot_template,
|
|
821
825
|
ctx,
|
|
822
|
-
/*$$scope*/ ctx[
|
|
826
|
+
/*$$scope*/ ctx[26],
|
|
823
827
|
!current
|
|
824
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
825
|
-
: get_slot_changes(box_slot_template, /*$$scope*/ ctx[
|
|
828
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
829
|
+
: get_slot_changes(box_slot_template, /*$$scope*/ ctx[26], dirty, get_box_slot_changes),
|
|
826
830
|
get_box_slot_context
|
|
827
831
|
);
|
|
828
832
|
}
|
|
@@ -871,8 +875,9 @@
|
|
|
871
875
|
if (yaxis_slot) yaxis_slot.d(detaching);
|
|
872
876
|
if (default_slot) default_slot.d(detaching);
|
|
873
877
|
if (box_slot) box_slot.d(detaching);
|
|
874
|
-
/*div0_binding*/ ctx[
|
|
878
|
+
/*div0_binding*/ ctx[28](null);
|
|
875
879
|
if (if_block3) if_block3.d();
|
|
880
|
+
/*div1_binding*/ ctx[29](null);
|
|
876
881
|
mounted = false;
|
|
877
882
|
dispose();
|
|
878
883
|
}
|
|
@@ -945,20 +950,21 @@
|
|
|
945
950
|
const clipPathID = "plottingArea" + Math.round(Math.random() * 10000);
|
|
946
951
|
|
|
947
952
|
/* parameters for internal use inside the component */
|
|
948
|
-
let
|
|
953
|
+
let plotElement;
|
|
949
954
|
|
|
955
|
+
let axesElement;
|
|
950
956
|
let axesMargins = [0.034, 0.034, 0.034, 0.034]; // initial margins (will be multiplied to FACTORS)
|
|
951
957
|
|
|
952
958
|
/* reactive parameters to be shared with children via context */
|
|
953
959
|
const width = writable(100); // actual width of plotting area in pixels
|
|
954
960
|
|
|
955
|
-
component_subscribe($$self, width, value => $$invalidate(
|
|
961
|
+
component_subscribe($$self, width, value => $$invalidate(24, $width = value));
|
|
956
962
|
const height = writable(100); // actual height of plotting area in pixels
|
|
957
|
-
component_subscribe($$self, height, value => $$invalidate(
|
|
963
|
+
component_subscribe($$self, height, value => $$invalidate(22, $height = value));
|
|
958
964
|
const xLim = writable([undefined, undefined]); // actual limits for x-axis in plot units
|
|
959
|
-
component_subscribe($$self, xLim, value => $$invalidate(
|
|
965
|
+
component_subscribe($$self, xLim, value => $$invalidate(25, $xLim = value));
|
|
960
966
|
const yLim = writable([undefined, undefined]); // actual limits for y-axis in plot units
|
|
961
|
-
component_subscribe($$self, yLim, value => $$invalidate(
|
|
967
|
+
component_subscribe($$self, yLim, value => $$invalidate(23, $yLim = value));
|
|
962
968
|
const scale = writable("medium"); // scale factor (how big the shown plot is)
|
|
963
969
|
component_subscribe($$self, scale, value => $$invalidate(4, $scale = value));
|
|
964
970
|
const isOk = writable(false); // are axes ready for drawing
|
|
@@ -966,18 +972,18 @@
|
|
|
966
972
|
|
|
967
973
|
/** Adds margins for x-axis (e.g. when x-axis must be shown) */
|
|
968
974
|
const addXAxisMargins = function () {
|
|
969
|
-
$$invalidate(
|
|
970
|
-
$$invalidate(
|
|
971
|
-
$$invalidate(
|
|
972
|
-
$$invalidate(
|
|
975
|
+
$$invalidate(20, axesMargins[0] = 1, axesMargins);
|
|
976
|
+
$$invalidate(20, axesMargins[2] = 0.5, axesMargins);
|
|
977
|
+
$$invalidate(20, axesMargins[1] = axesMargins[1] > 0.5 ? axesMargins[1] : 0.5, axesMargins);
|
|
978
|
+
$$invalidate(20, axesMargins[3] = axesMargins[3] > 0.5 ? axesMargins[3] : 0.5, axesMargins);
|
|
973
979
|
};
|
|
974
980
|
|
|
975
981
|
/** Adds margins for y-axis (e.g. when y-axis must be shown) */
|
|
976
982
|
const addYAxisMargins = function () {
|
|
977
|
-
$$invalidate(
|
|
978
|
-
$$invalidate(
|
|
979
|
-
$$invalidate(
|
|
980
|
-
$$invalidate(
|
|
983
|
+
$$invalidate(20, axesMargins[1] = 1, axesMargins);
|
|
984
|
+
$$invalidate(20, axesMargins[3] = 0.5, axesMargins);
|
|
985
|
+
$$invalidate(20, axesMargins[0] = axesMargins[0] > 0.5 ? axesMargins[0] : 0.5, axesMargins);
|
|
986
|
+
$$invalidate(20, axesMargins[2] = axesMargins[2] > 0.5 ? axesMargins[2] : 0.5, axesMargins);
|
|
981
987
|
};
|
|
982
988
|
|
|
983
989
|
/** Adjusts limits for x-axis (e.g. when new series is added)
|
|
@@ -1126,20 +1132,6 @@
|
|
|
1126
1132
|
|
|
1127
1133
|
setContext('axes', context);
|
|
1128
1134
|
|
|
1129
|
-
/* observer for the plotting area size */
|
|
1130
|
-
var ro = new ResizeObserver(entries => {
|
|
1131
|
-
for (let entry of entries) {
|
|
1132
|
-
const cr = entry.contentRect;
|
|
1133
|
-
width.update(x => cr.width);
|
|
1134
|
-
height.update(x => cr.height);
|
|
1135
|
-
scale.update(x => getScale(cr.width, cr.height));
|
|
1136
|
-
}
|
|
1137
|
-
});
|
|
1138
|
-
|
|
1139
|
-
onMount(() => {
|
|
1140
|
-
ro.observe(axesWrapper);
|
|
1141
|
-
});
|
|
1142
|
-
|
|
1143
1135
|
// handle click on plot elements and dispatch manual events
|
|
1144
1136
|
function dispatchClickEvent(eventName, el) {
|
|
1145
1137
|
dispatch(eventName, {
|
|
@@ -1165,51 +1157,73 @@
|
|
|
1165
1157
|
dispatch("axesclick");
|
|
1166
1158
|
}
|
|
1167
1159
|
|
|
1160
|
+
/* observer for the plotting area size */
|
|
1161
|
+
var ro = new ResizeObserver(entries => {
|
|
1162
|
+
for (let entry of entries) {
|
|
1163
|
+
const pcr = plotElement.getBoundingClientRect();
|
|
1164
|
+
const acr = axesElement.getBoundingClientRect();
|
|
1165
|
+
width.update(x => acr.width);
|
|
1166
|
+
height.update(x => acr.height);
|
|
1167
|
+
scale.update(x => getScale(pcr.width, pcr.height));
|
|
1168
|
+
}
|
|
1169
|
+
});
|
|
1170
|
+
|
|
1171
|
+
onMount(() => {
|
|
1172
|
+
ro.observe(plotElement);
|
|
1173
|
+
});
|
|
1174
|
+
|
|
1168
1175
|
function div0_binding($$value) {
|
|
1169
1176
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1170
|
-
|
|
1171
|
-
$$invalidate(
|
|
1177
|
+
axesElement = $$value;
|
|
1178
|
+
$$invalidate(6, axesElement);
|
|
1179
|
+
});
|
|
1180
|
+
}
|
|
1181
|
+
|
|
1182
|
+
function div1_binding($$value) {
|
|
1183
|
+
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1184
|
+
plotElement = $$value;
|
|
1185
|
+
$$invalidate(5, plotElement);
|
|
1172
1186
|
});
|
|
1173
1187
|
}
|
|
1174
1188
|
|
|
1175
1189
|
$$self.$$set = $$props => {
|
|
1176
|
-
if ('limX' in $$props) $$invalidate(
|
|
1177
|
-
if ('limY' in $$props) $$invalidate(
|
|
1190
|
+
if ('limX' in $$props) $$invalidate(17, limX = $$props.limX);
|
|
1191
|
+
if ('limY' in $$props) $$invalidate(18, limY = $$props.limY);
|
|
1178
1192
|
if ('title' in $$props) $$invalidate(0, title = $$props.title);
|
|
1179
1193
|
if ('xLabel' in $$props) $$invalidate(1, xLabel = $$props.xLabel);
|
|
1180
1194
|
if ('yLabel' in $$props) $$invalidate(2, yLabel = $$props.yLabel);
|
|
1181
|
-
if ('multiSeries' in $$props) $$invalidate(
|
|
1182
|
-
if ('$$scope' in $$props) $$invalidate(
|
|
1195
|
+
if ('multiSeries' in $$props) $$invalidate(19, multiSeries = $$props.multiSeries);
|
|
1196
|
+
if ('$$scope' in $$props) $$invalidate(26, $$scope = $$props.$$scope);
|
|
1183
1197
|
};
|
|
1184
1198
|
|
|
1185
1199
|
$$self.$$.update = () => {
|
|
1186
|
-
if ($$self.$$.dirty[0] & /*limX*/
|
|
1200
|
+
if ($$self.$$.dirty[0] & /*limX*/ 131072) {
|
|
1187
1201
|
// this is reactive in case if limX and limY are interactively changed by parent script
|
|
1188
1202
|
if (!limX.some(v => v === undefined)) xLim.update(v => limX);
|
|
1189
1203
|
}
|
|
1190
1204
|
|
|
1191
|
-
if ($$self.$$.dirty[0] & /*limY*/
|
|
1205
|
+
if ($$self.$$.dirty[0] & /*limY*/ 262144) {
|
|
1192
1206
|
if (!limY.some(v => v === undefined)) yLim.update(v => limY);
|
|
1193
1207
|
}
|
|
1194
1208
|
|
|
1195
|
-
if ($$self.$$.dirty[0] & /*axesMargins, $scale*/
|
|
1209
|
+
if ($$self.$$.dirty[0] & /*axesMargins, $scale*/ 1048592) {
|
|
1196
1210
|
// computes real margins in pixels based on current scale
|
|
1197
|
-
$$invalidate(
|
|
1211
|
+
$$invalidate(21, margins = axesMargins.map(v => v * AXES_MARGIN_FACTORS[$scale]));
|
|
1198
1212
|
}
|
|
1199
1213
|
|
|
1200
|
-
if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/
|
|
1214
|
+
if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/ 65011712) {
|
|
1201
1215
|
// computes status which tells that axes limits look fine and it is safe to draw
|
|
1202
1216
|
// the status is based on the axis limits validity
|
|
1203
1217
|
isOk.update(v => Array.isArray($yLim) && Array.isArray($xLim) && $xLim.length === 2 && $yLim.length === 2 && !$yLim.some(v => v === undefined) && !$xLim.some(v => v === undefined) && !$yLim.some(v => isNaN(v)) && !$xLim.some(v => isNaN(v)) && $xLim[1] !== $xLim[0] && $yLim[1] !== $yLim[0] && $width > margins[1] + margins[3] && $height > margins[0] + margins[2]);
|
|
1204
1218
|
}
|
|
1205
1219
|
|
|
1206
|
-
if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/
|
|
1220
|
+
if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/ 50331656) {
|
|
1207
1221
|
// computes coordinates for clip path box
|
|
1208
|
-
$$invalidate(
|
|
1222
|
+
$$invalidate(8, cpx = $isOk ? scaleX($xLim, $xLim, $width) : [0, 1]);
|
|
1209
1223
|
}
|
|
1210
1224
|
|
|
1211
|
-
if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/
|
|
1212
|
-
$$invalidate(
|
|
1225
|
+
if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/ 12582920) {
|
|
1226
|
+
$$invalidate(7, cpy = $isOk ? scaleY($yLim, $yLim, $height) : [1, 0]);
|
|
1213
1227
|
}
|
|
1214
1228
|
};
|
|
1215
1229
|
|
|
@@ -1219,7 +1233,8 @@
|
|
|
1219
1233
|
yLabel,
|
|
1220
1234
|
$isOk,
|
|
1221
1235
|
$scale,
|
|
1222
|
-
|
|
1236
|
+
plotElement,
|
|
1237
|
+
axesElement,
|
|
1223
1238
|
cpy,
|
|
1224
1239
|
cpx,
|
|
1225
1240
|
clipPathID,
|
|
@@ -1241,7 +1256,8 @@
|
|
|
1241
1256
|
$xLim,
|
|
1242
1257
|
$$scope,
|
|
1243
1258
|
slots,
|
|
1244
|
-
div0_binding
|
|
1259
|
+
div0_binding,
|
|
1260
|
+
div1_binding
|
|
1245
1261
|
];
|
|
1246
1262
|
}
|
|
1247
1263
|
|
|
@@ -1256,12 +1272,12 @@
|
|
|
1256
1272
|
create_fragment$b,
|
|
1257
1273
|
safe_not_equal,
|
|
1258
1274
|
{
|
|
1259
|
-
limX:
|
|
1260
|
-
limY:
|
|
1275
|
+
limX: 17,
|
|
1276
|
+
limY: 18,
|
|
1261
1277
|
title: 0,
|
|
1262
1278
|
xLabel: 1,
|
|
1263
1279
|
yLabel: 2,
|
|
1264
|
-
multiSeries:
|
|
1280
|
+
multiSeries: 19
|
|
1265
1281
|
},
|
|
1266
1282
|
add_css$3,
|
|
1267
1283
|
[-1, -1]
|
|
@@ -1283,7 +1299,7 @@
|
|
|
1283
1299
|
"PRIMARY_TEXT": "#333",
|
|
1284
1300
|
};
|
|
1285
1301
|
|
|
1286
|
-
/* src/XAxis.svelte generated by Svelte v3.
|
|
1302
|
+
/* src/XAxis.svelte generated by Svelte v3.48.0 */
|
|
1287
1303
|
|
|
1288
1304
|
function get_each_context$5(ctx, list, i) {
|
|
1289
1305
|
const child_ctx = ctx.slice();
|
|
@@ -1663,7 +1679,7 @@
|
|
|
1663
1679
|
}
|
|
1664
1680
|
}
|
|
1665
1681
|
|
|
1666
|
-
/* src/YAxis.svelte generated by Svelte v3.
|
|
1682
|
+
/* src/YAxis.svelte generated by Svelte v3.48.0 */
|
|
1667
1683
|
|
|
1668
1684
|
function get_each_context$4(ctx, list, i) {
|
|
1669
1685
|
const child_ctx = ctx.slice();
|
|
@@ -2049,7 +2065,7 @@
|
|
|
2049
2065
|
}
|
|
2050
2066
|
}
|
|
2051
2067
|
|
|
2052
|
-
/* src/Rectangles.svelte generated by Svelte v3.
|
|
2068
|
+
/* src/Rectangles.svelte generated by Svelte v3.48.0 */
|
|
2053
2069
|
|
|
2054
2070
|
function get_each_context$3(ctx, list, i) {
|
|
2055
2071
|
const child_ctx = ctx.slice();
|
|
@@ -2345,7 +2361,7 @@
|
|
|
2345
2361
|
}
|
|
2346
2362
|
}
|
|
2347
2363
|
|
|
2348
|
-
/* src/Box.svelte generated by Svelte v3.
|
|
2364
|
+
/* src/Box.svelte generated by Svelte v3.48.0 */
|
|
2349
2365
|
|
|
2350
2366
|
function create_if_block$5(ctx) {
|
|
2351
2367
|
let g;
|
|
@@ -2512,7 +2528,7 @@
|
|
|
2512
2528
|
}
|
|
2513
2529
|
}
|
|
2514
2530
|
|
|
2515
|
-
/* src/Segments.svelte generated by Svelte v3.
|
|
2531
|
+
/* src/Segments.svelte generated by Svelte v3.48.0 */
|
|
2516
2532
|
|
|
2517
2533
|
function get_each_context$2(ctx, list, i) {
|
|
2518
2534
|
const child_ctx = ctx.slice();
|
|
@@ -2779,10 +2795,10 @@
|
|
|
2779
2795
|
}
|
|
2780
2796
|
}
|
|
2781
2797
|
|
|
2782
|
-
/* src/TextLabels.svelte generated by Svelte v3.
|
|
2798
|
+
/* src/TextLabels.svelte generated by Svelte v3.48.0 */
|
|
2783
2799
|
|
|
2784
2800
|
function add_css$2(target) {
|
|
2785
|
-
append_styles(target, "svelte-
|
|
2801
|
+
append_styles(target, "svelte-1xvrp9d", "text.svelte-1xvrp9d,text.svelte-1xvrp9d>tspan{dominant-baseline:middle}");
|
|
2786
2802
|
}
|
|
2787
2803
|
|
|
2788
2804
|
function get_each_context$1(ctx, list, i) {
|
|
@@ -2881,7 +2897,7 @@
|
|
|
2881
2897
|
attr(text_1, "y", text_1_y_value = /*y*/ ctx[6][/*i*/ ctx[29]]);
|
|
2882
2898
|
attr(text_1, "dx", /*dx*/ ctx[5]);
|
|
2883
2899
|
attr(text_1, "dy", /*dy*/ ctx[4]);
|
|
2884
|
-
attr(text_1, "class", "svelte-
|
|
2900
|
+
attr(text_1, "class", "svelte-1xvrp9d");
|
|
2885
2901
|
},
|
|
2886
2902
|
m(target, anchor) {
|
|
2887
2903
|
insert(target, text_1, anchor);
|
|
@@ -3102,7 +3118,7 @@
|
|
|
3102
3118
|
}
|
|
3103
3119
|
}
|
|
3104
3120
|
|
|
3105
|
-
/* src/TextLegend.svelte generated by Svelte v3.
|
|
3121
|
+
/* src/TextLegend.svelte generated by Svelte v3.48.0 */
|
|
3106
3122
|
|
|
3107
3123
|
function get_each_context(ctx, list, i) {
|
|
3108
3124
|
const child_ctx = ctx.slice();
|
|
@@ -3370,7 +3386,7 @@
|
|
|
3370
3386
|
}
|
|
3371
3387
|
|
|
3372
3388
|
/**********************************************
|
|
3373
|
-
* Functions for statistical tests
|
|
3389
|
+
* Functions for statistical tests and models *
|
|
3374
3390
|
**********************************************/
|
|
3375
3391
|
|
|
3376
3392
|
|
|
@@ -3426,7 +3442,7 @@
|
|
|
3426
3442
|
return x.slice(1).map( (y, i) => (y - x[i]));
|
|
3427
3443
|
}
|
|
3428
3444
|
|
|
3429
|
-
/* src/BarSeries.svelte generated by Svelte v3.
|
|
3445
|
+
/* src/BarSeries.svelte generated by Svelte v3.48.0 */
|
|
3430
3446
|
|
|
3431
3447
|
function add_css$1(target) {
|
|
3432
3448
|
append_styles(target, "svelte-kw726w", ".series_bar > rect{stroke-width:1px}.series_bar > rect:hover{opacity:90%}");
|
|
@@ -3594,7 +3610,7 @@
|
|
|
3594
3610
|
}
|
|
3595
3611
|
}
|
|
3596
3612
|
|
|
3597
|
-
/* src/ScatterSeries.svelte generated by Svelte v3.
|
|
3613
|
+
/* src/ScatterSeries.svelte generated by Svelte v3.48.0 */
|
|
3598
3614
|
|
|
3599
3615
|
function add_css(target) {
|
|
3600
3616
|
append_styles(target, "svelte-byxua3", ".series_scatter > text{font-size:1em;cursor:default}.series_scatter > text:hover{opacity:90%}.series_scatter > *:hover + .labels_hover{visibility:visible;opacity:1}");
|
|
@@ -3761,7 +3777,7 @@
|
|
|
3761
3777
|
}
|
|
3762
3778
|
}
|
|
3763
3779
|
|
|
3764
|
-
/* src/LineSeries.svelte generated by Svelte v3.
|
|
3780
|
+
/* src/LineSeries.svelte generated by Svelte v3.48.0 */
|
|
3765
3781
|
|
|
3766
3782
|
function create_if_block$1(ctx) {
|
|
3767
3783
|
let g;
|
|
@@ -3952,7 +3968,7 @@
|
|
|
3952
3968
|
}
|
|
3953
3969
|
}
|
|
3954
3970
|
|
|
3955
|
-
/* src/AreaSeries.svelte generated by Svelte v3.
|
|
3971
|
+
/* src/AreaSeries.svelte generated by Svelte v3.48.0 */
|
|
3956
3972
|
|
|
3957
3973
|
function create_if_block(ctx) {
|
|
3958
3974
|
let g;
|
package/dist/index.mjs
CHANGED
|
@@ -159,9 +159,9 @@ function set_style(node, key, value, important) {
|
|
|
159
159
|
function toggle_class(element, name, toggle) {
|
|
160
160
|
element.classList[toggle ? 'add' : 'remove'](name);
|
|
161
161
|
}
|
|
162
|
-
function custom_event(type, detail, bubbles = false) {
|
|
162
|
+
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|
163
163
|
const e = document.createEvent('CustomEvent');
|
|
164
|
-
e.initCustomEvent(type, bubbles,
|
|
164
|
+
e.initCustomEvent(type, bubbles, cancelable, detail);
|
|
165
165
|
return e;
|
|
166
166
|
}
|
|
167
167
|
|
|
@@ -179,20 +179,23 @@ function onMount(fn) {
|
|
|
179
179
|
}
|
|
180
180
|
function createEventDispatcher() {
|
|
181
181
|
const component = get_current_component();
|
|
182
|
-
return (type, detail) => {
|
|
182
|
+
return (type, detail, { cancelable = false } = {}) => {
|
|
183
183
|
const callbacks = component.$$.callbacks[type];
|
|
184
184
|
if (callbacks) {
|
|
185
185
|
// TODO are there situations where events could be dispatched
|
|
186
186
|
// in a server (non-DOM) environment?
|
|
187
|
-
const event = custom_event(type, detail);
|
|
187
|
+
const event = custom_event(type, detail, { cancelable });
|
|
188
188
|
callbacks.slice().forEach(fn => {
|
|
189
189
|
fn.call(component, event);
|
|
190
190
|
});
|
|
191
|
+
return !event.defaultPrevented;
|
|
191
192
|
}
|
|
193
|
+
return true;
|
|
192
194
|
};
|
|
193
195
|
}
|
|
194
196
|
function setContext(key, context) {
|
|
195
197
|
get_current_component().$$.context.set(key, context);
|
|
198
|
+
return context;
|
|
196
199
|
}
|
|
197
200
|
function getContext(key) {
|
|
198
201
|
return get_current_component().$$.context.get(key);
|
|
@@ -493,7 +496,7 @@ function writable(value, start = noop) {
|
|
|
493
496
|
return { set, update, subscribe };
|
|
494
497
|
}
|
|
495
498
|
|
|
496
|
-
/* src/Axes.svelte generated by Svelte v3.
|
|
499
|
+
/* src/Axes.svelte generated by Svelte v3.48.0 */
|
|
497
500
|
|
|
498
501
|
function add_css$3(target) {
|
|
499
502
|
append_styles(target, "svelte-n80kcc", ".plot{font-family:Arial, Helvetica, sans-serif;display:grid;grid-template-columns:min-content 1fr;grid-template-rows:auto 1fr auto;grid-template-areas:\". title\"\n \"ylab axes\"\n \". xlab\";box-sizing:border-box;background:#fefefe;min-width:100px;min-height:50px;width:100%;height:100%;padding:0;margin:0}.plot_small{font-size:11px}.plot_medium{font-size:13px}.plot_large{font-size:16px}.plot_error{display:flex}.plot_error > .axes-wrapper{display:none}.message_error{font-size:1.2em;color:crimson;padding:20px;text-align:center}.axes-wrapper.svelte-n80kcc{grid-area:axes;position:relative;box-sizing:border-box;display:flex;width:100%;height:100%;padding:0;margin:0}.axes{display:block;box-sizing:border-box;position:absolute;padding:0;margin:0;height:100%;width:100%;max-height:100%;max-width:100%;min-height:100%;min-width:100%}.axes__xlabel{grid-area:xlab;font-size:1.0em;font-weight:600;padding:0.25em;text-align:center}.axes__ylabel{grid-area:ylab;font-size:1.0em;font-weight:600;padding:0.25em;text-align:center;vertical-align:middle;display:flex}.axes__ylabel > span{width:1.5em;line-height:1.5em;display:inline-block;writing-mode:vertical-rl;transform:rotate(180deg)}.axes__title{background:transparent;grid-area:title;font-size:1.3em;font-weight:bold;line-height:1.2em;padding:0.5em 0;text-align:center}.axis-labels{fill:#303030;font-size:0.95em}.labels{fill:#606060;font-size:0.90em}.labels{visibility:hidden;transition:visibility 0.25s linear, opacity 0.25s linear;opacity:0}");
|
|
@@ -506,7 +509,7 @@ const get_yaxis_slot_context = ctx => ({});
|
|
|
506
509
|
const get_xaxis_slot_changes = dirty => ({});
|
|
507
510
|
const get_xaxis_slot_context = ctx => ({});
|
|
508
511
|
|
|
509
|
-
// (
|
|
512
|
+
// (342:3) {#if title !== ""}
|
|
510
513
|
function create_if_block_3(ctx) {
|
|
511
514
|
let div;
|
|
512
515
|
|
|
@@ -527,7 +530,7 @@ function create_if_block_3(ctx) {
|
|
|
527
530
|
};
|
|
528
531
|
}
|
|
529
532
|
|
|
530
|
-
// (
|
|
533
|
+
// (343:3) {#if yLabel !== ""}
|
|
531
534
|
function create_if_block_2(ctx) {
|
|
532
535
|
let div;
|
|
533
536
|
let span;
|
|
@@ -551,7 +554,7 @@ function create_if_block_2(ctx) {
|
|
|
551
554
|
};
|
|
552
555
|
}
|
|
553
556
|
|
|
554
|
-
// (
|
|
557
|
+
// (344:3) {#if xLabel !== ""}
|
|
555
558
|
function create_if_block_1(ctx) {
|
|
556
559
|
let div;
|
|
557
560
|
let span;
|
|
@@ -575,7 +578,7 @@ function create_if_block_1(ctx) {
|
|
|
575
578
|
};
|
|
576
579
|
}
|
|
577
580
|
|
|
578
|
-
// (
|
|
581
|
+
// (372:3) {#if !$isOk}
|
|
579
582
|
function create_if_block$9(ctx) {
|
|
580
583
|
let p;
|
|
581
584
|
|
|
@@ -620,14 +623,14 @@ function create_fragment$b(ctx) {
|
|
|
620
623
|
let if_block0 = /*title*/ ctx[0] !== "" && create_if_block_3(ctx);
|
|
621
624
|
let if_block1 = /*yLabel*/ ctx[2] !== "" && create_if_block_2(ctx);
|
|
622
625
|
let if_block2 = /*xLabel*/ ctx[1] !== "" && create_if_block_1(ctx);
|
|
623
|
-
const xaxis_slot_template = /*#slots*/ ctx[
|
|
624
|
-
const xaxis_slot = create_slot(xaxis_slot_template, ctx, /*$$scope*/ ctx[
|
|
625
|
-
const yaxis_slot_template = /*#slots*/ ctx[
|
|
626
|
-
const yaxis_slot = create_slot(yaxis_slot_template, ctx, /*$$scope*/ ctx[
|
|
627
|
-
const default_slot_template = /*#slots*/ ctx[
|
|
628
|
-
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[
|
|
629
|
-
const box_slot_template = /*#slots*/ ctx[
|
|
630
|
-
const box_slot = create_slot(box_slot_template, ctx, /*$$scope*/ ctx[
|
|
626
|
+
const xaxis_slot_template = /*#slots*/ ctx[27].xaxis;
|
|
627
|
+
const xaxis_slot = create_slot(xaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_xaxis_slot_context);
|
|
628
|
+
const yaxis_slot_template = /*#slots*/ ctx[27].yaxis;
|
|
629
|
+
const yaxis_slot = create_slot(yaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_yaxis_slot_context);
|
|
630
|
+
const default_slot_template = /*#slots*/ ctx[27].default;
|
|
631
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], null);
|
|
632
|
+
const box_slot_template = /*#slots*/ ctx[27].box;
|
|
633
|
+
const box_slot = create_slot(box_slot_template, ctx, /*$$scope*/ ctx[26], get_box_slot_context);
|
|
631
634
|
let if_block3 = !/*$isOk*/ ctx[3] && create_if_block$9();
|
|
632
635
|
|
|
633
636
|
return {
|
|
@@ -652,12 +655,12 @@ function create_fragment$b(ctx) {
|
|
|
652
655
|
t3 = space();
|
|
653
656
|
if (if_block3) if_block3.c();
|
|
654
657
|
set_style(rect, "pointer-events", "none");
|
|
655
|
-
attr(rect, "x", rect_x_value = /*cpx*/ ctx[
|
|
656
|
-
attr(rect, "y", rect_y_value = /*cpy*/ ctx[
|
|
657
|
-
attr(rect, "width", rect_width_value = /*cpx*/ ctx[
|
|
658
|
-
attr(rect, "height", rect_height_value = /*cpy*/ ctx[
|
|
659
|
-
attr(clipPath, "id", /*clipPathID*/ ctx[
|
|
660
|
-
attr(g, "clip-path", "url(#" + /*clipPathID*/ ctx[
|
|
658
|
+
attr(rect, "x", rect_x_value = /*cpx*/ ctx[8][0]);
|
|
659
|
+
attr(rect, "y", rect_y_value = /*cpy*/ ctx[7][1]);
|
|
660
|
+
attr(rect, "width", rect_width_value = /*cpx*/ ctx[8][1] - /*cpx*/ ctx[8][0]);
|
|
661
|
+
attr(rect, "height", rect_height_value = /*cpy*/ ctx[7][0] - /*cpy*/ ctx[7][1]);
|
|
662
|
+
attr(clipPath, "id", /*clipPathID*/ ctx[9]);
|
|
663
|
+
attr(g, "clip-path", "url(#" + /*clipPathID*/ ctx[9] + ")");
|
|
661
664
|
attr(svg, "preserveAspectRatio", "none");
|
|
662
665
|
attr(svg, "class", "axes");
|
|
663
666
|
attr(div0, "class", "axes-wrapper svelte-n80kcc");
|
|
@@ -696,13 +699,14 @@ function create_fragment$b(ctx) {
|
|
|
696
699
|
box_slot.m(svg, null);
|
|
697
700
|
}
|
|
698
701
|
|
|
699
|
-
/*div0_binding*/ ctx[
|
|
702
|
+
/*div0_binding*/ ctx[28](div0);
|
|
700
703
|
append(div1, t3);
|
|
701
704
|
if (if_block3) if_block3.m(div1, null);
|
|
705
|
+
/*div1_binding*/ ctx[29](div1);
|
|
702
706
|
current = true;
|
|
703
707
|
|
|
704
708
|
if (!mounted) {
|
|
705
|
-
dispose = listen(svg, "click", /*handleClick*/ ctx[
|
|
709
|
+
dispose = listen(svg, "click", /*handleClick*/ ctx[16]);
|
|
706
710
|
mounted = true;
|
|
707
711
|
}
|
|
708
712
|
},
|
|
@@ -746,77 +750,77 @@ function create_fragment$b(ctx) {
|
|
|
746
750
|
if_block2 = null;
|
|
747
751
|
}
|
|
748
752
|
|
|
749
|
-
if (!current || dirty[0] & /*cpx*/
|
|
753
|
+
if (!current || dirty[0] & /*cpx*/ 256 && rect_x_value !== (rect_x_value = /*cpx*/ ctx[8][0])) {
|
|
750
754
|
attr(rect, "x", rect_x_value);
|
|
751
755
|
}
|
|
752
756
|
|
|
753
|
-
if (!current || dirty[0] & /*cpy*/
|
|
757
|
+
if (!current || dirty[0] & /*cpy*/ 128 && rect_y_value !== (rect_y_value = /*cpy*/ ctx[7][1])) {
|
|
754
758
|
attr(rect, "y", rect_y_value);
|
|
755
759
|
}
|
|
756
760
|
|
|
757
|
-
if (!current || dirty[0] & /*cpx*/
|
|
761
|
+
if (!current || dirty[0] & /*cpx*/ 256 && rect_width_value !== (rect_width_value = /*cpx*/ ctx[8][1] - /*cpx*/ ctx[8][0])) {
|
|
758
762
|
attr(rect, "width", rect_width_value);
|
|
759
763
|
}
|
|
760
764
|
|
|
761
|
-
if (!current || dirty[0] & /*cpy*/
|
|
765
|
+
if (!current || dirty[0] & /*cpy*/ 128 && rect_height_value !== (rect_height_value = /*cpy*/ ctx[7][0] - /*cpy*/ ctx[7][1])) {
|
|
762
766
|
attr(rect, "height", rect_height_value);
|
|
763
767
|
}
|
|
764
768
|
|
|
765
769
|
if (xaxis_slot) {
|
|
766
|
-
if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
770
|
+
if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
767
771
|
update_slot_base(
|
|
768
772
|
xaxis_slot,
|
|
769
773
|
xaxis_slot_template,
|
|
770
774
|
ctx,
|
|
771
|
-
/*$$scope*/ ctx[
|
|
775
|
+
/*$$scope*/ ctx[26],
|
|
772
776
|
!current
|
|
773
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
774
|
-
: get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[
|
|
777
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
778
|
+
: get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_xaxis_slot_changes),
|
|
775
779
|
get_xaxis_slot_context
|
|
776
780
|
);
|
|
777
781
|
}
|
|
778
782
|
}
|
|
779
783
|
|
|
780
784
|
if (yaxis_slot) {
|
|
781
|
-
if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
785
|
+
if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
782
786
|
update_slot_base(
|
|
783
787
|
yaxis_slot,
|
|
784
788
|
yaxis_slot_template,
|
|
785
789
|
ctx,
|
|
786
|
-
/*$$scope*/ ctx[
|
|
790
|
+
/*$$scope*/ ctx[26],
|
|
787
791
|
!current
|
|
788
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
789
|
-
: get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[
|
|
792
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
793
|
+
: get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_yaxis_slot_changes),
|
|
790
794
|
get_yaxis_slot_context
|
|
791
795
|
);
|
|
792
796
|
}
|
|
793
797
|
}
|
|
794
798
|
|
|
795
799
|
if (default_slot) {
|
|
796
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
800
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
797
801
|
update_slot_base(
|
|
798
802
|
default_slot,
|
|
799
803
|
default_slot_template,
|
|
800
804
|
ctx,
|
|
801
|
-
/*$$scope*/ ctx[
|
|
805
|
+
/*$$scope*/ ctx[26],
|
|
802
806
|
!current
|
|
803
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
804
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
807
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
808
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, null),
|
|
805
809
|
null
|
|
806
810
|
);
|
|
807
811
|
}
|
|
808
812
|
}
|
|
809
813
|
|
|
810
814
|
if (box_slot) {
|
|
811
|
-
if (box_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
815
|
+
if (box_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
812
816
|
update_slot_base(
|
|
813
817
|
box_slot,
|
|
814
818
|
box_slot_template,
|
|
815
819
|
ctx,
|
|
816
|
-
/*$$scope*/ ctx[
|
|
820
|
+
/*$$scope*/ ctx[26],
|
|
817
821
|
!current
|
|
818
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
819
|
-
: get_slot_changes(box_slot_template, /*$$scope*/ ctx[
|
|
822
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
823
|
+
: get_slot_changes(box_slot_template, /*$$scope*/ ctx[26], dirty, get_box_slot_changes),
|
|
820
824
|
get_box_slot_context
|
|
821
825
|
);
|
|
822
826
|
}
|
|
@@ -865,8 +869,9 @@ function create_fragment$b(ctx) {
|
|
|
865
869
|
if (yaxis_slot) yaxis_slot.d(detaching);
|
|
866
870
|
if (default_slot) default_slot.d(detaching);
|
|
867
871
|
if (box_slot) box_slot.d(detaching);
|
|
868
|
-
/*div0_binding*/ ctx[
|
|
872
|
+
/*div0_binding*/ ctx[28](null);
|
|
869
873
|
if (if_block3) if_block3.d();
|
|
874
|
+
/*div1_binding*/ ctx[29](null);
|
|
870
875
|
mounted = false;
|
|
871
876
|
dispose();
|
|
872
877
|
}
|
|
@@ -939,20 +944,21 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
939
944
|
const clipPathID = "plottingArea" + Math.round(Math.random() * 10000);
|
|
940
945
|
|
|
941
946
|
/* parameters for internal use inside the component */
|
|
942
|
-
let
|
|
947
|
+
let plotElement;
|
|
943
948
|
|
|
949
|
+
let axesElement;
|
|
944
950
|
let axesMargins = [0.034, 0.034, 0.034, 0.034]; // initial margins (will be multiplied to FACTORS)
|
|
945
951
|
|
|
946
952
|
/* reactive parameters to be shared with children via context */
|
|
947
953
|
const width = writable(100); // actual width of plotting area in pixels
|
|
948
954
|
|
|
949
|
-
component_subscribe($$self, width, value => $$invalidate(
|
|
955
|
+
component_subscribe($$self, width, value => $$invalidate(24, $width = value));
|
|
950
956
|
const height = writable(100); // actual height of plotting area in pixels
|
|
951
|
-
component_subscribe($$self, height, value => $$invalidate(
|
|
957
|
+
component_subscribe($$self, height, value => $$invalidate(22, $height = value));
|
|
952
958
|
const xLim = writable([undefined, undefined]); // actual limits for x-axis in plot units
|
|
953
|
-
component_subscribe($$self, xLim, value => $$invalidate(
|
|
959
|
+
component_subscribe($$self, xLim, value => $$invalidate(25, $xLim = value));
|
|
954
960
|
const yLim = writable([undefined, undefined]); // actual limits for y-axis in plot units
|
|
955
|
-
component_subscribe($$self, yLim, value => $$invalidate(
|
|
961
|
+
component_subscribe($$self, yLim, value => $$invalidate(23, $yLim = value));
|
|
956
962
|
const scale = writable("medium"); // scale factor (how big the shown plot is)
|
|
957
963
|
component_subscribe($$self, scale, value => $$invalidate(4, $scale = value));
|
|
958
964
|
const isOk = writable(false); // are axes ready for drawing
|
|
@@ -960,18 +966,18 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
960
966
|
|
|
961
967
|
/** Adds margins for x-axis (e.g. when x-axis must be shown) */
|
|
962
968
|
const addXAxisMargins = function () {
|
|
963
|
-
$$invalidate(
|
|
964
|
-
$$invalidate(
|
|
965
|
-
$$invalidate(
|
|
966
|
-
$$invalidate(
|
|
969
|
+
$$invalidate(20, axesMargins[0] = 1, axesMargins);
|
|
970
|
+
$$invalidate(20, axesMargins[2] = 0.5, axesMargins);
|
|
971
|
+
$$invalidate(20, axesMargins[1] = axesMargins[1] > 0.5 ? axesMargins[1] : 0.5, axesMargins);
|
|
972
|
+
$$invalidate(20, axesMargins[3] = axesMargins[3] > 0.5 ? axesMargins[3] : 0.5, axesMargins);
|
|
967
973
|
};
|
|
968
974
|
|
|
969
975
|
/** Adds margins for y-axis (e.g. when y-axis must be shown) */
|
|
970
976
|
const addYAxisMargins = function () {
|
|
971
|
-
$$invalidate(
|
|
972
|
-
$$invalidate(
|
|
973
|
-
$$invalidate(
|
|
974
|
-
$$invalidate(
|
|
977
|
+
$$invalidate(20, axesMargins[1] = 1, axesMargins);
|
|
978
|
+
$$invalidate(20, axesMargins[3] = 0.5, axesMargins);
|
|
979
|
+
$$invalidate(20, axesMargins[0] = axesMargins[0] > 0.5 ? axesMargins[0] : 0.5, axesMargins);
|
|
980
|
+
$$invalidate(20, axesMargins[2] = axesMargins[2] > 0.5 ? axesMargins[2] : 0.5, axesMargins);
|
|
975
981
|
};
|
|
976
982
|
|
|
977
983
|
/** Adjusts limits for x-axis (e.g. when new series is added)
|
|
@@ -1120,20 +1126,6 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
1120
1126
|
|
|
1121
1127
|
setContext('axes', context);
|
|
1122
1128
|
|
|
1123
|
-
/* observer for the plotting area size */
|
|
1124
|
-
var ro = new ResizeObserver(entries => {
|
|
1125
|
-
for (let entry of entries) {
|
|
1126
|
-
const cr = entry.contentRect;
|
|
1127
|
-
width.update(x => cr.width);
|
|
1128
|
-
height.update(x => cr.height);
|
|
1129
|
-
scale.update(x => getScale(cr.width, cr.height));
|
|
1130
|
-
}
|
|
1131
|
-
});
|
|
1132
|
-
|
|
1133
|
-
onMount(() => {
|
|
1134
|
-
ro.observe(axesWrapper);
|
|
1135
|
-
});
|
|
1136
|
-
|
|
1137
1129
|
// handle click on plot elements and dispatch manual events
|
|
1138
1130
|
function dispatchClickEvent(eventName, el) {
|
|
1139
1131
|
dispatch(eventName, {
|
|
@@ -1159,51 +1151,73 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
1159
1151
|
dispatch("axesclick");
|
|
1160
1152
|
}
|
|
1161
1153
|
|
|
1154
|
+
/* observer for the plotting area size */
|
|
1155
|
+
var ro = new ResizeObserver(entries => {
|
|
1156
|
+
for (let entry of entries) {
|
|
1157
|
+
const pcr = plotElement.getBoundingClientRect();
|
|
1158
|
+
const acr = axesElement.getBoundingClientRect();
|
|
1159
|
+
width.update(x => acr.width);
|
|
1160
|
+
height.update(x => acr.height);
|
|
1161
|
+
scale.update(x => getScale(pcr.width, pcr.height));
|
|
1162
|
+
}
|
|
1163
|
+
});
|
|
1164
|
+
|
|
1165
|
+
onMount(() => {
|
|
1166
|
+
ro.observe(plotElement);
|
|
1167
|
+
});
|
|
1168
|
+
|
|
1162
1169
|
function div0_binding($$value) {
|
|
1163
1170
|
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1164
|
-
|
|
1165
|
-
$$invalidate(
|
|
1171
|
+
axesElement = $$value;
|
|
1172
|
+
$$invalidate(6, axesElement);
|
|
1173
|
+
});
|
|
1174
|
+
}
|
|
1175
|
+
|
|
1176
|
+
function div1_binding($$value) {
|
|
1177
|
+
binding_callbacks[$$value ? 'unshift' : 'push'](() => {
|
|
1178
|
+
plotElement = $$value;
|
|
1179
|
+
$$invalidate(5, plotElement);
|
|
1166
1180
|
});
|
|
1167
1181
|
}
|
|
1168
1182
|
|
|
1169
1183
|
$$self.$$set = $$props => {
|
|
1170
|
-
if ('limX' in $$props) $$invalidate(
|
|
1171
|
-
if ('limY' in $$props) $$invalidate(
|
|
1184
|
+
if ('limX' in $$props) $$invalidate(17, limX = $$props.limX);
|
|
1185
|
+
if ('limY' in $$props) $$invalidate(18, limY = $$props.limY);
|
|
1172
1186
|
if ('title' in $$props) $$invalidate(0, title = $$props.title);
|
|
1173
1187
|
if ('xLabel' in $$props) $$invalidate(1, xLabel = $$props.xLabel);
|
|
1174
1188
|
if ('yLabel' in $$props) $$invalidate(2, yLabel = $$props.yLabel);
|
|
1175
|
-
if ('multiSeries' in $$props) $$invalidate(
|
|
1176
|
-
if ('$$scope' in $$props) $$invalidate(
|
|
1189
|
+
if ('multiSeries' in $$props) $$invalidate(19, multiSeries = $$props.multiSeries);
|
|
1190
|
+
if ('$$scope' in $$props) $$invalidate(26, $$scope = $$props.$$scope);
|
|
1177
1191
|
};
|
|
1178
1192
|
|
|
1179
1193
|
$$self.$$.update = () => {
|
|
1180
|
-
if ($$self.$$.dirty[0] & /*limX*/
|
|
1194
|
+
if ($$self.$$.dirty[0] & /*limX*/ 131072) {
|
|
1181
1195
|
// this is reactive in case if limX and limY are interactively changed by parent script
|
|
1182
1196
|
if (!limX.some(v => v === undefined)) xLim.update(v => limX);
|
|
1183
1197
|
}
|
|
1184
1198
|
|
|
1185
|
-
if ($$self.$$.dirty[0] & /*limY*/
|
|
1199
|
+
if ($$self.$$.dirty[0] & /*limY*/ 262144) {
|
|
1186
1200
|
if (!limY.some(v => v === undefined)) yLim.update(v => limY);
|
|
1187
1201
|
}
|
|
1188
1202
|
|
|
1189
|
-
if ($$self.$$.dirty[0] & /*axesMargins, $scale*/
|
|
1203
|
+
if ($$self.$$.dirty[0] & /*axesMargins, $scale*/ 1048592) {
|
|
1190
1204
|
// computes real margins in pixels based on current scale
|
|
1191
|
-
$$invalidate(
|
|
1205
|
+
$$invalidate(21, margins = axesMargins.map(v => v * AXES_MARGIN_FACTORS[$scale]));
|
|
1192
1206
|
}
|
|
1193
1207
|
|
|
1194
|
-
if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/
|
|
1208
|
+
if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/ 65011712) {
|
|
1195
1209
|
// computes status which tells that axes limits look fine and it is safe to draw
|
|
1196
1210
|
// the status is based on the axis limits validity
|
|
1197
1211
|
isOk.update(v => Array.isArray($yLim) && Array.isArray($xLim) && $xLim.length === 2 && $yLim.length === 2 && !$yLim.some(v => v === undefined) && !$xLim.some(v => v === undefined) && !$yLim.some(v => isNaN(v)) && !$xLim.some(v => isNaN(v)) && $xLim[1] !== $xLim[0] && $yLim[1] !== $yLim[0] && $width > margins[1] + margins[3] && $height > margins[0] + margins[2]);
|
|
1198
1212
|
}
|
|
1199
1213
|
|
|
1200
|
-
if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/
|
|
1214
|
+
if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/ 50331656) {
|
|
1201
1215
|
// computes coordinates for clip path box
|
|
1202
|
-
$$invalidate(
|
|
1216
|
+
$$invalidate(8, cpx = $isOk ? scaleX($xLim, $xLim, $width) : [0, 1]);
|
|
1203
1217
|
}
|
|
1204
1218
|
|
|
1205
|
-
if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/
|
|
1206
|
-
$$invalidate(
|
|
1219
|
+
if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/ 12582920) {
|
|
1220
|
+
$$invalidate(7, cpy = $isOk ? scaleY($yLim, $yLim, $height) : [1, 0]);
|
|
1207
1221
|
}
|
|
1208
1222
|
};
|
|
1209
1223
|
|
|
@@ -1213,7 +1227,8 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
1213
1227
|
yLabel,
|
|
1214
1228
|
$isOk,
|
|
1215
1229
|
$scale,
|
|
1216
|
-
|
|
1230
|
+
plotElement,
|
|
1231
|
+
axesElement,
|
|
1217
1232
|
cpy,
|
|
1218
1233
|
cpx,
|
|
1219
1234
|
clipPathID,
|
|
@@ -1235,7 +1250,8 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
1235
1250
|
$xLim,
|
|
1236
1251
|
$$scope,
|
|
1237
1252
|
slots,
|
|
1238
|
-
div0_binding
|
|
1253
|
+
div0_binding,
|
|
1254
|
+
div1_binding
|
|
1239
1255
|
];
|
|
1240
1256
|
}
|
|
1241
1257
|
|
|
@@ -1250,12 +1266,12 @@ class Axes extends SvelteComponent {
|
|
|
1250
1266
|
create_fragment$b,
|
|
1251
1267
|
safe_not_equal,
|
|
1252
1268
|
{
|
|
1253
|
-
limX:
|
|
1254
|
-
limY:
|
|
1269
|
+
limX: 17,
|
|
1270
|
+
limY: 18,
|
|
1255
1271
|
title: 0,
|
|
1256
1272
|
xLabel: 1,
|
|
1257
1273
|
yLabel: 2,
|
|
1258
|
-
multiSeries:
|
|
1274
|
+
multiSeries: 19
|
|
1259
1275
|
},
|
|
1260
1276
|
add_css$3,
|
|
1261
1277
|
[-1, -1]
|
|
@@ -1277,7 +1293,7 @@ const Colors = {
|
|
|
1277
1293
|
"PRIMARY_TEXT": "#333",
|
|
1278
1294
|
};
|
|
1279
1295
|
|
|
1280
|
-
/* src/XAxis.svelte generated by Svelte v3.
|
|
1296
|
+
/* src/XAxis.svelte generated by Svelte v3.48.0 */
|
|
1281
1297
|
|
|
1282
1298
|
function get_each_context$5(ctx, list, i) {
|
|
1283
1299
|
const child_ctx = ctx.slice();
|
|
@@ -1657,7 +1673,7 @@ class XAxis extends SvelteComponent {
|
|
|
1657
1673
|
}
|
|
1658
1674
|
}
|
|
1659
1675
|
|
|
1660
|
-
/* src/YAxis.svelte generated by Svelte v3.
|
|
1676
|
+
/* src/YAxis.svelte generated by Svelte v3.48.0 */
|
|
1661
1677
|
|
|
1662
1678
|
function get_each_context$4(ctx, list, i) {
|
|
1663
1679
|
const child_ctx = ctx.slice();
|
|
@@ -2043,7 +2059,7 @@ class YAxis extends SvelteComponent {
|
|
|
2043
2059
|
}
|
|
2044
2060
|
}
|
|
2045
2061
|
|
|
2046
|
-
/* src/Rectangles.svelte generated by Svelte v3.
|
|
2062
|
+
/* src/Rectangles.svelte generated by Svelte v3.48.0 */
|
|
2047
2063
|
|
|
2048
2064
|
function get_each_context$3(ctx, list, i) {
|
|
2049
2065
|
const child_ctx = ctx.slice();
|
|
@@ -2339,7 +2355,7 @@ class Rectangles extends SvelteComponent {
|
|
|
2339
2355
|
}
|
|
2340
2356
|
}
|
|
2341
2357
|
|
|
2342
|
-
/* src/Box.svelte generated by Svelte v3.
|
|
2358
|
+
/* src/Box.svelte generated by Svelte v3.48.0 */
|
|
2343
2359
|
|
|
2344
2360
|
function create_if_block$5(ctx) {
|
|
2345
2361
|
let g;
|
|
@@ -2506,7 +2522,7 @@ class Box extends SvelteComponent {
|
|
|
2506
2522
|
}
|
|
2507
2523
|
}
|
|
2508
2524
|
|
|
2509
|
-
/* src/Segments.svelte generated by Svelte v3.
|
|
2525
|
+
/* src/Segments.svelte generated by Svelte v3.48.0 */
|
|
2510
2526
|
|
|
2511
2527
|
function get_each_context$2(ctx, list, i) {
|
|
2512
2528
|
const child_ctx = ctx.slice();
|
|
@@ -2773,10 +2789,10 @@ class Segments extends SvelteComponent {
|
|
|
2773
2789
|
}
|
|
2774
2790
|
}
|
|
2775
2791
|
|
|
2776
|
-
/* src/TextLabels.svelte generated by Svelte v3.
|
|
2792
|
+
/* src/TextLabels.svelte generated by Svelte v3.48.0 */
|
|
2777
2793
|
|
|
2778
2794
|
function add_css$2(target) {
|
|
2779
|
-
append_styles(target, "svelte-
|
|
2795
|
+
append_styles(target, "svelte-1xvrp9d", "text.svelte-1xvrp9d,text.svelte-1xvrp9d>tspan{dominant-baseline:middle}");
|
|
2780
2796
|
}
|
|
2781
2797
|
|
|
2782
2798
|
function get_each_context$1(ctx, list, i) {
|
|
@@ -2875,7 +2891,7 @@ function create_each_block$1(ctx) {
|
|
|
2875
2891
|
attr(text_1, "y", text_1_y_value = /*y*/ ctx[6][/*i*/ ctx[29]]);
|
|
2876
2892
|
attr(text_1, "dx", /*dx*/ ctx[5]);
|
|
2877
2893
|
attr(text_1, "dy", /*dy*/ ctx[4]);
|
|
2878
|
-
attr(text_1, "class", "svelte-
|
|
2894
|
+
attr(text_1, "class", "svelte-1xvrp9d");
|
|
2879
2895
|
},
|
|
2880
2896
|
m(target, anchor) {
|
|
2881
2897
|
insert(target, text_1, anchor);
|
|
@@ -3096,7 +3112,7 @@ class TextLabels extends SvelteComponent {
|
|
|
3096
3112
|
}
|
|
3097
3113
|
}
|
|
3098
3114
|
|
|
3099
|
-
/* src/TextLegend.svelte generated by Svelte v3.
|
|
3115
|
+
/* src/TextLegend.svelte generated by Svelte v3.48.0 */
|
|
3100
3116
|
|
|
3101
3117
|
function get_each_context(ctx, list, i) {
|
|
3102
3118
|
const child_ctx = ctx.slice();
|
|
@@ -3364,7 +3380,7 @@ class TextLegend extends SvelteComponent {
|
|
|
3364
3380
|
}
|
|
3365
3381
|
|
|
3366
3382
|
/**********************************************
|
|
3367
|
-
* Functions for statistical tests
|
|
3383
|
+
* Functions for statistical tests and models *
|
|
3368
3384
|
**********************************************/
|
|
3369
3385
|
|
|
3370
3386
|
|
|
@@ -3420,7 +3436,7 @@ function diff(x) {
|
|
|
3420
3436
|
return x.slice(1).map( (y, i) => (y - x[i]));
|
|
3421
3437
|
}
|
|
3422
3438
|
|
|
3423
|
-
/* src/BarSeries.svelte generated by Svelte v3.
|
|
3439
|
+
/* src/BarSeries.svelte generated by Svelte v3.48.0 */
|
|
3424
3440
|
|
|
3425
3441
|
function add_css$1(target) {
|
|
3426
3442
|
append_styles(target, "svelte-kw726w", ".series_bar > rect{stroke-width:1px}.series_bar > rect:hover{opacity:90%}");
|
|
@@ -3588,7 +3604,7 @@ class BarSeries extends SvelteComponent {
|
|
|
3588
3604
|
}
|
|
3589
3605
|
}
|
|
3590
3606
|
|
|
3591
|
-
/* src/ScatterSeries.svelte generated by Svelte v3.
|
|
3607
|
+
/* src/ScatterSeries.svelte generated by Svelte v3.48.0 */
|
|
3592
3608
|
|
|
3593
3609
|
function add_css(target) {
|
|
3594
3610
|
append_styles(target, "svelte-byxua3", ".series_scatter > text{font-size:1em;cursor:default}.series_scatter > text:hover{opacity:90%}.series_scatter > *:hover + .labels_hover{visibility:visible;opacity:1}");
|
|
@@ -3755,7 +3771,7 @@ class ScatterSeries extends SvelteComponent {
|
|
|
3755
3771
|
}
|
|
3756
3772
|
}
|
|
3757
3773
|
|
|
3758
|
-
/* src/LineSeries.svelte generated by Svelte v3.
|
|
3774
|
+
/* src/LineSeries.svelte generated by Svelte v3.48.0 */
|
|
3759
3775
|
|
|
3760
3776
|
function create_if_block$1(ctx) {
|
|
3761
3777
|
let g;
|
|
@@ -3946,7 +3962,7 @@ class LineSeries extends SvelteComponent {
|
|
|
3946
3962
|
}
|
|
3947
3963
|
}
|
|
3948
3964
|
|
|
3949
|
-
/* src/AreaSeries.svelte generated by Svelte v3.
|
|
3965
|
+
/* src/AreaSeries.svelte generated by Svelte v3.48.0 */
|
|
3950
3966
|
|
|
3951
3967
|
function create_if_block(ctx) {
|
|
3952
3968
|
let g;
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"svelte": "^3.0.0"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"mdatools": "^0.
|
|
17
|
+
"mdatools": "^0.5.3"
|
|
18
18
|
},
|
|
19
19
|
"keywords": [
|
|
20
20
|
"svelte",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"dist"
|
|
26
26
|
],
|
|
27
27
|
"description": "Svelte components for creating simple plots",
|
|
28
|
-
"version": "1.
|
|
28
|
+
"version": "1.1.1",
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|
|
31
31
|
"url": "svkucheryavski/svelte-plots-basic"
|
package/src/Axes.svelte
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
<script>
|
|
2
|
-
import {
|
|
2
|
+
import { setContext, createEventDispatcher, onMount } from 'svelte';
|
|
3
3
|
import { writable } from 'svelte/store';
|
|
4
4
|
|
|
5
5
|
/* input parameters */
|
|
@@ -34,6 +34,7 @@
|
|
|
34
34
|
"large": 20
|
|
35
35
|
};
|
|
36
36
|
|
|
37
|
+
|
|
37
38
|
// line styles for different scales and types
|
|
38
39
|
const LINE_STYLES = {
|
|
39
40
|
small: ["0", "3,3", "1,1", "3,1"],
|
|
@@ -45,7 +46,8 @@
|
|
|
45
46
|
const clipPathID = "plottingArea" + Math.round(Math.random() * 10000);
|
|
46
47
|
|
|
47
48
|
/* parameters for internal use inside the component */
|
|
48
|
-
let
|
|
49
|
+
let plotElement;
|
|
50
|
+
let axesElement;
|
|
49
51
|
let axesMargins = [0.034, 0.034, 0.034, 0.034]; // initial margins (will be multiplied to FACTORS)
|
|
50
52
|
|
|
51
53
|
/* reactive parameters to be shared with children via context */
|
|
@@ -263,21 +265,6 @@
|
|
|
263
265
|
|
|
264
266
|
setContext('axes', context);
|
|
265
267
|
|
|
266
|
-
/* observer for the plotting area size */
|
|
267
|
-
var ro = new ResizeObserver(entries => {
|
|
268
|
-
for (let entry of entries) {
|
|
269
|
-
const cr = entry.contentRect;
|
|
270
|
-
width.update(x => cr.width);
|
|
271
|
-
height.update(x => cr.height);
|
|
272
|
-
scale.update(x => getScale(cr.width, cr.height));
|
|
273
|
-
}
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
onMount(() => {
|
|
277
|
-
ro.observe(axesWrapper);
|
|
278
|
-
});
|
|
279
|
-
|
|
280
|
-
|
|
281
268
|
// handle click on plot elements and dispatch manual events
|
|
282
269
|
function dispatchClickEvent(eventName, el) {
|
|
283
270
|
dispatch(eventName, {seriesTitle: el.parentNode.getAttribute('title'), elementID: el.dataset.id});
|
|
@@ -329,10 +316,27 @@
|
|
|
329
316
|
// computes coordinates for clip path box
|
|
330
317
|
$: cpx = $isOk ? scaleX($xLim, $xLim, $width) : [0, 1];
|
|
331
318
|
$: cpy = $isOk ? scaleY($yLim, $yLim, $height) : [1, 0];
|
|
319
|
+
|
|
320
|
+
/* observer for the plotting area size */
|
|
321
|
+
var ro = new ResizeObserver(entries => {
|
|
322
|
+
for (let entry of entries) {
|
|
323
|
+
|
|
324
|
+
const pcr = plotElement.getBoundingClientRect();
|
|
325
|
+
const acr = axesElement.getBoundingClientRect();
|
|
326
|
+
|
|
327
|
+
width.update(x => acr.width);
|
|
328
|
+
height.update(x => acr.height);
|
|
329
|
+
scale.update(x => getScale(pcr.width, pcr.height));
|
|
330
|
+
}
|
|
331
|
+
});
|
|
332
|
+
|
|
333
|
+
onMount(() => {
|
|
334
|
+
ro.observe(plotElement);
|
|
335
|
+
});
|
|
332
336
|
</script>
|
|
333
337
|
|
|
334
338
|
|
|
335
|
-
<div class="plot {'plot_' + $scale}" class:plot_error="{!$isOk}">
|
|
339
|
+
<div class="plot {'plot_' + $scale}" bind:this={plotElement} class:plot_error="{!$isOk}">
|
|
336
340
|
|
|
337
341
|
<!-- plot title and axis labels -->
|
|
338
342
|
{#if title !== ""}<div class="axes__title">{@html title}</div>{/if}
|
|
@@ -340,7 +344,7 @@
|
|
|
340
344
|
{#if xLabel !== ""}<div class="axes__xlabel"><span>{@html xLabel}</span></div>{/if}
|
|
341
345
|
|
|
342
346
|
<!-- axes (coordinate system) -->
|
|
343
|
-
<div class="axes-wrapper" bind:this={
|
|
347
|
+
<div class="axes-wrapper" bind:this={axesElement} >
|
|
344
348
|
<svg on:click={handleClick} preserveAspectRatio="none" class="axes">
|
|
345
349
|
|
|
346
350
|
<!-- define clipping path -->
|