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/dist/index.js CHANGED
@@ -162,12 +162,65 @@
162
162
  node.style.setProperty(key, value, important ? 'important' : '');
163
163
  }
164
164
  }
165
+ // unfortunately this can't be a constant as that wouldn't be tree-shakeable
166
+ // so we cache the result instead
167
+ let crossorigin;
168
+ function is_crossorigin() {
169
+ if (crossorigin === undefined) {
170
+ crossorigin = false;
171
+ try {
172
+ if (typeof window !== 'undefined' && window.parent) {
173
+ void window.parent.document;
174
+ }
175
+ }
176
+ catch (error) {
177
+ crossorigin = true;
178
+ }
179
+ }
180
+ return crossorigin;
181
+ }
182
+ function add_resize_listener(node, fn) {
183
+ const computed_style = getComputedStyle(node);
184
+ if (computed_style.position === 'static') {
185
+ node.style.position = 'relative';
186
+ }
187
+ const iframe = element('iframe');
188
+ iframe.setAttribute('style', 'display: block; position: absolute; top: 0; left: 0; width: 100%; height: 100%; ' +
189
+ 'overflow: hidden; border: 0; opacity: 0; pointer-events: none; z-index: -1;');
190
+ iframe.setAttribute('aria-hidden', 'true');
191
+ iframe.tabIndex = -1;
192
+ const crossorigin = is_crossorigin();
193
+ let unsubscribe;
194
+ if (crossorigin) {
195
+ iframe.src = "data:text/html,<script>onresize=function(){parent.postMessage(0,'*')}</script>";
196
+ unsubscribe = listen(window, 'message', (event) => {
197
+ if (event.source === iframe.contentWindow)
198
+ fn();
199
+ });
200
+ }
201
+ else {
202
+ iframe.src = 'about:blank';
203
+ iframe.onload = () => {
204
+ unsubscribe = listen(iframe.contentWindow, 'resize', fn);
205
+ };
206
+ }
207
+ append(node, iframe);
208
+ return () => {
209
+ if (crossorigin) {
210
+ unsubscribe();
211
+ }
212
+ else if (unsubscribe && iframe.contentWindow) {
213
+ unsubscribe();
214
+ }
215
+ detach(iframe);
216
+ };
217
+ }
165
218
  function toggle_class(element, name, toggle) {
166
219
  element.classList[toggle ? 'add' : 'remove'](name);
167
220
  }
168
- function custom_event(type, detail, bubbles = false) {
221
+ function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
169
222
  const e = document.createEvent('CustomEvent');
170
- e.initCustomEvent(type, bubbles, false, detail);
223
+ e.initCustomEvent(type, bubbles, cancelable, detail);
171
224
  return e;
172
225
  }
173
226
 
@@ -180,25 +233,25 @@
180
233
  throw new Error('Function called outside component initialization');
181
234
  return current_component;
182
235
  }
183
- function onMount(fn) {
184
- get_current_component().$$.on_mount.push(fn);
185
- }
186
236
  function createEventDispatcher() {
187
237
  const component = get_current_component();
188
- return (type, detail) => {
238
+ return (type, detail, { cancelable = false } = {}) => {
189
239
  const callbacks = component.$$.callbacks[type];
190
240
  if (callbacks) {
191
241
  // TODO are there situations where events could be dispatched
192
242
  // in a server (non-DOM) environment?
193
- const event = custom_event(type, detail);
243
+ const event = custom_event(type, detail, { cancelable });
194
244
  callbacks.slice().forEach(fn => {
195
245
  fn.call(component, event);
196
246
  });
247
+ return !event.defaultPrevented;
197
248
  }
249
+ return true;
198
250
  };
199
251
  }
200
252
  function setContext(key, context) {
201
253
  get_current_component().$$.context.set(key, context);
254
+ return context;
202
255
  }
203
256
  function getContext(key) {
204
257
  return get_current_component().$$.context.get(key);
@@ -499,7 +552,7 @@
499
552
  return { set, update, subscribe };
500
553
  }
501
554
 
502
- /* src/Axes.svelte generated by Svelte v3.46.3 */
555
+ /* src/Axes.svelte generated by Svelte v3.48.0 */
503
556
 
504
557
  function add_css$3(target) {
505
558
  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 +565,7 @@
512
565
  const get_xaxis_slot_changes = dirty => ({});
513
566
  const get_xaxis_slot_context = ctx => ({});
514
567
 
515
- // (338:3) {#if title !== ""}
568
+ // (329:3) {#if title !== ""}
516
569
  function create_if_block_3(ctx) {
517
570
  let div;
518
571
 
@@ -533,7 +586,7 @@
533
586
  };
534
587
  }
535
588
 
536
- // (339:3) {#if yLabel !== ""}
589
+ // (330:3) {#if yLabel !== ""}
537
590
  function create_if_block_2(ctx) {
538
591
  let div;
539
592
  let span;
@@ -557,7 +610,7 @@
557
610
  };
558
611
  }
559
612
 
560
- // (340:3) {#if xLabel !== ""}
613
+ // (331:3) {#if xLabel !== ""}
561
614
  function create_if_block_1(ctx) {
562
615
  let div;
563
616
  let span;
@@ -581,7 +634,7 @@
581
634
  };
582
635
  }
583
636
 
584
- // (368:3) {#if !$isOk}
637
+ // (359:3) {#if !$isOk}
585
638
  function create_if_block$9(ctx) {
586
639
  let p;
587
640
 
@@ -618,23 +671,25 @@
618
671
  let rect_width_value;
619
672
  let rect_height_value;
620
673
  let g;
674
+ let div0_resize_listener;
621
675
  let t3;
622
676
  let div1_class_value;
677
+ let div1_resize_listener;
623
678
  let current;
624
679
  let mounted;
625
680
  let dispose;
626
681
  let if_block0 = /*title*/ ctx[0] !== "" && create_if_block_3(ctx);
627
682
  let if_block1 = /*yLabel*/ ctx[2] !== "" && create_if_block_2(ctx);
628
683
  let if_block2 = /*xLabel*/ ctx[1] !== "" && create_if_block_1(ctx);
629
- const xaxis_slot_template = /*#slots*/ ctx[26].xaxis;
630
- const xaxis_slot = create_slot(xaxis_slot_template, ctx, /*$$scope*/ ctx[25], get_xaxis_slot_context);
631
- const yaxis_slot_template = /*#slots*/ ctx[26].yaxis;
632
- const yaxis_slot = create_slot(yaxis_slot_template, ctx, /*$$scope*/ ctx[25], get_yaxis_slot_context);
633
- const default_slot_template = /*#slots*/ ctx[26].default;
634
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[25], null);
635
- const box_slot_template = /*#slots*/ ctx[26].box;
636
- const box_slot = create_slot(box_slot_template, ctx, /*$$scope*/ ctx[25], get_box_slot_context);
637
- let if_block3 = !/*$isOk*/ ctx[3] && create_if_block$9();
684
+ const xaxis_slot_template = /*#slots*/ ctx[27].xaxis;
685
+ const xaxis_slot = create_slot(xaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_xaxis_slot_context);
686
+ const yaxis_slot_template = /*#slots*/ ctx[27].yaxis;
687
+ const yaxis_slot = create_slot(yaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_yaxis_slot_context);
688
+ const default_slot_template = /*#slots*/ ctx[27].default;
689
+ const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], null);
690
+ const box_slot_template = /*#slots*/ ctx[27].box;
691
+ const box_slot = create_slot(box_slot_template, ctx, /*$$scope*/ ctx[26], get_box_slot_context);
692
+ let if_block3 = !/*$isOk*/ ctx[6] && create_if_block$9();
638
693
 
639
694
  return {
640
695
  c() {
@@ -658,17 +713,19 @@
658
713
  t3 = space();
659
714
  if (if_block3) if_block3.c();
660
715
  set_style(rect, "pointer-events", "none");
661
- attr(rect, "x", rect_x_value = /*cpx*/ ctx[7][0]);
662
- attr(rect, "y", rect_y_value = /*cpy*/ ctx[6][1]);
663
- attr(rect, "width", rect_width_value = /*cpx*/ ctx[7][1] - /*cpx*/ ctx[7][0]);
664
- attr(rect, "height", rect_height_value = /*cpy*/ ctx[6][0] - /*cpy*/ ctx[6][1]);
665
- attr(clipPath, "id", /*clipPathID*/ ctx[8]);
666
- attr(g, "clip-path", "url(#" + /*clipPathID*/ ctx[8] + ")");
716
+ attr(rect, "x", rect_x_value = /*cpx*/ ctx[10][0]);
717
+ attr(rect, "y", rect_y_value = /*cpy*/ ctx[9][1]);
718
+ attr(rect, "width", rect_width_value = /*cpx*/ ctx[10][1] - /*cpx*/ ctx[10][0]);
719
+ attr(rect, "height", rect_height_value = /*cpy*/ ctx[9][0] - /*cpy*/ ctx[9][1]);
720
+ attr(clipPath, "id", /*clipPathID*/ ctx[11]);
721
+ attr(g, "clip-path", "url(#" + /*clipPathID*/ ctx[11] + ")");
667
722
  attr(svg, "preserveAspectRatio", "none");
668
723
  attr(svg, "class", "axes");
669
724
  attr(div0, "class", "axes-wrapper svelte-n80kcc");
670
- attr(div1, "class", div1_class_value = "plot " + ('plot_' + /*$scale*/ ctx[4]) + " svelte-n80kcc");
671
- toggle_class(div1, "plot_error", !/*$isOk*/ ctx[3]);
725
+ add_render_callback(() => /*div0_elementresize_handler*/ ctx[28].call(div0));
726
+ attr(div1, "class", div1_class_value = "plot " + ('plot_' + /*$scale*/ ctx[8]) + " svelte-n80kcc");
727
+ add_render_callback(() => /*div1_elementresize_handler*/ ctx[29].call(div1));
728
+ toggle_class(div1, "plot_error", !/*$isOk*/ ctx[6]);
672
729
  },
673
730
  m(target, anchor) {
674
731
  insert(target, div1, anchor);
@@ -702,13 +759,14 @@
702
759
  box_slot.m(svg, null);
703
760
  }
704
761
 
705
- /*div0_binding*/ ctx[27](div0);
762
+ div0_resize_listener = add_resize_listener(div0, /*div0_elementresize_handler*/ ctx[28].bind(div0));
706
763
  append(div1, t3);
707
764
  if (if_block3) if_block3.m(div1, null);
765
+ div1_resize_listener = add_resize_listener(div1, /*div1_elementresize_handler*/ ctx[29].bind(div1));
708
766
  current = true;
709
767
 
710
768
  if (!mounted) {
711
- dispose = listen(svg, "click", /*handleClick*/ ctx[15]);
769
+ dispose = listen(svg, "click", /*handleClick*/ ctx[18]);
712
770
  mounted = true;
713
771
  }
714
772
  },
@@ -752,83 +810,83 @@
752
810
  if_block2 = null;
753
811
  }
754
812
 
755
- if (!current || dirty[0] & /*cpx*/ 128 && rect_x_value !== (rect_x_value = /*cpx*/ ctx[7][0])) {
813
+ if (!current || dirty[0] & /*cpx*/ 1024 && rect_x_value !== (rect_x_value = /*cpx*/ ctx[10][0])) {
756
814
  attr(rect, "x", rect_x_value);
757
815
  }
758
816
 
759
- if (!current || dirty[0] & /*cpy*/ 64 && rect_y_value !== (rect_y_value = /*cpy*/ ctx[6][1])) {
817
+ if (!current || dirty[0] & /*cpy*/ 512 && rect_y_value !== (rect_y_value = /*cpy*/ ctx[9][1])) {
760
818
  attr(rect, "y", rect_y_value);
761
819
  }
762
820
 
763
- if (!current || dirty[0] & /*cpx*/ 128 && rect_width_value !== (rect_width_value = /*cpx*/ ctx[7][1] - /*cpx*/ ctx[7][0])) {
821
+ if (!current || dirty[0] & /*cpx*/ 1024 && rect_width_value !== (rect_width_value = /*cpx*/ ctx[10][1] - /*cpx*/ ctx[10][0])) {
764
822
  attr(rect, "width", rect_width_value);
765
823
  }
766
824
 
767
- if (!current || dirty[0] & /*cpy*/ 64 && rect_height_value !== (rect_height_value = /*cpy*/ ctx[6][0] - /*cpy*/ ctx[6][1])) {
825
+ if (!current || dirty[0] & /*cpy*/ 512 && rect_height_value !== (rect_height_value = /*cpy*/ ctx[9][0] - /*cpy*/ ctx[9][1])) {
768
826
  attr(rect, "height", rect_height_value);
769
827
  }
770
828
 
771
829
  if (xaxis_slot) {
772
- if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 33554432)) {
830
+ if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
773
831
  update_slot_base(
774
832
  xaxis_slot,
775
833
  xaxis_slot_template,
776
834
  ctx,
777
- /*$$scope*/ ctx[25],
835
+ /*$$scope*/ ctx[26],
778
836
  !current
779
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
780
- : get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[25], dirty, get_xaxis_slot_changes),
837
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
838
+ : get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_xaxis_slot_changes),
781
839
  get_xaxis_slot_context
782
840
  );
783
841
  }
784
842
  }
785
843
 
786
844
  if (yaxis_slot) {
787
- if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 33554432)) {
845
+ if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
788
846
  update_slot_base(
789
847
  yaxis_slot,
790
848
  yaxis_slot_template,
791
849
  ctx,
792
- /*$$scope*/ ctx[25],
850
+ /*$$scope*/ ctx[26],
793
851
  !current
794
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
795
- : get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[25], dirty, get_yaxis_slot_changes),
852
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
853
+ : get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_yaxis_slot_changes),
796
854
  get_yaxis_slot_context
797
855
  );
798
856
  }
799
857
  }
800
858
 
801
859
  if (default_slot) {
802
- if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 33554432)) {
860
+ if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
803
861
  update_slot_base(
804
862
  default_slot,
805
863
  default_slot_template,
806
864
  ctx,
807
- /*$$scope*/ ctx[25],
865
+ /*$$scope*/ ctx[26],
808
866
  !current
809
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
810
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[25], dirty, null),
867
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
868
+ : get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, null),
811
869
  null
812
870
  );
813
871
  }
814
872
  }
815
873
 
816
874
  if (box_slot) {
817
- if (box_slot.p && (!current || dirty[0] & /*$$scope*/ 33554432)) {
875
+ if (box_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
818
876
  update_slot_base(
819
877
  box_slot,
820
878
  box_slot_template,
821
879
  ctx,
822
- /*$$scope*/ ctx[25],
880
+ /*$$scope*/ ctx[26],
823
881
  !current
824
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[25])
825
- : get_slot_changes(box_slot_template, /*$$scope*/ ctx[25], dirty, get_box_slot_changes),
882
+ ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
883
+ : get_slot_changes(box_slot_template, /*$$scope*/ ctx[26], dirty, get_box_slot_changes),
826
884
  get_box_slot_context
827
885
  );
828
886
  }
829
887
  }
830
888
 
831
- if (!/*$isOk*/ ctx[3]) {
889
+ if (!/*$isOk*/ ctx[6]) {
832
890
  if (if_block3) ; else {
833
891
  if_block3 = create_if_block$9();
834
892
  if_block3.c();
@@ -839,12 +897,12 @@
839
897
  if_block3 = null;
840
898
  }
841
899
 
842
- if (!current || dirty[0] & /*$scale*/ 16 && div1_class_value !== (div1_class_value = "plot " + ('plot_' + /*$scale*/ ctx[4]) + " svelte-n80kcc")) {
900
+ if (!current || dirty[0] & /*$scale*/ 256 && div1_class_value !== (div1_class_value = "plot " + ('plot_' + /*$scale*/ ctx[8]) + " svelte-n80kcc")) {
843
901
  attr(div1, "class", div1_class_value);
844
902
  }
845
903
 
846
- if (dirty[0] & /*$scale, $isOk*/ 24) {
847
- toggle_class(div1, "plot_error", !/*$isOk*/ ctx[3]);
904
+ if (dirty[0] & /*$scale, $isOk*/ 320) {
905
+ toggle_class(div1, "plot_error", !/*$isOk*/ ctx[6]);
848
906
  }
849
907
  },
850
908
  i(local) {
@@ -871,8 +929,9 @@
871
929
  if (yaxis_slot) yaxis_slot.d(detaching);
872
930
  if (default_slot) default_slot.d(detaching);
873
931
  if (box_slot) box_slot.d(detaching);
874
- /*div0_binding*/ ctx[27](null);
932
+ div0_resize_listener();
875
933
  if (if_block3) if_block3.d();
934
+ div1_resize_listener();
876
935
  mounted = false;
877
936
  dispose();
878
937
  }
@@ -945,39 +1004,40 @@
945
1004
  const clipPathID = "plottingArea" + Math.round(Math.random() * 10000);
946
1005
 
947
1006
  /* parameters for internal use inside the component */
948
- let axesWrapper; // pointer to axes wrapper DOM element
1007
+ let plotWidth; // width of plot
949
1008
 
1009
+ let plotHeight; // height of plot
950
1010
  let axesMargins = [0.034, 0.034, 0.034, 0.034]; // initial margins (will be multiplied to FACTORS)
951
1011
 
952
1012
  /* reactive parameters to be shared with children via context */
953
1013
  const width = writable(100); // actual width of plotting area in pixels
954
1014
 
955
- component_subscribe($$self, width, value => $$invalidate(23, $width = value));
1015
+ component_subscribe($$self, width, value => $$invalidate(7, $width = value));
956
1016
  const height = writable(100); // actual height of plotting area in pixels
957
- component_subscribe($$self, height, value => $$invalidate(21, $height = value));
1017
+ component_subscribe($$self, height, value => $$invalidate(5, $height = value));
958
1018
  const xLim = writable([undefined, undefined]); // actual limits for x-axis in plot units
959
- component_subscribe($$self, xLim, value => $$invalidate(24, $xLim = value));
1019
+ component_subscribe($$self, xLim, value => $$invalidate(25, $xLim = value));
960
1020
  const yLim = writable([undefined, undefined]); // actual limits for y-axis in plot units
961
- component_subscribe($$self, yLim, value => $$invalidate(22, $yLim = value));
1021
+ component_subscribe($$self, yLim, value => $$invalidate(24, $yLim = value));
962
1022
  const scale = writable("medium"); // scale factor (how big the shown plot is)
963
- component_subscribe($$self, scale, value => $$invalidate(4, $scale = value));
1023
+ component_subscribe($$self, scale, value => $$invalidate(8, $scale = value));
964
1024
  const isOk = writable(false); // are axes ready for drawing
965
- component_subscribe($$self, isOk, value => $$invalidate(3, $isOk = value));
1025
+ component_subscribe($$self, isOk, value => $$invalidate(6, $isOk = value));
966
1026
 
967
1027
  /** Adds margins for x-axis (e.g. when x-axis must be shown) */
968
1028
  const addXAxisMargins = function () {
969
- $$invalidate(19, axesMargins[0] = 1, axesMargins);
970
- $$invalidate(19, axesMargins[2] = 0.5, axesMargins);
971
- $$invalidate(19, axesMargins[1] = axesMargins[1] > 0.5 ? axesMargins[1] : 0.5, axesMargins);
972
- $$invalidate(19, axesMargins[3] = axesMargins[3] > 0.5 ? axesMargins[3] : 0.5, axesMargins);
1029
+ $$invalidate(22, axesMargins[0] = 1, axesMargins);
1030
+ $$invalidate(22, axesMargins[2] = 0.5, axesMargins);
1031
+ $$invalidate(22, axesMargins[1] = axesMargins[1] > 0.5 ? axesMargins[1] : 0.5, axesMargins);
1032
+ $$invalidate(22, axesMargins[3] = axesMargins[3] > 0.5 ? axesMargins[3] : 0.5, axesMargins);
973
1033
  };
974
1034
 
975
1035
  /** Adds margins for y-axis (e.g. when y-axis must be shown) */
976
1036
  const addYAxisMargins = function () {
977
- $$invalidate(19, axesMargins[1] = 1, axesMargins);
978
- $$invalidate(19, axesMargins[3] = 0.5, axesMargins);
979
- $$invalidate(19, axesMargins[0] = axesMargins[0] > 0.5 ? axesMargins[0] : 0.5, axesMargins);
980
- $$invalidate(19, axesMargins[2] = axesMargins[2] > 0.5 ? axesMargins[2] : 0.5, axesMargins);
1037
+ $$invalidate(22, axesMargins[1] = 1, axesMargins);
1038
+ $$invalidate(22, axesMargins[3] = 0.5, axesMargins);
1039
+ $$invalidate(22, axesMargins[0] = axesMargins[0] > 0.5 ? axesMargins[0] : 0.5, axesMargins);
1040
+ $$invalidate(22, axesMargins[2] = axesMargins[2] > 0.5 ? axesMargins[2] : 0.5, axesMargins);
981
1041
  };
982
1042
 
983
1043
  /** Adjusts limits for x-axis (e.g. when new series is added)
@@ -1126,20 +1186,6 @@
1126
1186
 
1127
1187
  setContext('axes', context);
1128
1188
 
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
1189
  // handle click on plot elements and dispatch manual events
1144
1190
  function dispatchClickEvent(eventName, el) {
1145
1191
  dispatch(eventName, {
@@ -1165,51 +1211,63 @@
1165
1211
  dispatch("axesclick");
1166
1212
  }
1167
1213
 
1168
- function div0_binding($$value) {
1169
- binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1170
- axesWrapper = $$value;
1171
- $$invalidate(5, axesWrapper);
1172
- });
1214
+ function div0_elementresize_handler() {
1215
+ $height = this.clientHeight;
1216
+ height.set($height);
1217
+ $width = this.clientWidth;
1218
+ width.set($width);
1219
+ }
1220
+
1221
+ function div1_elementresize_handler() {
1222
+ plotHeight = this.clientHeight;
1223
+ plotWidth = this.clientWidth;
1224
+ $$invalidate(4, plotHeight);
1225
+ $$invalidate(3, plotWidth);
1173
1226
  }
1174
1227
 
1175
1228
  $$self.$$set = $$props => {
1176
- if ('limX' in $$props) $$invalidate(16, limX = $$props.limX);
1177
- if ('limY' in $$props) $$invalidate(17, limY = $$props.limY);
1229
+ if ('limX' in $$props) $$invalidate(19, limX = $$props.limX);
1230
+ if ('limY' in $$props) $$invalidate(20, limY = $$props.limY);
1178
1231
  if ('title' in $$props) $$invalidate(0, title = $$props.title);
1179
1232
  if ('xLabel' in $$props) $$invalidate(1, xLabel = $$props.xLabel);
1180
1233
  if ('yLabel' in $$props) $$invalidate(2, yLabel = $$props.yLabel);
1181
- if ('multiSeries' in $$props) $$invalidate(18, multiSeries = $$props.multiSeries);
1182
- if ('$$scope' in $$props) $$invalidate(25, $$scope = $$props.$$scope);
1234
+ if ('multiSeries' in $$props) $$invalidate(21, multiSeries = $$props.multiSeries);
1235
+ if ('$$scope' in $$props) $$invalidate(26, $$scope = $$props.$$scope);
1183
1236
  };
1184
1237
 
1185
1238
  $$self.$$.update = () => {
1186
- if ($$self.$$.dirty[0] & /*limX*/ 65536) {
1239
+ if ($$self.$$.dirty[0] & /*plotWidth, plotHeight*/ 24) {
1240
+ // update plot scale based on its size
1241
+ scale.update(x => getScale(plotWidth, plotHeight));
1242
+ }
1243
+
1244
+ if ($$self.$$.dirty[0] & /*limX*/ 524288) {
1187
1245
  // this is reactive in case if limX and limY are interactively changed by parent script
1188
1246
  if (!limX.some(v => v === undefined)) xLim.update(v => limX);
1189
1247
  }
1190
1248
 
1191
- if ($$self.$$.dirty[0] & /*limY*/ 131072) {
1249
+ if ($$self.$$.dirty[0] & /*limY*/ 1048576) {
1192
1250
  if (!limY.some(v => v === undefined)) yLim.update(v => limY);
1193
1251
  }
1194
1252
 
1195
- if ($$self.$$.dirty[0] & /*axesMargins, $scale*/ 524304) {
1253
+ if ($$self.$$.dirty[0] & /*axesMargins, $scale*/ 4194560) {
1196
1254
  // computes real margins in pixels based on current scale
1197
- $$invalidate(20, margins = axesMargins.map(v => v * AXES_MARGIN_FACTORS[$scale]));
1255
+ $$invalidate(23, margins = axesMargins.map(v => v * AXES_MARGIN_FACTORS[$scale]));
1198
1256
  }
1199
1257
 
1200
- if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/ 32505856) {
1258
+ if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/ 58720416) {
1201
1259
  // computes status which tells that axes limits look fine and it is safe to draw
1202
1260
  // the status is based on the axis limits validity
1203
1261
  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
1262
  }
1205
1263
 
1206
- if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/ 25165832) {
1264
+ if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/ 33554624) {
1207
1265
  // computes coordinates for clip path box
1208
- $$invalidate(7, cpx = $isOk ? scaleX($xLim, $xLim, $width) : [0, 1]);
1266
+ $$invalidate(10, cpx = $isOk ? scaleX($xLim, $xLim, $width) : [0, 1]);
1209
1267
  }
1210
1268
 
1211
- if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/ 6291464) {
1212
- $$invalidate(6, cpy = $isOk ? scaleY($yLim, $yLim, $height) : [1, 0]);
1269
+ if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/ 16777312) {
1270
+ $$invalidate(9, cpy = $isOk ? scaleY($yLim, $yLim, $height) : [1, 0]);
1213
1271
  }
1214
1272
  };
1215
1273
 
@@ -1217,9 +1275,12 @@
1217
1275
  title,
1218
1276
  xLabel,
1219
1277
  yLabel,
1278
+ plotWidth,
1279
+ plotHeight,
1280
+ $height,
1220
1281
  $isOk,
1282
+ $width,
1221
1283
  $scale,
1222
- axesWrapper,
1223
1284
  cpy,
1224
1285
  cpx,
1225
1286
  clipPathID,
@@ -1235,13 +1296,12 @@
1235
1296
  multiSeries,
1236
1297
  axesMargins,
1237
1298
  margins,
1238
- $height,
1239
1299
  $yLim,
1240
- $width,
1241
1300
  $xLim,
1242
1301
  $$scope,
1243
1302
  slots,
1244
- div0_binding
1303
+ div0_elementresize_handler,
1304
+ div1_elementresize_handler
1245
1305
  ];
1246
1306
  }
1247
1307
 
@@ -1256,12 +1316,12 @@
1256
1316
  create_fragment$b,
1257
1317
  safe_not_equal,
1258
1318
  {
1259
- limX: 16,
1260
- limY: 17,
1319
+ limX: 19,
1320
+ limY: 20,
1261
1321
  title: 0,
1262
1322
  xLabel: 1,
1263
1323
  yLabel: 2,
1264
- multiSeries: 18
1324
+ multiSeries: 21
1265
1325
  },
1266
1326
  add_css$3,
1267
1327
  [-1, -1]
@@ -1283,7 +1343,7 @@
1283
1343
  "PRIMARY_TEXT": "#333",
1284
1344
  };
1285
1345
 
1286
- /* src/XAxis.svelte generated by Svelte v3.46.3 */
1346
+ /* src/XAxis.svelte generated by Svelte v3.48.0 */
1287
1347
 
1288
1348
  function get_each_context$5(ctx, list, i) {
1289
1349
  const child_ctx = ctx.slice();
@@ -1663,7 +1723,7 @@
1663
1723
  }
1664
1724
  }
1665
1725
 
1666
- /* src/YAxis.svelte generated by Svelte v3.46.3 */
1726
+ /* src/YAxis.svelte generated by Svelte v3.48.0 */
1667
1727
 
1668
1728
  function get_each_context$4(ctx, list, i) {
1669
1729
  const child_ctx = ctx.slice();
@@ -2049,7 +2109,7 @@
2049
2109
  }
2050
2110
  }
2051
2111
 
2052
- /* src/Rectangles.svelte generated by Svelte v3.46.3 */
2112
+ /* src/Rectangles.svelte generated by Svelte v3.48.0 */
2053
2113
 
2054
2114
  function get_each_context$3(ctx, list, i) {
2055
2115
  const child_ctx = ctx.slice();
@@ -2345,7 +2405,7 @@
2345
2405
  }
2346
2406
  }
2347
2407
 
2348
- /* src/Box.svelte generated by Svelte v3.46.3 */
2408
+ /* src/Box.svelte generated by Svelte v3.48.0 */
2349
2409
 
2350
2410
  function create_if_block$5(ctx) {
2351
2411
  let g;
@@ -2512,7 +2572,7 @@
2512
2572
  }
2513
2573
  }
2514
2574
 
2515
- /* src/Segments.svelte generated by Svelte v3.46.3 */
2575
+ /* src/Segments.svelte generated by Svelte v3.48.0 */
2516
2576
 
2517
2577
  function get_each_context$2(ctx, list, i) {
2518
2578
  const child_ctx = ctx.slice();
@@ -2779,7 +2839,7 @@
2779
2839
  }
2780
2840
  }
2781
2841
 
2782
- /* src/TextLabels.svelte generated by Svelte v3.46.3 */
2842
+ /* src/TextLabels.svelte generated by Svelte v3.48.0 */
2783
2843
 
2784
2844
  function add_css$2(target) {
2785
2845
  append_styles(target, "svelte-1xvrp9d", "text.svelte-1xvrp9d,text.svelte-1xvrp9d>tspan{dominant-baseline:middle}");
@@ -3102,7 +3162,7 @@
3102
3162
  }
3103
3163
  }
3104
3164
 
3105
- /* src/TextLegend.svelte generated by Svelte v3.46.3 */
3165
+ /* src/TextLegend.svelte generated by Svelte v3.48.0 */
3106
3166
 
3107
3167
  function get_each_context(ctx, list, i) {
3108
3168
  const child_ctx = ctx.slice();
@@ -3370,7 +3430,7 @@
3370
3430
  }
3371
3431
 
3372
3432
  /**********************************************
3373
- * Functions for statistical tests *
3433
+ * Functions for statistical tests and models *
3374
3434
  **********************************************/
3375
3435
 
3376
3436
 
@@ -3426,7 +3486,7 @@
3426
3486
  return x.slice(1).map( (y, i) => (y - x[i]));
3427
3487
  }
3428
3488
 
3429
- /* src/BarSeries.svelte generated by Svelte v3.46.3 */
3489
+ /* src/BarSeries.svelte generated by Svelte v3.48.0 */
3430
3490
 
3431
3491
  function add_css$1(target) {
3432
3492
  append_styles(target, "svelte-kw726w", ".series_bar > rect{stroke-width:1px}.series_bar > rect:hover{opacity:90%}");
@@ -3594,7 +3654,7 @@
3594
3654
  }
3595
3655
  }
3596
3656
 
3597
- /* src/ScatterSeries.svelte generated by Svelte v3.46.3 */
3657
+ /* src/ScatterSeries.svelte generated by Svelte v3.48.0 */
3598
3658
 
3599
3659
  function add_css(target) {
3600
3660
  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 +3821,7 @@
3761
3821
  }
3762
3822
  }
3763
3823
 
3764
- /* src/LineSeries.svelte generated by Svelte v3.46.3 */
3824
+ /* src/LineSeries.svelte generated by Svelte v3.48.0 */
3765
3825
 
3766
3826
  function create_if_block$1(ctx) {
3767
3827
  let g;
@@ -3952,7 +4012,7 @@
3952
4012
  }
3953
4013
  }
3954
4014
 
3955
- /* src/AreaSeries.svelte generated by Svelte v3.46.3 */
4015
+ /* src/AreaSeries.svelte generated by Svelte v3.48.0 */
3956
4016
 
3957
4017
  function create_if_block(ctx) {
3958
4018
  let g;