@datarailsshared/dr_renderer 1.5.180 → 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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.5.180",
3
+ "version": "1.5.194",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -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
- DrGaugeChart.createTicks = function (plotBands, options) {
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;
@@ -1369,7 +1369,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1369
1369
  }
1370
1370
 
1371
1371
  if (has_delta && additionOptions && ob.name == additionOptions.delta_column.name) {
1372
- ob = highchartsRenderer.getVariantSeries(ob, additionOptions.delta_column, pivotData);
1372
+ ob = highchartsRenderer.getVariantSeries(ob, additionOptions.delta_column, pivotData, colors);
1373
1373
  variat_serias = ob;
1374
1374
  }
1375
1375
 
@@ -1562,7 +1562,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1562
1562
  }
1563
1563
 
1564
1564
  if (has_delta && row_n_value && row_n_value.some(val => val === additionOptions.delta_column.name)) {
1565
- ob = highchartsRenderer.getVariantSeries(ob, additionOptions.delta_column, pivotData);
1565
+ ob = highchartsRenderer.getVariantSeries(ob, additionOptions.delta_column, pivotData, colors);
1566
1566
  variat_serias = ob;
1567
1567
  }
1568
1568
 
@@ -1872,8 +1872,8 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
1872
1872
  }
1873
1873
  }
1874
1874
 
1875
- highchartsRenderer.getVariantSeries = function (series, delta_column_options, pivotData) {
1876
- const varianceColor = delta_column_options.color || highchartsRenderer.variance_color || Highcharts.getOptions().colors[7];
1875
+ highchartsRenderer.getVariantSeries = function (series, delta_column_options, pivotData, colors) {
1876
+ const varianceColor = delta_column_options.color || colors[7] || highchartsRenderer.variance_color || Highcharts.getOptions().colors[7];
1877
1877
  series.name = delta_column_options.name.replace('_', '');
1878
1878
  series.initialName = series.name;
1879
1879
  series.color = varianceColor;