@peter.prib/renderengine 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/REFERENCE.md +42 -3
- package/dist/renderengine-workspace.umd.js +1079 -118
- package/dist/renderengine.umd.js +1079 -118
- package/package.json +1 -1
- package/src/chartCatalog.js +49 -4
- package/src/charting/Gauge.js +6 -0
- package/src/charting/charts/ArcGauge.js +55 -0
- package/src/charting/charts/BarGauge.js +32 -11
- package/src/charting/charts/BulletGauge.js +52 -56
- package/src/charting/charts/DialGauge.js +54 -26
- package/src/charting/charts/GaugeChart.js +141 -13
- package/src/charting/charts/KpiTile.js +72 -0
- package/src/charting/charts/MultiRingGauge.js +54 -0
- package/src/charting/charts/RingGauge.js +23 -0
- package/src/charting/charts/ThermometerGauge.js +43 -0
- package/src/charting/gauges/ArcTrack.js +51 -0
- package/src/charting/gauges/GaugeAnimation.js +51 -0
- package/src/charting/gauges/GaugeBands.js +48 -0
- package/src/charting/gauges/GaugeScale.js +87 -0
- package/src/charting/gauges/GaugeTrack.js +44 -0
- package/src/charting/gauges/GaugeValue.js +61 -0
- package/src/charting/gauges/HorizontalTrack.js +14 -0
- package/src/charting/gauges/LinearTrack.js +29 -0
- package/src/charting/gauges/Sparkline.js +42 -0
- package/src/charting/gauges/VerticalTrack.js +17 -0
- package/src/index.js +84 -12
package/src/index.js
CHANGED
|
@@ -39,6 +39,13 @@ import { WaterfallChart } from './charting/charts/WaterfallChart.js';
|
|
|
39
39
|
import { BarGauge } from './charting/charts/BarGauge.js';
|
|
40
40
|
import { BulletGauge } from './charting/charts/BulletGauge.js';
|
|
41
41
|
import { DialGauge } from './charting/charts/DialGauge.js';
|
|
42
|
+
import { ArcGauge } from './charting/charts/ArcGauge.js';
|
|
43
|
+
import { RingGauge } from './charting/charts/RingGauge.js';
|
|
44
|
+
import { MultiRingGauge } from './charting/charts/MultiRingGauge.js';
|
|
45
|
+
import { KpiTile } from './charting/charts/KpiTile.js';
|
|
46
|
+
import { ThermometerGauge } from './charting/charts/ThermometerGauge.js';
|
|
47
|
+
import { GaugeAnimation } from './charting/gauges/GaugeAnimation.js';
|
|
48
|
+
import { GaugeValue } from './charting/gauges/GaugeValue.js';
|
|
42
49
|
import { BarChart3D } from './charting/charts/BarChart3D.js';
|
|
43
50
|
import { BubbleChart3D } from './charting/charts/BubbleChart3D.js';
|
|
44
51
|
import { BarChart3DOrbit } from './charting/charts/BarChart3DOrbit.js';
|
|
@@ -1657,14 +1664,11 @@ export class RenderEngine {
|
|
|
1657
1664
|
|
|
1658
1665
|
/**
|
|
1659
1666
|
* Renders a bar gauge.
|
|
1660
|
-
* @param {number} value The value to display (0-100).
|
|
1667
|
+
* @param {number|{value:number, target?:number}} value The value to display (0-100 unless options.min/max are given).
|
|
1661
1668
|
* @param {object} [options] Charting options.
|
|
1662
1669
|
*/
|
|
1663
1670
|
barGauge(value, options = {}) {
|
|
1664
|
-
|
|
1665
|
-
this._chart3D = false; // leaving 3D mode — clears the SVG-zoom guard added for bubbleChart3D
|
|
1666
|
-
this._chartState = { type: 'barGauge', data: value, options };
|
|
1667
|
-
this._renderChart(new BarGauge(this.renderer, value, options));
|
|
1671
|
+
this._renderGauge(BarGauge, 'barGauge', value, options);
|
|
1668
1672
|
}
|
|
1669
1673
|
|
|
1670
1674
|
/**
|
|
@@ -1674,22 +1678,90 @@ export class RenderEngine {
|
|
|
1674
1678
|
* @param {object} [options] Charting options.
|
|
1675
1679
|
*/
|
|
1676
1680
|
bulletGauge(data, options = {}) {
|
|
1677
|
-
|
|
1678
|
-
this._chart3D = false;
|
|
1679
|
-
this._chartState = { type: 'bullet', data, options };
|
|
1680
|
-
this._renderChart(new BulletGauge(this.renderer, data, options));
|
|
1681
|
+
this._renderGauge(BulletGauge, 'bullet', data, options);
|
|
1681
1682
|
}
|
|
1682
1683
|
|
|
1683
1684
|
/**
|
|
1684
1685
|
* Renders a dial gauge.
|
|
1685
|
-
* @param {number} value The value to display (0-100).
|
|
1686
|
+
* @param {number|{value:number, target?:number}} value The value to display (0-100 unless options.min/max are given).
|
|
1686
1687
|
* @param {object} [options] Charting options.
|
|
1687
1688
|
*/
|
|
1688
1689
|
dialGauge(value, options = {}) {
|
|
1690
|
+
this._renderGauge(DialGauge, 'dialGauge', value, options);
|
|
1691
|
+
}
|
|
1692
|
+
|
|
1693
|
+
/**
|
|
1694
|
+
* Renders an arc gauge: a half circle (or any start angle and sweep) filled to the value.
|
|
1695
|
+
* @param {number|{value:number, target?:number}} value The value (0-100 unless options.min/max are given).
|
|
1696
|
+
* @param {object} [options] The gauge options (see REFERENCE.md, Gauges), cx, cy, r, thickness, startAngle, sweep, cap.
|
|
1697
|
+
*/
|
|
1698
|
+
arcGauge(value, options = {}) {
|
|
1699
|
+
this._renderGauge(ArcGauge, 'arcGauge', value, options);
|
|
1700
|
+
}
|
|
1701
|
+
|
|
1702
|
+
/**
|
|
1703
|
+
* Renders a progress ring, its value in the middle.
|
|
1704
|
+
* @param {number|{value:number, target?:number}} value The value (0-100 unless options.min/max are given).
|
|
1705
|
+
* @param {object} [options] The gauge options, cx, cy, r, thickness.
|
|
1706
|
+
*/
|
|
1707
|
+
ringGauge(value, options = {}) {
|
|
1708
|
+
this._renderGauge(RingGauge, 'ringGauge', value, options);
|
|
1709
|
+
}
|
|
1710
|
+
|
|
1711
|
+
/**
|
|
1712
|
+
* Renders several values as rings one inside the other, with a legend.
|
|
1713
|
+
* @param {Array<number|{value:number, label?:string, color?:string, min?:number, max?:number}>} values Outer ring first.
|
|
1714
|
+
* @param {object} [options] cx, cy, r, thickness, gap, colors, legend, min, max, format, units, title.
|
|
1715
|
+
*/
|
|
1716
|
+
multiRingGauge(values, options = {}) {
|
|
1717
|
+
this._renderGauge(MultiRingGauge, 'multiRingGauge', values, options);
|
|
1718
|
+
}
|
|
1719
|
+
|
|
1720
|
+
/**
|
|
1721
|
+
* Renders a KPI tile: a figure, its change since the previous value, and a sparkline of its history.
|
|
1722
|
+
* @param {number|{value?:number, previous?:number, history?:number[]}} data
|
|
1723
|
+
* @param {object} [options] x, y, width, height, format, units, change ('percent'|'value'), upIsGood, bands, sparkColor, background, title.
|
|
1724
|
+
*/
|
|
1725
|
+
kpiTile(data, options = {}) {
|
|
1726
|
+
this._renderGauge(KpiTile, 'kpiTile', data, options);
|
|
1727
|
+
}
|
|
1728
|
+
|
|
1729
|
+
/**
|
|
1730
|
+
* Renders a thermometer: a tube filled from a bulb up to the value.
|
|
1731
|
+
* @param {number|{value:number, target?:number}} value The value (0-100 unless options.min/max are given).
|
|
1732
|
+
* @param {object} [options] The gauge options, x, y, width, height, bulb.
|
|
1733
|
+
*/
|
|
1734
|
+
thermometerGauge(value, options = {}) {
|
|
1735
|
+
this._renderGauge(ThermometerGauge, 'thermometerGauge', value, options);
|
|
1736
|
+
}
|
|
1737
|
+
|
|
1738
|
+
/**
|
|
1739
|
+
* Every gauge method draws through here. With `options.animate` (true:
|
|
1740
|
+
* 400ms, or milliseconds) a gauge of the same type already showing eases
|
|
1741
|
+
* from the value it shows to the new one; a newer call stops an older
|
|
1742
|
+
* animation and starts from where it got to.
|
|
1743
|
+
* @private
|
|
1744
|
+
*/
|
|
1745
|
+
_renderGauge(GaugeType, type, data, options = {}) {
|
|
1689
1746
|
if (!this.renderer) return;
|
|
1690
1747
|
this._chart3D = false; // leaving 3D mode — clears the SVG-zoom guard added for bubbleChart3D
|
|
1691
|
-
this._chartState = { type
|
|
1692
|
-
this.
|
|
1748
|
+
this._chartState = { type, data, options };
|
|
1749
|
+
this._gaugeAnimation?.stop();
|
|
1750
|
+
const shown = this._gaugeShown?.type === type ? this._gaugeShown.data : null;
|
|
1751
|
+
const draw = (frame) => {
|
|
1752
|
+
this._gaugeShown = { type, data: frame };
|
|
1753
|
+
this._renderChart(new GaugeType(this.renderer, frame, options));
|
|
1754
|
+
};
|
|
1755
|
+
if (!options.animate || shown == null) {
|
|
1756
|
+
draw(data);
|
|
1757
|
+
return;
|
|
1758
|
+
}
|
|
1759
|
+
this._gaugeAnimation = new GaugeAnimation({
|
|
1760
|
+
from: GaugeValue.from(shown, options),
|
|
1761
|
+
to: GaugeValue.from(data, options),
|
|
1762
|
+
duration: options.animate === true ? 400 : Number(options.animate),
|
|
1763
|
+
draw,
|
|
1764
|
+
}).start();
|
|
1693
1765
|
}
|
|
1694
1766
|
|
|
1695
1767
|
_arcPath(cx, cy, r, startAngle, endAngle) {
|