@datarailsshared/dr_renderer 1.2.455 → 1.2.457

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.2.455",
3
+ "version": "1.2.457",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -25,24 +25,24 @@ const GAUGE_OPTIONS_DEFAULT = {
25
25
  },
26
26
  goal: {
27
27
  title: "Goal",
28
- value: 180,
28
+ value: 1000000,
29
29
  },
30
30
  isAbsoluteValue: false,
31
31
  segments: [
32
32
  {
33
33
  from: 0,
34
- to: 60,
34
+ to: 50,
35
35
  title: "Low",
36
36
  color: "#BF1D30",
37
37
  },
38
38
  {
39
- from: 61,
40
- to: 80,
39
+ from: 51,
40
+ to: 90,
41
41
  title: "Medium",
42
42
  color: "#FFA310",
43
43
  },
44
44
  {
45
- from: 81,
45
+ from: 91,
46
46
  to: 100,
47
47
  title: "High",
48
48
  color: "#037C5A",
@@ -91,9 +91,10 @@ function DrGaugeChart(pivotData, opts) {
91
91
  gauge: { thickness },
92
92
  } = options;
93
93
 
94
- const bands = segments.map((item) => {
94
+ const bands = segments.map((item, index) => {
95
+ const itemFrom = !!index ? item.from - 1 : item.from;
95
96
  return {
96
- from: isAbsoluteValue ? Math.max(0, item.from - 1) : (Math.max(0, item.from - 1) * goalValue) / 100,
97
+ from: isAbsoluteValue ? itemFrom : (itemFrom * goalValue) / 100,
97
98
  to: isAbsoluteValue ? item.to : (item.to * goalValue) / 100,
98
99
  color: item.color,
99
100
  thickness: thickness,
@@ -101,15 +102,14 @@ function DrGaugeChart(pivotData, opts) {
101
102
  };
102
103
  });
103
104
 
104
- // clamp segments
105
- bands[0].from = 0;
105
+ // clamp last segment
106
106
  bands[bands.length - 1].to = Math.max(bands[bands.length - 1].to, goalValue);
107
107
 
108
108
  return bands;
109
109
  };
110
110
 
111
111
  this.createTicks = function (plotBands, options) {
112
- return [...new Set([0, ...plotBands.map((b) => b.to), options.goal.value])].sort((a, b) => a - b);
112
+ return [...new Set([plotBands[0].from || 0, ...plotBands.map((b) => b.to), options.goal.value])].sort((a, b) => a - b);
113
113
  };
114
114
 
115
115
  this.mergeOptions = function (options) {
@@ -122,7 +122,7 @@ function DrGaugeChart(pivotData, opts) {
122
122
 
123
123
  this.getAngleForValue = function (
124
124
  value,
125
- min = 0,
125
+ min = this.min,
126
126
  max = this.max,
127
127
  startAngle = this.options.gauge.startAngle,
128
128
  endAngle = this.options.gauge.endAngle
@@ -496,7 +496,7 @@ function DrGaugeChart(pivotData, opts) {
496
496
 
497
497
  // the value axis
498
498
  yAxis: {
499
- min: 0,
499
+ min: this.min,
500
500
  max: this.max,
501
501
  tickPositions: this.ticks,
502
502
  tickPosition: "inside",
@@ -558,6 +558,7 @@ function DrGaugeChart(pivotData, opts) {
558
558
  this.ticks = this.createTicks(this.plotBands, this.options);
559
559
  this.value = this.getValue(pivotData, opts);
560
560
  this.max = this.ticks[this.ticks.length - 1];
561
+ this.min = this.ticks[0];
561
562
  }
562
563
 
563
564
  module.exports = { DrGaugeChart, GAUGE_OPTIONS_DEFAULT };
@@ -7357,19 +7357,13 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
7357
7357
  },
7358
7358
  {
7359
7359
  element_type: 'checkbox',
7360
- element_label: 'Goal %',
7361
- value_name: 'show_percentage_in_goal',
7362
- default_value: true,
7363
- },
7364
- {
7365
- element_type: 'checkbox',
7366
- element_label: 'Value %',
7360
+ element_label: 'Value % out of Goal',
7367
7361
  value_name: 'show_percentage_in_value',
7368
7362
  default_value: true,
7369
7363
  },
7370
7364
  {
7371
7365
  element_type: 'checkbox',
7372
- element_label: 'Segments %',
7366
+ element_label: 'Segment % out Goal',
7373
7367
  value_name: 'show_percentage_in_segments',
7374
7368
  default_value: true,
7375
7369
  },
@@ -186,7 +186,7 @@ describe("DrGaugeChart", () => {
186
186
  ]);
187
187
  });
188
188
 
189
- it("should clamp values (min is always 0, max of goal and last segment)", () => {
189
+ it("should clamp values (max of goal and last segment)", () => {
190
190
  expect(
191
191
  chart.createPlotBands({
192
192
  isAbsoluteValue: true,
@@ -219,7 +219,7 @@ describe("DrGaugeChart", () => {
219
219
  })
220
220
  ).toEqual([
221
221
  {
222
- from: 0,
222
+ from: 100,
223
223
  to: 200,
224
224
  color: "red",
225
225
  thickness: 10,