@datarailsshared/dr_renderer 1.2.461 → 1.2.463
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/package.json
CHANGED
@@ -444,8 +444,9 @@ function DrGaugeChart(pivotData, opts) {
|
|
444
444
|
chart.goalIcon.toFront();
|
445
445
|
};
|
446
446
|
|
447
|
-
this.clampValueToPane = function (value, max = this.max) {
|
448
|
-
|
447
|
+
this.clampValueToPane = function (value, max = this.max, min = this.min) {
|
448
|
+
const correction = Math.abs(max - min) * 0.02;
|
449
|
+
return helpers.clamp(min - correction, value, max + correction);
|
449
450
|
};
|
450
451
|
|
451
452
|
this.configChart = function () {
|
@@ -2242,7 +2242,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2242
2242
|
return newOptions;
|
2243
2243
|
}
|
2244
2244
|
|
2245
|
-
const rangeArr = [range.low, range.medium, Math.max(range.high || 100, 100)];
|
2245
|
+
const rangeArr = [1 * range.low, 1 * range.medium, Math.max(1 * range.high || 100, 100)];
|
2246
2246
|
|
2247
2247
|
newOptions.segments.forEach((segment, i) => {
|
2248
2248
|
segment.from = (rangeArr[i - 1] + 1) || segment.from;
|
@@ -2253,7 +2253,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
2253
2253
|
newOptions.goal = highchartsRenderer.objectCopyJsonMethod(GAUGE_OPTIONS_DEFAULT.goal);
|
2254
2254
|
}
|
2255
2255
|
|
2256
|
-
newOptions.goal.value = range.max || newOptions.goal.value;
|
2256
|
+
newOptions.goal.value = 1 * range.max || newOptions.goal.value;
|
2257
2257
|
|
2258
2258
|
delete newOptions.range;
|
2259
2259
|
|
@@ -1687,26 +1687,26 @@ describe("DrGaugeChart", () => {
|
|
1687
1687
|
|
1688
1688
|
it("calls helpers.clamp with correct bounds and value", () => {
|
1689
1689
|
const value = 50;
|
1690
|
-
const result = chart.clampValueToPane(value, 100);
|
1690
|
+
const result = chart.clampValueToPane(value, 100, 0);
|
1691
1691
|
|
1692
1692
|
expect(helpers.clamp).toHaveBeenCalledWith(-2, value, 102);
|
1693
1693
|
expect(result).toBe(value); // Value is within range
|
1694
1694
|
});
|
1695
1695
|
|
1696
1696
|
it("returns clamped value when below range", () => {
|
1697
|
-
const value = -
|
1698
|
-
const result = chart.clampValueToPane(value, 100);
|
1697
|
+
const value = -1000;
|
1698
|
+
const result = chart.clampValueToPane(value, 100, -100);
|
1699
1699
|
|
1700
|
-
expect(helpers.clamp).toHaveBeenCalledWith(-
|
1701
|
-
expect(result).toBe(-
|
1700
|
+
expect(helpers.clamp).toHaveBeenCalledWith(-104, value, 104);
|
1701
|
+
expect(result).toBe(-104); // Clamped to minimum
|
1702
1702
|
});
|
1703
1703
|
|
1704
1704
|
it("returns clamped value when above range", () => {
|
1705
1705
|
const value = 200;
|
1706
|
-
const result = chart.clampValueToPane(value, 100);
|
1706
|
+
const result = chart.clampValueToPane(value, 100, -100);
|
1707
1707
|
|
1708
|
-
expect(helpers.clamp).toHaveBeenCalledWith(-
|
1709
|
-
expect(result).toBe(
|
1708
|
+
expect(helpers.clamp).toHaveBeenCalledWith(-104, value, 104);
|
1709
|
+
expect(result).toBe(104); // Clamped to maximum
|
1710
1710
|
});
|
1711
1711
|
|
1712
1712
|
it("uses the deafult max umless it is provided", () => {
|
@@ -8771,6 +8771,37 @@ describe('highcharts_renderer', () => {
|
|
8771
8771
|
}]);
|
8772
8772
|
});
|
8773
8773
|
|
8774
|
+
it('should prepopulate segments with the old range data (string)', () => {
|
8775
|
+
const res = highchartsRenderer.transformOldGaugeOptions({
|
8776
|
+
opt1: 1,
|
8777
|
+
opt2: '2',
|
8778
|
+
range: {
|
8779
|
+
low: '20',
|
8780
|
+
medium: '30',
|
8781
|
+
high: '70',
|
8782
|
+
max: '200'
|
8783
|
+
}
|
8784
|
+
});
|
8785
|
+
expect(res.segments).toEqual([{
|
8786
|
+
from: 0,
|
8787
|
+
to: 20,
|
8788
|
+
color: GAUGE_OPTIONS_DEFAULT.segments[0].color,
|
8789
|
+
title: GAUGE_OPTIONS_DEFAULT.segments[0].title,
|
8790
|
+
},
|
8791
|
+
{
|
8792
|
+
from: 21,
|
8793
|
+
to: 30,
|
8794
|
+
color: GAUGE_OPTIONS_DEFAULT.segments[1].color,
|
8795
|
+
title: GAUGE_OPTIONS_DEFAULT.segments[1].title
|
8796
|
+
},
|
8797
|
+
{
|
8798
|
+
from: 31,
|
8799
|
+
to: 100,
|
8800
|
+
color: GAUGE_OPTIONS_DEFAULT.segments[2].color,
|
8801
|
+
title: GAUGE_OPTIONS_DEFAULT.segments[2].title
|
8802
|
+
}]);
|
8803
|
+
});
|
8804
|
+
|
8774
8805
|
it('should remove old range object', () => {
|
8775
8806
|
const res = highchartsRenderer.transformOldGaugeOptions({
|
8776
8807
|
opt1: 1,
|