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