@datarailsshared/dr_renderer 1.3.31 → 1.3.33

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.3.31",
3
+ "version": "1.3.33",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -115,22 +115,18 @@ function DrGaugeChart(pivotData, opts) {
115
115
  };
116
116
 
117
117
  this.formatValueLabel = function (value, options) {
118
- return `<span style="display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: ${
119
- options.label.font_size
120
- }px;">
118
+ return `<span style="display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: ${options.label.font_size
119
+ }px;">
121
120
  <span style="font-weight: 600; font-size: 1.3em; line-height: 1; color: ${options.label.font_color}">
122
121
  ${this.formatValue(value)}
123
- ${
124
- options.label.show_percentage_in_value
125
- ? `<span style="font-size: 0.5833em; font-weight: 600; color: ${
126
- options.gauge.colors.meta
122
+ ${options.label.show_percentage_in_value
123
+ ? `<span style="font-size: 0.5833em; font-weight: 600; color: ${options.gauge.colors.meta
127
124
  };">(${this.toPercent(value)})</span>`
128
125
  : ""
129
- }
126
+ }
130
127
  </span>
131
- <span style="font-weight: 500; font-size: 0.875em; line-height: 1; color: ${
132
- options.gauge.colors.meta
133
- };">Current status</span>
128
+ <span style="font-weight: 500; font-size: 0.875em; line-height: 1; color: ${options.gauge.colors.meta
129
+ };">Current status</span>
134
130
  </span>`;
135
131
  };
136
132
 
@@ -334,8 +330,7 @@ function DrGaugeChart(pivotData, opts) {
334
330
  // goal tooltip if lebels are hidden
335
331
  if (tick.pos === options.goal.value && !options.label.show) {
336
332
  drTooltip.add(
337
- `${
338
- options.label.show_goal_name ? options.goal.title || "" : ""
333
+ `${options.label.show_goal_name ? options.goal.title || "" : ""
339
334
  }<span style="font-weight: 600">${this.formatValue(options.goal.value)}</span>`,
340
335
  chart.goalIcon.element,
341
336
  {
@@ -385,10 +380,9 @@ function DrGaugeChart(pivotData, opts) {
385
380
  gauge: { thickness },
386
381
  } = options;
387
382
 
388
- const bands = segments.map((item, index) => {
389
- const itemFrom = !!index ? item.from - 1 : item.from;
383
+ const bands = segments.map((item) => {
390
384
  return {
391
- from: isAbsoluteValue ? itemFrom : (itemFrom * goalValue) / 100,
385
+ from: isAbsoluteValue ? item.from : (item.from * goalValue) / 100,
392
386
  to: isAbsoluteValue ? item.to : (item.to * goalValue) / 100,
393
387
  color: item.color,
394
388
  thickness: thickness,
@@ -451,6 +445,7 @@ function DrGaugeChart(pivotData, opts) {
451
445
  },
452
446
  margin: [0, 0, 0, 0],
453
447
  spacing: [0, 0, 0, 0],
448
+ animation: !DrGaugeChart.highchartsRenderer.chartAnimationsDisabled(),
454
449
  },
455
450
 
456
451
  pane: {
@@ -510,6 +505,7 @@ function DrGaugeChart(pivotData, opts) {
510
505
  backgroundColor: this.options.gauge.pivot.color,
511
506
  radius: this.options.gauge.pivot.radius,
512
507
  },
508
+ animation: !DrGaugeChart.highchartsRenderer.chartAnimationsDisabled(),
513
509
  },
514
510
  ],
515
511
  };
@@ -531,7 +527,7 @@ DrGaugeChart.createTicks = function (plotBands, options) {
531
527
  return _.uniq([plotBands[0].from || 0, ...plotBands.map((b) => b.to), options.goal.value]).sort((a, b) => a - b);
532
528
  };
533
529
 
534
- DrGaugeChart.getBorderPosition = function (chart, options, position) {
530
+ DrGaugeChart.getBorderPosition = function (chart, options, position) {
535
531
  const { center, size } = chart.pane[0].options;
536
532
  const {
537
533
  gauge: { tickLength, tickWidth },
@@ -9932,6 +9932,10 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
9932
9932
  disableAnimation = disabled;
9933
9933
  };
9934
9934
 
9935
+ highchartsRenderer.chartAnimationsDisabled = function () {
9936
+ return disableAnimation;
9937
+ };
9938
+
9935
9939
  highchartsRenderer.adjustFormatToSupportedByMoment = function(format) {
9936
9940
  return typeof format === 'string'
9937
9941
  ? format.replace(/y/g, 'Y').replace(/d/g, 'D').replace(/h/g, 'H')
@@ -5,6 +5,7 @@ const { DrChartTooltip } = require("../src/dr_chart_tooltip");
5
5
  jest.mock("../src/dr_chart_tooltip"); // Mock the tooltip class
6
6
 
7
7
  const mockFormattedValue = "16,549";
8
+ let disableChartAnimation = false;
8
9
 
9
10
  DrGaugeChart.highchartsRenderer = {
10
11
  CHART_TYPES: {
@@ -20,6 +21,8 @@ DrGaugeChart.highchartsRenderer = {
20
21
  formatValue: jest.fn().mockReturnValue({
21
22
  value: mockFormattedValue,
22
23
  }),
24
+ disableChartAnimations: jest.fn((value) => disableChartAnimation = value),
25
+ chartAnimationsDisabled: jest.fn(() => disableChartAnimation),
23
26
  };
24
27
 
25
28
  const mockAggregationValue = 1000;
@@ -111,6 +114,11 @@ describe("DrGaugeChart", () => {
111
114
  chart.render();
112
115
  expect(chart.configChart).toHaveBeenCalled();
113
116
  });
117
+
118
+ it("disables chart animations by demand", () => {
119
+ chart.render();
120
+ expect(DrGaugeChart.highchartsRenderer.chartAnimationsDisabled).toHaveBeenCalledTimes(2);
121
+ });
114
122
  });
115
123
 
116
124
  describe("isLeftQuarter", () => {
@@ -152,13 +160,13 @@ describe("DrGaugeChart", () => {
152
160
  title: "Title 1",
153
161
  },
154
162
  {
155
- from: 201,
163
+ from: 200,
156
164
  to: 400,
157
165
  color: "blue",
158
166
  title: "Title 2",
159
167
  },
160
168
  {
161
- from: 401,
169
+ from: 400,
162
170
  to: 800,
163
171
  color: "blue",
164
172
  title: "Title 3",
@@ -208,13 +216,13 @@ describe("DrGaugeChart", () => {
208
216
  title: "Title 1",
209
217
  },
210
218
  {
211
- from: 201,
219
+ from: 200,
212
220
  to: 400,
213
221
  color: "blue",
214
222
  title: "Title 2",
215
223
  },
216
224
  {
217
- from: 401,
225
+ from: 400,
218
226
  to: 800,
219
227
  color: "blue",
220
228
  title: "Title 3",
@@ -264,13 +272,13 @@ describe("DrGaugeChart", () => {
264
272
  title: "Title 1",
265
273
  },
266
274
  {
267
- from: 51,
275
+ from: 50,
268
276
  to: 100,
269
277
  color: "blue",
270
278
  title: "Title 2",
271
279
  },
272
280
  {
273
- from: 101,
281
+ from: 100,
274
282
  to: 175,
275
283
  color: "blue",
276
284
  title: "Title 3",
@@ -1745,13 +1753,13 @@ describe("DrGaugeChart", () => {
1745
1753
  color: "#BF1D30",
1746
1754
  },
1747
1755
  {
1748
- from: 51,
1756
+ from: 50,
1749
1757
  to: 160,
1750
1758
  title: "Medium",
1751
1759
  color: "#FFA310",
1752
1760
  },
1753
1761
  {
1754
- from: 161,
1762
+ from: 160,
1755
1763
  to: 200,
1756
1764
  title: "High",
1757
1765
  color: "#037C5A",