@axdspub/axiom-charts 0.0.25 → 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 +101 -71
- 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 +2 -2
|
@@ -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
|
}
|
|
@@ -1660,15 +1689,16 @@ class AxiomRadialRose extends AxiomPlotRoot {
|
|
|
1660
1689
|
this.stacks = undefined;
|
|
1661
1690
|
}
|
|
1662
1691
|
setStackedData() {
|
|
1663
|
-
var _a, _b;
|
|
1692
|
+
var _a, _b, _c;
|
|
1664
1693
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1665
1694
|
let parsedData = [];
|
|
1666
1695
|
if (this.data === undefined) {
|
|
1667
1696
|
this.data = yield this.getData();
|
|
1668
1697
|
parsedData = (_b = (_a = this.data.parsed) === null || _a === void 0 ? void 0 : _a.data) !== null && _b !== void 0 ? _b : [];
|
|
1669
1698
|
}
|
|
1670
|
-
|
|
1671
|
-
|
|
1699
|
+
const y = (_c = this.data.parsed) === null || _c === void 0 ? void 0 : _c.accessors.y;
|
|
1700
|
+
if (this.stacks === undefined && y !== undefined) {
|
|
1701
|
+
this.stacks = this.getStackedData(parsedData, y);
|
|
1672
1702
|
}
|
|
1673
1703
|
});
|
|
1674
1704
|
}
|
|
@@ -1680,7 +1710,7 @@ class AxiomRadialRose extends AxiomPlotRoot {
|
|
|
1680
1710
|
return [0, this.getMaxStackTotal(this.stacks)];
|
|
1681
1711
|
});
|
|
1682
1712
|
}
|
|
1683
|
-
getStackedData(parsedData) {
|
|
1713
|
+
getStackedData(parsedData, yAccessor) {
|
|
1684
1714
|
const degreesPerBin = 360 / this.numBins;
|
|
1685
1715
|
const directionBins = d3.range(0, 360, degreesPerBin);
|
|
1686
1716
|
const speedBins = this.speedBins;
|
|
@@ -1695,8 +1725,8 @@ class AxiomRadialRose extends AxiomPlotRoot {
|
|
|
1695
1725
|
parsedData.forEach(row => {
|
|
1696
1726
|
const directionBinIndex = Math.floor(row.direction / degreesPerBin);
|
|
1697
1727
|
const stack = stacks[directionBinIndex];
|
|
1698
|
-
if (row
|
|
1699
|
-
const speedBin = Math.floor(row
|
|
1728
|
+
if (Number(yAccessor(row)) < speedBins[speedBins.length - 1]) {
|
|
1729
|
+
const speedBin = Math.floor(Number(yAccessor(row)));
|
|
1700
1730
|
stack[speedBin] += 1;
|
|
1701
1731
|
}
|
|
1702
1732
|
});
|
|
@@ -1714,9 +1744,6 @@ class AxiomRadialRose extends AxiomPlotRoot {
|
|
|
1714
1744
|
});
|
|
1715
1745
|
var _a, _b, _c, _d, _e, _f;
|
|
1716
1746
|
return __awaiter(this, void 0, void 0, function* () {
|
|
1717
|
-
yield this.setStackedData();
|
|
1718
|
-
if (this.stacks === undefined || this.speedBins === undefined)
|
|
1719
|
-
return;
|
|
1720
1747
|
const xAccessors = this.getAccessorsAtAxis('x');
|
|
1721
1748
|
const xAccessor = this.getAccessorAtAxis('x');
|
|
1722
1749
|
const x0Accessor = xAccessors.x0;
|
|
@@ -1725,6 +1752,7 @@ class AxiomRadialRose extends AxiomPlotRoot {
|
|
|
1725
1752
|
const yAccessor = this.getAccessorAtAxis('y');
|
|
1726
1753
|
const y0Accessor = yAccessors.y0;
|
|
1727
1754
|
const y1Accessor = yAccessors.y1;
|
|
1755
|
+
yield this.setStackedData();
|
|
1728
1756
|
const chart = this.chart;
|
|
1729
1757
|
const chartElements = chart.getChartElements();
|
|
1730
1758
|
if (chartElements === undefined || chartElements.svg === null) {
|
|
@@ -1740,6 +1768,8 @@ class AxiomRadialRose extends AxiomPlotRoot {
|
|
|
1740
1768
|
console.log('Missing one of: xAxisScale, yAxisScale, parsedData, xAccessor(s), yAccessor(s)');
|
|
1741
1769
|
return undefined;
|
|
1742
1770
|
}
|
|
1771
|
+
if (this.stacks === undefined || this.speedBins === undefined)
|
|
1772
|
+
return;
|
|
1743
1773
|
const maxStackTotal = this.getMaxStackTotal(this.stacks);
|
|
1744
1774
|
const xScale = d3.scaleBand()
|
|
1745
1775
|
.domain(d3.range(0, 360, 360 / this.numBins))
|