svelte-plots-basic 1.1.2 → 1.1.4

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 DELETED
@@ -1,4194 +0,0 @@
1
- (function (global, factory) {
2
- typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) :
3
- typeof define === 'function' && define.amd ? define(['exports'], factory) :
4
- (global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.PlotsBasic = {}));
5
- })(this, (function (exports) { 'use strict';
6
-
7
- function noop() { }
8
- function assign(tar, src) {
9
- // @ts-ignore
10
- for (const k in src)
11
- tar[k] = src[k];
12
- return tar;
13
- }
14
- function run(fn) {
15
- return fn();
16
- }
17
- function blank_object() {
18
- return Object.create(null);
19
- }
20
- function run_all(fns) {
21
- fns.forEach(run);
22
- }
23
- function is_function(thing) {
24
- return typeof thing === 'function';
25
- }
26
- function safe_not_equal(a, b) {
27
- return a != a ? b == b : a !== b || ((a && typeof a === 'object') || typeof a === 'function');
28
- }
29
- function is_empty(obj) {
30
- return Object.keys(obj).length === 0;
31
- }
32
- function subscribe(store, ...callbacks) {
33
- if (store == null) {
34
- return noop;
35
- }
36
- const unsub = store.subscribe(...callbacks);
37
- return unsub.unsubscribe ? () => unsub.unsubscribe() : unsub;
38
- }
39
- function component_subscribe(component, store, callback) {
40
- component.$$.on_destroy.push(subscribe(store, callback));
41
- }
42
- function create_slot(definition, ctx, $$scope, fn) {
43
- if (definition) {
44
- const slot_ctx = get_slot_context(definition, ctx, $$scope, fn);
45
- return definition[0](slot_ctx);
46
- }
47
- }
48
- function get_slot_context(definition, ctx, $$scope, fn) {
49
- return definition[1] && fn
50
- ? assign($$scope.ctx.slice(), definition[1](fn(ctx)))
51
- : $$scope.ctx;
52
- }
53
- function get_slot_changes(definition, $$scope, dirty, fn) {
54
- if (definition[2] && fn) {
55
- const lets = definition[2](fn(dirty));
56
- if ($$scope.dirty === undefined) {
57
- return lets;
58
- }
59
- if (typeof lets === 'object') {
60
- const merged = [];
61
- const len = Math.max($$scope.dirty.length, lets.length);
62
- for (let i = 0; i < len; i += 1) {
63
- merged[i] = $$scope.dirty[i] | lets[i];
64
- }
65
- return merged;
66
- }
67
- return $$scope.dirty | lets;
68
- }
69
- return $$scope.dirty;
70
- }
71
- function update_slot_base(slot, slot_definition, ctx, $$scope, slot_changes, get_slot_context_fn) {
72
- if (slot_changes) {
73
- const slot_context = get_slot_context(slot_definition, ctx, $$scope, get_slot_context_fn);
74
- slot.p(slot_context, slot_changes);
75
- }
76
- }
77
- function get_all_dirty_from_scope($$scope) {
78
- if ($$scope.ctx.length > 32) {
79
- const dirty = [];
80
- const length = $$scope.ctx.length / 32;
81
- for (let i = 0; i < length; i++) {
82
- dirty[i] = -1;
83
- }
84
- return dirty;
85
- }
86
- return -1;
87
- }
88
- function append(target, node) {
89
- target.appendChild(node);
90
- }
91
- function append_styles(target, style_sheet_id, styles) {
92
- const append_styles_to = get_root_for_style(target);
93
- if (!append_styles_to.getElementById(style_sheet_id)) {
94
- const style = element('style');
95
- style.id = style_sheet_id;
96
- style.textContent = styles;
97
- append_stylesheet(append_styles_to, style);
98
- }
99
- }
100
- function get_root_for_style(node) {
101
- if (!node)
102
- return document;
103
- const root = node.getRootNode ? node.getRootNode() : node.ownerDocument;
104
- if (root && root.host) {
105
- return root;
106
- }
107
- return node.ownerDocument;
108
- }
109
- function append_stylesheet(node, style) {
110
- append(node.head || node, style);
111
- return style.sheet;
112
- }
113
- function insert(target, node, anchor) {
114
- target.insertBefore(node, anchor || null);
115
- }
116
- function detach(node) {
117
- node.parentNode.removeChild(node);
118
- }
119
- function destroy_each(iterations, detaching) {
120
- for (let i = 0; i < iterations.length; i += 1) {
121
- if (iterations[i])
122
- iterations[i].d(detaching);
123
- }
124
- }
125
- function element(name) {
126
- return document.createElement(name);
127
- }
128
- function svg_element(name) {
129
- return document.createElementNS('http://www.w3.org/2000/svg', name);
130
- }
131
- function text(data) {
132
- return document.createTextNode(data);
133
- }
134
- function space() {
135
- return text(' ');
136
- }
137
- function empty() {
138
- return text('');
139
- }
140
- function listen(node, event, handler, options) {
141
- node.addEventListener(event, handler, options);
142
- return () => node.removeEventListener(event, handler, options);
143
- }
144
- function attr(node, attribute, value) {
145
- if (value == null)
146
- node.removeAttribute(attribute);
147
- else if (node.getAttribute(attribute) !== value)
148
- node.setAttribute(attribute, value);
149
- }
150
- function children(element) {
151
- return Array.from(element.childNodes);
152
- }
153
- function set_data(text, data) {
154
- data = '' + data;
155
- if (text.wholeText !== data)
156
- text.data = data;
157
- }
158
- function set_style(node, key, value, important) {
159
- if (value === null) {
160
- node.style.removeProperty(key);
161
- }
162
- else {
163
- node.style.setProperty(key, value, important ? 'important' : '');
164
- }
165
- }
166
- function toggle_class(element, name, toggle) {
167
- element.classList[toggle ? 'add' : 'remove'](name);
168
- }
169
- function custom_event(type, detail, { bubbles = false, cancelable = false } = {}) {
170
- const e = document.createEvent('CustomEvent');
171
- e.initCustomEvent(type, bubbles, cancelable, detail);
172
- return e;
173
- }
174
-
175
- let current_component;
176
- function set_current_component(component) {
177
- current_component = component;
178
- }
179
- function get_current_component() {
180
- if (!current_component)
181
- throw new Error('Function called outside component initialization');
182
- return current_component;
183
- }
184
- function onMount(fn) {
185
- get_current_component().$$.on_mount.push(fn);
186
- }
187
- function createEventDispatcher() {
188
- const component = get_current_component();
189
- return (type, detail, { cancelable = false } = {}) => {
190
- const callbacks = component.$$.callbacks[type];
191
- if (callbacks) {
192
- // TODO are there situations where events could be dispatched
193
- // in a server (non-DOM) environment?
194
- const event = custom_event(type, detail, { cancelable });
195
- callbacks.slice().forEach(fn => {
196
- fn.call(component, event);
197
- });
198
- return !event.defaultPrevented;
199
- }
200
- return true;
201
- };
202
- }
203
- function setContext(key, context) {
204
- get_current_component().$$.context.set(key, context);
205
- return context;
206
- }
207
- function getContext(key) {
208
- return get_current_component().$$.context.get(key);
209
- }
210
-
211
- const dirty_components = [];
212
- const binding_callbacks = [];
213
- const render_callbacks = [];
214
- const flush_callbacks = [];
215
- const resolved_promise = Promise.resolve();
216
- let update_scheduled = false;
217
- function schedule_update() {
218
- if (!update_scheduled) {
219
- update_scheduled = true;
220
- resolved_promise.then(flush);
221
- }
222
- }
223
- function add_render_callback(fn) {
224
- render_callbacks.push(fn);
225
- }
226
- // flush() calls callbacks in this order:
227
- // 1. All beforeUpdate callbacks, in order: parents before children
228
- // 2. All bind:this callbacks, in reverse order: children before parents.
229
- // 3. All afterUpdate callbacks, in order: parents before children. EXCEPT
230
- // for afterUpdates called during the initial onMount, which are called in
231
- // reverse order: children before parents.
232
- // Since callbacks might update component values, which could trigger another
233
- // call to flush(), the following steps guard against this:
234
- // 1. During beforeUpdate, any updated components will be added to the
235
- // dirty_components array and will cause a reentrant call to flush(). Because
236
- // the flush index is kept outside the function, the reentrant call will pick
237
- // up where the earlier call left off and go through all dirty components. The
238
- // current_component value is saved and restored so that the reentrant call will
239
- // not interfere with the "parent" flush() call.
240
- // 2. bind:this callbacks cannot trigger new flush() calls.
241
- // 3. During afterUpdate, any updated components will NOT have their afterUpdate
242
- // callback called a second time; the seen_callbacks set, outside the flush()
243
- // function, guarantees this behavior.
244
- const seen_callbacks = new Set();
245
- let flushidx = 0; // Do *not* move this inside the flush() function
246
- function flush() {
247
- const saved_component = current_component;
248
- do {
249
- // first, call beforeUpdate functions
250
- // and update components
251
- while (flushidx < dirty_components.length) {
252
- const component = dirty_components[flushidx];
253
- flushidx++;
254
- set_current_component(component);
255
- update(component.$$);
256
- }
257
- set_current_component(null);
258
- dirty_components.length = 0;
259
- flushidx = 0;
260
- while (binding_callbacks.length)
261
- binding_callbacks.pop()();
262
- // then, once components are updated, call
263
- // afterUpdate functions. This may cause
264
- // subsequent updates...
265
- for (let i = 0; i < render_callbacks.length; i += 1) {
266
- const callback = render_callbacks[i];
267
- if (!seen_callbacks.has(callback)) {
268
- // ...so guard against infinite loops
269
- seen_callbacks.add(callback);
270
- callback();
271
- }
272
- }
273
- render_callbacks.length = 0;
274
- } while (dirty_components.length);
275
- while (flush_callbacks.length) {
276
- flush_callbacks.pop()();
277
- }
278
- update_scheduled = false;
279
- seen_callbacks.clear();
280
- set_current_component(saved_component);
281
- }
282
- function update($$) {
283
- if ($$.fragment !== null) {
284
- $$.update();
285
- run_all($$.before_update);
286
- const dirty = $$.dirty;
287
- $$.dirty = [-1];
288
- $$.fragment && $$.fragment.p($$.ctx, dirty);
289
- $$.after_update.forEach(add_render_callback);
290
- }
291
- }
292
- const outroing = new Set();
293
- let outros;
294
- function group_outros() {
295
- outros = {
296
- r: 0,
297
- c: [],
298
- p: outros // parent group
299
- };
300
- }
301
- function check_outros() {
302
- if (!outros.r) {
303
- run_all(outros.c);
304
- }
305
- outros = outros.p;
306
- }
307
- function transition_in(block, local) {
308
- if (block && block.i) {
309
- outroing.delete(block);
310
- block.i(local);
311
- }
312
- }
313
- function transition_out(block, local, detach, callback) {
314
- if (block && block.o) {
315
- if (outroing.has(block))
316
- return;
317
- outroing.add(block);
318
- outros.c.push(() => {
319
- outroing.delete(block);
320
- if (callback) {
321
- if (detach)
322
- block.d(1);
323
- callback();
324
- }
325
- });
326
- block.o(local);
327
- }
328
- else if (callback) {
329
- callback();
330
- }
331
- }
332
- function create_component(block) {
333
- block && block.c();
334
- }
335
- function mount_component(component, target, anchor, customElement) {
336
- const { fragment, on_mount, on_destroy, after_update } = component.$$;
337
- fragment && fragment.m(target, anchor);
338
- if (!customElement) {
339
- // onMount happens before the initial afterUpdate
340
- add_render_callback(() => {
341
- const new_on_destroy = on_mount.map(run).filter(is_function);
342
- if (on_destroy) {
343
- on_destroy.push(...new_on_destroy);
344
- }
345
- else {
346
- // Edge case - component was destroyed immediately,
347
- // most likely as a result of a binding initialising
348
- run_all(new_on_destroy);
349
- }
350
- component.$$.on_mount = [];
351
- });
352
- }
353
- after_update.forEach(add_render_callback);
354
- }
355
- function destroy_component(component, detaching) {
356
- const $$ = component.$$;
357
- if ($$.fragment !== null) {
358
- run_all($$.on_destroy);
359
- $$.fragment && $$.fragment.d(detaching);
360
- // TODO null out other refs, including component.$$ (but need to
361
- // preserve final state?)
362
- $$.on_destroy = $$.fragment = null;
363
- $$.ctx = [];
364
- }
365
- }
366
- function make_dirty(component, i) {
367
- if (component.$$.dirty[0] === -1) {
368
- dirty_components.push(component);
369
- schedule_update();
370
- component.$$.dirty.fill(0);
371
- }
372
- component.$$.dirty[(i / 31) | 0] |= (1 << (i % 31));
373
- }
374
- function init(component, options, instance, create_fragment, not_equal, props, append_styles, dirty = [-1]) {
375
- const parent_component = current_component;
376
- set_current_component(component);
377
- const $$ = component.$$ = {
378
- fragment: null,
379
- ctx: null,
380
- // state
381
- props,
382
- update: noop,
383
- not_equal,
384
- bound: blank_object(),
385
- // lifecycle
386
- on_mount: [],
387
- on_destroy: [],
388
- on_disconnect: [],
389
- before_update: [],
390
- after_update: [],
391
- context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
392
- // everything else
393
- callbacks: blank_object(),
394
- dirty,
395
- skip_bound: false,
396
- root: options.target || parent_component.$$.root
397
- };
398
- append_styles && append_styles($$.root);
399
- let ready = false;
400
- $$.ctx = instance
401
- ? instance(component, options.props || {}, (i, ret, ...rest) => {
402
- const value = rest.length ? rest[0] : ret;
403
- if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
404
- if (!$$.skip_bound && $$.bound[i])
405
- $$.bound[i](value);
406
- if (ready)
407
- make_dirty(component, i);
408
- }
409
- return ret;
410
- })
411
- : [];
412
- $$.update();
413
- ready = true;
414
- run_all($$.before_update);
415
- // `false` as a special case of no DOM component
416
- $$.fragment = create_fragment ? create_fragment($$.ctx) : false;
417
- if (options.target) {
418
- if (options.hydrate) {
419
- const nodes = children(options.target);
420
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
421
- $$.fragment && $$.fragment.l(nodes);
422
- nodes.forEach(detach);
423
- }
424
- else {
425
- // eslint-disable-next-line @typescript-eslint/no-non-null-assertion
426
- $$.fragment && $$.fragment.c();
427
- }
428
- if (options.intro)
429
- transition_in(component.$$.fragment);
430
- mount_component(component, options.target, options.anchor, options.customElement);
431
- flush();
432
- }
433
- set_current_component(parent_component);
434
- }
435
- /**
436
- * Base class for Svelte components. Used when dev=false.
437
- */
438
- class SvelteComponent {
439
- $destroy() {
440
- destroy_component(this, 1);
441
- this.$destroy = noop;
442
- }
443
- $on(type, callback) {
444
- const callbacks = (this.$$.callbacks[type] || (this.$$.callbacks[type] = []));
445
- callbacks.push(callback);
446
- return () => {
447
- const index = callbacks.indexOf(callback);
448
- if (index !== -1)
449
- callbacks.splice(index, 1);
450
- };
451
- }
452
- $set($$props) {
453
- if (this.$$set && !is_empty($$props)) {
454
- this.$$.skip_bound = true;
455
- this.$$set($$props);
456
- this.$$.skip_bound = false;
457
- }
458
- }
459
- }
460
-
461
- const subscriber_queue = [];
462
- /**
463
- * Create a `Writable` store that allows both updating and reading by subscription.
464
- * @param {*=}value initial value
465
- * @param {StartStopNotifier=}start start and stop notifications for subscriptions
466
- */
467
- function writable(value, start = noop) {
468
- let stop;
469
- const subscribers = new Set();
470
- function set(new_value) {
471
- if (safe_not_equal(value, new_value)) {
472
- value = new_value;
473
- if (stop) { // store is ready
474
- const run_queue = !subscriber_queue.length;
475
- for (const subscriber of subscribers) {
476
- subscriber[1]();
477
- subscriber_queue.push(subscriber, value);
478
- }
479
- if (run_queue) {
480
- for (let i = 0; i < subscriber_queue.length; i += 2) {
481
- subscriber_queue[i][0](subscriber_queue[i + 1]);
482
- }
483
- subscriber_queue.length = 0;
484
- }
485
- }
486
- }
487
- }
488
- function update(fn) {
489
- set(fn(value));
490
- }
491
- function subscribe(run, invalidate = noop) {
492
- const subscriber = [run, invalidate];
493
- subscribers.add(subscriber);
494
- if (subscribers.size === 1) {
495
- stop = start(set) || noop;
496
- }
497
- run(value);
498
- return () => {
499
- subscribers.delete(subscriber);
500
- if (subscribers.size === 0) {
501
- stop();
502
- stop = null;
503
- }
504
- };
505
- }
506
- return { set, update, subscribe };
507
- }
508
-
509
- /* src/Axes.svelte generated by Svelte v3.50.1 */
510
-
511
- function add_css$3(target) {
512
- append_styles(target, "svelte-11hqgob", ".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-11hqgob{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-content{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}");
513
- }
514
-
515
- const get_box_slot_changes = dirty => ({});
516
- const get_box_slot_context = ctx => ({});
517
- const get_yaxis_slot_changes = dirty => ({});
518
- const get_yaxis_slot_context = ctx => ({});
519
- const get_xaxis_slot_changes = dirty => ({});
520
- const get_xaxis_slot_context = ctx => ({});
521
-
522
- // (342:3) {#if title !== ""}
523
- function create_if_block_3(ctx) {
524
- let div;
525
-
526
- return {
527
- c() {
528
- div = element("div");
529
- attr(div, "class", "axes__title");
530
- },
531
- m(target, anchor) {
532
- insert(target, div, anchor);
533
- div.innerHTML = /*title*/ ctx[0];
534
- },
535
- p(ctx, dirty) {
536
- if (dirty[0] & /*title*/ 1) div.innerHTML = /*title*/ ctx[0]; },
537
- d(detaching) {
538
- if (detaching) detach(div);
539
- }
540
- };
541
- }
542
-
543
- // (343:3) {#if yLabel !== ""}
544
- function create_if_block_2(ctx) {
545
- let div;
546
- let span;
547
-
548
- return {
549
- c() {
550
- div = element("div");
551
- span = element("span");
552
- attr(div, "class", "axes__ylabel");
553
- },
554
- m(target, anchor) {
555
- insert(target, div, anchor);
556
- append(div, span);
557
- span.innerHTML = /*yLabel*/ ctx[2];
558
- },
559
- p(ctx, dirty) {
560
- if (dirty[0] & /*yLabel*/ 4) span.innerHTML = /*yLabel*/ ctx[2]; },
561
- d(detaching) {
562
- if (detaching) detach(div);
563
- }
564
- };
565
- }
566
-
567
- // (344:3) {#if xLabel !== ""}
568
- function create_if_block_1(ctx) {
569
- let div;
570
- let span;
571
-
572
- return {
573
- c() {
574
- div = element("div");
575
- span = element("span");
576
- attr(div, "class", "axes__xlabel");
577
- },
578
- m(target, anchor) {
579
- insert(target, div, anchor);
580
- append(div, span);
581
- span.innerHTML = /*xLabel*/ ctx[1];
582
- },
583
- p(ctx, dirty) {
584
- if (dirty[0] & /*xLabel*/ 2) span.innerHTML = /*xLabel*/ ctx[1]; },
585
- d(detaching) {
586
- if (detaching) detach(div);
587
- }
588
- };
589
- }
590
-
591
- // (372:3) {#if !$isOk}
592
- function create_if_block$9(ctx) {
593
- let p;
594
-
595
- return {
596
- c() {
597
- p = element("p");
598
-
599
- p.innerHTML = `Axes component was not properly initialized. <br/>
600
- Add plot series (check that coordinates are numeric) or define axes limits manually.`;
601
-
602
- attr(p, "class", "message_error");
603
- },
604
- m(target, anchor) {
605
- insert(target, p, anchor);
606
- },
607
- d(detaching) {
608
- if (detaching) detach(p);
609
- }
610
- };
611
- }
612
-
613
- function create_fragment$b(ctx) {
614
- let div1;
615
- let t0;
616
- let t1;
617
- let t2;
618
- let div0;
619
- let svg;
620
- let defs;
621
- let clipPath;
622
- let rect;
623
- let rect_x_value;
624
- let rect_y_value;
625
- let rect_width_value;
626
- let rect_height_value;
627
- let g;
628
- let t3;
629
- let div1_class_value;
630
- let current;
631
- let mounted;
632
- let dispose;
633
- let if_block0 = /*title*/ ctx[0] !== "" && create_if_block_3(ctx);
634
- let if_block1 = /*yLabel*/ ctx[2] !== "" && create_if_block_2(ctx);
635
- let if_block2 = /*xLabel*/ ctx[1] !== "" && create_if_block_1(ctx);
636
- const xaxis_slot_template = /*#slots*/ ctx[27].xaxis;
637
- const xaxis_slot = create_slot(xaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_xaxis_slot_context);
638
- const yaxis_slot_template = /*#slots*/ ctx[27].yaxis;
639
- const yaxis_slot = create_slot(yaxis_slot_template, ctx, /*$$scope*/ ctx[26], get_yaxis_slot_context);
640
- const default_slot_template = /*#slots*/ ctx[27].default;
641
- const default_slot = create_slot(default_slot_template, ctx, /*$$scope*/ ctx[26], null);
642
- const box_slot_template = /*#slots*/ ctx[27].box;
643
- const box_slot = create_slot(box_slot_template, ctx, /*$$scope*/ ctx[26], get_box_slot_context);
644
- let if_block3 = !/*$isOk*/ ctx[3] && create_if_block$9();
645
-
646
- return {
647
- c() {
648
- div1 = element("div");
649
- if (if_block0) if_block0.c();
650
- t0 = space();
651
- if (if_block1) if_block1.c();
652
- t1 = space();
653
- if (if_block2) if_block2.c();
654
- t2 = space();
655
- div0 = element("div");
656
- svg = svg_element("svg");
657
- defs = svg_element("defs");
658
- clipPath = svg_element("clipPath");
659
- rect = svg_element("rect");
660
- if (xaxis_slot) xaxis_slot.c();
661
- if (yaxis_slot) yaxis_slot.c();
662
- g = svg_element("g");
663
- if (default_slot) default_slot.c();
664
- if (box_slot) box_slot.c();
665
- t3 = space();
666
- if (if_block3) if_block3.c();
667
- set_style(rect, "pointer-events", "none");
668
- attr(rect, "x", rect_x_value = /*cpx*/ ctx[8][0]);
669
- attr(rect, "y", rect_y_value = /*cpy*/ ctx[7][1]);
670
- attr(rect, "width", rect_width_value = /*cpx*/ ctx[8][1] - /*cpx*/ ctx[8][0]);
671
- attr(rect, "height", rect_height_value = /*cpy*/ ctx[7][0] - /*cpy*/ ctx[7][1]);
672
- attr(clipPath, "id", /*clipPathID*/ ctx[9]);
673
- attr(g, "class", "axes-content");
674
- attr(g, "clip-path", "url(#" + /*clipPathID*/ ctx[9] + ")");
675
- attr(svg, "preserveAspectRatio", "none");
676
- attr(svg, "class", "axes");
677
- attr(div0, "class", "axes-wrapper svelte-11hqgob");
678
- attr(div1, "class", div1_class_value = "plot " + ('plot_' + /*$scale*/ ctx[4]) + " svelte-11hqgob");
679
- toggle_class(div1, "plot_error", !/*$isOk*/ ctx[3]);
680
- },
681
- m(target, anchor) {
682
- insert(target, div1, anchor);
683
- if (if_block0) if_block0.m(div1, null);
684
- append(div1, t0);
685
- if (if_block1) if_block1.m(div1, null);
686
- append(div1, t1);
687
- if (if_block2) if_block2.m(div1, null);
688
- append(div1, t2);
689
- append(div1, div0);
690
- append(div0, svg);
691
- append(svg, defs);
692
- append(defs, clipPath);
693
- append(clipPath, rect);
694
-
695
- if (xaxis_slot) {
696
- xaxis_slot.m(svg, null);
697
- }
698
-
699
- if (yaxis_slot) {
700
- yaxis_slot.m(svg, null);
701
- }
702
-
703
- append(svg, g);
704
-
705
- if (default_slot) {
706
- default_slot.m(g, null);
707
- }
708
-
709
- if (box_slot) {
710
- box_slot.m(svg, null);
711
- }
712
-
713
- /*div0_binding*/ ctx[28](div0);
714
- append(div1, t3);
715
- if (if_block3) if_block3.m(div1, null);
716
- /*div1_binding*/ ctx[29](div1);
717
- current = true;
718
-
719
- if (!mounted) {
720
- dispose = listen(svg, "click", /*handleClick*/ ctx[16]);
721
- mounted = true;
722
- }
723
- },
724
- p(ctx, dirty) {
725
- if (/*title*/ ctx[0] !== "") {
726
- if (if_block0) {
727
- if_block0.p(ctx, dirty);
728
- } else {
729
- if_block0 = create_if_block_3(ctx);
730
- if_block0.c();
731
- if_block0.m(div1, t0);
732
- }
733
- } else if (if_block0) {
734
- if_block0.d(1);
735
- if_block0 = null;
736
- }
737
-
738
- if (/*yLabel*/ ctx[2] !== "") {
739
- if (if_block1) {
740
- if_block1.p(ctx, dirty);
741
- } else {
742
- if_block1 = create_if_block_2(ctx);
743
- if_block1.c();
744
- if_block1.m(div1, t1);
745
- }
746
- } else if (if_block1) {
747
- if_block1.d(1);
748
- if_block1 = null;
749
- }
750
-
751
- if (/*xLabel*/ ctx[1] !== "") {
752
- if (if_block2) {
753
- if_block2.p(ctx, dirty);
754
- } else {
755
- if_block2 = create_if_block_1(ctx);
756
- if_block2.c();
757
- if_block2.m(div1, t2);
758
- }
759
- } else if (if_block2) {
760
- if_block2.d(1);
761
- if_block2 = null;
762
- }
763
-
764
- if (!current || dirty[0] & /*cpx*/ 256 && rect_x_value !== (rect_x_value = /*cpx*/ ctx[8][0])) {
765
- attr(rect, "x", rect_x_value);
766
- }
767
-
768
- if (!current || dirty[0] & /*cpy*/ 128 && rect_y_value !== (rect_y_value = /*cpy*/ ctx[7][1])) {
769
- attr(rect, "y", rect_y_value);
770
- }
771
-
772
- if (!current || dirty[0] & /*cpx*/ 256 && rect_width_value !== (rect_width_value = /*cpx*/ ctx[8][1] - /*cpx*/ ctx[8][0])) {
773
- attr(rect, "width", rect_width_value);
774
- }
775
-
776
- if (!current || dirty[0] & /*cpy*/ 128 && rect_height_value !== (rect_height_value = /*cpy*/ ctx[7][0] - /*cpy*/ ctx[7][1])) {
777
- attr(rect, "height", rect_height_value);
778
- }
779
-
780
- if (xaxis_slot) {
781
- if (xaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
782
- update_slot_base(
783
- xaxis_slot,
784
- xaxis_slot_template,
785
- ctx,
786
- /*$$scope*/ ctx[26],
787
- !current
788
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
789
- : get_slot_changes(xaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_xaxis_slot_changes),
790
- get_xaxis_slot_context
791
- );
792
- }
793
- }
794
-
795
- if (yaxis_slot) {
796
- if (yaxis_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
797
- update_slot_base(
798
- yaxis_slot,
799
- yaxis_slot_template,
800
- ctx,
801
- /*$$scope*/ ctx[26],
802
- !current
803
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
804
- : get_slot_changes(yaxis_slot_template, /*$$scope*/ ctx[26], dirty, get_yaxis_slot_changes),
805
- get_yaxis_slot_context
806
- );
807
- }
808
- }
809
-
810
- if (default_slot) {
811
- if (default_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
812
- update_slot_base(
813
- default_slot,
814
- default_slot_template,
815
- ctx,
816
- /*$$scope*/ ctx[26],
817
- !current
818
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
819
- : get_slot_changes(default_slot_template, /*$$scope*/ ctx[26], dirty, null),
820
- null
821
- );
822
- }
823
- }
824
-
825
- if (box_slot) {
826
- if (box_slot.p && (!current || dirty[0] & /*$$scope*/ 67108864)) {
827
- update_slot_base(
828
- box_slot,
829
- box_slot_template,
830
- ctx,
831
- /*$$scope*/ ctx[26],
832
- !current
833
- ? get_all_dirty_from_scope(/*$$scope*/ ctx[26])
834
- : get_slot_changes(box_slot_template, /*$$scope*/ ctx[26], dirty, get_box_slot_changes),
835
- get_box_slot_context
836
- );
837
- }
838
- }
839
-
840
- if (!/*$isOk*/ ctx[3]) {
841
- if (if_block3) ; else {
842
- if_block3 = create_if_block$9();
843
- if_block3.c();
844
- if_block3.m(div1, null);
845
- }
846
- } else if (if_block3) {
847
- if_block3.d(1);
848
- if_block3 = null;
849
- }
850
-
851
- if (!current || dirty[0] & /*$scale*/ 16 && div1_class_value !== (div1_class_value = "plot " + ('plot_' + /*$scale*/ ctx[4]) + " svelte-11hqgob")) {
852
- attr(div1, "class", div1_class_value);
853
- }
854
-
855
- if (!current || dirty[0] & /*$scale, $isOk*/ 24) {
856
- toggle_class(div1, "plot_error", !/*$isOk*/ ctx[3]);
857
- }
858
- },
859
- i(local) {
860
- if (current) return;
861
- transition_in(xaxis_slot, local);
862
- transition_in(yaxis_slot, local);
863
- transition_in(default_slot, local);
864
- transition_in(box_slot, local);
865
- current = true;
866
- },
867
- o(local) {
868
- transition_out(xaxis_slot, local);
869
- transition_out(yaxis_slot, local);
870
- transition_out(default_slot, local);
871
- transition_out(box_slot, local);
872
- current = false;
873
- },
874
- d(detaching) {
875
- if (detaching) detach(div1);
876
- if (if_block0) if_block0.d();
877
- if (if_block1) if_block1.d();
878
- if (if_block2) if_block2.d();
879
- if (xaxis_slot) xaxis_slot.d(detaching);
880
- if (yaxis_slot) yaxis_slot.d(detaching);
881
- if (default_slot) default_slot.d(detaching);
882
- if (box_slot) box_slot.d(detaching);
883
- /*div0_binding*/ ctx[28](null);
884
- if (if_block3) if_block3.d();
885
- /*div1_binding*/ ctx[29](null);
886
- mounted = false;
887
- dispose();
888
- }
889
- };
890
- }
891
-
892
- function niceNum(localRange, round) {
893
- const exponent = Math.floor(Math.log10(localRange));
894
- const fraction = localRange / Math.pow(10, exponent);
895
- let niceFraction;
896
-
897
- if (round) {
898
- if (fraction < 1.5) niceFraction = 1; else if (fraction < 3) niceFraction = 2; else if (fraction < 7) niceFraction = 5; else niceFraction = 10;
899
- } else {
900
- if (fraction <= 1) niceFraction = 1; else if (fraction <= 2) niceFraction = 2; else if (fraction <= 5) niceFraction = 5; else niceFraction = 10;
901
- }
902
-
903
- return niceFraction * Math.pow(10, exponent);
904
- }
905
-
906
- /** Computes a scale level
907
- * @param {numeric} width - width of plotting area in pixels
908
- * @param {numeric} height - height of plotting area in pixels
909
- * @returns {text} the scale level ("small", "medium" or "large")
910
- */
911
- function getScale(width, height) {
912
- if (height < 300.2 || width < 300.2) return "small";
913
- if (height < 600.2 || width < 600.2) return "medium";
914
- return "large";
915
- }
916
-
917
- function instance$b($$self, $$props, $$invalidate) {
918
- let margins;
919
- let cpx;
920
- let cpy;
921
- let $height;
922
- let $yLim;
923
- let $isOk;
924
- let $width;
925
- let $xLim;
926
- let $scale;
927
- let { $$slots: slots = {}, $$scope } = $$props;
928
- let { limX = [undefined, undefined] } = $$props;
929
- let { limY = [undefined, undefined] } = $$props;
930
- let { title = "" } = $$props;
931
- let { xLabel = "" } = $$props;
932
- let { yLabel = "" } = $$props;
933
- let { multiSeries = true } = $$props;
934
-
935
- // event dispatcher
936
- const dispatch = createEventDispatcher();
937
-
938
- // how big are margins (number of pixels in unit margin value) between axis and plot area if axis are shown
939
- const AXES_MARGIN_FACTORS = { "small": 30, "medium": 40, "large": 50 };
940
-
941
- // number of ticks along each axis
942
- const TICK_NUM = { "small": 5, "medium": 8, "large": 12 };
943
-
944
- // margin between plot series elements and data labels
945
- const LABELS_MARGIN = { "small": 10, "medium": 15, "large": 20 };
946
-
947
- // line styles for different scales and types
948
- const LINE_STYLES = {
949
- small: ["0", "3,3", "1,1", "3,1"],
950
- medium: ["0", "5,5", "2,2", "5,2"],
951
- large: ["0", "7,7", "3,3", "7,3"]
952
- };
953
-
954
- // constant to make clip path ID unique
955
- const clipPathID = "plottingArea" + Math.round(Math.random() * 10000);
956
-
957
- /* parameters for internal use inside the component */
958
- let plotElement;
959
-
960
- let axesElement;
961
- let axesMargins = [0.034, 0.034, 0.034, 0.034]; // initial margins (will be multiplied to FACTORS)
962
-
963
- /* reactive parameters to be shared with children via context */
964
- const width = writable(100); // actual width of plotting area in pixels
965
-
966
- component_subscribe($$self, width, value => $$invalidate(24, $width = value));
967
- const height = writable(100); // actual height of plotting area in pixels
968
- component_subscribe($$self, height, value => $$invalidate(22, $height = value));
969
- const xLim = writable([undefined, undefined]); // actual limits for x-axis in plot units
970
- component_subscribe($$self, xLim, value => $$invalidate(25, $xLim = value));
971
- const yLim = writable([undefined, undefined]); // actual limits for y-axis in plot units
972
- component_subscribe($$self, yLim, value => $$invalidate(23, $yLim = value));
973
- const scale = writable("medium"); // scale factor (how big the shown plot is)
974
- component_subscribe($$self, scale, value => $$invalidate(4, $scale = value));
975
- const isOk = writable(false); // are axes ready for drawing
976
- component_subscribe($$self, isOk, value => $$invalidate(3, $isOk = value));
977
-
978
- /** Adds margins for x-axis (e.g. when x-axis must be shown) */
979
- const addXAxisMargins = function () {
980
- $$invalidate(20, axesMargins[0] = 1, axesMargins);
981
- $$invalidate(20, axesMargins[2] = 0.5, axesMargins);
982
- $$invalidate(20, axesMargins[1] = axesMargins[1] > 0.5 ? axesMargins[1] : 0.5, axesMargins);
983
- $$invalidate(20, axesMargins[3] = axesMargins[3] > 0.5 ? axesMargins[3] : 0.5, axesMargins);
984
- };
985
-
986
- /** Adds margins for y-axis (e.g. when y-axis must be shown) */
987
- const addYAxisMargins = function () {
988
- $$invalidate(20, axesMargins[1] = 1, axesMargins);
989
- $$invalidate(20, axesMargins[3] = 0.5, axesMargins);
990
- $$invalidate(20, axesMargins[0] = axesMargins[0] > 0.5 ? axesMargins[0] : 0.5, axesMargins);
991
- $$invalidate(20, axesMargins[2] = axesMargins[2] > 0.5 ? axesMargins[2] : 0.5, axesMargins);
992
- };
993
-
994
- /** Adjusts limits for x-axis (e.g. when new series is added)
995
- * @param {Array} newLim - vector with new limits (two values)
996
- */
997
- const adjustXAxisLimits = function (newLim) {
998
- if (!limX.some(v => v === undefined)) return;
999
- xLim.update(lim => adjustAxisLimits(lim, newLim));
1000
- };
1001
-
1002
- /** Adjusts limits for y-axis (e.g. when new series is added)
1003
- * @param {Array} newLim - vector with new limits (two values)
1004
- */
1005
- const adjustYAxisLimits = function (newLim) {
1006
- if (!limY.some(v => v === undefined)) return;
1007
- yLim.update(lim => adjustAxisLimits(lim, newLim));
1008
- };
1009
-
1010
- /** Adjusts x- or y- axis limits (e.g. when new elements are added)
1011
- * @param {Array} lim - vector with limits for current axis (two values)
1012
- * @param {Array} newLim - vector with new limits (two values)
1013
- * @returns {Array} vector with rescaled values
1014
- *
1015
- * The new limits are set separately for min and max. Either if current value is undefined or
1016
- * if new value is outside the current limits (smaller than min or larger than max).
1017
- */
1018
- const adjustAxisLimits = function (lim, newLim) {
1019
- let adjustedLim = [
1020
- lim[0] !== undefined && multiSeries === true && lim[0] < newLim[0]
1021
- ? lim[0]
1022
- : newLim[0],
1023
- lim[1] !== undefined && multiSeries === true && lim[1] > newLim[1]
1024
- ? lim[1]
1025
- : newLim[1]
1026
- ];
1027
-
1028
- // special case when both limits are zero
1029
- if (adjustedLim[0] === 0 && adjustedLim[1] === 0) {
1030
- adjustedLim = [-0.1, 0.1];
1031
- }
1032
-
1033
- // special case when limits are equal (add ±5%)
1034
- if (adjustedLim[0] === adjustedLim[1]) {
1035
- adjustedLim = [adjustedLim[0] * 0.95, adjustedLim[0] * 1.05];
1036
- }
1037
-
1038
- return adjustedLim;
1039
- };
1040
-
1041
- /** Rescales x-values from plot coordinates to screen (SVG) coordinates
1042
- * @param {Array} x - vector with coordinates (or objects size) in original plot coordinates
1043
- * @param {Array} xLim - vector with current limits for x-axis in original plot coordinates
1044
- * @param {number} width - width of coordinate system in pixels
1045
- * @param {boolean} doSizeScreen - scale size of objects (true) or coordinates
1046
- * @returns {Array} vector with rescaled values
1047
- */
1048
- const scaleX = function (x, xLim, width, doSizeScale = false) {
1049
- if (!$isOk || x === undefined || !Array.isArray(x)) return undefined;
1050
-
1051
- if (doSizeScale) {
1052
- // scale size of objects instead of coordinates
1053
- return x.map(v => v / (xLim[1] - xLim[0]) * (width - margins[1] - margins[3]));
1054
- }
1055
-
1056
- return x.map(v => (v - xLim[0]) / (xLim[1] - xLim[0]) * (width - margins[1] - margins[3]) + margins[1]);
1057
- };
1058
-
1059
- /** Rescales x-values from plot coordinates to screen (SVG) coordinates
1060
- * @param {Array} x - vector with coordinates (or objects size) in original plot coordinates
1061
- * @param {Array} xLim - vector with current limits for x-axis in original plot coordinates
1062
- * @param {number} width - width of coordinate system in pixels
1063
- * @param {boolean} doSizeScreen - scale size of objects (true) or coordinates
1064
- * @returns {Array} vector with rescaled values
1065
- */
1066
- const scaleY = function (y, yLim, height, doSizeScale = false) {
1067
- if (!$isOk || y === undefined || !Array.isArray(y)) return undefined;
1068
-
1069
- if (doSizeScale) {
1070
- // scale size of objects instead of coordinates
1071
- return y.map(v => v / (yLim[1] - yLim[0]) * (height - margins[0] - margins[2]));
1072
- }
1073
-
1074
- // for coordinates we also need to invert (flip) the y-axis
1075
- return y.map(v => (yLim[1] - v) / (yLim[1] - yLim[0]) * (height - margins[0] - margins[2]) + margins[2]);
1076
- };
1077
-
1078
- /** Computes nice tick values for axis
1079
- * @param {Array} ticks - vector with ticks if alredy available (if not, new will be computed)
1080
- * @param {Array} lim - vector with axis limits tickets must be computed for
1081
- * @param {number} maxTickNum - maximum number of ticks to compute
1082
- * @param {boolean} round - round or not the fractions when computing nice numbers for the ticks
1083
- * @returns {Array} a vector with computed tick positions
1084
- */
1085
- const getAxisTicks = function (ticks, lim, maxTickNum, round = true) {
1086
- // if ticks are already provided do not recompute them
1087
- if (ticks !== undefined) return ticks;
1088
-
1089
- // check if limits are ok
1090
- if (!Array.isArray(lim) || lim[0] === undefined || lim[1] === undefined) return undefined;
1091
-
1092
- // get range as a nice number and compute min, max and steps for the tick sequence
1093
- const range = niceNum(lim[1] - lim[0], round);
1094
-
1095
- const tickSpacing = niceNum(range / (maxTickNum - 1), round);
1096
- const tickMin = Math.ceil(lim[0] / tickSpacing) * tickSpacing;
1097
- const tickMax = Math.floor(lim[1] / tickSpacing) * tickSpacing;
1098
-
1099
- // recompute maxTickNum
1100
- maxTickNum = Math.round((tickMax - tickMin + 1) / tickSpacing) + 1;
1101
-
1102
- // create a sequence and return
1103
- ticks = [...Array(maxTickNum)].map((x, i) => tickMin + i * tickSpacing);
1104
-
1105
- // if step is smaller than 1 round values to remove small decimals accidentiall added by JS
1106
- if (Math.abs(tickSpacing) < 1) {
1107
- const r = Math.pow(10, 1 + Math.round(-Math.log10(tickSpacing)));
1108
- ticks = ticks.map(v => Math.round((v + Number.EPSILON) * r) / r);
1109
- }
1110
-
1111
- // make sure the ticks are not aligned with axes limits
1112
- return ticks.filter(x => x >= lim[0] & x <= lim[1]);
1113
- };
1114
-
1115
- /* context with Axes constants, properties and methods to share with children */
1116
- let context = {
1117
- // methods
1118
- addXAxisMargins,
1119
- addYAxisMargins,
1120
- adjustXAxisLimits,
1121
- adjustYAxisLimits,
1122
- getAxisTicks,
1123
- scaleX,
1124
- scaleY,
1125
- // variables
1126
- isOk,
1127
- scale,
1128
- width,
1129
- height,
1130
- xLim,
1131
- yLim,
1132
- // constants
1133
- LINE_STYLES,
1134
- LABELS_MARGIN,
1135
- TICK_NUM
1136
- };
1137
-
1138
- setContext('axes', context);
1139
-
1140
- // handle click on plot elements and dispatch manual events
1141
- function dispatchClickEvent(eventName, el) {
1142
- dispatch(eventName, {
1143
- seriesTitle: el.parentNode.getAttribute('title'),
1144
- elementID: el.dataset.id
1145
- });
1146
- }
1147
-
1148
- function handleClick(e) {
1149
- // scatter plot markers
1150
- if (e.target.tagName === "text" && e.target.parentNode.classList.contains("series_scatter")) {
1151
- dispatchClickEvent("markerclick", e.target);
1152
- return;
1153
- }
1154
-
1155
- // bar plot bars
1156
- if (e.target.tagName === "rect" && e.target.parentNode.classList.contains("series_bar")) {
1157
- dispatchClickEvent("barclick", e.target);
1158
- return;
1159
- }
1160
-
1161
- // outside any plot element
1162
- dispatch("axesclick");
1163
- }
1164
-
1165
- /* observer for the plotting area size */
1166
- var ro = new ResizeObserver(entries => {
1167
- for (let entry of entries) {
1168
- const pcr = plotElement.getBoundingClientRect();
1169
- const acr = axesElement.getBoundingClientRect();
1170
- width.update(x => acr.width);
1171
- height.update(x => acr.height);
1172
- scale.update(x => getScale(pcr.width, pcr.height));
1173
- }
1174
- });
1175
-
1176
- onMount(() => {
1177
- ro.observe(plotElement);
1178
- });
1179
-
1180
- function div0_binding($$value) {
1181
- binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1182
- axesElement = $$value;
1183
- $$invalidate(6, axesElement);
1184
- });
1185
- }
1186
-
1187
- function div1_binding($$value) {
1188
- binding_callbacks[$$value ? 'unshift' : 'push'](() => {
1189
- plotElement = $$value;
1190
- $$invalidate(5, plotElement);
1191
- });
1192
- }
1193
-
1194
- $$self.$$set = $$props => {
1195
- if ('limX' in $$props) $$invalidate(17, limX = $$props.limX);
1196
- if ('limY' in $$props) $$invalidate(18, limY = $$props.limY);
1197
- if ('title' in $$props) $$invalidate(0, title = $$props.title);
1198
- if ('xLabel' in $$props) $$invalidate(1, xLabel = $$props.xLabel);
1199
- if ('yLabel' in $$props) $$invalidate(2, yLabel = $$props.yLabel);
1200
- if ('multiSeries' in $$props) $$invalidate(19, multiSeries = $$props.multiSeries);
1201
- if ('$$scope' in $$props) $$invalidate(26, $$scope = $$props.$$scope);
1202
- };
1203
-
1204
- $$self.$$.update = () => {
1205
- if ($$self.$$.dirty[0] & /*limX*/ 131072) {
1206
- // this is reactive in case if limX and limY are interactively changed by parent script
1207
- if (!limX.some(v => v === undefined)) xLim.update(v => limX);
1208
- }
1209
-
1210
- if ($$self.$$.dirty[0] & /*limY*/ 262144) {
1211
- if (!limY.some(v => v === undefined)) yLim.update(v => limY);
1212
- }
1213
-
1214
- if ($$self.$$.dirty[0] & /*axesMargins, $scale*/ 1048592) {
1215
- // computes real margins in pixels based on current scale
1216
- $$invalidate(21, margins = axesMargins.map(v => v * AXES_MARGIN_FACTORS[$scale]));
1217
- }
1218
-
1219
- if ($$self.$$.dirty[0] & /*$yLim, $xLim, $width, margins, $height*/ 65011712) {
1220
- // computes status which tells that axes limits look fine and it is safe to draw
1221
- // the status is based on the axis limits validity
1222
- 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]);
1223
- }
1224
-
1225
- if ($$self.$$.dirty[0] & /*$isOk, $xLim, $width*/ 50331656) {
1226
- // computes coordinates for clip path box
1227
- $$invalidate(8, cpx = $isOk ? scaleX($xLim, $xLim, $width) : [0, 1]);
1228
- }
1229
-
1230
- if ($$self.$$.dirty[0] & /*$isOk, $yLim, $height*/ 12582920) {
1231
- $$invalidate(7, cpy = $isOk ? scaleY($yLim, $yLim, $height) : [1, 0]);
1232
- }
1233
- };
1234
-
1235
- return [
1236
- title,
1237
- xLabel,
1238
- yLabel,
1239
- $isOk,
1240
- $scale,
1241
- plotElement,
1242
- axesElement,
1243
- cpy,
1244
- cpx,
1245
- clipPathID,
1246
- width,
1247
- height,
1248
- xLim,
1249
- yLim,
1250
- scale,
1251
- isOk,
1252
- handleClick,
1253
- limX,
1254
- limY,
1255
- multiSeries,
1256
- axesMargins,
1257
- margins,
1258
- $height,
1259
- $yLim,
1260
- $width,
1261
- $xLim,
1262
- $$scope,
1263
- slots,
1264
- div0_binding,
1265
- div1_binding
1266
- ];
1267
- }
1268
-
1269
- class Axes extends SvelteComponent {
1270
- constructor(options) {
1271
- super();
1272
-
1273
- init(
1274
- this,
1275
- options,
1276
- instance$b,
1277
- create_fragment$b,
1278
- safe_not_equal,
1279
- {
1280
- limX: 17,
1281
- limY: 18,
1282
- title: 0,
1283
- xLabel: 1,
1284
- yLabel: 2,
1285
- multiSeries: 19
1286
- },
1287
- add_css$3,
1288
- [-1, -1]
1289
- );
1290
- }
1291
- }
1292
-
1293
- const Colors = {
1294
- "AXIS_LINE": "#303030",
1295
- "AXIS_TICK": "#606060",
1296
- "WHITE": "#fff",
1297
- "BLACK": "#000",
1298
- "GRAY": "#909090",
1299
- "MIDDLEGRAY": "#dadada",
1300
- "LIGHTGRAY": "#f0f0f0",
1301
- "DARKGRAY": "#606060",
1302
-
1303
- "PRIMARY": "#2266ff",
1304
- "PRIMARY_TEXT": "#333",
1305
- };
1306
-
1307
- /* src/XAxis.svelte generated by Svelte v3.50.1 */
1308
-
1309
- function get_each_context$5(ctx, list, i) {
1310
- const child_ctx = ctx.slice();
1311
- child_ctx[26] = list[i];
1312
- child_ctx[28] = i;
1313
- return child_ctx;
1314
- }
1315
-
1316
- // (57:0) {#if $isOk && x !== undefined && y !== undefined }
1317
- function create_if_block$8(ctx) {
1318
- let g;
1319
- let line;
1320
- let line_x__value;
1321
- let line_x__value_1;
1322
- let line_y__value;
1323
- let line_y__value_1;
1324
- let each_value = /*ticksX*/ ctx[4];
1325
- let each_blocks = [];
1326
-
1327
- for (let i = 0; i < each_value.length; i += 1) {
1328
- each_blocks[i] = create_each_block$5(get_each_context$5(ctx, each_value, i));
1329
- }
1330
-
1331
- return {
1332
- c() {
1333
- g = svg_element("g");
1334
-
1335
- for (let i = 0; i < each_blocks.length; i += 1) {
1336
- each_blocks[i].c();
1337
- }
1338
-
1339
- line = svg_element("line");
1340
- attr(line, "x1", line_x__value = /*x*/ ctx[5][0]);
1341
- attr(line, "x2", line_x__value_1 = /*x*/ ctx[5][1]);
1342
- attr(line, "y1", line_y__value = /*y*/ ctx[2][0]);
1343
- attr(line, "y2", line_y__value_1 = /*y*/ ctx[2][0]);
1344
- attr(line, "style", /*axisLineStyleStr*/ ctx[7]);
1345
- attr(g, "class", "mdaplot__axis mdaplot__xaxis");
1346
- },
1347
- m(target, anchor) {
1348
- insert(target, g, anchor);
1349
-
1350
- for (let i = 0; i < each_blocks.length; i += 1) {
1351
- each_blocks[i].m(g, null);
1352
- }
1353
-
1354
- append(g, line);
1355
- },
1356
- p(ctx, dirty) {
1357
- if (dirty & /*ticksX, ticksY, dy, tickLabels, axisLineStyleStr, y, gridLineStyleStr*/ 415) {
1358
- each_value = /*ticksX*/ ctx[4];
1359
- let i;
1360
-
1361
- for (i = 0; i < each_value.length; i += 1) {
1362
- const child_ctx = get_each_context$5(ctx, each_value, i);
1363
-
1364
- if (each_blocks[i]) {
1365
- each_blocks[i].p(child_ctx, dirty);
1366
- } else {
1367
- each_blocks[i] = create_each_block$5(child_ctx);
1368
- each_blocks[i].c();
1369
- each_blocks[i].m(g, line);
1370
- }
1371
- }
1372
-
1373
- for (; i < each_blocks.length; i += 1) {
1374
- each_blocks[i].d(1);
1375
- }
1376
-
1377
- each_blocks.length = each_value.length;
1378
- }
1379
-
1380
- if (dirty & /*x*/ 32 && line_x__value !== (line_x__value = /*x*/ ctx[5][0])) {
1381
- attr(line, "x1", line_x__value);
1382
- }
1383
-
1384
- if (dirty & /*x*/ 32 && line_x__value_1 !== (line_x__value_1 = /*x*/ ctx[5][1])) {
1385
- attr(line, "x2", line_x__value_1);
1386
- }
1387
-
1388
- if (dirty & /*y*/ 4 && line_y__value !== (line_y__value = /*y*/ ctx[2][0])) {
1389
- attr(line, "y1", line_y__value);
1390
- }
1391
-
1392
- if (dirty & /*y*/ 4 && line_y__value_1 !== (line_y__value_1 = /*y*/ ctx[2][0])) {
1393
- attr(line, "y2", line_y__value_1);
1394
- }
1395
- },
1396
- d(detaching) {
1397
- if (detaching) detach(g);
1398
- destroy_each(each_blocks, detaching);
1399
- }
1400
- };
1401
- }
1402
-
1403
- // (59:3) {#each ticksX as tx, i}
1404
- function create_each_block$5(ctx) {
1405
- let line0;
1406
- let line0_x__value;
1407
- let line0_x__value_1;
1408
- let line0_y__value;
1409
- let line0_y__value_1;
1410
- let line1;
1411
- let line1_x__value;
1412
- let line1_x__value_1;
1413
- let line1_y__value;
1414
- let line1_y__value_1;
1415
- let text_1;
1416
- let t_value = /*tickLabels*/ ctx[0][/*i*/ ctx[28]] + "";
1417
- let t;
1418
- let text_1_x_value;
1419
- let text_1_y_value;
1420
-
1421
- return {
1422
- c() {
1423
- line0 = svg_element("line");
1424
- line1 = svg_element("line");
1425
- text_1 = svg_element("text");
1426
- t = text(t_value);
1427
- attr(line0, "x1", line0_x__value = /*tx*/ ctx[26]);
1428
- attr(line0, "x2", line0_x__value_1 = /*tx*/ ctx[26]);
1429
- attr(line0, "y1", line0_y__value = /*y*/ ctx[2][0]);
1430
- attr(line0, "y2", line0_y__value_1 = /*y*/ ctx[2][1]);
1431
- attr(line0, "style", /*gridLineStyleStr*/ ctx[8]);
1432
- attr(line1, "x1", line1_x__value = /*tx*/ ctx[26]);
1433
- attr(line1, "x2", line1_x__value_1 = /*tx*/ ctx[26]);
1434
- attr(line1, "y1", line1_y__value = /*ticksY*/ ctx[3][0]);
1435
- attr(line1, "y2", line1_y__value_1 = /*ticksY*/ ctx[3][1]);
1436
- attr(line1, "style", /*axisLineStyleStr*/ ctx[7]);
1437
- attr(text_1, "x", text_1_x_value = /*tx*/ ctx[26]);
1438
- attr(text_1, "y", text_1_y_value = /*ticksY*/ ctx[3][1]);
1439
- attr(text_1, "dx", "0");
1440
- attr(text_1, "dy", /*dy*/ ctx[1]);
1441
- attr(text_1, "class", "mdaplot__axis-labels");
1442
- attr(text_1, "dominant-baseline", "middle");
1443
- attr(text_1, "text-anchor", "middle");
1444
- },
1445
- m(target, anchor) {
1446
- insert(target, line0, anchor);
1447
- insert(target, line1, anchor);
1448
- insert(target, text_1, anchor);
1449
- append(text_1, t);
1450
- },
1451
- p(ctx, dirty) {
1452
- if (dirty & /*ticksX*/ 16 && line0_x__value !== (line0_x__value = /*tx*/ ctx[26])) {
1453
- attr(line0, "x1", line0_x__value);
1454
- }
1455
-
1456
- if (dirty & /*ticksX*/ 16 && line0_x__value_1 !== (line0_x__value_1 = /*tx*/ ctx[26])) {
1457
- attr(line0, "x2", line0_x__value_1);
1458
- }
1459
-
1460
- if (dirty & /*y*/ 4 && line0_y__value !== (line0_y__value = /*y*/ ctx[2][0])) {
1461
- attr(line0, "y1", line0_y__value);
1462
- }
1463
-
1464
- if (dirty & /*y*/ 4 && line0_y__value_1 !== (line0_y__value_1 = /*y*/ ctx[2][1])) {
1465
- attr(line0, "y2", line0_y__value_1);
1466
- }
1467
-
1468
- if (dirty & /*ticksX*/ 16 && line1_x__value !== (line1_x__value = /*tx*/ ctx[26])) {
1469
- attr(line1, "x1", line1_x__value);
1470
- }
1471
-
1472
- if (dirty & /*ticksX*/ 16 && line1_x__value_1 !== (line1_x__value_1 = /*tx*/ ctx[26])) {
1473
- attr(line1, "x2", line1_x__value_1);
1474
- }
1475
-
1476
- if (dirty & /*ticksY*/ 8 && line1_y__value !== (line1_y__value = /*ticksY*/ ctx[3][0])) {
1477
- attr(line1, "y1", line1_y__value);
1478
- }
1479
-
1480
- if (dirty & /*ticksY*/ 8 && line1_y__value_1 !== (line1_y__value_1 = /*ticksY*/ ctx[3][1])) {
1481
- attr(line1, "y2", line1_y__value_1);
1482
- }
1483
-
1484
- if (dirty & /*tickLabels*/ 1 && t_value !== (t_value = /*tickLabels*/ ctx[0][/*i*/ ctx[28]] + "")) set_data(t, t_value);
1485
-
1486
- if (dirty & /*ticksX*/ 16 && text_1_x_value !== (text_1_x_value = /*tx*/ ctx[26])) {
1487
- attr(text_1, "x", text_1_x_value);
1488
- }
1489
-
1490
- if (dirty & /*ticksY*/ 8 && text_1_y_value !== (text_1_y_value = /*ticksY*/ ctx[3][1])) {
1491
- attr(text_1, "y", text_1_y_value);
1492
- }
1493
-
1494
- if (dirty & /*dy*/ 2) {
1495
- attr(text_1, "dy", /*dy*/ ctx[1]);
1496
- }
1497
- },
1498
- d(detaching) {
1499
- if (detaching) detach(line0);
1500
- if (detaching) detach(line1);
1501
- if (detaching) detach(text_1);
1502
- }
1503
- };
1504
- }
1505
-
1506
- function create_fragment$a(ctx) {
1507
- let if_block_anchor;
1508
- let if_block = /*$isOk*/ ctx[6] && /*x*/ ctx[5] !== undefined && /*y*/ ctx[2] !== undefined && create_if_block$8(ctx);
1509
-
1510
- return {
1511
- c() {
1512
- if (if_block) if_block.c();
1513
- if_block_anchor = empty();
1514
- },
1515
- m(target, anchor) {
1516
- if (if_block) if_block.m(target, anchor);
1517
- insert(target, if_block_anchor, anchor);
1518
- },
1519
- p(ctx, [dirty]) {
1520
- if (/*$isOk*/ ctx[6] && /*x*/ ctx[5] !== undefined && /*y*/ ctx[2] !== undefined) {
1521
- if (if_block) {
1522
- if_block.p(ctx, dirty);
1523
- } else {
1524
- if_block = create_if_block$8(ctx);
1525
- if_block.c();
1526
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
1527
- }
1528
- } else if (if_block) {
1529
- if_block.d(1);
1530
- if_block = null;
1531
- }
1532
- },
1533
- i: noop,
1534
- o: noop,
1535
- d(detaching) {
1536
- if (if_block) if_block.d(detaching);
1537
- if (detaching) detach(if_block_anchor);
1538
- }
1539
- };
1540
- }
1541
-
1542
- function instance$a($$self, $$props, $$invalidate) {
1543
- let x;
1544
- let y;
1545
- let dy;
1546
- let tickNum;
1547
- let ticksX;
1548
- let ticksY;
1549
- let $axesWidth;
1550
- let $xLim;
1551
- let $scale;
1552
- let $axesHeight;
1553
- let $yLim;
1554
- let $isOk;
1555
- let { slot = "xaxis" } = $$props;
1556
- let { ticks = undefined } = $$props;
1557
- let { tickLabels = ticks } = $$props;
1558
- let { showGrid = false } = $$props;
1559
-
1560
- // set up tick mode
1561
- const tickMode = ticks === undefined ? "auto" : "manual";
1562
-
1563
- /* sanity checks of input parameters */
1564
- if (slot !== "xaxis") {
1565
- throw "Component XAxis must have \"slot='xaxis'\" attribute.";
1566
- }
1567
-
1568
- if (ticks !== undefined && !Array.isArray(ticks)) {
1569
- throw "XAxis: 'ticks' must be a vector of numbers.";
1570
- }
1571
-
1572
- if (ticks !== undefined && !(Array.isArray(tickLabels) && tickLabels.length == ticks.length)) {
1573
- throw "XAxis: 'tickLabels' must be a vector of the same size as ticks.";
1574
- }
1575
-
1576
- /* styles for axis and grid lines */
1577
- const axisLineStyleStr = `stroke:${Colors.DARKGRAY};line-width:1px;`;
1578
-
1579
- const gridLineStyleStr = `stroke:${Colors.MIDDLEGRAY};stroke-opacity:${showGrid ? 1 : 0};stroke-dasharray:2px;`;
1580
-
1581
- // get axes context and adjust x margins
1582
- const axes = getContext('axes');
1583
-
1584
- axes.addXAxisMargins();
1585
-
1586
- // get reactive variables needed to compute coordinates
1587
- const xLim = axes.xLim;
1588
-
1589
- component_subscribe($$self, xLim, value => $$invalidate(20, $xLim = value));
1590
- const yLim = axes.yLim;
1591
- component_subscribe($$self, yLim, value => $$invalidate(23, $yLim = value));
1592
- const axesWidth = axes.width;
1593
- component_subscribe($$self, axesWidth, value => $$invalidate(19, $axesWidth = value));
1594
- const axesHeight = axes.height;
1595
- component_subscribe($$self, axesHeight, value => $$invalidate(22, $axesHeight = value));
1596
- const scale = axes.scale;
1597
- component_subscribe($$self, scale, value => $$invalidate(21, $scale = value));
1598
- const isOk = axes.isOk;
1599
- component_subscribe($$self, isOk, value => $$invalidate(6, $isOk = value));
1600
-
1601
- $$self.$$set = $$props => {
1602
- if ('slot' in $$props) $$invalidate(16, slot = $$props.slot);
1603
- if ('ticks' in $$props) $$invalidate(15, ticks = $$props.ticks);
1604
- if ('tickLabels' in $$props) $$invalidate(0, tickLabels = $$props.tickLabels);
1605
- if ('showGrid' in $$props) $$invalidate(17, showGrid = $$props.showGrid);
1606
- };
1607
-
1608
- $$self.$$.update = () => {
1609
- if ($$self.$$.dirty & /*$xLim, $axesWidth*/ 1572864) {
1610
- // reactive variables for coordinates of axis lines
1611
- $$invalidate(5, x = axes.scaleX($xLim, $xLim, $axesWidth));
1612
- }
1613
-
1614
- if ($$self.$$.dirty & /*$yLim, $axesHeight*/ 12582912) {
1615
- $$invalidate(2, y = axes.scaleY($yLim, $yLim, $axesHeight));
1616
- }
1617
-
1618
- if ($$self.$$.dirty & /*$scale*/ 2097152) {
1619
- // reactive variables for ticks and their coordinates
1620
- $$invalidate(1, dy = $scale === "small" ? 7 : 10);
1621
- }
1622
-
1623
- if ($$self.$$.dirty & /*$scale*/ 2097152) {
1624
- $$invalidate(18, tickNum = axes.TICK_NUM[$scale]);
1625
- }
1626
-
1627
- if ($$self.$$.dirty & /*$xLim, tickNum, ticks*/ 1343488) {
1628
- $$invalidate(15, ticks = tickMode === "auto"
1629
- ? axes.getAxisTicks(undefined, $xLim, tickNum, true)
1630
- : ticks);
1631
- }
1632
-
1633
- if ($$self.$$.dirty & /*ticks, tickLabels*/ 32769) {
1634
- $$invalidate(0, tickLabels = tickMode === "auto" ? ticks : tickLabels);
1635
- }
1636
-
1637
- if ($$self.$$.dirty & /*ticks, $xLim, $axesWidth*/ 1605632) {
1638
- $$invalidate(4, ticksX = axes.scaleX(ticks, $xLim, $axesWidth));
1639
- }
1640
-
1641
- if ($$self.$$.dirty & /*y, dy*/ 6) {
1642
- $$invalidate(3, ticksY = y === undefined ? undefined : [y[0], y[0] + dy]);
1643
- }
1644
- };
1645
-
1646
- return [
1647
- tickLabels,
1648
- dy,
1649
- y,
1650
- ticksY,
1651
- ticksX,
1652
- x,
1653
- $isOk,
1654
- axisLineStyleStr,
1655
- gridLineStyleStr,
1656
- xLim,
1657
- yLim,
1658
- axesWidth,
1659
- axesHeight,
1660
- scale,
1661
- isOk,
1662
- ticks,
1663
- slot,
1664
- showGrid,
1665
- tickNum,
1666
- $axesWidth,
1667
- $xLim,
1668
- $scale,
1669
- $axesHeight,
1670
- $yLim
1671
- ];
1672
- }
1673
-
1674
- class XAxis extends SvelteComponent {
1675
- constructor(options) {
1676
- super();
1677
-
1678
- init(this, options, instance$a, create_fragment$a, safe_not_equal, {
1679
- slot: 16,
1680
- ticks: 15,
1681
- tickLabels: 0,
1682
- showGrid: 17
1683
- });
1684
- }
1685
- }
1686
-
1687
- /* src/YAxis.svelte generated by Svelte v3.50.1 */
1688
-
1689
- function get_each_context$4(ctx, list, i) {
1690
- const child_ctx = ctx.slice();
1691
- child_ctx[26] = list[i];
1692
- child_ctx[28] = i;
1693
- return child_ctx;
1694
- }
1695
-
1696
- // (60:0) {#if x !== undefined && y !== undefined }
1697
- function create_if_block$7(ctx) {
1698
- let g;
1699
- let line;
1700
- let line_x__value;
1701
- let line_x__value_1;
1702
- let line_y__value;
1703
- let line_y__value_1;
1704
- let each_value = /*ticksY*/ ctx[4];
1705
- let each_blocks = [];
1706
-
1707
- for (let i = 0; i < each_value.length; i += 1) {
1708
- each_blocks[i] = create_each_block$4(get_each_context$4(ctx, each_value, i));
1709
- }
1710
-
1711
- return {
1712
- c() {
1713
- g = svg_element("g");
1714
-
1715
- for (let i = 0; i < each_blocks.length; i += 1) {
1716
- each_blocks[i].c();
1717
- }
1718
-
1719
- line = svg_element("line");
1720
- attr(line, "x1", line_x__value = /*x*/ ctx[1][0]);
1721
- attr(line, "x2", line_x__value_1 = /*x*/ ctx[1][0]);
1722
- attr(line, "y1", line_y__value = /*y*/ ctx[5][0]);
1723
- attr(line, "y2", line_y__value_1 = /*y*/ ctx[5][1]);
1724
- attr(line, "style", /*axisLineStyleStr*/ ctx[7]);
1725
- attr(g, "class", "mdaplot__axis mdaplot__yaxis");
1726
- },
1727
- m(target, anchor) {
1728
- insert(target, g, anchor);
1729
-
1730
- for (let i = 0; i < each_blocks.length; i += 1) {
1731
- each_blocks[i].m(g, null);
1732
- }
1733
-
1734
- append(g, line);
1735
- },
1736
- p(ctx, dirty) {
1737
- if (dirty & /*ticksX, ticksY, dx, transform, tickLabels, axisLineStyleStr, x, gridLineStyleStr*/ 479) {
1738
- each_value = /*ticksY*/ ctx[4];
1739
- let i;
1740
-
1741
- for (i = 0; i < each_value.length; i += 1) {
1742
- const child_ctx = get_each_context$4(ctx, each_value, i);
1743
-
1744
- if (each_blocks[i]) {
1745
- each_blocks[i].p(child_ctx, dirty);
1746
- } else {
1747
- each_blocks[i] = create_each_block$4(child_ctx);
1748
- each_blocks[i].c();
1749
- each_blocks[i].m(g, line);
1750
- }
1751
- }
1752
-
1753
- for (; i < each_blocks.length; i += 1) {
1754
- each_blocks[i].d(1);
1755
- }
1756
-
1757
- each_blocks.length = each_value.length;
1758
- }
1759
-
1760
- if (dirty & /*x*/ 2 && line_x__value !== (line_x__value = /*x*/ ctx[1][0])) {
1761
- attr(line, "x1", line_x__value);
1762
- }
1763
-
1764
- if (dirty & /*x*/ 2 && line_x__value_1 !== (line_x__value_1 = /*x*/ ctx[1][0])) {
1765
- attr(line, "x2", line_x__value_1);
1766
- }
1767
-
1768
- if (dirty & /*y*/ 32 && line_y__value !== (line_y__value = /*y*/ ctx[5][0])) {
1769
- attr(line, "y1", line_y__value);
1770
- }
1771
-
1772
- if (dirty & /*y*/ 32 && line_y__value_1 !== (line_y__value_1 = /*y*/ ctx[5][1])) {
1773
- attr(line, "y2", line_y__value_1);
1774
- }
1775
- },
1776
- d(detaching) {
1777
- if (detaching) detach(g);
1778
- destroy_each(each_blocks, detaching);
1779
- }
1780
- };
1781
- }
1782
-
1783
- // (62:3) {#each ticksY as ty, i}
1784
- function create_each_block$4(ctx) {
1785
- let line0;
1786
- let line0_x__value;
1787
- let line0_x__value_1;
1788
- let line0_y__value;
1789
- let line0_y__value_1;
1790
- let line1;
1791
- let line1_x__value;
1792
- let line1_x__value_1;
1793
- let line1_y__value;
1794
- let line1_y__value_1;
1795
- let text_1;
1796
- let t_value = /*tickLabels*/ ctx[0][/*i*/ ctx[28]] + "";
1797
- let t;
1798
- let text_1_x_value;
1799
- let text_1_y_value;
1800
-
1801
- return {
1802
- c() {
1803
- line0 = svg_element("line");
1804
- line1 = svg_element("line");
1805
- text_1 = svg_element("text");
1806
- t = text(t_value);
1807
- attr(line0, "x1", line0_x__value = /*x*/ ctx[1][0]);
1808
- attr(line0, "x2", line0_x__value_1 = /*x*/ ctx[1][1]);
1809
- attr(line0, "y1", line0_y__value = /*ty*/ ctx[26]);
1810
- attr(line0, "y2", line0_y__value_1 = /*ty*/ ctx[26]);
1811
- attr(line0, "style", /*gridLineStyleStr*/ ctx[8]);
1812
- attr(line1, "x1", line1_x__value = /*ticksX*/ ctx[3][0]);
1813
- attr(line1, "x2", line1_x__value_1 = /*ticksX*/ ctx[3][1]);
1814
- attr(line1, "y1", line1_y__value = /*ty*/ ctx[26]);
1815
- attr(line1, "y2", line1_y__value_1 = /*ty*/ ctx[26]);
1816
- attr(line1, "style", /*axisLineStyleStr*/ ctx[7]);
1817
- attr(text_1, "x", text_1_x_value = /*ticksX*/ ctx[3][0]);
1818
- attr(text_1, "y", text_1_y_value = /*ty*/ ctx[26]);
1819
- attr(text_1, "dx", /*dx*/ ctx[2]);
1820
- attr(text_1, "dy", 0);
1821
- attr(text_1, "transform", /*transform*/ ctx[6]);
1822
- set_style(text_1, "background", "red");
1823
- attr(text_1, "class", "mdaplot__axis-labels");
1824
- attr(text_1, "dominant-baseline", "middle");
1825
- attr(text_1, "text-anchor", "end");
1826
- },
1827
- m(target, anchor) {
1828
- insert(target, line0, anchor);
1829
- insert(target, line1, anchor);
1830
- insert(target, text_1, anchor);
1831
- append(text_1, t);
1832
- },
1833
- p(ctx, dirty) {
1834
- if (dirty & /*x*/ 2 && line0_x__value !== (line0_x__value = /*x*/ ctx[1][0])) {
1835
- attr(line0, "x1", line0_x__value);
1836
- }
1837
-
1838
- if (dirty & /*x*/ 2 && line0_x__value_1 !== (line0_x__value_1 = /*x*/ ctx[1][1])) {
1839
- attr(line0, "x2", line0_x__value_1);
1840
- }
1841
-
1842
- if (dirty & /*ticksY*/ 16 && line0_y__value !== (line0_y__value = /*ty*/ ctx[26])) {
1843
- attr(line0, "y1", line0_y__value);
1844
- }
1845
-
1846
- if (dirty & /*ticksY*/ 16 && line0_y__value_1 !== (line0_y__value_1 = /*ty*/ ctx[26])) {
1847
- attr(line0, "y2", line0_y__value_1);
1848
- }
1849
-
1850
- if (dirty & /*ticksX*/ 8 && line1_x__value !== (line1_x__value = /*ticksX*/ ctx[3][0])) {
1851
- attr(line1, "x1", line1_x__value);
1852
- }
1853
-
1854
- if (dirty & /*ticksX*/ 8 && line1_x__value_1 !== (line1_x__value_1 = /*ticksX*/ ctx[3][1])) {
1855
- attr(line1, "x2", line1_x__value_1);
1856
- }
1857
-
1858
- if (dirty & /*ticksY*/ 16 && line1_y__value !== (line1_y__value = /*ty*/ ctx[26])) {
1859
- attr(line1, "y1", line1_y__value);
1860
- }
1861
-
1862
- if (dirty & /*ticksY*/ 16 && line1_y__value_1 !== (line1_y__value_1 = /*ty*/ ctx[26])) {
1863
- attr(line1, "y2", line1_y__value_1);
1864
- }
1865
-
1866
- if (dirty & /*tickLabels*/ 1 && t_value !== (t_value = /*tickLabels*/ ctx[0][/*i*/ ctx[28]] + "")) set_data(t, t_value);
1867
-
1868
- if (dirty & /*ticksX*/ 8 && text_1_x_value !== (text_1_x_value = /*ticksX*/ ctx[3][0])) {
1869
- attr(text_1, "x", text_1_x_value);
1870
- }
1871
-
1872
- if (dirty & /*ticksY*/ 16 && text_1_y_value !== (text_1_y_value = /*ty*/ ctx[26])) {
1873
- attr(text_1, "y", text_1_y_value);
1874
- }
1875
-
1876
- if (dirty & /*dx*/ 4) {
1877
- attr(text_1, "dx", /*dx*/ ctx[2]);
1878
- }
1879
- },
1880
- d(detaching) {
1881
- if (detaching) detach(line0);
1882
- if (detaching) detach(line1);
1883
- if (detaching) detach(text_1);
1884
- }
1885
- };
1886
- }
1887
-
1888
- function create_fragment$9(ctx) {
1889
- let if_block_anchor;
1890
- let if_block = /*x*/ ctx[1] !== undefined && /*y*/ ctx[5] !== undefined && create_if_block$7(ctx);
1891
-
1892
- return {
1893
- c() {
1894
- if (if_block) if_block.c();
1895
- if_block_anchor = empty();
1896
- },
1897
- m(target, anchor) {
1898
- if (if_block) if_block.m(target, anchor);
1899
- insert(target, if_block_anchor, anchor);
1900
- },
1901
- p(ctx, [dirty]) {
1902
- if (/*x*/ ctx[1] !== undefined && /*y*/ ctx[5] !== undefined) {
1903
- if (if_block) {
1904
- if_block.p(ctx, dirty);
1905
- } else {
1906
- if_block = create_if_block$7(ctx);
1907
- if_block.c();
1908
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
1909
- }
1910
- } else if (if_block) {
1911
- if_block.d(1);
1912
- if_block = null;
1913
- }
1914
- },
1915
- i: noop,
1916
- o: noop,
1917
- d(detaching) {
1918
- if (if_block) if_block.d(detaching);
1919
- if (detaching) detach(if_block_anchor);
1920
- }
1921
- };
1922
- }
1923
-
1924
- function instance$9($$self, $$props, $$invalidate) {
1925
- let x;
1926
- let y;
1927
- let dx;
1928
- let tickNum;
1929
- let ticksY;
1930
- let ticksX;
1931
- let $axesHeight;
1932
- let $yLim;
1933
- let $scale;
1934
- let $axesWidth;
1935
- let $xLim;
1936
- let { slot = "yaxis" } = $$props;
1937
- let { ticks = undefined } = $$props;
1938
- let { tickLabels = ticks } = $$props;
1939
- let { showGrid = false } = $$props;
1940
- let { las = 1 } = $$props;
1941
-
1942
- // set up tick mode
1943
- const tickMode = ticks === undefined ? "auto" : "manual";
1944
-
1945
- // TODO: set up tick text translation
1946
- const transform = las > 1 ? "" : "";
1947
-
1948
- /* sanity checks of input parameters */
1949
- if (slot !== "yaxis") {
1950
- throw "Component YAxis must have \"slot='yaxis'\" attribute.";
1951
- }
1952
-
1953
- if (ticks !== undefined && !Array.isArray(ticks)) {
1954
- throw "YAxis: 'ticks' must be a vector of numbers.";
1955
- }
1956
-
1957
- if (ticks !== undefined && !(Array.isArray(tickLabels) && tickLabels.length == ticks.length)) {
1958
- throw "YAxis: 'tickLabels' must be a vector of the same size as ticks.";
1959
- }
1960
-
1961
- /* styles for axis and grid lines */
1962
- const axisLineStyleStr = `stroke:${Colors.DARKGRAY};line-width:1px;`;
1963
-
1964
- const gridLineStyleStr = `stroke:${Colors.MIDDLEGRAY};stroke-opacity:${showGrid ? 1 : 0};stroke-dasharray:2px;`;
1965
-
1966
- // get axes context and adjust x margins
1967
- const axes = getContext('axes');
1968
-
1969
- axes.addYAxisMargins();
1970
-
1971
- // get reactive variables needed to compute coordinates
1972
- const xLim = axes.xLim;
1973
-
1974
- component_subscribe($$self, xLim, value => $$invalidate(23, $xLim = value));
1975
- const yLim = axes.yLim;
1976
- component_subscribe($$self, yLim, value => $$invalidate(20, $yLim = value));
1977
- const axesWidth = axes.width;
1978
- component_subscribe($$self, axesWidth, value => $$invalidate(22, $axesWidth = value));
1979
- const axesHeight = axes.height;
1980
- component_subscribe($$self, axesHeight, value => $$invalidate(19, $axesHeight = value));
1981
- const scale = axes.scale;
1982
- component_subscribe($$self, scale, value => $$invalidate(21, $scale = value));
1983
-
1984
- $$self.$$set = $$props => {
1985
- if ('slot' in $$props) $$invalidate(15, slot = $$props.slot);
1986
- if ('ticks' in $$props) $$invalidate(14, ticks = $$props.ticks);
1987
- if ('tickLabels' in $$props) $$invalidate(0, tickLabels = $$props.tickLabels);
1988
- if ('showGrid' in $$props) $$invalidate(16, showGrid = $$props.showGrid);
1989
- if ('las' in $$props) $$invalidate(17, las = $$props.las);
1990
- };
1991
-
1992
- $$self.$$.update = () => {
1993
- if ($$self.$$.dirty & /*$xLim, $axesWidth*/ 12582912) {
1994
- // reactive variables for coordinates of axis lines
1995
- $$invalidate(1, x = axes.scaleX($xLim, $xLim, $axesWidth));
1996
- }
1997
-
1998
- if ($$self.$$.dirty & /*$yLim, $axesHeight*/ 1572864) {
1999
- $$invalidate(5, y = axes.scaleY($yLim, $yLim, $axesHeight));
2000
- }
2001
-
2002
- if ($$self.$$.dirty & /*$scale*/ 2097152) {
2003
- // reactive variables for ticks and their coordinates
2004
- $$invalidate(2, dx = $scale === "small" ? -4 : -6);
2005
- }
2006
-
2007
- if ($$self.$$.dirty & /*$scale*/ 2097152) {
2008
- $$invalidate(18, tickNum = axes.TICK_NUM[$scale]);
2009
- }
2010
-
2011
- if ($$self.$$.dirty & /*$yLim, tickNum, ticks*/ 1327104) {
2012
- $$invalidate(14, ticks = tickMode === "auto"
2013
- ? axes.getAxisTicks(undefined, $yLim, tickNum, true)
2014
- : ticks);
2015
- }
2016
-
2017
- if ($$self.$$.dirty & /*ticks, tickLabels*/ 16385) {
2018
- $$invalidate(0, tickLabels = tickMode === "auto" ? ticks : tickLabels);
2019
- }
2020
-
2021
- if ($$self.$$.dirty & /*ticks, $yLim, $axesHeight*/ 1589248) {
2022
- $$invalidate(4, ticksY = axes.scaleY(ticks, $yLim, $axesHeight));
2023
- }
2024
-
2025
- if ($$self.$$.dirty & /*x, dx*/ 6) {
2026
- $$invalidate(3, ticksX = x === undefined ? undefined : [x[0] + dx, x[0]]);
2027
- }
2028
- };
2029
-
2030
- return [
2031
- tickLabels,
2032
- x,
2033
- dx,
2034
- ticksX,
2035
- ticksY,
2036
- y,
2037
- transform,
2038
- axisLineStyleStr,
2039
- gridLineStyleStr,
2040
- xLim,
2041
- yLim,
2042
- axesWidth,
2043
- axesHeight,
2044
- scale,
2045
- ticks,
2046
- slot,
2047
- showGrid,
2048
- las,
2049
- tickNum,
2050
- $axesHeight,
2051
- $yLim,
2052
- $scale,
2053
- $axesWidth,
2054
- $xLim
2055
- ];
2056
- }
2057
-
2058
- class YAxis extends SvelteComponent {
2059
- constructor(options) {
2060
- super();
2061
-
2062
- init(this, options, instance$9, create_fragment$9, safe_not_equal, {
2063
- slot: 15,
2064
- ticks: 14,
2065
- tickLabels: 0,
2066
- showGrid: 16,
2067
- las: 17
2068
- });
2069
- }
2070
- }
2071
-
2072
- /* src/Rectangles.svelte generated by Svelte v3.50.1 */
2073
-
2074
- function get_each_context$3(ctx, list, i) {
2075
- const child_ctx = ctx.slice();
2076
- child_ctx[25] = list[i];
2077
- child_ctx[27] = i;
2078
- return child_ctx;
2079
- }
2080
-
2081
- // (55:0) {#if rx !== undefined && ry !== undefined}
2082
- function create_if_block$6(ctx) {
2083
- let g;
2084
- let g_class_value;
2085
- let each_value = /*left*/ ctx[0];
2086
- let each_blocks = [];
2087
-
2088
- for (let i = 0; i < each_value.length; i += 1) {
2089
- each_blocks[i] = create_each_block$3(get_each_context$3(ctx, each_value, i));
2090
- }
2091
-
2092
- return {
2093
- c() {
2094
- g = svg_element("g");
2095
-
2096
- for (let i = 0; i < each_blocks.length; i += 1) {
2097
- each_blocks[i].c();
2098
- }
2099
-
2100
- attr(g, "class", g_class_value = "series " + /*style*/ ctx[2]);
2101
- attr(g, "title", /*title*/ ctx[1]);
2102
- attr(g, "style", /*barsStyleStr*/ ctx[3]);
2103
- },
2104
- m(target, anchor) {
2105
- insert(target, g, anchor);
2106
-
2107
- for (let i = 0; i < each_blocks.length; i += 1) {
2108
- each_blocks[i].m(g, null);
2109
- }
2110
- },
2111
- p(ctx, dirty) {
2112
- if (dirty & /*rx, ry, rw, rh, left*/ 241) {
2113
- each_value = /*left*/ ctx[0];
2114
- let i;
2115
-
2116
- for (i = 0; i < each_value.length; i += 1) {
2117
- const child_ctx = get_each_context$3(ctx, each_value, i);
2118
-
2119
- if (each_blocks[i]) {
2120
- each_blocks[i].p(child_ctx, dirty);
2121
- } else {
2122
- each_blocks[i] = create_each_block$3(child_ctx);
2123
- each_blocks[i].c();
2124
- each_blocks[i].m(g, null);
2125
- }
2126
- }
2127
-
2128
- for (; i < each_blocks.length; i += 1) {
2129
- each_blocks[i].d(1);
2130
- }
2131
-
2132
- each_blocks.length = each_value.length;
2133
- }
2134
-
2135
- if (dirty & /*style*/ 4 && g_class_value !== (g_class_value = "series " + /*style*/ ctx[2])) {
2136
- attr(g, "class", g_class_value);
2137
- }
2138
-
2139
- if (dirty & /*title*/ 2) {
2140
- attr(g, "title", /*title*/ ctx[1]);
2141
- }
2142
-
2143
- if (dirty & /*barsStyleStr*/ 8) {
2144
- attr(g, "style", /*barsStyleStr*/ ctx[3]);
2145
- }
2146
- },
2147
- d(detaching) {
2148
- if (detaching) detach(g);
2149
- destroy_each(each_blocks, detaching);
2150
- }
2151
- };
2152
- }
2153
-
2154
- // (57:3) {#each left as v, i}
2155
- function create_each_block$3(ctx) {
2156
- let rect;
2157
- let rect_x_value;
2158
- let rect_y_value;
2159
- let rect_width_value;
2160
- let rect_height_value;
2161
-
2162
- return {
2163
- c() {
2164
- rect = svg_element("rect");
2165
- attr(rect, "x", rect_x_value = /*rx*/ ctx[7][/*i*/ ctx[27]]);
2166
- attr(rect, "y", rect_y_value = /*ry*/ ctx[6][/*i*/ ctx[27]]);
2167
- attr(rect, "width", rect_width_value = /*rw*/ ctx[5][/*i*/ ctx[27]]);
2168
- attr(rect, "height", rect_height_value = /*rh*/ ctx[4][/*i*/ ctx[27]]);
2169
- },
2170
- m(target, anchor) {
2171
- insert(target, rect, anchor);
2172
- },
2173
- p(ctx, dirty) {
2174
- if (dirty & /*rx*/ 128 && rect_x_value !== (rect_x_value = /*rx*/ ctx[7][/*i*/ ctx[27]])) {
2175
- attr(rect, "x", rect_x_value);
2176
- }
2177
-
2178
- if (dirty & /*ry*/ 64 && rect_y_value !== (rect_y_value = /*ry*/ ctx[6][/*i*/ ctx[27]])) {
2179
- attr(rect, "y", rect_y_value);
2180
- }
2181
-
2182
- if (dirty & /*rw*/ 32 && rect_width_value !== (rect_width_value = /*rw*/ ctx[5][/*i*/ ctx[27]])) {
2183
- attr(rect, "width", rect_width_value);
2184
- }
2185
-
2186
- if (dirty & /*rh*/ 16 && rect_height_value !== (rect_height_value = /*rh*/ ctx[4][/*i*/ ctx[27]])) {
2187
- attr(rect, "height", rect_height_value);
2188
- }
2189
- },
2190
- d(detaching) {
2191
- if (detaching) detach(rect);
2192
- }
2193
- };
2194
- }
2195
-
2196
- function create_fragment$8(ctx) {
2197
- let if_block_anchor;
2198
- let if_block = /*rx*/ ctx[7] !== undefined && /*ry*/ ctx[6] !== undefined && create_if_block$6(ctx);
2199
-
2200
- return {
2201
- c() {
2202
- if (if_block) if_block.c();
2203
- if_block_anchor = empty();
2204
- },
2205
- m(target, anchor) {
2206
- if (if_block) if_block.m(target, anchor);
2207
- insert(target, if_block_anchor, anchor);
2208
- },
2209
- p(ctx, [dirty]) {
2210
- if (/*rx*/ ctx[7] !== undefined && /*ry*/ ctx[6] !== undefined) {
2211
- if (if_block) {
2212
- if_block.p(ctx, dirty);
2213
- } else {
2214
- if_block = create_if_block$6(ctx);
2215
- if_block.c();
2216
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
2217
- }
2218
- } else if (if_block) {
2219
- if_block.d(1);
2220
- if_block = null;
2221
- }
2222
- },
2223
- i: noop,
2224
- o: noop,
2225
- d(detaching) {
2226
- if (if_block) if_block.d(detaching);
2227
- if (detaching) detach(if_block_anchor);
2228
- }
2229
- };
2230
- }
2231
-
2232
- function instance$8($$self, $$props, $$invalidate) {
2233
- let rx;
2234
- let ry;
2235
- let rw;
2236
- let rh;
2237
- let barsStyleStr;
2238
- let $axesHeight;
2239
- let $yLim;
2240
- let $axesWidth;
2241
- let $xLim;
2242
- let { left } = $$props;
2243
- let { top } = $$props;
2244
- let { width } = $$props;
2245
- let { height } = $$props;
2246
- let { labels = undefined } = $$props;
2247
- let { faceColor = Colors.PRIMARY } = $$props;
2248
- let { borderColor = faceColor } = $$props;
2249
- let { lineWidth = 1 } = $$props;
2250
- let { title = "" } = $$props;
2251
- let { style = "series_rect" } = $$props;
2252
-
2253
- // multiply width and height values if needed
2254
- if (!Array.isArray(left) || !Array.isArray(top) || left.length < 1 || left.length != top.length) {
2255
- throw "Rectangles: parameters 'left' and 'top' must be vectors of the same size.";
2256
- }
2257
-
2258
- // we make this reactive in case if left and right has been changed but not width
2259
- const n = left.length;
2260
-
2261
- if (!Array.isArray(height)) height = Array(n).fill(height);
2262
- if (!Array.isArray(width)) width = Array(n).fill(width);
2263
-
2264
- /* sanity check for input parameters */
2265
- if (top.length !== n || width.length !== n || height.length !== n) {
2266
- throw "Rectangles: x, y, w and h should have the same length (w and h can be single values).";
2267
- }
2268
-
2269
- if (labels !== undefined && (!Array.isArray(labels) || labels.length !== n)) {
2270
- throw "Rectangles: vector with labels should have the same length as vectors with x and y coordinates.";
2271
- }
2272
-
2273
- // get axes context and reactive variables needed to compute coordinates
2274
- const axes = getContext('axes');
2275
-
2276
- const xLim = axes.xLim;
2277
- component_subscribe($$self, xLim, value => $$invalidate(22, $xLim = value));
2278
- const yLim = axes.yLim;
2279
- component_subscribe($$self, yLim, value => $$invalidate(20, $yLim = value));
2280
- const axesWidth = axes.width;
2281
- component_subscribe($$self, axesWidth, value => $$invalidate(21, $axesWidth = value));
2282
- const axesHeight = axes.height;
2283
- component_subscribe($$self, axesHeight, value => $$invalidate(19, $axesHeight = value));
2284
-
2285
- $$self.$$set = $$props => {
2286
- if ('left' in $$props) $$invalidate(0, left = $$props.left);
2287
- if ('top' in $$props) $$invalidate(14, top = $$props.top);
2288
- if ('width' in $$props) $$invalidate(12, width = $$props.width);
2289
- if ('height' in $$props) $$invalidate(13, height = $$props.height);
2290
- if ('labels' in $$props) $$invalidate(15, labels = $$props.labels);
2291
- if ('faceColor' in $$props) $$invalidate(16, faceColor = $$props.faceColor);
2292
- if ('borderColor' in $$props) $$invalidate(17, borderColor = $$props.borderColor);
2293
- if ('lineWidth' in $$props) $$invalidate(18, lineWidth = $$props.lineWidth);
2294
- if ('title' in $$props) $$invalidate(1, title = $$props.title);
2295
- if ('style' in $$props) $$invalidate(2, style = $$props.style);
2296
- };
2297
-
2298
- $$self.$$.update = () => {
2299
- if ($$self.$$.dirty & /*left, $xLim, $axesWidth*/ 6291457) {
2300
- // reactive variables for coordinates of data points in pixels
2301
- $$invalidate(7, rx = axes.scaleX(left, $xLim, $axesWidth));
2302
- }
2303
-
2304
- if ($$self.$$.dirty & /*top, $yLim, $axesHeight*/ 1589248) {
2305
- $$invalidate(6, ry = axes.scaleY(top, $yLim, $axesHeight));
2306
- }
2307
-
2308
- if ($$self.$$.dirty & /*width, $xLim, $axesWidth*/ 6295552) {
2309
- $$invalidate(5, rw = axes.scaleX(width, $xLim, $axesWidth, true));
2310
- }
2311
-
2312
- if ($$self.$$.dirty & /*height, $yLim, $axesHeight*/ 1581056) {
2313
- $$invalidate(4, rh = axes.scaleY(height, $yLim, $axesHeight, true));
2314
- }
2315
-
2316
- if ($$self.$$.dirty & /*faceColor, borderColor, lineWidth*/ 458752) {
2317
- // styles for bars and labels
2318
- $$invalidate(3, barsStyleStr = `fill:${faceColor};stroke:${borderColor};stroke-width: ${lineWidth}px;`);
2319
- }
2320
- };
2321
-
2322
- return [
2323
- left,
2324
- title,
2325
- style,
2326
- barsStyleStr,
2327
- rh,
2328
- rw,
2329
- ry,
2330
- rx,
2331
- xLim,
2332
- yLim,
2333
- axesWidth,
2334
- axesHeight,
2335
- width,
2336
- height,
2337
- top,
2338
- labels,
2339
- faceColor,
2340
- borderColor,
2341
- lineWidth,
2342
- $axesHeight,
2343
- $yLim,
2344
- $axesWidth,
2345
- $xLim
2346
- ];
2347
- }
2348
-
2349
- class Rectangles extends SvelteComponent {
2350
- constructor(options) {
2351
- super();
2352
-
2353
- init(this, options, instance$8, create_fragment$8, safe_not_equal, {
2354
- left: 0,
2355
- top: 14,
2356
- width: 12,
2357
- height: 13,
2358
- labels: 15,
2359
- faceColor: 16,
2360
- borderColor: 17,
2361
- lineWidth: 18,
2362
- title: 1,
2363
- style: 2
2364
- });
2365
- }
2366
- }
2367
-
2368
- /* src/Box.svelte generated by Svelte v3.50.1 */
2369
-
2370
- function create_if_block$5(ctx) {
2371
- let g;
2372
- let rectangles;
2373
- let current;
2374
-
2375
- rectangles = new Rectangles({
2376
- props: {
2377
- left: /*left*/ ctx[3],
2378
- top: /*top*/ ctx[2],
2379
- width: /*width*/ ctx[1],
2380
- height: /*height*/ ctx[0],
2381
- borderColor: Colors.DARKGRAY,
2382
- faceColor: "transparent"
2383
- }
2384
- });
2385
-
2386
- return {
2387
- c() {
2388
- g = svg_element("g");
2389
- create_component(rectangles.$$.fragment);
2390
- set_style(g, "pointer-events", "none");
2391
- attr(g, "class", "mdaplot__axes-box");
2392
- },
2393
- m(target, anchor) {
2394
- insert(target, g, anchor);
2395
- mount_component(rectangles, g, null);
2396
- current = true;
2397
- },
2398
- p(ctx, dirty) {
2399
- const rectangles_changes = {};
2400
- if (dirty & /*left*/ 8) rectangles_changes.left = /*left*/ ctx[3];
2401
- if (dirty & /*top*/ 4) rectangles_changes.top = /*top*/ ctx[2];
2402
- if (dirty & /*width*/ 2) rectangles_changes.width = /*width*/ ctx[1];
2403
- if (dirty & /*height*/ 1) rectangles_changes.height = /*height*/ ctx[0];
2404
- rectangles.$set(rectangles_changes);
2405
- },
2406
- i(local) {
2407
- if (current) return;
2408
- transition_in(rectangles.$$.fragment, local);
2409
- current = true;
2410
- },
2411
- o(local) {
2412
- transition_out(rectangles.$$.fragment, local);
2413
- current = false;
2414
- },
2415
- d(detaching) {
2416
- if (detaching) detach(g);
2417
- destroy_component(rectangles);
2418
- }
2419
- };
2420
- }
2421
-
2422
- function create_fragment$7(ctx) {
2423
- let if_block_anchor;
2424
- let current;
2425
- let if_block = /*$isOk*/ ctx[4] && create_if_block$5(ctx);
2426
-
2427
- return {
2428
- c() {
2429
- if (if_block) if_block.c();
2430
- if_block_anchor = empty();
2431
- },
2432
- m(target, anchor) {
2433
- if (if_block) if_block.m(target, anchor);
2434
- insert(target, if_block_anchor, anchor);
2435
- current = true;
2436
- },
2437
- p(ctx, [dirty]) {
2438
- if (/*$isOk*/ ctx[4]) {
2439
- if (if_block) {
2440
- if_block.p(ctx, dirty);
2441
-
2442
- if (dirty & /*$isOk*/ 16) {
2443
- transition_in(if_block, 1);
2444
- }
2445
- } else {
2446
- if_block = create_if_block$5(ctx);
2447
- if_block.c();
2448
- transition_in(if_block, 1);
2449
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
2450
- }
2451
- } else if (if_block) {
2452
- group_outros();
2453
-
2454
- transition_out(if_block, 1, 1, () => {
2455
- if_block = null;
2456
- });
2457
-
2458
- check_outros();
2459
- }
2460
- },
2461
- i(local) {
2462
- if (current) return;
2463
- transition_in(if_block);
2464
- current = true;
2465
- },
2466
- o(local) {
2467
- transition_out(if_block);
2468
- current = false;
2469
- },
2470
- d(detaching) {
2471
- if (if_block) if_block.d(detaching);
2472
- if (detaching) detach(if_block_anchor);
2473
- }
2474
- };
2475
- }
2476
-
2477
- function instance$7($$self, $$props, $$invalidate) {
2478
- let left;
2479
- let top;
2480
- let width;
2481
- let height;
2482
- let $yLim;
2483
- let $xLim;
2484
- let $isOk;
2485
- let { slot } = $$props;
2486
-
2487
- // check that the box is located in a correct slot
2488
- if (slot !== "box") {
2489
- throw "Component Box must have \"slot='box'\" attribute.";
2490
- }
2491
-
2492
- // get axes context and reactive variables needed to compute coordinates
2493
- const axes = getContext('axes');
2494
-
2495
- const xLim = axes.xLim;
2496
- component_subscribe($$self, xLim, value => $$invalidate(10, $xLim = value));
2497
- const yLim = axes.yLim;
2498
- component_subscribe($$self, yLim, value => $$invalidate(9, $yLim = value));
2499
- const isOk = axes.isOk;
2500
- component_subscribe($$self, isOk, value => $$invalidate(4, $isOk = value));
2501
-
2502
- $$self.$$set = $$props => {
2503
- if ('slot' in $$props) $$invalidate(8, slot = $$props.slot);
2504
- };
2505
-
2506
- $$self.$$.update = () => {
2507
- if ($$self.$$.dirty & /*$xLim*/ 1024) {
2508
- // reactive variables for coordinates of box points in pixels
2509
- $$invalidate(3, left = [$xLim[0]]);
2510
- }
2511
-
2512
- if ($$self.$$.dirty & /*$yLim*/ 512) {
2513
- $$invalidate(2, top = [$yLim[1]]);
2514
- }
2515
-
2516
- if ($$self.$$.dirty & /*$xLim*/ 1024) {
2517
- $$invalidate(1, width = [$xLim[1] - $xLim[0]]);
2518
- }
2519
-
2520
- if ($$self.$$.dirty & /*$yLim*/ 512) {
2521
- $$invalidate(0, height = [$yLim[1] - $yLim[0]]);
2522
- }
2523
- };
2524
-
2525
- return [height, width, top, left, $isOk, xLim, yLim, isOk, slot, $yLim, $xLim];
2526
- }
2527
-
2528
- class Box extends SvelteComponent {
2529
- constructor(options) {
2530
- super();
2531
- init(this, options, instance$7, create_fragment$7, safe_not_equal, { slot: 8 });
2532
- }
2533
- }
2534
-
2535
- /* src/Segments.svelte generated by Svelte v3.50.1 */
2536
-
2537
- function get_each_context$2(ctx, list, i) {
2538
- const child_ctx = ctx.slice();
2539
- child_ctx[24] = list[i];
2540
- child_ctx[26] = i;
2541
- return child_ctx;
2542
- }
2543
-
2544
- // (41:0) {#if x1 !== undefined && y1 !== undefined}
2545
- function create_if_block$4(ctx) {
2546
- let each_1_anchor;
2547
- let each_value = /*x1*/ ctx[4];
2548
- let each_blocks = [];
2549
-
2550
- for (let i = 0; i < each_value.length; i += 1) {
2551
- each_blocks[i] = create_each_block$2(get_each_context$2(ctx, each_value, i));
2552
- }
2553
-
2554
- return {
2555
- c() {
2556
- for (let i = 0; i < each_blocks.length; i += 1) {
2557
- each_blocks[i].c();
2558
- }
2559
-
2560
- each_1_anchor = empty();
2561
- },
2562
- m(target, anchor) {
2563
- for (let i = 0; i < each_blocks.length; i += 1) {
2564
- each_blocks[i].m(target, anchor);
2565
- }
2566
-
2567
- insert(target, each_1_anchor, anchor);
2568
- },
2569
- p(ctx, dirty) {
2570
- if (dirty & /*x1, x2, y1, y2, lineStyleStr*/ 31) {
2571
- each_value = /*x1*/ ctx[4];
2572
- let i;
2573
-
2574
- for (i = 0; i < each_value.length; i += 1) {
2575
- const child_ctx = get_each_context$2(ctx, each_value, i);
2576
-
2577
- if (each_blocks[i]) {
2578
- each_blocks[i].p(child_ctx, dirty);
2579
- } else {
2580
- each_blocks[i] = create_each_block$2(child_ctx);
2581
- each_blocks[i].c();
2582
- each_blocks[i].m(each_1_anchor.parentNode, each_1_anchor);
2583
- }
2584
- }
2585
-
2586
- for (; i < each_blocks.length; i += 1) {
2587
- each_blocks[i].d(1);
2588
- }
2589
-
2590
- each_blocks.length = each_value.length;
2591
- }
2592
- },
2593
- d(detaching) {
2594
- destroy_each(each_blocks, detaching);
2595
- if (detaching) detach(each_1_anchor);
2596
- }
2597
- };
2598
- }
2599
-
2600
- // (42:3) {#each x1 as v, i}
2601
- function create_each_block$2(ctx) {
2602
- let line;
2603
- let line_x__value;
2604
- let line_x__value_1;
2605
- let line_y__value;
2606
- let line_y__value_1;
2607
-
2608
- return {
2609
- c() {
2610
- line = svg_element("line");
2611
- attr(line, "x1", line_x__value = /*x1*/ ctx[4][/*i*/ ctx[26]]);
2612
- attr(line, "x2", line_x__value_1 = /*x2*/ ctx[3][/*i*/ ctx[26]]);
2613
- attr(line, "y1", line_y__value = /*y1*/ ctx[2][/*i*/ ctx[26]]);
2614
- attr(line, "y2", line_y__value_1 = /*y2*/ ctx[1][/*i*/ ctx[26]]);
2615
- attr(line, "style", /*lineStyleStr*/ ctx[0]);
2616
- },
2617
- m(target, anchor) {
2618
- insert(target, line, anchor);
2619
- },
2620
- p(ctx, dirty) {
2621
- if (dirty & /*x1*/ 16 && line_x__value !== (line_x__value = /*x1*/ ctx[4][/*i*/ ctx[26]])) {
2622
- attr(line, "x1", line_x__value);
2623
- }
2624
-
2625
- if (dirty & /*x2*/ 8 && line_x__value_1 !== (line_x__value_1 = /*x2*/ ctx[3][/*i*/ ctx[26]])) {
2626
- attr(line, "x2", line_x__value_1);
2627
- }
2628
-
2629
- if (dirty & /*y1*/ 4 && line_y__value !== (line_y__value = /*y1*/ ctx[2][/*i*/ ctx[26]])) {
2630
- attr(line, "y1", line_y__value);
2631
- }
2632
-
2633
- if (dirty & /*y2*/ 2 && line_y__value_1 !== (line_y__value_1 = /*y2*/ ctx[1][/*i*/ ctx[26]])) {
2634
- attr(line, "y2", line_y__value_1);
2635
- }
2636
-
2637
- if (dirty & /*lineStyleStr*/ 1) {
2638
- attr(line, "style", /*lineStyleStr*/ ctx[0]);
2639
- }
2640
- },
2641
- d(detaching) {
2642
- if (detaching) detach(line);
2643
- }
2644
- };
2645
- }
2646
-
2647
- function create_fragment$6(ctx) {
2648
- let if_block_anchor;
2649
- let if_block = /*x1*/ ctx[4] !== undefined && /*y1*/ ctx[2] !== undefined && create_if_block$4(ctx);
2650
-
2651
- return {
2652
- c() {
2653
- if (if_block) if_block.c();
2654
- if_block_anchor = empty();
2655
- },
2656
- m(target, anchor) {
2657
- if (if_block) if_block.m(target, anchor);
2658
- insert(target, if_block_anchor, anchor);
2659
- },
2660
- p(ctx, [dirty]) {
2661
- if (/*x1*/ ctx[4] !== undefined && /*y1*/ ctx[2] !== undefined) {
2662
- if (if_block) {
2663
- if_block.p(ctx, dirty);
2664
- } else {
2665
- if_block = create_if_block$4(ctx);
2666
- if_block.c();
2667
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
2668
- }
2669
- } else if (if_block) {
2670
- if_block.d(1);
2671
- if_block = null;
2672
- }
2673
- },
2674
- i: noop,
2675
- o: noop,
2676
- d(detaching) {
2677
- if (if_block) if_block.d(detaching);
2678
- if (detaching) detach(if_block_anchor);
2679
- }
2680
- };
2681
- }
2682
-
2683
- function instance$6($$self, $$props, $$invalidate) {
2684
- let x1;
2685
- let x2;
2686
- let y1;
2687
- let y2;
2688
- let lineStyleStr;
2689
- let $scale;
2690
- let $axesHeight;
2691
- let $yLim;
2692
- let $axesWidth;
2693
- let $xLim;
2694
- let { xStart } = $$props;
2695
- let { xEnd } = $$props;
2696
- let { yStart } = $$props;
2697
- let { yEnd } = $$props;
2698
- let { lineColor = Colors.PRIMARY } = $$props;
2699
- let { lineType = 1 } = $$props;
2700
- let { lineWidth = 1 } = $$props;
2701
-
2702
- /* sanity check for input parameters */
2703
- if (!Array.isArray(xStart) || !Array.isArray(xEnd) || !Array.isArray(yStart) || !Array.isArray(yEnd)) {
2704
- throw "Segments: parameters 'xStart', 'yStart', 'xEnd' and 'yEnd' must be vectors.";
2705
- }
2706
-
2707
- const n = xStart.length;
2708
-
2709
- if (xEnd.length !== n || yStart.length !== n || yEnd.length !== n) {
2710
- throw "Segments: parameters 'xStart', 'yStart', 'xEnd' and 'yEnd' should have the same length.";
2711
- }
2712
-
2713
- // get axes context and reactive variables needed to compute coordinates
2714
- const axes = getContext('axes');
2715
-
2716
- const xLim = axes.xLim;
2717
- component_subscribe($$self, xLim, value => $$invalidate(21, $xLim = value));
2718
- const yLim = axes.yLim;
2719
- component_subscribe($$self, yLim, value => $$invalidate(19, $yLim = value));
2720
- const axesWidth = axes.width;
2721
- component_subscribe($$self, axesWidth, value => $$invalidate(20, $axesWidth = value));
2722
- const axesHeight = axes.height;
2723
- component_subscribe($$self, axesHeight, value => $$invalidate(18, $axesHeight = value));
2724
- const scale = axes.scale;
2725
- component_subscribe($$self, scale, value => $$invalidate(17, $scale = value));
2726
-
2727
- $$self.$$set = $$props => {
2728
- if ('xStart' in $$props) $$invalidate(10, xStart = $$props.xStart);
2729
- if ('xEnd' in $$props) $$invalidate(11, xEnd = $$props.xEnd);
2730
- if ('yStart' in $$props) $$invalidate(12, yStart = $$props.yStart);
2731
- if ('yEnd' in $$props) $$invalidate(13, yEnd = $$props.yEnd);
2732
- if ('lineColor' in $$props) $$invalidate(14, lineColor = $$props.lineColor);
2733
- if ('lineType' in $$props) $$invalidate(15, lineType = $$props.lineType);
2734
- if ('lineWidth' in $$props) $$invalidate(16, lineWidth = $$props.lineWidth);
2735
- };
2736
-
2737
- $$self.$$.update = () => {
2738
- if ($$self.$$.dirty & /*xStart, $xLim, $axesWidth*/ 3146752) {
2739
- // reactive variables for coordinates of data points in pixels (and line style)
2740
- $$invalidate(4, x1 = axes.scaleX(xStart, $xLim, $axesWidth));
2741
- }
2742
-
2743
- if ($$self.$$.dirty & /*xEnd, $xLim, $axesWidth*/ 3147776) {
2744
- $$invalidate(3, x2 = axes.scaleX(xEnd, $xLim, $axesWidth));
2745
- }
2746
-
2747
- if ($$self.$$.dirty & /*yStart, $yLim, $axesHeight*/ 790528) {
2748
- $$invalidate(2, y1 = axes.scaleY(yStart, $yLim, $axesHeight));
2749
- }
2750
-
2751
- if ($$self.$$.dirty & /*yEnd, $yLim, $axesHeight*/ 794624) {
2752
- $$invalidate(1, y2 = axes.scaleY(yEnd, $yLim, $axesHeight));
2753
- }
2754
-
2755
- if ($$self.$$.dirty & /*lineColor, lineWidth, $scale, lineType*/ 245760) {
2756
- $$invalidate(0, lineStyleStr = `stroke:${lineColor};stroke-width: ${lineWidth}px;stroke-dasharray:${axes.LINE_STYLES[$scale][lineType - 1]}`);
2757
- }
2758
- };
2759
-
2760
- return [
2761
- lineStyleStr,
2762
- y2,
2763
- y1,
2764
- x2,
2765
- x1,
2766
- xLim,
2767
- yLim,
2768
- axesWidth,
2769
- axesHeight,
2770
- scale,
2771
- xStart,
2772
- xEnd,
2773
- yStart,
2774
- yEnd,
2775
- lineColor,
2776
- lineType,
2777
- lineWidth,
2778
- $scale,
2779
- $axesHeight,
2780
- $yLim,
2781
- $axesWidth,
2782
- $xLim
2783
- ];
2784
- }
2785
-
2786
- class Segments extends SvelteComponent {
2787
- constructor(options) {
2788
- super();
2789
-
2790
- init(this, options, instance$6, create_fragment$6, safe_not_equal, {
2791
- xStart: 10,
2792
- xEnd: 11,
2793
- yStart: 12,
2794
- yEnd: 13,
2795
- lineColor: 14,
2796
- lineType: 15,
2797
- lineWidth: 16
2798
- });
2799
- }
2800
- }
2801
-
2802
- /* src/TextLabels.svelte generated by Svelte v3.50.1 */
2803
-
2804
- function add_css$2(target) {
2805
- append_styles(target, "svelte-1xvrp9d", "text.svelte-1xvrp9d,text.svelte-1xvrp9d>tspan{dominant-baseline:middle}");
2806
- }
2807
-
2808
- function get_each_context$1(ctx, list, i) {
2809
- const child_ctx = ctx.slice();
2810
- child_ctx[27] = list[i];
2811
- child_ctx[29] = i;
2812
- return child_ctx;
2813
- }
2814
-
2815
- // (66:0) {#if x !== undefined && y !== undefined}
2816
- function create_if_block$3(ctx) {
2817
- let g;
2818
- let g_class_value;
2819
- let each_value = /*x*/ ctx[7];
2820
- let each_blocks = [];
2821
-
2822
- for (let i = 0; i < each_value.length; i += 1) {
2823
- each_blocks[i] = create_each_block$1(get_each_context$1(ctx, each_value, i));
2824
- }
2825
-
2826
- return {
2827
- c() {
2828
- g = svg_element("g");
2829
-
2830
- for (let i = 0; i < each_blocks.length; i += 1) {
2831
- each_blocks[i].c();
2832
- }
2833
-
2834
- attr(g, "class", g_class_value = "series " + /*style*/ ctx[1]);
2835
- attr(g, "title", /*title*/ ctx[2]);
2836
- attr(g, "style", /*textStyleStr*/ ctx[3]);
2837
- },
2838
- m(target, anchor) {
2839
- insert(target, g, anchor);
2840
-
2841
- for (let i = 0; i < each_blocks.length; i += 1) {
2842
- each_blocks[i].m(g, null);
2843
- }
2844
- },
2845
- p(ctx, dirty) {
2846
- if (dirty & /*x, y, dx, dy, labels*/ 241) {
2847
- each_value = /*x*/ ctx[7];
2848
- let i;
2849
-
2850
- for (i = 0; i < each_value.length; i += 1) {
2851
- const child_ctx = get_each_context$1(ctx, each_value, i);
2852
-
2853
- if (each_blocks[i]) {
2854
- each_blocks[i].p(child_ctx, dirty);
2855
- } else {
2856
- each_blocks[i] = create_each_block$1(child_ctx);
2857
- each_blocks[i].c();
2858
- each_blocks[i].m(g, null);
2859
- }
2860
- }
2861
-
2862
- for (; i < each_blocks.length; i += 1) {
2863
- each_blocks[i].d(1);
2864
- }
2865
-
2866
- each_blocks.length = each_value.length;
2867
- }
2868
-
2869
- if (dirty & /*style*/ 2 && g_class_value !== (g_class_value = "series " + /*style*/ ctx[1])) {
2870
- attr(g, "class", g_class_value);
2871
- }
2872
-
2873
- if (dirty & /*title*/ 4) {
2874
- attr(g, "title", /*title*/ ctx[2]);
2875
- }
2876
-
2877
- if (dirty & /*textStyleStr*/ 8) {
2878
- attr(g, "style", /*textStyleStr*/ ctx[3]);
2879
- }
2880
- },
2881
- d(detaching) {
2882
- if (detaching) detach(g);
2883
- destroy_each(each_blocks, detaching);
2884
- }
2885
- };
2886
- }
2887
-
2888
- // (68:3) {#each x as v, i}
2889
- function create_each_block$1(ctx) {
2890
- let text_1;
2891
- let raw_value = /*labels*/ ctx[0][/*i*/ ctx[29]] + "";
2892
- let text_1_x_value;
2893
- let text_1_y_value;
2894
-
2895
- return {
2896
- c() {
2897
- text_1 = svg_element("text");
2898
- attr(text_1, "data-id", /*i*/ ctx[29]);
2899
- attr(text_1, "x", text_1_x_value = /*x*/ ctx[7][/*i*/ ctx[29]]);
2900
- attr(text_1, "y", text_1_y_value = /*y*/ ctx[6][/*i*/ ctx[29]]);
2901
- attr(text_1, "dx", /*dx*/ ctx[5]);
2902
- attr(text_1, "dy", /*dy*/ ctx[4]);
2903
- attr(text_1, "class", "svelte-1xvrp9d");
2904
- },
2905
- m(target, anchor) {
2906
- insert(target, text_1, anchor);
2907
- text_1.innerHTML = raw_value;
2908
- },
2909
- p(ctx, dirty) {
2910
- if (dirty & /*labels*/ 1 && raw_value !== (raw_value = /*labels*/ ctx[0][/*i*/ ctx[29]] + "")) text_1.innerHTML = raw_value;
2911
- if (dirty & /*x*/ 128 && text_1_x_value !== (text_1_x_value = /*x*/ ctx[7][/*i*/ ctx[29]])) {
2912
- attr(text_1, "x", text_1_x_value);
2913
- }
2914
-
2915
- if (dirty & /*y*/ 64 && text_1_y_value !== (text_1_y_value = /*y*/ ctx[6][/*i*/ ctx[29]])) {
2916
- attr(text_1, "y", text_1_y_value);
2917
- }
2918
-
2919
- if (dirty & /*dx*/ 32) {
2920
- attr(text_1, "dx", /*dx*/ ctx[5]);
2921
- }
2922
-
2923
- if (dirty & /*dy*/ 16) {
2924
- attr(text_1, "dy", /*dy*/ ctx[4]);
2925
- }
2926
- },
2927
- d(detaching) {
2928
- if (detaching) detach(text_1);
2929
- }
2930
- };
2931
- }
2932
-
2933
- function create_fragment$5(ctx) {
2934
- let if_block_anchor;
2935
- let if_block = /*x*/ ctx[7] !== undefined && /*y*/ ctx[6] !== undefined && create_if_block$3(ctx);
2936
-
2937
- return {
2938
- c() {
2939
- if (if_block) if_block.c();
2940
- if_block_anchor = empty();
2941
- },
2942
- m(target, anchor) {
2943
- if (if_block) if_block.m(target, anchor);
2944
- insert(target, if_block_anchor, anchor);
2945
- },
2946
- p(ctx, [dirty]) {
2947
- if (/*x*/ ctx[7] !== undefined && /*y*/ ctx[6] !== undefined) {
2948
- if (if_block) {
2949
- if_block.p(ctx, dirty);
2950
- } else {
2951
- if_block = create_if_block$3(ctx);
2952
- if_block.c();
2953
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
2954
- }
2955
- } else if (if_block) {
2956
- if_block.d(1);
2957
- if_block = null;
2958
- }
2959
- },
2960
- i: noop,
2961
- o: noop,
2962
- d(detaching) {
2963
- if (if_block) if_block.d(detaching);
2964
- if (detaching) detach(if_block_anchor);
2965
- }
2966
- };
2967
- }
2968
-
2969
- function instance$5($$self, $$props, $$invalidate) {
2970
- let x;
2971
- let y;
2972
- let dx;
2973
- let dy;
2974
- let textStyleStr;
2975
- let $scale;
2976
- let $axesHeight;
2977
- let $yLim;
2978
- let $axesWidth;
2979
- let $xLim;
2980
- let { xValues } = $$props;
2981
- let { yValues } = $$props;
2982
- let { labels } = $$props;
2983
- let { pos = 0 } = $$props;
2984
- let { faceColor = Colors.PRIMARY_TEXT } = $$props;
2985
- let { borderColor = "transparent" } = $$props;
2986
- let { borderWidth = 0 } = $$props;
2987
- let { textSize = 1 } = $$props;
2988
- let { style = "" } = $$props;
2989
- let { title = "series_text" } = $$props;
2990
-
2991
- // text-anchor values depending on position
2992
- const textAnchors = ["middle", "middle", "start", "middle", "end"];
2993
-
2994
- // sanity check for input parameters
2995
- if (!Array.isArray(xValues) || !Array.isArray(yValues) || xValues.length !== yValues.length) {
2996
- throw "TextLabels: parameters 'xValues' and 'yValues' must be vectors of the same length.";
2997
- }
2998
-
2999
- // get axes context and reactive variables needed to compute coordinates
3000
- const axes = getContext('axes');
3001
-
3002
- const xLim = axes.xLim;
3003
- component_subscribe($$self, xLim, value => $$invalidate(24, $xLim = value));
3004
- const yLim = axes.yLim;
3005
- component_subscribe($$self, yLim, value => $$invalidate(22, $yLim = value));
3006
- const axesWidth = axes.width;
3007
- component_subscribe($$self, axesWidth, value => $$invalidate(23, $axesWidth = value));
3008
- const axesHeight = axes.height;
3009
- component_subscribe($$self, axesHeight, value => $$invalidate(21, $axesHeight = value));
3010
- const scale = axes.scale;
3011
- component_subscribe($$self, scale, value => $$invalidate(20, $scale = value));
3012
-
3013
- $$self.$$set = $$props => {
3014
- if ('xValues' in $$props) $$invalidate(13, xValues = $$props.xValues);
3015
- if ('yValues' in $$props) $$invalidate(14, yValues = $$props.yValues);
3016
- if ('labels' in $$props) $$invalidate(0, labels = $$props.labels);
3017
- if ('pos' in $$props) $$invalidate(15, pos = $$props.pos);
3018
- if ('faceColor' in $$props) $$invalidate(16, faceColor = $$props.faceColor);
3019
- if ('borderColor' in $$props) $$invalidate(17, borderColor = $$props.borderColor);
3020
- if ('borderWidth' in $$props) $$invalidate(18, borderWidth = $$props.borderWidth);
3021
- if ('textSize' in $$props) $$invalidate(19, textSize = $$props.textSize);
3022
- if ('style' in $$props) $$invalidate(1, style = $$props.style);
3023
- if ('title' in $$props) $$invalidate(2, title = $$props.title);
3024
- };
3025
-
3026
- $$self.$$.update = () => {
3027
- if ($$self.$$.dirty & /*xValues, labels*/ 8193) {
3028
- // multiply label values if needed
3029
- {
3030
- const n = xValues.length;
3031
- if (!Array.isArray(labels)) $$invalidate(0, labels = Array(n).fill(labels));
3032
-
3033
- // workaround for an issue when xValues and yValues are changed in parent app
3034
- // but array of labels is still the same as in the
3035
- if (labels.length != n) $$invalidate(0, labels = Array(n).fill(labels[0]));
3036
-
3037
- // check that the length of labels vector is correct
3038
- if (labels.length !== n) {
3039
- throw "TextLabels: parameter 'labels' must be a single text value or a vector of the same size as 'x' and 'y'.";
3040
- }
3041
- }
3042
- }
3043
-
3044
- if ($$self.$$.dirty & /*xValues, $xLim, $axesWidth*/ 25174016) {
3045
- // reactive variables for coordinates of data points in pixels
3046
- $$invalidate(7, x = axes.scaleX(xValues, $xLim, $axesWidth));
3047
- }
3048
-
3049
- if ($$self.$$.dirty & /*yValues, $yLim, $axesHeight*/ 6307840) {
3050
- $$invalidate(6, y = axes.scaleY(yValues, $yLim, $axesHeight));
3051
- }
3052
-
3053
- if ($$self.$$.dirty & /*pos, $scale*/ 1081344) {
3054
- $$invalidate(5, dx = [0, 0, 1, 0, -1][pos] * axes.LABELS_MARGIN[$scale]);
3055
- }
3056
-
3057
- if ($$self.$$.dirty & /*pos, $scale*/ 1081344) {
3058
- $$invalidate(4, dy = [0, 1, 0, -1, 0][pos] * axes.LABELS_MARGIN[$scale]);
3059
- }
3060
-
3061
- if ($$self.$$.dirty & /*faceColor, borderWidth, borderColor, textSize, pos*/ 1015808) {
3062
- // styles for the elements
3063
- $$invalidate(3, textStyleStr = `fill:${faceColor};stroke-width:${borderWidth}px;stroke:${borderColor};
3064
- font-size:${textSize}em; text-anchor:${textAnchors[pos]};`);
3065
- }
3066
- };
3067
-
3068
- return [
3069
- labels,
3070
- style,
3071
- title,
3072
- textStyleStr,
3073
- dy,
3074
- dx,
3075
- y,
3076
- x,
3077
- xLim,
3078
- yLim,
3079
- axesWidth,
3080
- axesHeight,
3081
- scale,
3082
- xValues,
3083
- yValues,
3084
- pos,
3085
- faceColor,
3086
- borderColor,
3087
- borderWidth,
3088
- textSize,
3089
- $scale,
3090
- $axesHeight,
3091
- $yLim,
3092
- $axesWidth,
3093
- $xLim
3094
- ];
3095
- }
3096
-
3097
- class TextLabels extends SvelteComponent {
3098
- constructor(options) {
3099
- super();
3100
-
3101
- init(
3102
- this,
3103
- options,
3104
- instance$5,
3105
- create_fragment$5,
3106
- safe_not_equal,
3107
- {
3108
- xValues: 13,
3109
- yValues: 14,
3110
- labels: 0,
3111
- pos: 15,
3112
- faceColor: 16,
3113
- borderColor: 17,
3114
- borderWidth: 18,
3115
- textSize: 19,
3116
- style: 1,
3117
- title: 2
3118
- },
3119
- add_css$2
3120
- );
3121
- }
3122
- }
3123
-
3124
- /* src/TextLegend.svelte generated by Svelte v3.50.1 */
3125
-
3126
- function get_each_context(ctx, list, i) {
3127
- const child_ctx = ctx.slice();
3128
- child_ctx[22] = list[i];
3129
- child_ctx[24] = i;
3130
- return child_ctx;
3131
- }
3132
-
3133
- // (32:0) {#if x !== undefined && y !== undefined && elements.length > 0}
3134
- function create_if_block$2(ctx) {
3135
- let text_1;
3136
- let each_value = /*elements*/ ctx[2];
3137
- let each_blocks = [];
3138
-
3139
- for (let i = 0; i < each_value.length; i += 1) {
3140
- each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
3141
- }
3142
-
3143
- return {
3144
- c() {
3145
- text_1 = svg_element("text");
3146
-
3147
- for (let i = 0; i < each_blocks.length; i += 1) {
3148
- each_blocks[i].c();
3149
- }
3150
-
3151
- attr(text_1, "style", /*textStyleStr*/ ctx[3]);
3152
- attr(text_1, "x", /*x*/ ctx[5]);
3153
- attr(text_1, "y", /*y*/ ctx[4]);
3154
- attr(text_1, "dx", /*dx*/ ctx[0]);
3155
- attr(text_1, "dy", /*dy*/ ctx[1]);
3156
- attr(text_1, "dominant-baseline", "middle");
3157
- attr(text_1, "text-anchor", "start");
3158
- },
3159
- m(target, anchor) {
3160
- insert(target, text_1, anchor);
3161
-
3162
- for (let i = 0; i < each_blocks.length; i += 1) {
3163
- each_blocks[i].m(text_1, null);
3164
- }
3165
- },
3166
- p(ctx, dirty) {
3167
- if (dirty & /*x, dx, dy, elements*/ 39) {
3168
- each_value = /*elements*/ ctx[2];
3169
- let i;
3170
-
3171
- for (i = 0; i < each_value.length; i += 1) {
3172
- const child_ctx = get_each_context(ctx, each_value, i);
3173
-
3174
- if (each_blocks[i]) {
3175
- each_blocks[i].p(child_ctx, dirty);
3176
- } else {
3177
- each_blocks[i] = create_each_block(child_ctx);
3178
- each_blocks[i].c();
3179
- each_blocks[i].m(text_1, null);
3180
- }
3181
- }
3182
-
3183
- for (; i < each_blocks.length; i += 1) {
3184
- each_blocks[i].d(1);
3185
- }
3186
-
3187
- each_blocks.length = each_value.length;
3188
- }
3189
-
3190
- if (dirty & /*textStyleStr*/ 8) {
3191
- attr(text_1, "style", /*textStyleStr*/ ctx[3]);
3192
- }
3193
-
3194
- if (dirty & /*x*/ 32) {
3195
- attr(text_1, "x", /*x*/ ctx[5]);
3196
- }
3197
-
3198
- if (dirty & /*y*/ 16) {
3199
- attr(text_1, "y", /*y*/ ctx[4]);
3200
- }
3201
-
3202
- if (dirty & /*dx*/ 1) {
3203
- attr(text_1, "dx", /*dx*/ ctx[0]);
3204
- }
3205
-
3206
- if (dirty & /*dy*/ 2) {
3207
- attr(text_1, "dy", /*dy*/ ctx[1]);
3208
- }
3209
- },
3210
- d(detaching) {
3211
- if (detaching) detach(text_1);
3212
- destroy_each(each_blocks, detaching);
3213
- }
3214
- };
3215
- }
3216
-
3217
- // (34:6) {#each elements as el, i}
3218
- function create_each_block(ctx) {
3219
- let tspan;
3220
- let raw_value = /*el*/ ctx[22] + "";
3221
- let tspan_dy_value;
3222
-
3223
- return {
3224
- c() {
3225
- tspan = svg_element("tspan");
3226
- attr(tspan, "x", /*x*/ ctx[5]);
3227
- attr(tspan, "dx", /*dx*/ ctx[0]);
3228
- attr(tspan, "dy", tspan_dy_value = /*i*/ ctx[24] === 0 ? 0 : /*dy*/ ctx[1]);
3229
- },
3230
- m(target, anchor) {
3231
- insert(target, tspan, anchor);
3232
- tspan.innerHTML = raw_value;
3233
- },
3234
- p(ctx, dirty) {
3235
- if (dirty & /*elements*/ 4 && raw_value !== (raw_value = /*el*/ ctx[22] + "")) tspan.innerHTML = raw_value;
3236
- if (dirty & /*x*/ 32) {
3237
- attr(tspan, "x", /*x*/ ctx[5]);
3238
- }
3239
-
3240
- if (dirty & /*dx*/ 1) {
3241
- attr(tspan, "dx", /*dx*/ ctx[0]);
3242
- }
3243
-
3244
- if (dirty & /*dy*/ 2 && tspan_dy_value !== (tspan_dy_value = /*i*/ ctx[24] === 0 ? 0 : /*dy*/ ctx[1])) {
3245
- attr(tspan, "dy", tspan_dy_value);
3246
- }
3247
- },
3248
- d(detaching) {
3249
- if (detaching) detach(tspan);
3250
- }
3251
- };
3252
- }
3253
-
3254
- function create_fragment$4(ctx) {
3255
- let if_block_anchor;
3256
- let if_block = /*x*/ ctx[5] !== undefined && /*y*/ ctx[4] !== undefined && /*elements*/ ctx[2].length > 0 && create_if_block$2(ctx);
3257
-
3258
- return {
3259
- c() {
3260
- if (if_block) if_block.c();
3261
- if_block_anchor = empty();
3262
- },
3263
- m(target, anchor) {
3264
- if (if_block) if_block.m(target, anchor);
3265
- insert(target, if_block_anchor, anchor);
3266
- },
3267
- p(ctx, [dirty]) {
3268
- if (/*x*/ ctx[5] !== undefined && /*y*/ ctx[4] !== undefined && /*elements*/ ctx[2].length > 0) {
3269
- if (if_block) {
3270
- if_block.p(ctx, dirty);
3271
- } else {
3272
- if_block = create_if_block$2(ctx);
3273
- if_block.c();
3274
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
3275
- }
3276
- } else if (if_block) {
3277
- if_block.d(1);
3278
- if_block = null;
3279
- }
3280
- },
3281
- i: noop,
3282
- o: noop,
3283
- d(detaching) {
3284
- if (if_block) if_block.d(detaching);
3285
- if (detaching) detach(if_block_anchor);
3286
- }
3287
- };
3288
- }
3289
-
3290
- function instance$4($$self, $$props, $$invalidate) {
3291
- let x;
3292
- let y;
3293
- let textStyleStr;
3294
- let $axesHeight;
3295
- let $yLim;
3296
- let $axesWidth;
3297
- let $xLim;
3298
- let { left } = $$props;
3299
- let { top } = $$props;
3300
- let { dx = "0" } = $$props;
3301
- let { dy = "1.25em" } = $$props;
3302
- let { elements } = $$props;
3303
- let { faceColor = Colors.PRIMARY_TEXT } = $$props;
3304
- let { borderColor = "transparent" } = $$props;
3305
- let { borderWidth = 0 } = $$props;
3306
- let { textSize = 1 } = $$props;
3307
-
3308
- // get axes context and reactive variables needed to compute coordinates
3309
- const axes = getContext('axes');
3310
-
3311
- const xLim = axes.xLim;
3312
- component_subscribe($$self, xLim, value => $$invalidate(19, $xLim = value));
3313
- const yLim = axes.yLim;
3314
- component_subscribe($$self, yLim, value => $$invalidate(17, $yLim = value));
3315
- const axesWidth = axes.width;
3316
- component_subscribe($$self, axesWidth, value => $$invalidate(18, $axesWidth = value));
3317
- const axesHeight = axes.height;
3318
- component_subscribe($$self, axesHeight, value => $$invalidate(16, $axesHeight = value));
3319
- axes.scale;
3320
-
3321
- $$self.$$set = $$props => {
3322
- if ('left' in $$props) $$invalidate(10, left = $$props.left);
3323
- if ('top' in $$props) $$invalidate(11, top = $$props.top);
3324
- if ('dx' in $$props) $$invalidate(0, dx = $$props.dx);
3325
- if ('dy' in $$props) $$invalidate(1, dy = $$props.dy);
3326
- if ('elements' in $$props) $$invalidate(2, elements = $$props.elements);
3327
- if ('faceColor' in $$props) $$invalidate(12, faceColor = $$props.faceColor);
3328
- if ('borderColor' in $$props) $$invalidate(13, borderColor = $$props.borderColor);
3329
- if ('borderWidth' in $$props) $$invalidate(14, borderWidth = $$props.borderWidth);
3330
- if ('textSize' in $$props) $$invalidate(15, textSize = $$props.textSize);
3331
- };
3332
-
3333
- $$self.$$.update = () => {
3334
- if ($$self.$$.dirty & /*left, $xLim, $axesWidth*/ 787456) {
3335
- // reactive variables for coordinates of data points in pixels
3336
- $$invalidate(5, x = axes.scaleX([left], $xLim, $axesWidth));
3337
- }
3338
-
3339
- if ($$self.$$.dirty & /*top, $yLim, $axesHeight*/ 198656) {
3340
- $$invalidate(4, y = axes.scaleY([top], $yLim, $axesHeight));
3341
- }
3342
-
3343
- if ($$self.$$.dirty & /*faceColor, borderWidth, borderColor, textSize*/ 61440) {
3344
- // styles for bars and labels
3345
- $$invalidate(3, textStyleStr = `fill:${faceColor};stroke-width:${borderWidth}px;stroke:${borderColor};font-size:${textSize}em;`);
3346
- }
3347
- };
3348
-
3349
- return [
3350
- dx,
3351
- dy,
3352
- elements,
3353
- textStyleStr,
3354
- y,
3355
- x,
3356
- xLim,
3357
- yLim,
3358
- axesWidth,
3359
- axesHeight,
3360
- left,
3361
- top,
3362
- faceColor,
3363
- borderColor,
3364
- borderWidth,
3365
- textSize,
3366
- $axesHeight,
3367
- $yLim,
3368
- $axesWidth,
3369
- $xLim
3370
- ];
3371
- }
3372
-
3373
- class TextLegend extends SvelteComponent {
3374
- constructor(options) {
3375
- super();
3376
-
3377
- init(this, options, instance$4, create_fragment$4, safe_not_equal, {
3378
- left: 10,
3379
- top: 11,
3380
- dx: 0,
3381
- dy: 1,
3382
- elements: 2,
3383
- faceColor: 12,
3384
- borderColor: 13,
3385
- borderWidth: 14,
3386
- textSize: 15
3387
- });
3388
- }
3389
- }
3390
-
3391
- /**********************************************
3392
- * Functions for statistical tests and models *
3393
- **********************************************/
3394
-
3395
-
3396
- /**
3397
- * Finds smallest value in a vector
3398
- * @param {number[]} x - vector with values
3399
- * @returns {number}
3400
- */
3401
- function min(x) {
3402
- let n = x.length;
3403
- let min = Number.POSITIVE_INFINITY;
3404
-
3405
- while (n--) min = x[n] < min ? x[n] : min;
3406
- return min;
3407
- }
3408
-
3409
-
3410
- /**
3411
- * Finds largest value in a vector
3412
- * @param {number[]} x - vector with values
3413
- * @returns {number}
3414
- */
3415
- function max(x) {
3416
- let n = x.length;
3417
- let max = Number.NEGATIVE_INFINITY;
3418
-
3419
- while (n--) max = x[n] > max ? x[n] : max;
3420
- return max;
3421
- }
3422
-
3423
-
3424
- /**
3425
- * Computes a range of values in a vector with a margin
3426
- * @param {number[]} x - vector with values
3427
- * @param {number} margin - margin in parts of one (e.g. 0.1 for 10% or 2 for 200%)
3428
- * @returns{number[]} array with marginal range boundaries
3429
- */
3430
- function mrange(x, margin = 0.05) {
3431
- const mn = min(x);
3432
- const mx = max(x);
3433
- const d = mx - mn;
3434
-
3435
- return [mn - d * margin, max(x) + d * margin];
3436
- }
3437
-
3438
-
3439
- /**
3440
- * Computes difference between all adjacent values in a vector
3441
- * @param {number[]} x - vector with values
3442
- * @returns {number[]} vector with the differences
3443
- */
3444
- function diff(x) {
3445
- return x.slice(1).map( (y, i) => (y - x[i]));
3446
- }
3447
-
3448
- /* src/BarSeries.svelte generated by Svelte v3.50.1 */
3449
-
3450
- function add_css$1(target) {
3451
- append_styles(target, "svelte-kw726w", ".series_bar > rect{stroke-width:1px}.series_bar > rect:hover{opacity:90%}");
3452
- }
3453
-
3454
- function create_fragment$3(ctx) {
3455
- let rectangles;
3456
- let current;
3457
-
3458
- rectangles = new Rectangles({
3459
- props: {
3460
- style: "series_bar",
3461
- left: /*left*/ ctx[4],
3462
- top: /*top*/ ctx[5],
3463
- width: /*width*/ ctx[3],
3464
- height: /*height*/ ctx[6],
3465
- borderColor: /*borderColor*/ ctx[2],
3466
- faceColor: /*faceColor*/ ctx[1],
3467
- title: /*title*/ ctx[0]
3468
- }
3469
- });
3470
-
3471
- return {
3472
- c() {
3473
- create_component(rectangles.$$.fragment);
3474
- },
3475
- m(target, anchor) {
3476
- mount_component(rectangles, target, anchor);
3477
- current = true;
3478
- },
3479
- p(ctx, [dirty]) {
3480
- const rectangles_changes = {};
3481
- if (dirty & /*left*/ 16) rectangles_changes.left = /*left*/ ctx[4];
3482
- if (dirty & /*top*/ 32) rectangles_changes.top = /*top*/ ctx[5];
3483
- if (dirty & /*width*/ 8) rectangles_changes.width = /*width*/ ctx[3];
3484
- if (dirty & /*height*/ 64) rectangles_changes.height = /*height*/ ctx[6];
3485
- if (dirty & /*borderColor*/ 4) rectangles_changes.borderColor = /*borderColor*/ ctx[2];
3486
- if (dirty & /*faceColor*/ 2) rectangles_changes.faceColor = /*faceColor*/ ctx[1];
3487
- if (dirty & /*title*/ 1) rectangles_changes.title = /*title*/ ctx[0];
3488
- rectangles.$set(rectangles_changes);
3489
- },
3490
- i(local) {
3491
- if (current) return;
3492
- transition_in(rectangles.$$.fragment, local);
3493
- current = true;
3494
- },
3495
- o(local) {
3496
- transition_out(rectangles.$$.fragment, local);
3497
- current = false;
3498
- },
3499
- d(detaching) {
3500
- destroy_component(rectangles, detaching);
3501
- }
3502
- };
3503
- }
3504
-
3505
- function instance$3($$self, $$props, $$invalidate) {
3506
- let { xValues } = $$props;
3507
- let { yValues } = $$props;
3508
- let { barWidth = 0.8 } = $$props;
3509
- let { title = "" } = $$props;
3510
- let { faceColor = Colors.PRIMARY } = $$props;
3511
- let { borderColor = Colors.PRIMARY } = $$props;
3512
- let { showLabels = "no" } = $$props;
3513
-
3514
- // TODO: implemented later
3515
- //export let labels = yValues;
3516
- /* internal parameters */
3517
- let width;
3518
-
3519
- let left;
3520
- let top;
3521
- let height;
3522
-
3523
- // to access shared parameters and methods from Axes
3524
- const axes = getContext('axes');
3525
-
3526
- $$self.$$set = $$props => {
3527
- if ('xValues' in $$props) $$invalidate(7, xValues = $$props.xValues);
3528
- if ('yValues' in $$props) $$invalidate(8, yValues = $$props.yValues);
3529
- if ('barWidth' in $$props) $$invalidate(9, barWidth = $$props.barWidth);
3530
- if ('title' in $$props) $$invalidate(0, title = $$props.title);
3531
- if ('faceColor' in $$props) $$invalidate(1, faceColor = $$props.faceColor);
3532
- if ('borderColor' in $$props) $$invalidate(2, borderColor = $$props.borderColor);
3533
- if ('showLabels' in $$props) $$invalidate(10, showLabels = $$props.showLabels);
3534
- };
3535
-
3536
- $$self.$$.update = () => {
3537
- if ($$self.$$.dirty & /*xValues, barWidth, width*/ 648) {
3538
- /* reactive actions related to x-values, fires when there are changes in:
3539
- * - xValues
3540
- * - barWidth
3541
- */
3542
- {
3543
- if (!Array.isArray(xValues)) {
3544
- throw "BarSeries: parameter 'xValues' must be a numeric vector.";
3545
- }
3546
-
3547
- if (barWidth <= 0 || barWidth > 1) {
3548
- throw "BarSeries: parameters 'barWidth' should be between 0 and 1.";
3549
- }
3550
-
3551
- const xValuesRange = mrange(xValues, 0.1);
3552
- xValuesRange[0] = xValuesRange[0] - barWidth * diff(xValuesRange) / xValues.length * 0.5;
3553
- xValuesRange[1] = xValuesRange[1] + barWidth * diff(xValuesRange) / xValues.length * 0.5;
3554
- axes.adjustXAxisLimits(xValuesRange);
3555
- $$invalidate(3, width = Array(xValues.length).fill(max(diff(xValues)) * barWidth));
3556
- $$invalidate(4, left = xValues.map((v, i) => v - width[i] / 2));
3557
- }
3558
- }
3559
-
3560
- if ($$self.$$.dirty & /*yValues, xValues, showLabels*/ 1408) {
3561
- /* reactive actions related to y-values, fires when there are changes in:
3562
- * - yValues
3563
- */
3564
- {
3565
- if (!Array.isArray(yValues) || xValues.length != yValues.length) {
3566
- throw "BarSeries: parameter 'yValues' must be a numeric vector of the same length as 'xValues'.";
3567
- }
3568
-
3569
- const yValuesRange = mrange(yValues, showLabels === "no" ? 0.05 : 0.20);
3570
- axes.adjustYAxisLimits(yValuesRange);
3571
- $$invalidate(5, top = yValues.map(v => v > 0 ? v : 0));
3572
- $$invalidate(6, height = yValues.map(v => Math.abs(v)));
3573
- }
3574
- }
3575
- };
3576
-
3577
- return [
3578
- title,
3579
- faceColor,
3580
- borderColor,
3581
- width,
3582
- left,
3583
- top,
3584
- height,
3585
- xValues,
3586
- yValues,
3587
- barWidth,
3588
- showLabels
3589
- ];
3590
- }
3591
-
3592
- class BarSeries extends SvelteComponent {
3593
- constructor(options) {
3594
- super();
3595
-
3596
- init(
3597
- this,
3598
- options,
3599
- instance$3,
3600
- create_fragment$3,
3601
- safe_not_equal,
3602
- {
3603
- xValues: 7,
3604
- yValues: 8,
3605
- barWidth: 9,
3606
- title: 0,
3607
- faceColor: 1,
3608
- borderColor: 2,
3609
- showLabels: 10
3610
- },
3611
- add_css$1
3612
- );
3613
- }
3614
- }
3615
-
3616
- /* src/ScatterSeries.svelte generated by Svelte v3.50.1 */
3617
-
3618
- function add_css(target) {
3619
- 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}");
3620
- }
3621
-
3622
- function create_fragment$2(ctx) {
3623
- let textlabels;
3624
- let current;
3625
-
3626
- textlabels = new TextLabels({
3627
- props: {
3628
- xValues: /*xValues*/ ctx[0],
3629
- yValues: /*yValues*/ ctx[1],
3630
- faceColor: /*faceColor*/ ctx[3],
3631
- borderColor: /*borderColor*/ ctx[4],
3632
- borderWidth: /*borderWidth*/ ctx[5],
3633
- title: /*title*/ ctx[2],
3634
- style: "series_scatter",
3635
- labels: /*markerSymbol*/ ctx[7],
3636
- textSize: /*markerSize*/ ctx[6]
3637
- }
3638
- });
3639
-
3640
- return {
3641
- c() {
3642
- create_component(textlabels.$$.fragment);
3643
- },
3644
- m(target, anchor) {
3645
- mount_component(textlabels, target, anchor);
3646
- current = true;
3647
- },
3648
- p(ctx, [dirty]) {
3649
- const textlabels_changes = {};
3650
- if (dirty & /*xValues*/ 1) textlabels_changes.xValues = /*xValues*/ ctx[0];
3651
- if (dirty & /*yValues*/ 2) textlabels_changes.yValues = /*yValues*/ ctx[1];
3652
- if (dirty & /*faceColor*/ 8) textlabels_changes.faceColor = /*faceColor*/ ctx[3];
3653
- if (dirty & /*borderColor*/ 16) textlabels_changes.borderColor = /*borderColor*/ ctx[4];
3654
- if (dirty & /*borderWidth*/ 32) textlabels_changes.borderWidth = /*borderWidth*/ ctx[5];
3655
- if (dirty & /*title*/ 4) textlabels_changes.title = /*title*/ ctx[2];
3656
- if (dirty & /*markerSymbol*/ 128) textlabels_changes.labels = /*markerSymbol*/ ctx[7];
3657
- if (dirty & /*markerSize*/ 64) textlabels_changes.textSize = /*markerSize*/ ctx[6];
3658
- textlabels.$set(textlabels_changes);
3659
- },
3660
- i(local) {
3661
- if (current) return;
3662
- transition_in(textlabels.$$.fragment, local);
3663
- current = true;
3664
- },
3665
- o(local) {
3666
- transition_out(textlabels.$$.fragment, local);
3667
- current = false;
3668
- },
3669
- d(detaching) {
3670
- destroy_component(textlabels, detaching);
3671
- }
3672
- };
3673
- }
3674
-
3675
- function instance$2($$self, $$props, $$invalidate) {
3676
- let { xValues } = $$props;
3677
- let { yValues } = $$props;
3678
- let { marker = 1 } = $$props;
3679
- let { title = "" } = $$props;
3680
- let { faceColor = "transparent" } = $$props;
3681
- let { borderColor = Colors.PRIMARY } = $$props;
3682
- let { borderWidth = 1 } = $$props;
3683
- let { markerSize = 1 } = $$props;
3684
-
3685
- // TODO: implement later
3686
- //export let labels = yValues;
3687
- //export let showLabels = "no"; // can be "no", "hover", "always"
3688
- /* constants for internal use */
3689
- const markers = ["●", "◼", "▲", "▼", "⬥", "+", "*", "⨯"];
3690
-
3691
- let markerSymbol;
3692
-
3693
- /* sanity check of input parameters */
3694
- if (typeof marker !== "number" || marker < 1 || marker > markers.length) {
3695
- throw `ScatterSeries: parameter 'marker' must be a number from 1 to ${markers.length}."`;
3696
- }
3697
-
3698
- // to access shared parameters and methods from Axes
3699
- const axes = getContext('axes');
3700
-
3701
- $$self.$$set = $$props => {
3702
- if ('xValues' in $$props) $$invalidate(0, xValues = $$props.xValues);
3703
- if ('yValues' in $$props) $$invalidate(1, yValues = $$props.yValues);
3704
- if ('marker' in $$props) $$invalidate(8, marker = $$props.marker);
3705
- if ('title' in $$props) $$invalidate(2, title = $$props.title);
3706
- if ('faceColor' in $$props) $$invalidate(3, faceColor = $$props.faceColor);
3707
- if ('borderColor' in $$props) $$invalidate(4, borderColor = $$props.borderColor);
3708
- if ('borderWidth' in $$props) $$invalidate(5, borderWidth = $$props.borderWidth);
3709
- if ('markerSize' in $$props) $$invalidate(6, markerSize = $$props.markerSize);
3710
- };
3711
-
3712
- $$self.$$.update = () => {
3713
- if ($$self.$$.dirty & /*xValues, marker*/ 257) {
3714
- /* reactive actions related to x-values, fires when there are changes in:
3715
- * - xValues
3716
- * - marker
3717
- */
3718
- {
3719
- if (!Array.isArray(xValues)) {
3720
- throw "ScatterSeries: parameter 'xValues' must be a numeric vector.";
3721
- }
3722
-
3723
- const xValuesRange = mrange(xValues, 0.05);
3724
- axes.adjustXAxisLimits(xValuesRange);
3725
- $$invalidate(7, markerSymbol = "");
3726
- $$invalidate(7, markerSymbol = markers[marker - 1]);
3727
- }
3728
- }
3729
-
3730
- if ($$self.$$.dirty & /*yValues, xValues*/ 3) {
3731
- /* reactive actions related to y-values, fires when there are changes in:
3732
- * - yValues
3733
- */
3734
- {
3735
- if (!Array.isArray(yValues) || xValues.length != yValues.length) {
3736
- throw "BarSeries: parameter 'yValues' must be a numeric vector of the same length as 'xValues'.";
3737
- }
3738
-
3739
- const yValuesRange = mrange(yValues, 0.05);
3740
- axes.adjustYAxisLimits(yValuesRange);
3741
- }
3742
- }
3743
- };
3744
-
3745
- return [
3746
- xValues,
3747
- yValues,
3748
- title,
3749
- faceColor,
3750
- borderColor,
3751
- borderWidth,
3752
- markerSize,
3753
- markerSymbol,
3754
- marker
3755
- ];
3756
- }
3757
-
3758
- class ScatterSeries extends SvelteComponent {
3759
- constructor(options) {
3760
- super();
3761
-
3762
- init(
3763
- this,
3764
- options,
3765
- instance$2,
3766
- create_fragment$2,
3767
- safe_not_equal,
3768
- {
3769
- xValues: 0,
3770
- yValues: 1,
3771
- marker: 8,
3772
- title: 2,
3773
- faceColor: 3,
3774
- borderColor: 4,
3775
- borderWidth: 5,
3776
- markerSize: 6
3777
- },
3778
- add_css
3779
- );
3780
- }
3781
- }
3782
-
3783
- /* src/LineSeries.svelte generated by Svelte v3.50.1 */
3784
-
3785
- function create_if_block$1(ctx) {
3786
- let g;
3787
- let polyline;
3788
-
3789
- return {
3790
- c() {
3791
- g = svg_element("g");
3792
- polyline = svg_element("polyline");
3793
- attr(polyline, "class", "line");
3794
- attr(polyline, "points", /*p*/ ctx[2]);
3795
- attr(g, "class", "series series_line");
3796
- attr(g, "style", /*lineStyleStr*/ ctx[1]);
3797
- attr(g, "title", /*title*/ ctx[0]);
3798
- },
3799
- m(target, anchor) {
3800
- insert(target, g, anchor);
3801
- append(g, polyline);
3802
- },
3803
- p(ctx, dirty) {
3804
- if (dirty & /*p*/ 4) {
3805
- attr(polyline, "points", /*p*/ ctx[2]);
3806
- }
3807
-
3808
- if (dirty & /*lineStyleStr*/ 2) {
3809
- attr(g, "style", /*lineStyleStr*/ ctx[1]);
3810
- }
3811
-
3812
- if (dirty & /*title*/ 1) {
3813
- attr(g, "title", /*title*/ ctx[0]);
3814
- }
3815
- },
3816
- d(detaching) {
3817
- if (detaching) detach(g);
3818
- }
3819
- };
3820
- }
3821
-
3822
- function create_fragment$1(ctx) {
3823
- let if_block_anchor;
3824
- let if_block = /*p*/ ctx[2] !== undefined && create_if_block$1(ctx);
3825
-
3826
- return {
3827
- c() {
3828
- if (if_block) if_block.c();
3829
- if_block_anchor = empty();
3830
- },
3831
- m(target, anchor) {
3832
- if (if_block) if_block.m(target, anchor);
3833
- insert(target, if_block_anchor, anchor);
3834
- },
3835
- p(ctx, [dirty]) {
3836
- if (/*p*/ ctx[2] !== undefined) {
3837
- if (if_block) {
3838
- if_block.p(ctx, dirty);
3839
- } else {
3840
- if_block = create_if_block$1(ctx);
3841
- if_block.c();
3842
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
3843
- }
3844
- } else if (if_block) {
3845
- if_block.d(1);
3846
- if_block = null;
3847
- }
3848
- },
3849
- i: noop,
3850
- o: noop,
3851
- d(detaching) {
3852
- if (if_block) if_block.d(detaching);
3853
- if (detaching) detach(if_block_anchor);
3854
- }
3855
- };
3856
- }
3857
-
3858
- function instance$1($$self, $$props, $$invalidate) {
3859
- let x;
3860
- let y;
3861
- let p;
3862
- let lineStyleStr;
3863
- let $scale;
3864
- let $axesHeight;
3865
- let $yLim;
3866
- let $axesWidth;
3867
- let $xLim;
3868
- let { xValues } = $$props;
3869
- let { yValues } = $$props;
3870
- let { title = "" } = $$props;
3871
- let { lineWidth = 1 } = $$props;
3872
- let { lineColor = Colors.PRIMARY } = $$props;
3873
- let { lineType = 1 } = $$props;
3874
-
3875
- /* sanity check of input parameters */
3876
- if (!Array.isArray(xValues) || !Array.isArray(yValues) || xValues.length != yValues.length) {
3877
- throw "LineSeries: parameters 'xValues' and 'yValues' must be numeric vectors of the same length.";
3878
- }
3879
-
3880
- // compute ranges for x and y values
3881
- const xValuesRange = mrange(xValues, 0.05);
3882
-
3883
- const yValuesRange = mrange(yValues, 0.05);
3884
-
3885
- // get axes context and adjust axes limits
3886
- const axes = getContext('axes');
3887
-
3888
- axes.adjustXAxisLimits(xValuesRange);
3889
- axes.adjustYAxisLimits(yValuesRange);
3890
-
3891
- // get reactive variables needed to compute coordinates
3892
- const xLim = axes.xLim;
3893
-
3894
- component_subscribe($$self, xLim, value => $$invalidate(19, $xLim = value));
3895
- const yLim = axes.yLim;
3896
- component_subscribe($$self, yLim, value => $$invalidate(17, $yLim = value));
3897
- const axesWidth = axes.width;
3898
- component_subscribe($$self, axesWidth, value => $$invalidate(18, $axesWidth = value));
3899
- const axesHeight = axes.height;
3900
- component_subscribe($$self, axesHeight, value => $$invalidate(16, $axesHeight = value));
3901
- const scale = axes.scale;
3902
- component_subscribe($$self, scale, value => $$invalidate(15, $scale = value));
3903
-
3904
- $$self.$$set = $$props => {
3905
- if ('xValues' in $$props) $$invalidate(8, xValues = $$props.xValues);
3906
- if ('yValues' in $$props) $$invalidate(9, yValues = $$props.yValues);
3907
- if ('title' in $$props) $$invalidate(0, title = $$props.title);
3908
- if ('lineWidth' in $$props) $$invalidate(10, lineWidth = $$props.lineWidth);
3909
- if ('lineColor' in $$props) $$invalidate(11, lineColor = $$props.lineColor);
3910
- if ('lineType' in $$props) $$invalidate(12, lineType = $$props.lineType);
3911
- };
3912
-
3913
- $$self.$$.update = () => {
3914
- if ($$self.$$.dirty & /*xValues, $xLim, $axesWidth*/ 786688) {
3915
- // reactive variables for coordinates of data points in pixels
3916
- $$invalidate(14, x = axes.scaleX(xValues, $xLim, $axesWidth));
3917
- }
3918
-
3919
- if ($$self.$$.dirty & /*yValues, $yLim, $axesHeight*/ 197120) {
3920
- $$invalidate(13, y = axes.scaleY(yValues, $yLim, $axesHeight));
3921
- }
3922
-
3923
- if ($$self.$$.dirty & /*x, y*/ 24576) {
3924
- $$invalidate(2, p = x !== undefined && y !== undefined
3925
- ? x.map((v, i) => `${v},${y[i]}`).join(' ')
3926
- : undefined);
3927
- }
3928
-
3929
- if ($$self.$$.dirty & /*lineColor, lineWidth, $scale, lineType*/ 39936) {
3930
- $$invalidate(1, lineStyleStr = `fill:transparent;stroke:${lineColor};stroke-width: ${lineWidth}px;
3931
- stroke-dasharray:${axes.LINE_STYLES[$scale][lineType - 1]}`);
3932
- }
3933
- };
3934
-
3935
- return [
3936
- title,
3937
- lineStyleStr,
3938
- p,
3939
- xLim,
3940
- yLim,
3941
- axesWidth,
3942
- axesHeight,
3943
- scale,
3944
- xValues,
3945
- yValues,
3946
- lineWidth,
3947
- lineColor,
3948
- lineType,
3949
- y,
3950
- x,
3951
- $scale,
3952
- $axesHeight,
3953
- $yLim,
3954
- $axesWidth,
3955
- $xLim
3956
- ];
3957
- }
3958
-
3959
- class LineSeries extends SvelteComponent {
3960
- constructor(options) {
3961
- super();
3962
-
3963
- init(this, options, instance$1, create_fragment$1, safe_not_equal, {
3964
- xValues: 8,
3965
- yValues: 9,
3966
- title: 0,
3967
- lineWidth: 10,
3968
- lineColor: 11,
3969
- lineType: 12
3970
- });
3971
- }
3972
- }
3973
-
3974
- /* src/AreaSeries.svelte generated by Svelte v3.50.1 */
3975
-
3976
- function create_if_block(ctx) {
3977
- let g;
3978
- let polygon;
3979
- let polygon_points_value;
3980
-
3981
- return {
3982
- c() {
3983
- g = svg_element("g");
3984
- polygon = svg_element("polygon");
3985
- attr(polygon, "points", polygon_points_value = /*x*/ ctx[1][0] + "," + /*y0*/ ctx[4] + " " + /*p*/ ctx[3] + " " + /*x*/ ctx[1][/*x*/ ctx[1].length - 1] + "," + /*y0*/ ctx[4][0]);
3986
- attr(g, "class", "series lineseries");
3987
- attr(g, "style", /*areaStyleStr*/ ctx[2]);
3988
- attr(g, "title", /*title*/ ctx[0]);
3989
- },
3990
- m(target, anchor) {
3991
- insert(target, g, anchor);
3992
- append(g, polygon);
3993
- },
3994
- p(ctx, dirty) {
3995
- if (dirty & /*x, y0, p*/ 26 && polygon_points_value !== (polygon_points_value = /*x*/ ctx[1][0] + "," + /*y0*/ ctx[4] + " " + /*p*/ ctx[3] + " " + /*x*/ ctx[1][/*x*/ ctx[1].length - 1] + "," + /*y0*/ ctx[4][0])) {
3996
- attr(polygon, "points", polygon_points_value);
3997
- }
3998
-
3999
- if (dirty & /*areaStyleStr*/ 4) {
4000
- attr(g, "style", /*areaStyleStr*/ ctx[2]);
4001
- }
4002
-
4003
- if (dirty & /*title*/ 1) {
4004
- attr(g, "title", /*title*/ ctx[0]);
4005
- }
4006
- },
4007
- d(detaching) {
4008
- if (detaching) detach(g);
4009
- }
4010
- };
4011
- }
4012
-
4013
- function create_fragment(ctx) {
4014
- let if_block_anchor;
4015
- let if_block = /*p*/ ctx[3] !== undefined && create_if_block(ctx);
4016
-
4017
- return {
4018
- c() {
4019
- if (if_block) if_block.c();
4020
- if_block_anchor = empty();
4021
- },
4022
- m(target, anchor) {
4023
- if (if_block) if_block.m(target, anchor);
4024
- insert(target, if_block_anchor, anchor);
4025
- },
4026
- p(ctx, [dirty]) {
4027
- if (/*p*/ ctx[3] !== undefined) {
4028
- if (if_block) {
4029
- if_block.p(ctx, dirty);
4030
- } else {
4031
- if_block = create_if_block(ctx);
4032
- if_block.c();
4033
- if_block.m(if_block_anchor.parentNode, if_block_anchor);
4034
- }
4035
- } else if (if_block) {
4036
- if_block.d(1);
4037
- if_block = null;
4038
- }
4039
- },
4040
- i: noop,
4041
- o: noop,
4042
- d(detaching) {
4043
- if (if_block) if_block.d(detaching);
4044
- if (detaching) detach(if_block_anchor);
4045
- }
4046
- };
4047
- }
4048
-
4049
- function instance($$self, $$props, $$invalidate) {
4050
- let y0;
4051
- let x;
4052
- let y;
4053
- let p;
4054
- let areaStyleStr;
4055
- let $scale;
4056
- let $axesHeight;
4057
- let $yLim;
4058
- let $axesWidth;
4059
- let $xLim;
4060
- let { xValues } = $$props;
4061
- let { yValues } = $$props;
4062
- let { title = "" } = $$props;
4063
- let { lineWidth = 1 } = $$props;
4064
- let { lineColor = Colors.PRIMARY } = $$props;
4065
- let { fillColor = Colors.PRIMARY } = $$props;
4066
- let { opacity = 1 } = $$props;
4067
- let { lineType = 1 } = $$props;
4068
-
4069
- /* sanity check of input parameters */
4070
- if (!Array.isArray(xValues) || !Array.isArray(yValues) || xValues.length != yValues.length) {
4071
- throw "AreaSeries: parameters 'xValues' and 'yValues' must be numeric vectors of the same length.";
4072
- }
4073
-
4074
- // compute ranges for x and y values
4075
- const xValuesRange = mrange(xValues, 0.05);
4076
-
4077
- const yValuesRange = mrange(yValues, 0.05);
4078
-
4079
- // get axes context and adjust axes limits
4080
- const axes = getContext('axes');
4081
-
4082
- axes.adjustXAxisLimits(xValuesRange);
4083
- axes.adjustYAxisLimits(yValuesRange);
4084
-
4085
- // get reactive variables needed to compute coordinates
4086
- const xLim = axes.xLim;
4087
-
4088
- component_subscribe($$self, xLim, value => $$invalidate(22, $xLim = value));
4089
- const yLim = axes.yLim;
4090
- component_subscribe($$self, yLim, value => $$invalidate(20, $yLim = value));
4091
- const axesWidth = axes.width;
4092
- component_subscribe($$self, axesWidth, value => $$invalidate(21, $axesWidth = value));
4093
- const axesHeight = axes.height;
4094
- component_subscribe($$self, axesHeight, value => $$invalidate(19, $axesHeight = value));
4095
- const scale = axes.scale;
4096
- component_subscribe($$self, scale, value => $$invalidate(18, $scale = value));
4097
-
4098
- $$self.$$set = $$props => {
4099
- if ('xValues' in $$props) $$invalidate(10, xValues = $$props.xValues);
4100
- if ('yValues' in $$props) $$invalidate(11, yValues = $$props.yValues);
4101
- if ('title' in $$props) $$invalidate(0, title = $$props.title);
4102
- if ('lineWidth' in $$props) $$invalidate(12, lineWidth = $$props.lineWidth);
4103
- if ('lineColor' in $$props) $$invalidate(13, lineColor = $$props.lineColor);
4104
- if ('fillColor' in $$props) $$invalidate(14, fillColor = $$props.fillColor);
4105
- if ('opacity' in $$props) $$invalidate(15, opacity = $$props.opacity);
4106
- if ('lineType' in $$props) $$invalidate(16, lineType = $$props.lineType);
4107
- };
4108
-
4109
- $$self.$$.update = () => {
4110
- if ($$self.$$.dirty & /*$yLim, $axesHeight*/ 1572864) {
4111
- // reactive variables for coordinates of data points in pixels
4112
- $$invalidate(4, y0 = axes.scaleY([0], $yLim, $axesHeight));
4113
- }
4114
-
4115
- if ($$self.$$.dirty & /*xValues, $xLim, $axesWidth*/ 6292480) {
4116
- $$invalidate(1, x = axes.scaleX(xValues, $xLim, $axesWidth));
4117
- }
4118
-
4119
- if ($$self.$$.dirty & /*yValues, $yLim, $axesHeight*/ 1574912) {
4120
- $$invalidate(17, y = axes.scaleY(yValues, $yLim, $axesHeight));
4121
- }
4122
-
4123
- if ($$self.$$.dirty & /*x, y*/ 131074) {
4124
- $$invalidate(3, p = x !== undefined && y !== undefined
4125
- ? x.map((v, i) => `${v},${y[i]}`).join(' ')
4126
- : undefined);
4127
- }
4128
-
4129
- if ($$self.$$.dirty & /*opacity, fillColor, lineColor, lineWidth, $scale, lineType*/ 389120) {
4130
- $$invalidate(2, areaStyleStr = `opacity:${opacity};fill:${fillColor};stroke:${lineColor};stroke-width: ${lineWidth}px;stroke-dasharray:${axes.LINE_STYLES[$scale][lineType - 1]}`);
4131
- }
4132
- };
4133
-
4134
- return [
4135
- title,
4136
- x,
4137
- areaStyleStr,
4138
- p,
4139
- y0,
4140
- xLim,
4141
- yLim,
4142
- axesWidth,
4143
- axesHeight,
4144
- scale,
4145
- xValues,
4146
- yValues,
4147
- lineWidth,
4148
- lineColor,
4149
- fillColor,
4150
- opacity,
4151
- lineType,
4152
- y,
4153
- $scale,
4154
- $axesHeight,
4155
- $yLim,
4156
- $axesWidth,
4157
- $xLim
4158
- ];
4159
- }
4160
-
4161
- class AreaSeries extends SvelteComponent {
4162
- constructor(options) {
4163
- super();
4164
-
4165
- init(this, options, instance, create_fragment, safe_not_equal, {
4166
- xValues: 10,
4167
- yValues: 11,
4168
- title: 0,
4169
- lineWidth: 12,
4170
- lineColor: 13,
4171
- fillColor: 14,
4172
- opacity: 15,
4173
- lineType: 16
4174
- });
4175
- }
4176
- }
4177
-
4178
- exports.AreaSeries = AreaSeries;
4179
- exports.Axes = Axes;
4180
- exports.BarSeries = BarSeries;
4181
- exports.Box = Box;
4182
- exports.Colors = Colors;
4183
- exports.LineSeries = LineSeries;
4184
- exports.Rectangles = Rectangles;
4185
- exports.ScatterSeries = ScatterSeries;
4186
- exports.Segments = Segments;
4187
- exports.TextLabels = TextLabels;
4188
- exports.TextLegend = TextLegend;
4189
- exports.XAxis = XAxis;
4190
- exports.YAxis = YAxis;
4191
-
4192
- Object.defineProperty(exports, '__esModule', { value: true });
4193
-
4194
- }));