svelte-plots-basic 1.0.7 → 1.1.0
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 +17 -15
- package/dist/index.js +182 -122
- package/dist/index.mjs +182 -122
- package/package.json +2 -2
- package/src/Axes.svelte +8 -17
package/dist/index.mjs
CHANGED
|
@@ -156,12 +156,65 @@ function set_style(node, key, value, important) {
|
|
|
156
156
|
node.style.setProperty(key, value, important ? 'important' : '');
|
|
157
157
|
}
|
|
158
158
|
}
|
|
159
|
+
// unfortunately this can't be a constant as that wouldn't be tree-shakeable
|
|
160
|
+
// so we cache the result instead
|
|
161
|
+
let crossorigin;
|
|
162
|
+
function is_crossorigin() {
|
|
163
|
+
if (crossorigin === undefined) {
|
|
164
|
+
crossorigin = false;
|
|
165
|
+
try {
|
|
166
|
+
if (typeof window !== 'undefined' && window.parent) {
|
|
167
|
+
void window.parent.document;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
catch (error) {
|
|
171
|
+
crossorigin = true;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
return crossorigin;
|
|
175
|
+
}
|
|
176
|
+
function add_resize_listener(node, fn) {
|
|
177
|
+
const computed_style = getComputedStyle(node);
|
|
178
|
+
if (computed_style.position === 'static') {
|
|
179
|
+
node.style.position = 'relative';
|
|
180
|
+
}
|
|
181
|
+
const iframe = element('iframe');
|
|
182
|
+
iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +
|
|
183
|
+
'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');
|
|
184
|
+
iframe.setAttribute('aria-hidden', 'true');
|
|
185
|
+
iframe.tabIndex = -1;
|
|
186
|
+
const crossorigin = is_crossorigin();
|
|
187
|
+
let unsubscribe;
|
|
188
|
+
if (crossorigin) {
|
|
189
|
+
iframe.src = "data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}</script>";
|
|
190
|
+
unsubscribe = listen(window, 'message', (event) => {
|
|
191
|
+
if (event.source === iframe.contentWindow)
|
|
192
|
+
fn();
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
else {
|
|
196
|
+
iframe.src = 'about:blank';
|
|
197
|
+
iframe.onload = () => {
|
|
198
|
+
unsubscribe = listen(iframe.contentWindow, 'resize', fn);
|
|
199
|
+
};
|
|
200
|
+
}
|
|
201
|
+
append(node, iframe);
|
|
202
|
+
return () => {
|
|
203
|
+
if (crossorigin) {
|
|
204
|
+
unsubscribe();
|
|
205
|
+
}
|
|
206
|
+
else if (unsubscribe && iframe.contentWindow) {
|
|
207
|
+
unsubscribe();
|
|
208
|
+
}
|
|
209
|
+
detach(iframe);
|
|
210
|
+
};
|
|
211
|
+
}
|
|
159
212
|
function toggle_class(element, name, toggle) {
|
|
160
213
|
element.classList[toggle ? 'add' : 'remove'](name);
|
|
161
214
|
}
|
|
162
|
-
function custom_event(type, detail, bubbles = false) {
|
|
215
|
+
function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
|
|
163
216
|
const e = document.createEvent('CustomEvent');
|
|
164
|
-
e.initCustomEvent(type, bubbles,
|
|
217
|
+
e.initCustomEvent(type, bubbles, cancelable, detail);
|
|
165
218
|
return e;
|
|
166
219
|
}
|
|
167
220
|
|
|
@@ -174,25 +227,25 @@ function get_current_component() {
|
|
|
174
227
|
throw new Error('Function called outside component initialization');
|
|
175
228
|
return current_component;
|
|
176
229
|
}
|
|
177
|
-
function onMount(fn) {
|
|
178
|
-
get_current_component().$$.on_mount.push(fn);
|
|
179
|
-
}
|
|
180
230
|
function createEventDispatcher() {
|
|
181
231
|
const component = get_current_component();
|
|
182
|
-
return (type, detail) => {
|
|
232
|
+
return (type, detail, { cancelable = false } = {}) => {
|
|
183
233
|
const callbacks = component.$$.callbacks[type];
|
|
184
234
|
if (callbacks) {
|
|
185
235
|
// TODO are there situations where events could be dispatched
|
|
186
236
|
// in a server (non-DOM) environment?
|
|
187
|
-
const event = custom_event(type, detail);
|
|
237
|
+
const event = custom_event(type, detail, { cancelable });
|
|
188
238
|
callbacks.slice().forEach(fn => {
|
|
189
239
|
fn.call(component, event);
|
|
190
240
|
});
|
|
241
|
+
return !event.defaultPrevented;
|
|
191
242
|
}
|
|
243
|
+
return true;
|
|
192
244
|
};
|
|
193
245
|
}
|
|
194
246
|
function setContext(key, context) {
|
|
195
247
|
get_current_component().$$.context.set(key, context);
|
|
248
|
+
return context;
|
|
196
249
|
}
|
|
197
250
|
function getContext(key) {
|
|
198
251
|
return get_current_component().$$.context.get(key);
|
|
@@ -493,7 +546,7 @@ function writable(value, start = noop) {
|
|
|
493
546
|
return { set, update, subscribe };
|
|
494
547
|
}
|
|
495
548
|
|
|
496
|
-
/* src/Axes.svelte generated by Svelte v3.
|
|
549
|
+
/* src/Axes.svelte generated by Svelte v3.48.0 */
|
|
497
550
|
|
|
498
551
|
function add_css$3(target) {
|
|
499
552
|
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 +559,7 @@ const get_yaxis_slot_context = ctx => ({});
|
|
|
506
559
|
const get_xaxis_slot_changes = dirty => ({});
|
|
507
560
|
const get_xaxis_slot_context = ctx => ({});
|
|
508
561
|
|
|
509
|
-
// (
|
|
562
|
+
// (329:3) {#if title !== ""}
|
|
510
563
|
function create_if_block_3(ctx) {
|
|
511
564
|
let div;
|
|
512
565
|
|
|
@@ -527,7 +580,7 @@ function create_if_block_3(ctx) {
|
|
|
527
580
|
};
|
|
528
581
|
}
|
|
529
582
|
|
|
530
|
-
// (
|
|
583
|
+
// (330:3) {#if yLabel !== ""}
|
|
531
584
|
function create_if_block_2(ctx) {
|
|
532
585
|
let div;
|
|
533
586
|
let span;
|
|
@@ -551,7 +604,7 @@ function create_if_block_2(ctx) {
|
|
|
551
604
|
};
|
|
552
605
|
}
|
|
553
606
|
|
|
554
|
-
// (
|
|
607
|
+
// (331:3) {#if xLabel !== ""}
|
|
555
608
|
function create_if_block_1(ctx) {
|
|
556
609
|
let div;
|
|
557
610
|
let span;
|
|
@@ -575,7 +628,7 @@ function create_if_block_1(ctx) {
|
|
|
575
628
|
};
|
|
576
629
|
}
|
|
577
630
|
|
|
578
|
-
// (
|
|
631
|
+
// (359:3) {#if !$isOk}
|
|
579
632
|
function create_if_block$9(ctx) {
|
|
580
633
|
let p;
|
|
581
634
|
|
|
@@ -612,23 +665,25 @@ function create_fragment$b(ctx) {
|
|
|
612
665
|
let rect_width_value;
|
|
613
666
|
let rect_height_value;
|
|
614
667
|
let g;
|
|
668
|
+
let div0_resize_listener;
|
|
615
669
|
let t3;
|
|
616
670
|
let div1_class_value;
|
|
671
|
+
let div1_resize_listener;
|
|
617
672
|
let current;
|
|
618
673
|
let mounted;
|
|
619
674
|
let dispose;
|
|
620
675
|
let if_block0 = /*title*/ ctx[0] !== "" && create_if_block_3(ctx);
|
|
621
676
|
let if_block1 = /*yLabel*/ ctx[2] !== "" && create_if_block_2(ctx);
|
|
622
677
|
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[
|
|
631
|
-
let if_block3 = !/*$isOk*/ ctx[
|
|
678
|
+
const xaxis_slot_template = /*#slots*/ ctx[27].xaxis;
|
|
679
|
+
const xaxis_slot = create_slot(xaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_xaxis_slot_context);
|
|
680
|
+
const yaxis_slot_template = /*#slots*/ ctx[27].yaxis;
|
|
681
|
+
const yaxis_slot = create_slot(yaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_yaxis_slot_context);
|
|
682
|
+
const default_slot_template = /*#slots*/ ctx[27].default;
|
|
683
|
+
const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], null);
|
|
684
|
+
const box_slot_template = /*#slots*/ ctx[27].box;
|
|
685
|
+
const box_slot = create_slot(box_slot_template, ctx, /*$$scope*/ ctx[26], get_box_slot_context);
|
|
686
|
+
let if_block3 = !/*$isOk*/ ctx[6] && create_if_block$9();
|
|
632
687
|
|
|
633
688
|
return {
|
|
634
689
|
c() {
|
|
@@ -652,17 +707,19 @@ function create_fragment$b(ctx) {
|
|
|
652
707
|
t3 = space();
|
|
653
708
|
if (if_block3) if_block3.c();
|
|
654
709
|
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[
|
|
710
|
+
attr(rect, "x", rect_x_value = /*cpx*/ ctx[10][0]);
|
|
711
|
+
attr(rect, "y", rect_y_value = /*cpy*/ ctx[9][1]);
|
|
712
|
+
attr(rect, "width", rect_width_value = /*cpx*/ ctx[10][1] - /*cpx*/ ctx[10][0]);
|
|
713
|
+
attr(rect, "height", rect_height_value = /*cpy*/ ctx[9][0] - /*cpy*/ ctx[9][1]);
|
|
714
|
+
attr(clipPath, "id", /*clipPathID*/ ctx[11]);
|
|
715
|
+
attr(g, "clip-path", "url(#" + /*clipPathID*/ ctx[11] + ")");
|
|
661
716
|
attr(svg, "preserveAspectRatio", "none");
|
|
662
717
|
attr(svg, "class", "axes");
|
|
663
718
|
attr(div0, "class", "axes-wrapper svelte-n80kcc");
|
|
664
|
-
|
|
665
|
-
|
|
719
|
+
add_render_callback(() => /*div0_elementresize_handler*/ ctx[28].call(div0));
|
|
720
|
+
attr(div1, "class", div1_class_value = "plot " + ('plot_' + /*$scale*/ ctx[8]) + " svelte-n80kcc");
|
|
721
|
+
add_render_callback(() => /*div1_elementresize_handler*/ ctx[29].call(div1));
|
|
722
|
+
toggle_class(div1, "plot_error", !/*$isOk*/ ctx[6]);
|
|
666
723
|
},
|
|
667
724
|
m(target, anchor) {
|
|
668
725
|
insert(target, div1, anchor);
|
|
@@ -696,13 +753,14 @@ function create_fragment$b(ctx) {
|
|
|
696
753
|
box_slot.m(svg, null);
|
|
697
754
|
}
|
|
698
755
|
|
|
699
|
-
/*
|
|
756
|
+
div0_resize_listener = add_resize_listener(div0, /*div0_elementresize_handler*/ ctx[28].bind(div0));
|
|
700
757
|
append(div1, t3);
|
|
701
758
|
if (if_block3) if_block3.m(div1, null);
|
|
759
|
+
div1_resize_listener = add_resize_listener(div1, /*div1_elementresize_handler*/ ctx[29].bind(div1));
|
|
702
760
|
current = true;
|
|
703
761
|
|
|
704
762
|
if (!mounted) {
|
|
705
|
-
dispose = listen(svg, "click", /*handleClick*/ ctx[
|
|
763
|
+
dispose = listen(svg, "click", /*handleClick*/ ctx[18]);
|
|
706
764
|
mounted = true;
|
|
707
765
|
}
|
|
708
766
|
},
|
|
@@ -746,83 +804,83 @@ function create_fragment$b(ctx) {
|
|
|
746
804
|
if_block2 = null;
|
|
747
805
|
}
|
|
748
806
|
|
|
749
|
-
if (!current || dirty[0] & /*cpx*/
|
|
807
|
+
if (!current || dirty[0] & /*cpx*/ 1024 && rect_x_value !== (rect_x_value = /*cpx*/ ctx[10][0])) {
|
|
750
808
|
attr(rect, "x", rect_x_value);
|
|
751
809
|
}
|
|
752
810
|
|
|
753
|
-
if (!current || dirty[0] & /*cpy*/
|
|
811
|
+
if (!current || dirty[0] & /*cpy*/ 512 && rect_y_value !== (rect_y_value = /*cpy*/ ctx[9][1])) {
|
|
754
812
|
attr(rect, "y", rect_y_value);
|
|
755
813
|
}
|
|
756
814
|
|
|
757
|
-
if (!current || dirty[0] & /*cpx*/
|
|
815
|
+
if (!current || dirty[0] & /*cpx*/ 1024 && rect_width_value !== (rect_width_value = /*cpx*/ ctx[10][1] - /*cpx*/ ctx[10][0])) {
|
|
758
816
|
attr(rect, "width", rect_width_value);
|
|
759
817
|
}
|
|
760
818
|
|
|
761
|
-
if (!current || dirty[0] & /*cpy*/
|
|
819
|
+
if (!current || dirty[0] & /*cpy*/ 512 && rect_height_value !== (rect_height_value = /*cpy*/ ctx[9][0] - /*cpy*/ ctx[9][1])) {
|
|
762
820
|
attr(rect, "height", rect_height_value);
|
|
763
821
|
}
|
|
764
822
|
|
|
765
823
|
if (xaxis_slot) {
|
|
766
|
-
if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
824
|
+
if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
767
825
|
update_slot_base(
|
|
768
826
|
xaxis_slot,
|
|
769
827
|
xaxis_slot_template,
|
|
770
828
|
ctx,
|
|
771
|
-
/*$$scope*/ ctx[
|
|
829
|
+
/*$$scope*/ ctx[26],
|
|
772
830
|
!current
|
|
773
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
774
|
-
: get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[
|
|
831
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
832
|
+
: get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_xaxis_slot_changes),
|
|
775
833
|
get_xaxis_slot_context
|
|
776
834
|
);
|
|
777
835
|
}
|
|
778
836
|
}
|
|
779
837
|
|
|
780
838
|
if (yaxis_slot) {
|
|
781
|
-
if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
839
|
+
if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
782
840
|
update_slot_base(
|
|
783
841
|
yaxis_slot,
|
|
784
842
|
yaxis_slot_template,
|
|
785
843
|
ctx,
|
|
786
|
-
/*$$scope*/ ctx[
|
|
844
|
+
/*$$scope*/ ctx[26],
|
|
787
845
|
!current
|
|
788
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
789
|
-
: get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[
|
|
846
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
847
|
+
: get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_yaxis_slot_changes),
|
|
790
848
|
get_yaxis_slot_context
|
|
791
849
|
);
|
|
792
850
|
}
|
|
793
851
|
}
|
|
794
852
|
|
|
795
853
|
if (default_slot) {
|
|
796
|
-
if (default_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
854
|
+
if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
797
855
|
update_slot_base(
|
|
798
856
|
default_slot,
|
|
799
857
|
default_slot_template,
|
|
800
858
|
ctx,
|
|
801
|
-
/*$$scope*/ ctx[
|
|
859
|
+
/*$$scope*/ ctx[26],
|
|
802
860
|
!current
|
|
803
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
804
|
-
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[
|
|
861
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
862
|
+
: get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, null),
|
|
805
863
|
null
|
|
806
864
|
);
|
|
807
865
|
}
|
|
808
866
|
}
|
|
809
867
|
|
|
810
868
|
if (box_slot) {
|
|
811
|
-
if (box_slot.p && (!current || dirty[0] & /*$$scope*/
|
|
869
|
+
if (box_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
|
|
812
870
|
update_slot_base(
|
|
813
871
|
box_slot,
|
|
814
872
|
box_slot_template,
|
|
815
873
|
ctx,
|
|
816
|
-
/*$$scope*/ ctx[
|
|
874
|
+
/*$$scope*/ ctx[26],
|
|
817
875
|
!current
|
|
818
|
-
? get_all_dirty_from_scope(/*$$scope*/ ctx[
|
|
819
|
-
: get_slot_changes(box_slot_template, /*$$scope*/ ctx[
|
|
876
|
+
? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
|
|
877
|
+
: get_slot_changes(box_slot_template, /*$$scope*/ ctx[26], dirty, get_box_slot_changes),
|
|
820
878
|
get_box_slot_context
|
|
821
879
|
);
|
|
822
880
|
}
|
|
823
881
|
}
|
|
824
882
|
|
|
825
|
-
if (!/*$isOk*/ ctx[
|
|
883
|
+
if (!/*$isOk*/ ctx[6]) {
|
|
826
884
|
if (if_block3) ; else {
|
|
827
885
|
if_block3 = create_if_block$9();
|
|
828
886
|
if_block3.c();
|
|
@@ -833,12 +891,12 @@ function create_fragment$b(ctx) {
|
|
|
833
891
|
if_block3 = null;
|
|
834
892
|
}
|
|
835
893
|
|
|
836
|
-
if (!current || dirty[0] & /*$scale*/
|
|
894
|
+
if (!current || dirty[0] & /*$scale*/ 256 && div1_class_value !== (div1_class_value = "plot " + ('plot_' + /*$scale*/ ctx[8]) + " svelte-n80kcc")) {
|
|
837
895
|
attr(div1, "class", div1_class_value);
|
|
838
896
|
}
|
|
839
897
|
|
|
840
|
-
if (dirty[0] & /*$scale, $isOk*/
|
|
841
|
-
toggle_class(div1, "plot_error", !/*$isOk*/ ctx[
|
|
898
|
+
if (dirty[0] & /*$scale, $isOk*/ 320) {
|
|
899
|
+
toggle_class(div1, "plot_error", !/*$isOk*/ ctx[6]);
|
|
842
900
|
}
|
|
843
901
|
},
|
|
844
902
|
i(local) {
|
|
@@ -865,8 +923,9 @@ function create_fragment$b(ctx) {
|
|
|
865
923
|
if (yaxis_slot) yaxis_slot.d(detaching);
|
|
866
924
|
if (default_slot) default_slot.d(detaching);
|
|
867
925
|
if (box_slot) box_slot.d(detaching);
|
|
868
|
-
|
|
926
|
+
div0_resize_listener();
|
|
869
927
|
if (if_block3) if_block3.d();
|
|
928
|
+
div1_resize_listener();
|
|
870
929
|
mounted = false;
|
|
871
930
|
dispose();
|
|
872
931
|
}
|
|
@@ -939,39 +998,40 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
939
998
|
const clipPathID = "plottingArea" + Math.round(Math.random() * 10000);
|
|
940
999
|
|
|
941
1000
|
/* parameters for internal use inside the component */
|
|
942
|
-
let
|
|
1001
|
+
let plotWidth; // width of plot
|
|
943
1002
|
|
|
1003
|
+
let plotHeight; // height of plot
|
|
944
1004
|
let axesMargins = [0.034, 0.034, 0.034, 0.034]; // initial margins (will be multiplied to FACTORS)
|
|
945
1005
|
|
|
946
1006
|
/* reactive parameters to be shared with children via context */
|
|
947
1007
|
const width = writable(100); // actual width of plotting area in pixels
|
|
948
1008
|
|
|
949
|
-
component_subscribe($$self, width, value => $$invalidate(
|
|
1009
|
+
component_subscribe($$self, width, value => $$invalidate(7, $width = value));
|
|
950
1010
|
const height = writable(100); // actual height of plotting area in pixels
|
|
951
|
-
component_subscribe($$self, height, value => $$invalidate(
|
|
1011
|
+
component_subscribe($$self, height, value => $$invalidate(5, $height = value));
|
|
952
1012
|
const xLim = writable([undefined, undefined]); // actual limits for x-axis in plot units
|
|
953
|
-
component_subscribe($$self, xLim, value => $$invalidate(
|
|
1013
|
+
component_subscribe($$self, xLim, value => $$invalidate(25, $xLim = value));
|
|
954
1014
|
const yLim = writable([undefined, undefined]); // actual limits for y-axis in plot units
|
|
955
|
-
component_subscribe($$self, yLim, value => $$invalidate(
|
|
1015
|
+
component_subscribe($$self, yLim, value => $$invalidate(24, $yLim = value));
|
|
956
1016
|
const scale = writable("medium"); // scale factor (how big the shown plot is)
|
|
957
|
-
component_subscribe($$self, scale, value => $$invalidate(
|
|
1017
|
+
component_subscribe($$self, scale, value => $$invalidate(8, $scale = value));
|
|
958
1018
|
const isOk = writable(false); // are axes ready for drawing
|
|
959
|
-
component_subscribe($$self, isOk, value => $$invalidate(
|
|
1019
|
+
component_subscribe($$self, isOk, value => $$invalidate(6, $isOk = value));
|
|
960
1020
|
|
|
961
1021
|
/** Adds margins for x-axis (e.g. when x-axis must be shown) */
|
|
962
1022
|
const addXAxisMargins = function () {
|
|
963
|
-
$$invalidate(
|
|
964
|
-
$$invalidate(
|
|
965
|
-
$$invalidate(
|
|
966
|
-
$$invalidate(
|
|
1023
|
+
$$invalidate(22, axesMargins[0] = 1, axesMargins);
|
|
1024
|
+
$$invalidate(22, axesMargins[2] = 0.5, axesMargins);
|
|
1025
|
+
$$invalidate(22, axesMargins[1] = axesMargins[1] > 0.5 ? axesMargins[1] : 0.5, axesMargins);
|
|
1026
|
+
$$invalidate(22, axesMargins[3] = axesMargins[3] > 0.5 ? axesMargins[3] : 0.5, axesMargins);
|
|
967
1027
|
};
|
|
968
1028
|
|
|
969
1029
|
/** Adds margins for y-axis (e.g. when y-axis must be shown) */
|
|
970
1030
|
const addYAxisMargins = function () {
|
|
971
|
-
$$invalidate(
|
|
972
|
-
$$invalidate(
|
|
973
|
-
$$invalidate(
|
|
974
|
-
$$invalidate(
|
|
1031
|
+
$$invalidate(22, axesMargins[1] = 1, axesMargins);
|
|
1032
|
+
$$invalidate(22, axesMargins[3] = 0.5, axesMargins);
|
|
1033
|
+
$$invalidate(22, axesMargins[0] = axesMargins[0] > 0.5 ? axesMargins[0] : 0.5, axesMargins);
|
|
1034
|
+
$$invalidate(22, axesMargins[2] = axesMargins[2] > 0.5 ? axesMargins[2] : 0.5, axesMargins);
|
|
975
1035
|
};
|
|
976
1036
|
|
|
977
1037
|
/** Adjusts limits for x-axis (e.g. when new series is added)
|
|
@@ -1120,20 +1180,6 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
1120
1180
|
|
|
1121
1181
|
setContext('axes', context);
|
|
1122
1182
|
|
|
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
1183
|
// handle click on plot elements and dispatch manual events
|
|
1138
1184
|
function dispatchClickEvent(eventName, el) {
|
|
1139
1185
|
dispatch(eventName, {
|
|
@@ -1159,51 +1205,63 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
1159
1205
|
dispatch("axesclick");
|
|
1160
1206
|
}
|
|
1161
1207
|
|
|
1162
|
-
function
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1208
|
+
function div0_elementresize_handler() {
|
|
1209
|
+
$height = this.clientHeight;
|
|
1210
|
+
height.set($height);
|
|
1211
|
+
$width = this.clientWidth;
|
|
1212
|
+
width.set($width);
|
|
1213
|
+
}
|
|
1214
|
+
|
|
1215
|
+
function div1_elementresize_handler() {
|
|
1216
|
+
plotHeight = this.clientHeight;
|
|
1217
|
+
plotWidth = this.clientWidth;
|
|
1218
|
+
$$invalidate(4, plotHeight);
|
|
1219
|
+
$$invalidate(3, plotWidth);
|
|
1167
1220
|
}
|
|
1168
1221
|
|
|
1169
1222
|
$$self.$$set = $$props => {
|
|
1170
|
-
if ('limX' in $$props) $$invalidate(
|
|
1171
|
-
if ('limY' in $$props) $$invalidate(
|
|
1223
|
+
if ('limX' in $$props) $$invalidate(19, limX = $$props.limX);
|
|
1224
|
+
if ('limY' in $$props) $$invalidate(20, limY = $$props.limY);
|
|
1172
1225
|
if ('title' in $$props) $$invalidate(0, title = $$props.title);
|
|
1173
1226
|
if ('xLabel' in $$props) $$invalidate(1, xLabel = $$props.xLabel);
|
|
1174
1227
|
if ('yLabel' in $$props) $$invalidate(2, yLabel = $$props.yLabel);
|
|
1175
|
-
if ('multiSeries' in $$props) $$invalidate(
|
|
1176
|
-
if ('$$scope' in $$props) $$invalidate(
|
|
1228
|
+
if ('multiSeries' in $$props) $$invalidate(21, multiSeries = $$props.multiSeries);
|
|
1229
|
+
if ('$$scope' in $$props) $$invalidate(26, $$scope = $$props.$$scope);
|
|
1177
1230
|
};
|
|
1178
1231
|
|
|
1179
1232
|
$$self.$$.update = () => {
|
|
1180
|
-
if ($$self.$$.dirty[0] & /*
|
|
1233
|
+
if ($$self.$$.dirty[0] & /*plotWidth, plotHeight*/ 24) {
|
|
1234
|
+
// update plot scale based on its size
|
|
1235
|
+
scale.update(x => getScale(plotWidth, plotHeight));
|
|
1236
|
+
}
|
|
1237
|
+
|
|
1238
|
+
if ($$self.$$.dirty[0] & /*limX*/ 524288) {
|
|
1181
1239
|
// this is reactive in case if limX and limY are interactively changed by parent script
|
|
1182
1240
|
if (!limX.some(v => v === undefined)) xLim.update(v => limX);
|
|
1183
1241
|
}
|
|
1184
1242
|
|
|
1185
|
-
if ($$self.$$.dirty[0] & /*limY*/
|
|
1243
|
+
if ($$self.$$.dirty[0] & /*limY*/ 1048576) {
|
|
1186
1244
|
if (!limY.some(v => v === undefined)) yLim.update(v => limY);
|
|
1187
1245
|
}
|
|
1188
1246
|
|
|
1189
|
-
if ($$self.$$.dirty[0] & /*axesMargins, $scale*/
|
|
1247
|
+
if ($$self.$$.dirty[0] & /*axesMargins, $scale*/ 4194560) {
|
|
1190
1248
|
// computes real margins in pixels based on current scale
|
|
1191
|
-
$$invalidate(
|
|
1249
|
+
$$invalidate(23, margins = axesMargins.map(v => v * AXES_MARGIN_FACTORS[$scale]));
|
|
1192
1250
|
}
|
|
1193
1251
|
|
|
1194
|
-
if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/
|
|
1252
|
+
if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/ 58720416) {
|
|
1195
1253
|
// computes status which tells that axes limits look fine and it is safe to draw
|
|
1196
1254
|
// the status is based on the axis limits validity
|
|
1197
1255
|
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
1256
|
}
|
|
1199
1257
|
|
|
1200
|
-
if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/
|
|
1258
|
+
if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/ 33554624) {
|
|
1201
1259
|
// computes coordinates for clip path box
|
|
1202
|
-
$$invalidate(
|
|
1260
|
+
$$invalidate(10, cpx = $isOk ? scaleX($xLim, $xLim, $width) : [0, 1]);
|
|
1203
1261
|
}
|
|
1204
1262
|
|
|
1205
|
-
if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/
|
|
1206
|
-
$$invalidate(
|
|
1263
|
+
if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/ 16777312) {
|
|
1264
|
+
$$invalidate(9, cpy = $isOk ? scaleY($yLim, $yLim, $height) : [1, 0]);
|
|
1207
1265
|
}
|
|
1208
1266
|
};
|
|
1209
1267
|
|
|
@@ -1211,9 +1269,12 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
1211
1269
|
title,
|
|
1212
1270
|
xLabel,
|
|
1213
1271
|
yLabel,
|
|
1272
|
+
plotWidth,
|
|
1273
|
+
plotHeight,
|
|
1274
|
+
$height,
|
|
1214
1275
|
$isOk,
|
|
1276
|
+
$width,
|
|
1215
1277
|
$scale,
|
|
1216
|
-
axesWrapper,
|
|
1217
1278
|
cpy,
|
|
1218
1279
|
cpx,
|
|
1219
1280
|
clipPathID,
|
|
@@ -1229,13 +1290,12 @@ function instance$b($$self, $$props, $$invalidate) {
|
|
|
1229
1290
|
multiSeries,
|
|
1230
1291
|
axesMargins,
|
|
1231
1292
|
margins,
|
|
1232
|
-
$height,
|
|
1233
1293
|
$yLim,
|
|
1234
|
-
$width,
|
|
1235
1294
|
$xLim,
|
|
1236
1295
|
$$scope,
|
|
1237
1296
|
slots,
|
|
1238
|
-
|
|
1297
|
+
div0_elementresize_handler,
|
|
1298
|
+
div1_elementresize_handler
|
|
1239
1299
|
];
|
|
1240
1300
|
}
|
|
1241
1301
|
|
|
@@ -1250,12 +1310,12 @@ class Axes extends SvelteComponent {
|
|
|
1250
1310
|
create_fragment$b,
|
|
1251
1311
|
safe_not_equal,
|
|
1252
1312
|
{
|
|
1253
|
-
limX:
|
|
1254
|
-
limY:
|
|
1313
|
+
limX: 19,
|
|
1314
|
+
limY: 20,
|
|
1255
1315
|
title: 0,
|
|
1256
1316
|
xLabel: 1,
|
|
1257
1317
|
yLabel: 2,
|
|
1258
|
-
multiSeries:
|
|
1318
|
+
multiSeries: 21
|
|
1259
1319
|
},
|
|
1260
1320
|
add_css$3,
|
|
1261
1321
|
[-1, -1]
|
|
@@ -1277,7 +1337,7 @@ const Colors = {
|
|
|
1277
1337
|
"PRIMARY_TEXT": "#333",
|
|
1278
1338
|
};
|
|
1279
1339
|
|
|
1280
|
-
/* src/XAxis.svelte generated by Svelte v3.
|
|
1340
|
+
/* src/XAxis.svelte generated by Svelte v3.48.0 */
|
|
1281
1341
|
|
|
1282
1342
|
function get_each_context$5(ctx, list, i) {
|
|
1283
1343
|
const child_ctx = ctx.slice();
|
|
@@ -1657,7 +1717,7 @@ class XAxis extends SvelteComponent {
|
|
|
1657
1717
|
}
|
|
1658
1718
|
}
|
|
1659
1719
|
|
|
1660
|
-
/* src/YAxis.svelte generated by Svelte v3.
|
|
1720
|
+
/* src/YAxis.svelte generated by Svelte v3.48.0 */
|
|
1661
1721
|
|
|
1662
1722
|
function get_each_context$4(ctx, list, i) {
|
|
1663
1723
|
const child_ctx = ctx.slice();
|
|
@@ -2043,7 +2103,7 @@ class YAxis extends SvelteComponent {
|
|
|
2043
2103
|
}
|
|
2044
2104
|
}
|
|
2045
2105
|
|
|
2046
|
-
/* src/Rectangles.svelte generated by Svelte v3.
|
|
2106
|
+
/* src/Rectangles.svelte generated by Svelte v3.48.0 */
|
|
2047
2107
|
|
|
2048
2108
|
function get_each_context$3(ctx, list, i) {
|
|
2049
2109
|
const child_ctx = ctx.slice();
|
|
@@ -2339,7 +2399,7 @@ class Rectangles extends SvelteComponent {
|
|
|
2339
2399
|
}
|
|
2340
2400
|
}
|
|
2341
2401
|
|
|
2342
|
-
/* src/Box.svelte generated by Svelte v3.
|
|
2402
|
+
/* src/Box.svelte generated by Svelte v3.48.0 */
|
|
2343
2403
|
|
|
2344
2404
|
function create_if_block$5(ctx) {
|
|
2345
2405
|
let g;
|
|
@@ -2506,7 +2566,7 @@ class Box extends SvelteComponent {
|
|
|
2506
2566
|
}
|
|
2507
2567
|
}
|
|
2508
2568
|
|
|
2509
|
-
/* src/Segments.svelte generated by Svelte v3.
|
|
2569
|
+
/* src/Segments.svelte generated by Svelte v3.48.0 */
|
|
2510
2570
|
|
|
2511
2571
|
function get_each_context$2(ctx, list, i) {
|
|
2512
2572
|
const child_ctx = ctx.slice();
|
|
@@ -2773,7 +2833,7 @@ class Segments extends SvelteComponent {
|
|
|
2773
2833
|
}
|
|
2774
2834
|
}
|
|
2775
2835
|
|
|
2776
|
-
/* src/TextLabels.svelte generated by Svelte v3.
|
|
2836
|
+
/* src/TextLabels.svelte generated by Svelte v3.48.0 */
|
|
2777
2837
|
|
|
2778
2838
|
function add_css$2(target) {
|
|
2779
2839
|
append_styles(target, "svelte-1xvrp9d", "text.svelte-1xvrp9d,text.svelte-1xvrp9d>tspan{dominant-baseline:middle}");
|
|
@@ -3096,7 +3156,7 @@ class TextLabels extends SvelteComponent {
|
|
|
3096
3156
|
}
|
|
3097
3157
|
}
|
|
3098
3158
|
|
|
3099
|
-
/* src/TextLegend.svelte generated by Svelte v3.
|
|
3159
|
+
/* src/TextLegend.svelte generated by Svelte v3.48.0 */
|
|
3100
3160
|
|
|
3101
3161
|
function get_each_context(ctx, list, i) {
|
|
3102
3162
|
const child_ctx = ctx.slice();
|
|
@@ -3364,7 +3424,7 @@ class TextLegend extends SvelteComponent {
|
|
|
3364
3424
|
}
|
|
3365
3425
|
|
|
3366
3426
|
/**********************************************
|
|
3367
|
-
* Functions for statistical tests
|
|
3427
|
+
* Functions for statistical tests and models *
|
|
3368
3428
|
**********************************************/
|
|
3369
3429
|
|
|
3370
3430
|
|
|
@@ -3420,7 +3480,7 @@ function diff(x) {
|
|
|
3420
3480
|
return x.slice(1).map( (y, i) => (y - x[i]));
|
|
3421
3481
|
}
|
|
3422
3482
|
|
|
3423
|
-
/* src/BarSeries.svelte generated by Svelte v3.
|
|
3483
|
+
/* src/BarSeries.svelte generated by Svelte v3.48.0 */
|
|
3424
3484
|
|
|
3425
3485
|
function add_css$1(target) {
|
|
3426
3486
|
append_styles(target, "svelte-kw726w", ".series_bar > rect{stroke-width:1px}.series_bar > rect:hover{opacity:90%}");
|
|
@@ -3588,7 +3648,7 @@ class BarSeries extends SvelteComponent {
|
|
|
3588
3648
|
}
|
|
3589
3649
|
}
|
|
3590
3650
|
|
|
3591
|
-
/* src/ScatterSeries.svelte generated by Svelte v3.
|
|
3651
|
+
/* src/ScatterSeries.svelte generated by Svelte v3.48.0 */
|
|
3592
3652
|
|
|
3593
3653
|
function add_css(target) {
|
|
3594
3654
|
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 +3815,7 @@ class ScatterSeries extends SvelteComponent {
|
|
|
3755
3815
|
}
|
|
3756
3816
|
}
|
|
3757
3817
|
|
|
3758
|
-
/* src/LineSeries.svelte generated by Svelte v3.
|
|
3818
|
+
/* src/LineSeries.svelte generated by Svelte v3.48.0 */
|
|
3759
3819
|
|
|
3760
3820
|
function create_if_block$1(ctx) {
|
|
3761
3821
|
let g;
|
|
@@ -3946,7 +4006,7 @@ class LineSeries extends SvelteComponent {
|
|
|
3946
4006
|
}
|
|
3947
4007
|
}
|
|
3948
4008
|
|
|
3949
|
-
/* src/AreaSeries.svelte generated by Svelte v3.
|
|
4009
|
+
/* src/AreaSeries.svelte generated by Svelte v3.48.0 */
|
|
3950
4010
|
|
|
3951
4011
|
function create_if_block(ctx) {
|
|
3952
4012
|
let g;
|