@datarailsshared/dr_renderer 1.3.31 → 1.3.32

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.32",
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
  {
@@ -451,6 +446,7 @@ function DrGaugeChart(pivotData, opts) {
451
446
  },
452
447
  margin: [0, 0, 0, 0],
453
448
  spacing: [0, 0, 0, 0],
449
+ animation: !DrGaugeChart.highchartsRenderer.chartAnimationsDisabled(),
454
450
  },
455
451
 
456
452
  pane: {
@@ -510,6 +506,7 @@ function DrGaugeChart(pivotData, opts) {
510
506
  backgroundColor: this.options.gauge.pivot.color,
511
507
  radius: this.options.gauge.pivot.radius,
512
508
  },
509
+ animation: !DrGaugeChart.highchartsRenderer.chartAnimationsDisabled(),
513
510
  },
514
511
  ],
515
512
  };
@@ -531,7 +528,7 @@ DrGaugeChart.createTicks = function (plotBands, options) {
531
528
  return _.uniq([plotBands[0].from || 0, ...plotBands.map((b) => b.to), options.goal.value]).sort((a, b) => a - b);
532
529
  };
533
530
 
534
- DrGaugeChart.getBorderPosition = function (chart, options, position) {
531
+ DrGaugeChart.getBorderPosition = function (chart, options, position) {
535
532
  const { center, size } = chart.pane[0].options;
536
533
  const {
537
534
  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", () => {