@datarailsshared/dr_renderer 1.5.190 → 1.5.194
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
|
@@ -110,7 +110,7 @@ function DrGaugeChart(pivotData, opts, isDynamicGoal) {
|
|
|
110
110
|
};
|
|
111
111
|
|
|
112
112
|
this.createTicks = function(plotBands, options) {
|
|
113
|
-
return DrGaugeChart.createTicks(plotBands, options);
|
|
113
|
+
return DrGaugeChart.createTicks(plotBands, options, this.format);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
116
|
this.mergeOptions = function (options) {
|
|
@@ -685,10 +685,33 @@ function DrGaugeChart(pivotData, opts, isDynamicGoal) {
|
|
|
685
685
|
this.min = this.ticks[0];
|
|
686
686
|
}
|
|
687
687
|
|
|
688
|
-
|
|
688
|
+
/**
|
|
689
|
+
* Creates a sorted, deduplicated array of tick values from plot band boundaries and the goal.
|
|
690
|
+
* When a number format is provided, ticks that are nearly equal to the goal due to
|
|
691
|
+
* floating-point drift and format identically are snapped to the exact goal value
|
|
692
|
+
* before deduplication, preventing overlapping labels.
|
|
693
|
+
* @param {Array<{from?: number, to: number}>} plotBands - The plot band definitions
|
|
694
|
+
* @param {{goal: {value: number}}} options - Chart options containing the goal
|
|
695
|
+
* @param {string} [format] - Optional number format string (e.g. "#,###.00") used to detect visually identical ticks
|
|
696
|
+
* @returns {number[]} Sorted, unique tick values
|
|
697
|
+
*/
|
|
698
|
+
DrGaugeChart.createTicks = function (plotBands, options, format) {
|
|
689
699
|
const goal = options.goal.value;
|
|
690
700
|
const ticks = [plotBands[0].from || 0, ...plotBands.map((b) => b.to)];
|
|
691
701
|
|
|
702
|
+
// Snap ticks that are nearly equal to goal (floating-point drift from
|
|
703
|
+
// percentage-to-absolute scaling) and format identically to the exact goal value
|
|
704
|
+
if (helpers.isNumber(goal) && format) {
|
|
705
|
+
const fmt = (v) => DrGaugeChart.highchartsRenderer.formatValue("n", format, v).value;
|
|
706
|
+
const formattedGoal = fmt(goal);
|
|
707
|
+
const epsilon = Math.abs(goal) * 1e-10 || 1e-10;
|
|
708
|
+
for (let i = 0; i < ticks.length; i++) {
|
|
709
|
+
if (ticks[i] !== goal && Math.abs(ticks[i] - goal) < epsilon && fmt(ticks[i]) === formattedGoal) {
|
|
710
|
+
ticks[i] = goal;
|
|
711
|
+
}
|
|
712
|
+
}
|
|
713
|
+
}
|
|
714
|
+
|
|
692
715
|
if (!DrGaugeChart.dynamicGoalFeatureEnabled() || goal < Math.max(...ticks) && goal > Math.min(...ticks)) {
|
|
693
716
|
ticks.push(options.goal.value);
|
|
694
717
|
}
|
|
@@ -81,8 +81,6 @@ export class GraphTableRenderer {
|
|
|
81
81
|
* This includes:
|
|
82
82
|
* - Destroying the Highcharts instance (if exists)
|
|
83
83
|
* - Calling destroy on table result (freeze panes observers, Handsontable instances, etc.)
|
|
84
|
-
* - Disposing the pivot model
|
|
85
|
-
* - Resetting internal state
|
|
86
84
|
* @returns {void}
|
|
87
85
|
*/
|
|
88
86
|
destroy(): void;
|