@datarailsshared/dr_renderer 1.3.59 → 1.4.5

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.
@@ -0,0 +1,44 @@
1
+ name: Build and Publish
2
+
3
+ on:
4
+ workflow_dispatch:
5
+ pull_request:
6
+ branches:
7
+ - 'master'
8
+ - 'main'
9
+ push:
10
+ branches:
11
+ - 'master'
12
+ - 'main'
13
+ - 'migration-to-github'
14
+
15
+ concurrency:
16
+ group: '${{ github.ref }}-${{ github.workflow }}'
17
+ cancel-in-progress: true
18
+
19
+ permissions:
20
+ contents: read
21
+ packages: write
22
+
23
+ jobs:
24
+ publish-npm:
25
+ name: Build, Test and Publish to NPM
26
+ uses: datarails/dr_github_reusable/.github/workflows/npm-build-publish.yml@main
27
+ with:
28
+ node_version: '14.16.1'
29
+ access_level: 'public'
30
+ branch_postfix: false
31
+ main_branch: 'master'
32
+ version_prefix: '1.4'
33
+ secrets:
34
+ NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
35
+
36
+ publish-gh-packages:
37
+ name: Publish to GitHub Packages
38
+ needs: publish-npm
39
+ uses: datarails/dr_github_reusable/.github/workflows/npm-publish-gh-packages.yml@main
40
+ with:
41
+ node_version: '14.16.1'
42
+ package_scope: '@datarails'
43
+ version: ${{ needs.publish-npm.outputs.version }}
44
+ secrets: inherit
package/.whitesource ADDED
@@ -0,0 +1,3 @@
1
+ {
2
+ "settingsInheritedFrom": "Datarails/whitesource-config@main"
3
+ }
package/README.md CHANGED
@@ -14,10 +14,52 @@ This project was generated by amazing Datarails R&D team
14
14
  let hr = dr_renderer.getInitHighchartsRenderer($, document, default_colors, Highcharts);
15
15
 
16
16
  ## Development
17
+
17
18
  ### Types
18
- To be able to compile types with `npm run build:types` you need to install typescript globally:
19
19
 
20
- ```npm i -g typescript```
20
+ To compile types for the project use: `npm run build:types`
21
21
 
22
22
  ## Publish to npm
23
- Just merge to prod branch
23
+
24
+ Just merge to master branch
25
+
26
+ ## Error Handling
27
+
28
+ The renderer includes a comprehensive error handling system with specific error types for different scenarios:
29
+
30
+ ### Error Codes
31
+
32
+ The following error codes are available via `RendererErrorCodes`:
33
+
34
+ - `NoDataError` (1) - No data is available for rendering
35
+ - `TooMuchDataError` (3) - Dataset exceeds capacity
36
+ - `DataConflictError` (5) - Conflicts detected in data being processed
37
+ - `GaugeConfigurationError` (6) - Gauge chart missing required data
38
+ - `GenericRenderingError` (7) - Generic rendering failure in PivotTable components
39
+ - `GenericComputationalError` (8) - Generic computational failure in PivotTable components
40
+
41
+ ### Error Classes
42
+
43
+ All errors extend the `BaseRendererError` class which includes:
44
+ - `code` - Unique error code for identification
45
+ - `title` - Human-readable error message
46
+ - `options` - Additional context or configuration
47
+
48
+ ### Usage Example
49
+
50
+ ```javascript
51
+ const { RendererErrorCodes, NoDataError, TooMuchDataError } = require('@datarailsshared/dr_renderer');
52
+
53
+ try {
54
+ // Your rendering code here
55
+ } catch (error) {
56
+ if (error instanceof NoDataError) {
57
+ console.log('No data available:', error.title);
58
+ } else if (error.code === RendererErrorCodes.TooMuchDataError) {
59
+ console.log('Too much data:', error.title);
60
+ }
61
+ }
62
+ ```
63
+
64
+ ###
65
+ ##
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@datarailsshared/dr_renderer",
3
- "version": "1.3.59",
3
+ "version": "1.4.5",
4
4
  "description": "DataRails charts and tables renderer",
5
5
  "keywords": [
6
6
  "datarails",
@@ -11,7 +11,7 @@
11
11
  "scripts": {
12
12
  "login": "npm login",
13
13
  "test": "jest --coverage",
14
- "build:types": "tsc --build --verbose"
14
+ "build:types": "npx tsc --build --verbose"
15
15
  },
16
16
  "author": "Sergey Spivakov",
17
17
  "repository": {
@@ -32,11 +32,10 @@
32
32
  "babel-jest": "^25.5.1",
33
33
  "jest": "^25.3.0",
34
34
  "moment": "^2.29.1",
35
- "serve": "^11.3.0"
36
- },
37
- "bugs": {
38
- "url": ""
35
+ "serve": "^11.3.0",
36
+ "typescript": "^5.0.0"
39
37
  },
38
+ "types": "src/index.d.ts",
40
39
  "homepage": "https://bitbucket.org/datarails/dr_renderer/src/master/",
41
40
  "whitelistedNonPeerDependencies": [],
42
41
  "main": "src/index.js",
@@ -110,7 +110,7 @@ function DrDonutChart(highchartsRenderer, pivotData, opts, drilldownFunc, disabl
110
110
  x="0"
111
111
  style="font-size: ${series.center[2] / 16}px; fill: #6D6E6F;">
112
112
  ${(additionOptions.total_value_label && additionOptions.total_value_label.total_value_label_text) || 'Total'}
113
- </tspan>`,
113
+ </tspan>`
114
114
  )
115
115
  .css({
116
116
  textAnchor: 'middle',
@@ -123,7 +123,7 @@ function DrDonutChart(highchartsRenderer, pivotData, opts, drilldownFunc, disabl
123
123
  const x = series.center[0] + chart.plotLeft;
124
124
  const y = chart.plotTop + series.center[1] - rect.height / 2;
125
125
 
126
- totalLabel.attr({ x, y });
126
+ totalLabel.attr({ x: x, y: y });
127
127
  };
128
128
 
129
129
  this.setDrilldownConfig = function (chartConfig) {
@@ -134,7 +134,7 @@ function DrDonutChart(highchartsRenderer, pivotData, opts, drilldownFunc, disabl
134
134
  pivotData,
135
135
  chartConfig,
136
136
  additionOptions,
137
- opts,
137
+ opts
138
138
  );
139
139
  } else {
140
140
  chartConfig.drilldown = highchartsRenderer.getDataLabelsStylesForDrillDown(additionOptions);
@@ -61,12 +61,12 @@ function DrGaugeCategoriesSummaryChart(pivotData, opts) {
61
61
 
62
62
  this.createPlotBands = function (options) {
63
63
  const {
64
- segments,
64
+ segments: segments,
65
65
  goal: { value: goalValue },
66
- gauge: { thickness },
66
+ gauge: { thickness: thickness },
67
67
  } = options;
68
68
 
69
- let bands = segments.map((item, index) => {
69
+ let bands = _.map(segments, (item, index) => {
70
70
  return {
71
71
  from: item.from,
72
72
  to: item.to,
@@ -120,7 +120,7 @@ function DrGaugeCategoriesSummaryChart(pivotData, opts) {
120
120
  }
121
121
  );
122
122
  }
123
- segmentsOutput = segmentsOutput.filter(
123
+ segmentsOutput = _.filter(segmentsOutput,
124
124
  (segment) => {
125
125
  return segment.from !== segment.to;
126
126
  }
@@ -133,8 +133,9 @@ function DrGaugeCategoriesSummaryChart(pivotData, opts) {
133
133
  }
134
134
 
135
135
  this.getCompletionPercentage = function (options) {
136
- const countOfCompletedItems = options.segments.find(segment => !!segment.isCompletionParameter)?.count || 0;
137
- const totalCount = options.segments.reduce((acc, segment) => acc + segment.count, 0);
136
+ const completedSegment = _.find(options.segments, segment => !!segment.isCompletionParameter);
137
+ const countOfCompletedItems = completedSegment ? completedSegment.count : 0;
138
+ const totalCount = _.reduce(options.segments, (acc, segment) => acc + segment.count, 0);
138
139
  if (totalCount === 0) {
139
140
  return 0;
140
141
  }
@@ -179,8 +180,7 @@ function DrGaugeCategoriesSummaryChart(pivotData, opts) {
179
180
 
180
181
 
181
182
  this.getPaneDimensions = function (chart, options) {
182
- const {renderer} = chart;
183
- const {offset} = options.gauge;
183
+ const offset = options.gauge.offset;
184
184
 
185
185
  const offsetBottom = options.gauge.valueOffset[0] + options.gauge.valueOffset[2] + offset[2];
186
186
 
@@ -199,7 +199,7 @@ function DrGaugeCategoriesSummaryChart(pivotData, opts) {
199
199
  const {radius, center} = this.getPaneDimensions(chart, options);
200
200
  chart.pane[0].options.size = 2 * radius;
201
201
  chart.pane[0].options.center = center;
202
- chart.yAxis[0].options.plotBands.forEach((band) => {
202
+ _.forEach(chart.yAxis[0].options.plotBands, (band) => {
203
203
  band.outerRadius = radius - (options.gauge.tickLength - options.gauge.thickness) / 2;
204
204
  });
205
205
  };
@@ -241,16 +241,16 @@ function DrGaugeCategoriesSummaryChart(pivotData, opts) {
241
241
  plotBorderWidth: 0,
242
242
  plotShadow: false,
243
243
  events: {
244
- render: ({target: chart}) => {
245
- this.moveCustomElementsToFront(chart);
244
+ render: (event) => {
245
+ this.moveCustomElementsToFront(event.target);
246
246
  },
247
- beforeRedraw: ({target: chart}) => {
248
- this.setPane(chart, this.options);
249
- this.updateCustomElements(chart, this.options);
247
+ beforeRedraw: (event) => {
248
+ this.setPane(event.target, this.options);
249
+ this.updateCustomElements(event.target, this.options);
250
250
  },
251
- beforeRender: ({target: chart}) => {
252
- this.setPane(chart, this.options);
253
- this.setCustomElements(chart, this.options);
251
+ beforeRender: (event) => {
252
+ this.setPane(event.target, this.options);
253
+ this.setCustomElements(event.target, this.options);
254
254
  }
255
255
  },
256
256
  margin: [0, 0, 0, 0],