@axdspub/axiom-charts 0.0.26 → 0.0.27
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/library/Libraries/axiom/index.js +91 -62
- package/library/Libraries/axiom/index.js.map +1 -1
- package/library/axiom-charts.d.ts +1 -0
- package/library/browser.js +13 -7
- package/library/browser.js.map +1 -1
- package/library/cjs.js +13 -7
- package/library/cjs.js.map +1 -1
- package/library/index.js +13 -7
- package/library/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -313,15 +313,21 @@ class ChartRoot {
|
|
|
313
313
|
const yGroups = this.plotImplementations !== undefined ? this.getPlotImplementationGroups(this.plotImplementations, 'y') : {};
|
|
314
314
|
return this.settings.margin.left * Object.keys(yGroups).length;
|
|
315
315
|
}
|
|
316
|
+
debouncedResize() {
|
|
317
|
+
var _a;
|
|
318
|
+
if (((_a = this.runtime.resizeEventHandler) === null || _a === void 0 ? void 0 : _a.cancel) !== undefined) {
|
|
319
|
+
this.runtime.resizeEventHandler.cancel();
|
|
320
|
+
console.log('cancel');
|
|
321
|
+
}
|
|
322
|
+
this.runtime.resizeEventHandler = debounce(() => { this.onResize(this.runtime.prevWidth, this.runtime.prevHeight); }, 1000);
|
|
323
|
+
this.runtime.resizeEventHandler();
|
|
324
|
+
}
|
|
316
325
|
init(drawImmediately = false) {
|
|
326
|
+
var _a;
|
|
317
327
|
return __awaiter(this, void 0, void 0, function* () {
|
|
318
|
-
this.runtime.resizeEventHandler = debounce(() => {
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
leading: true,
|
|
322
|
-
trailing: true
|
|
323
|
-
});
|
|
324
|
-
// window.addEventListener('resize', this.runtime.resizeEventHandler)
|
|
328
|
+
this.runtime.resizeEventHandler = debounce(() => { this.onResize(this.runtime.prevWidth, this.runtime.prevHeight); }, 1000);
|
|
329
|
+
window.addEventListener('resize', () => { this.debouncedResize(); });
|
|
330
|
+
(_a = this.plotImplementations) === null || _a === void 0 ? void 0 : _a.forEach(plot => { plot.destroy(); });
|
|
325
331
|
this.plotImplementations = this.createPlots();
|
|
326
332
|
// PRELOAD ALL CHART METADATA AND DATA
|
|
327
333
|
/* await Promise.all(this.plotImplementations.map(async p => {
|
|
@@ -439,6 +445,34 @@ class AxiomPlotRoot extends PlotRoot {
|
|
|
439
445
|
}
|
|
440
446
|
|
|
441
447
|
class AxiomLine extends AxiomPlotRoot {
|
|
448
|
+
constructor() {
|
|
449
|
+
super(...arguments);
|
|
450
|
+
this.onMouseScrub = (event) => {
|
|
451
|
+
const chart = this.chart;
|
|
452
|
+
if (chart.onPlotScrub === undefined)
|
|
453
|
+
return;
|
|
454
|
+
const xAccessor = this.getAccessorAtAxis('x');
|
|
455
|
+
const yAccessor = this.getAccessorAtAxis('y');
|
|
456
|
+
if (this.scrubSettings.axis === undefined ||
|
|
457
|
+
this.xScale === undefined ||
|
|
458
|
+
this.yScale === undefined ||
|
|
459
|
+
xAccessor === undefined ||
|
|
460
|
+
yAccessor === undefined ||
|
|
461
|
+
this.parsedData === undefined ||
|
|
462
|
+
this.offset === undefined) {
|
|
463
|
+
return;
|
|
464
|
+
}
|
|
465
|
+
const scrub = chart.getScrubEvent(event, this.scrubSettings.axis, this.xScale, this.yScale, xAccessor, yAccessor, this.parsedData, this.offset);
|
|
466
|
+
if (scrub === undefined || scrub.x === undefined)
|
|
467
|
+
return;
|
|
468
|
+
this.onScrub(scrub);
|
|
469
|
+
chart.drawPlotScrubbing(this.id, scrub, this.style, this.scrubSettings);
|
|
470
|
+
};
|
|
471
|
+
this.onScrubEnd = () => {
|
|
472
|
+
this.chart.erasePlotScrub(this.id);
|
|
473
|
+
super.onScrubEnd();
|
|
474
|
+
};
|
|
475
|
+
}
|
|
442
476
|
getDomainAccessor(axis) {
|
|
443
477
|
var _a, _b, _c;
|
|
444
478
|
const accessors = ((_c = (_b = (_a = this.runtime) === null || _a === void 0 ? void 0 : _a.data) === null || _b === void 0 ? void 0 : _b.parsed) === null || _c === void 0 ? void 0 : _c.accessors) !== undefined ? this.runtime.data.parsed.accessors : {};
|
|
@@ -526,35 +560,10 @@ class AxiomLine extends AxiomPlotRoot {
|
|
|
526
560
|
var _a, _b, _c;
|
|
527
561
|
const chartElements = this.chart.getChartElements();
|
|
528
562
|
if (chartElements !== undefined) {
|
|
529
|
-
(_a = chartElements.svg.node()) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseover',
|
|
530
|
-
(_b = chartElements.svg.node()) === null || _b === void 0 ? void 0 : _b.addEventListener('mousemove',
|
|
531
|
-
(_c = chartElements.svg.node()) === null || _c === void 0 ? void 0 : _c.addEventListener('mouseleave',
|
|
532
|
-
}
|
|
533
|
-
}
|
|
534
|
-
onMouseScrub(event) {
|
|
535
|
-
const chart = this.chart;
|
|
536
|
-
if (chart.onPlotScrub === undefined)
|
|
537
|
-
return;
|
|
538
|
-
const xAccessor = this.getAccessorAtAxis('x');
|
|
539
|
-
const yAccessor = this.getAccessorAtAxis('y');
|
|
540
|
-
if (this.scrubSettings.axis === undefined ||
|
|
541
|
-
this.xScale === undefined ||
|
|
542
|
-
this.yScale === undefined ||
|
|
543
|
-
xAccessor === undefined ||
|
|
544
|
-
yAccessor === undefined ||
|
|
545
|
-
this.parsedData === undefined ||
|
|
546
|
-
this.offset === undefined) {
|
|
547
|
-
return;
|
|
563
|
+
(_a = chartElements.svg.node()) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseover', this.onMouseScrub);
|
|
564
|
+
(_b = chartElements.svg.node()) === null || _b === void 0 ? void 0 : _b.addEventListener('mousemove', this.onMouseScrub);
|
|
565
|
+
(_c = chartElements.svg.node()) === null || _c === void 0 ? void 0 : _c.addEventListener('mouseleave', this.onScrubEnd);
|
|
548
566
|
}
|
|
549
|
-
const scrub = chart.getScrubEvent(event, this.scrubSettings.axis, this.xScale, this.yScale, xAccessor, yAccessor, this.parsedData, this.offset);
|
|
550
|
-
if (scrub === undefined || scrub.x === undefined)
|
|
551
|
-
return;
|
|
552
|
-
this.onScrub(scrub);
|
|
553
|
-
chart.drawPlotScrubbing(this.id, scrub, this.style, this.scrubSettings);
|
|
554
|
-
}
|
|
555
|
-
onScrubEnd() {
|
|
556
|
-
this.chart.erasePlotScrub(this.id);
|
|
557
|
-
super.onScrubEnd();
|
|
558
567
|
}
|
|
559
568
|
getStrokeStyle() {
|
|
560
569
|
const style = this.style !== undefined ? this.style : {};
|
|
@@ -572,6 +581,15 @@ class AxiomLine extends AxiomPlotRoot {
|
|
|
572
581
|
});
|
|
573
582
|
}
|
|
574
583
|
}
|
|
584
|
+
destroy() {
|
|
585
|
+
var _a, _b, _c;
|
|
586
|
+
const chartElements = this.chart.getChartElements();
|
|
587
|
+
if (chartElements !== undefined) {
|
|
588
|
+
(_a = chartElements.svg.node()) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseover', this.onMouseScrub);
|
|
589
|
+
(_b = chartElements.svg.node()) === null || _b === void 0 ? void 0 : _b.removeEventListener('mousemove', this.onMouseScrub);
|
|
590
|
+
(_c = chartElements.svg.node()) === null || _c === void 0 ? void 0 : _c.removeEventListener('mouseleave', this.onScrubEnd);
|
|
591
|
+
}
|
|
592
|
+
}
|
|
575
593
|
}
|
|
576
594
|
|
|
577
595
|
class AxiomArea extends AxiomPlotRoot {
|
|
@@ -691,6 +709,31 @@ class AxiomScatter extends AxiomPlotRoot {
|
|
|
691
709
|
constructor() {
|
|
692
710
|
super(...arguments);
|
|
693
711
|
this.circleClass = `${this.id}-scrub-circle`;
|
|
712
|
+
this.onMouseScrub = (event) => {
|
|
713
|
+
const chart = this.chart;
|
|
714
|
+
if (chart.onPlotScrub === undefined)
|
|
715
|
+
return;
|
|
716
|
+
const xAccessor = this.getAccessorAtAxis('x');
|
|
717
|
+
const yAccessor = this.getAccessorAtAxis('y');
|
|
718
|
+
if (this.scrubSettings.axis === undefined ||
|
|
719
|
+
this.xScale === undefined ||
|
|
720
|
+
this.yScale === undefined ||
|
|
721
|
+
xAccessor === undefined ||
|
|
722
|
+
yAccessor === undefined ||
|
|
723
|
+
this.parsedData === undefined ||
|
|
724
|
+
this.offset === undefined) {
|
|
725
|
+
return;
|
|
726
|
+
}
|
|
727
|
+
const scrub = chart.getScrubEvent(event, this.scrubSettings.axis, this.xScale, this.yScale, xAccessor, yAccessor, this.parsedData, this.offset);
|
|
728
|
+
if (scrub === undefined || scrub.x === undefined)
|
|
729
|
+
return;
|
|
730
|
+
this.onScrub(scrub);
|
|
731
|
+
chart.drawPlotScrubbing(this.id, scrub, this.style, this.scrubSettings);
|
|
732
|
+
};
|
|
733
|
+
this.onScrubEnd = () => {
|
|
734
|
+
this.chart.erasePlotScrub(this.id);
|
|
735
|
+
super.onScrubEnd();
|
|
736
|
+
};
|
|
694
737
|
}
|
|
695
738
|
getDomainAccessor(axis) {
|
|
696
739
|
var _a, _b, _c;
|
|
@@ -778,35 +821,19 @@ class AxiomScatter extends AxiomPlotRoot {
|
|
|
778
821
|
var _a, _b, _c;
|
|
779
822
|
const chartElements = this.chart.getChartElements();
|
|
780
823
|
if (chartElements !== undefined) {
|
|
781
|
-
(_a = chartElements.svg.node()) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseover',
|
|
782
|
-
(_b = chartElements.svg.node()) === null || _b === void 0 ? void 0 : _b.addEventListener('mousemove',
|
|
783
|
-
(_c = chartElements.svg.node()) === null || _c === void 0 ? void 0 : _c.addEventListener('mouseleave',
|
|
824
|
+
(_a = chartElements.svg.node()) === null || _a === void 0 ? void 0 : _a.addEventListener('mouseover', this.onMouseScrub);
|
|
825
|
+
(_b = chartElements.svg.node()) === null || _b === void 0 ? void 0 : _b.addEventListener('mousemove', this.onMouseScrub);
|
|
826
|
+
(_c = chartElements.svg.node()) === null || _c === void 0 ? void 0 : _c.addEventListener('mouseleave', this.onScrubEnd);
|
|
784
827
|
}
|
|
785
828
|
}
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
this.xScale === undefined ||
|
|
794
|
-
this.yScale === undefined ||
|
|
795
|
-
xAccessor === undefined ||
|
|
796
|
-
yAccessor === undefined ||
|
|
797
|
-
this.parsedData === undefined ||
|
|
798
|
-
this.offset === undefined) {
|
|
799
|
-
return;
|
|
829
|
+
destroy() {
|
|
830
|
+
var _a, _b, _c;
|
|
831
|
+
const chartElements = this.chart.getChartElements();
|
|
832
|
+
if (chartElements !== undefined) {
|
|
833
|
+
(_a = chartElements.svg.node()) === null || _a === void 0 ? void 0 : _a.removeEventListener('mouseover', this.onMouseScrub);
|
|
834
|
+
(_b = chartElements.svg.node()) === null || _b === void 0 ? void 0 : _b.removeEventListener('mousemove', this.onMouseScrub);
|
|
835
|
+
(_c = chartElements.svg.node()) === null || _c === void 0 ? void 0 : _c.removeEventListener('mouseleave', this.onScrubEnd);
|
|
800
836
|
}
|
|
801
|
-
const scrub = chart.getScrubEvent(event, this.scrubSettings.axis, this.xScale, this.yScale, xAccessor, yAccessor, this.parsedData, this.offset);
|
|
802
|
-
if (scrub === undefined || scrub.x === undefined)
|
|
803
|
-
return;
|
|
804
|
-
this.onScrub(scrub);
|
|
805
|
-
chart.drawPlotScrubbing(this.id, scrub, this.style, this.scrubSettings);
|
|
806
|
-
}
|
|
807
|
-
onScrubEnd() {
|
|
808
|
-
this.chart.erasePlotScrub(this.id);
|
|
809
|
-
super.onScrubEnd();
|
|
810
837
|
}
|
|
811
838
|
}
|
|
812
839
|
|
|
@@ -848,7 +875,8 @@ class AxiomBar extends AxiomPlotRoot {
|
|
|
848
875
|
return undefined;
|
|
849
876
|
if (chartElements.svg.select('g') !== undefined)
|
|
850
877
|
chartElements.svg.select('g').remove();
|
|
851
|
-
let {
|
|
878
|
+
let { height } = chart.settings;
|
|
879
|
+
let width = chart.getWidth();
|
|
852
880
|
width = Number(width);
|
|
853
881
|
height = Number(height);
|
|
854
882
|
const oneOrZero = y2Key === undefined ? 0 : 1; // Used to add in space for y2 if exists.
|
|
@@ -1428,6 +1456,7 @@ class AxiomChart extends ChartRoot {
|
|
|
1428
1456
|
});
|
|
1429
1457
|
}
|
|
1430
1458
|
destroy() {
|
|
1459
|
+
console.log('destroy');
|
|
1431
1460
|
this.chartElements = undefined;
|
|
1432
1461
|
super.destroy();
|
|
1433
1462
|
}
|