@datarailsshared/dr_renderer 1.2.463 → 1.3.1-27.merge
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/.circleci/config.yml +13 -7
- package/.github/workflows/build-deploy.yml +29 -0
- package/CODEOWNERS +1 -0
- package/package.json +1 -1
- package/src/charts/dr_donut_chart.js +163 -0
- package/src/charts/dr_gauge_categories_summary_chart.js +323 -0
- package/src/charts/dr_gauge_chart.js +179 -130
- package/src/dr-renderer-helpers.js +20 -0
- package/src/dr_chart_tooltip.js +16 -9
- package/src/dr_pivottable.js +27 -3
- package/src/highcharts_renderer.js +348 -301
- package/src/pivot.css +32 -18
- package/src/published_items_renderer.js +6 -6
- package/src/smart_queries_helper.js +96 -0
- package/tests/dr-renderer-helpers.test.js +48 -0
- package/tests/dr_chart_tooltip.test.js +50 -0
- package/tests/dr_gauge_chart.test.js +64 -40
- package/tests/highcharts_renderer.test.js +8 -397
package/.circleci/config.yml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
version: 2.1
|
2
2
|
|
3
3
|
orbs:
|
4
|
-
datarails-cicd-orb: datarails/datarails-cicd-orb@dev:primary
|
4
|
+
datarails-cicd-orb: datarails-ns/datarails-cicd-orb@dev:primary
|
5
5
|
|
6
6
|
defaults: &defaults
|
7
7
|
working_directory: ~/repo
|
@@ -24,7 +24,7 @@ jobs:
|
|
24
24
|
postfix="-$CIRCLE_BRANCH"
|
25
25
|
fi
|
26
26
|
|
27
|
-
VERSION="1.
|
27
|
+
VERSION="1.3.$CIRCLE_BUILD_NUM$postfix"
|
28
28
|
sed -i s/{{cicd_version}}/$VERSION/g ./package.json
|
29
29
|
cat ./package.json
|
30
30
|
- run:
|
@@ -40,8 +40,8 @@ jobs:
|
|
40
40
|
name: Publish package
|
41
41
|
command: npm publish . --access=public
|
42
42
|
- datarails-cicd-orb/add-ssh-id:
|
43
|
-
private_key_env_var:
|
44
|
-
public_key_env_var:
|
43
|
+
private_key_env_var: github_deploy_private_encoded
|
44
|
+
public_key_env_var: github_deploy_pub_encoded
|
45
45
|
is_public_key_encoded: true
|
46
46
|
is_private_key_encoded: true
|
47
47
|
- run:
|
@@ -52,14 +52,20 @@ jobs:
|
|
52
52
|
postfix="-$CIRCLE_BRANCH"
|
53
53
|
fi
|
54
54
|
|
55
|
-
VERSION="1.
|
55
|
+
VERSION="1.3.$CIRCLE_BUILD_NUM$postfix"
|
56
56
|
git config --global user.email noreplay@circleci.com
|
57
57
|
git config --global user.name circleci
|
58
58
|
git config --global -l
|
59
59
|
git tag -a "$CIRCLE_BRANCH/$VERSION" -m "circleci build"
|
60
|
-
|
60
|
+
# Test SSH connection to GitHub
|
61
|
+
output=$(ssh -o "StrictHostKeyChecking no" -T git@github.com 2>&1 || true)
|
62
|
+
echo "$output"
|
63
|
+
if ! echo "$output" | grep -q "Hi.*You've successfully authenticated"; then
|
64
|
+
echo "Failed to authenticate with GitHub"
|
65
|
+
exit 1
|
66
|
+
fi
|
67
|
+
# Push the tag after successful authentication
|
61
68
|
git push --tags origin
|
62
|
-
echo 555
|
63
69
|
workflows:
|
64
70
|
version: 2
|
65
71
|
npm-publish:
|
@@ -0,0 +1,29 @@
|
|
1
|
+
name: NPM Build and Publish
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch:
|
5
|
+
pull_request:
|
6
|
+
branches:
|
7
|
+
- 'master'
|
8
|
+
push:
|
9
|
+
branches:
|
10
|
+
- 'master'
|
11
|
+
|
12
|
+
concurrency:
|
13
|
+
group: '${{ github.ref }}-${{ github.workflow }}'
|
14
|
+
cancel-in-progress: true
|
15
|
+
|
16
|
+
jobs:
|
17
|
+
npm-workflow:
|
18
|
+
name: Build, Test and Publish
|
19
|
+
uses: datarails/dr_github_reusable/.github/workflows/npm-build-publish.yml@main
|
20
|
+
with:
|
21
|
+
access_level: 'public'
|
22
|
+
branch_postfix: true
|
23
|
+
main_branch: 'master'
|
24
|
+
runner: ${{ vars.GITHUB_RUNNER || 'datarails-dev' }}
|
25
|
+
skip_publish: ${{ github.event_name != 'pull_request' }}
|
26
|
+
secrets:
|
27
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
28
|
+
SSH_PRIVATE_KEY: ${{ secrets.GITHUB_PRIVATE_KEY }}
|
29
|
+
|
package/CODEOWNERS
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
* @Datarails/RnD_Team_Dragons
|
package/package.json
CHANGED
@@ -0,0 +1,163 @@
|
|
1
|
+
const helpers = require('./../dr-renderer-helpers');
|
2
|
+
|
3
|
+
function DrDonutChart(highchartsRenderer, pivotData, opts, drilldownFunc, disableAnimation) {
|
4
|
+
const additionOptions = opts.chartOptions
|
5
|
+
? opts.chartOptions
|
6
|
+
: highchartsRenderer.getDefaultValueForChart(highchartsRenderer.CHART_TYPES.DONUT_CHART);
|
7
|
+
let totalLabel;
|
8
|
+
|
9
|
+
this.render = function () {
|
10
|
+
return highchartsRenderer.ptCreateElementAndDraw(this.getConfig(), opts);
|
11
|
+
};
|
12
|
+
|
13
|
+
this.getConfig = function () {
|
14
|
+
const config = {
|
15
|
+
chart: this.getChartConfig(),
|
16
|
+
plotOptions: this.getPlotOptionsConfig(),
|
17
|
+
colors: this.getColorSettings(),
|
18
|
+
tooltip: this.getTooltipConfig(),
|
19
|
+
legend: highchartsRenderer.getOptionsForLegends(additionOptions, 1, false, true),
|
20
|
+
};
|
21
|
+
|
22
|
+
config.series = highchartsRenderer.ptCreateSeriesToDrillDownChart(pivotData, config, additionOptions, opts);
|
23
|
+
highchartsRenderer.setTitleAndSubTitle(config, opts, additionOptions);
|
24
|
+
helpers.disableLegendInteractionIfRequired(config, additionOptions);
|
25
|
+
this.setDrilldownConfig(config);
|
26
|
+
|
27
|
+
return config;
|
28
|
+
};
|
29
|
+
|
30
|
+
this.getChartConfig = function () {
|
31
|
+
const chartConfiguration = {
|
32
|
+
type: 'pie',
|
33
|
+
events: {
|
34
|
+
drilldown: function (e) {
|
35
|
+
if (drilldownFunc) drilldownFunc(e, this, 'drilldown');
|
36
|
+
},
|
37
|
+
drillup: function (e) {
|
38
|
+
if (drilldownFunc) drilldownFunc(e, this, 'drillup');
|
39
|
+
},
|
40
|
+
render: this.drawTotalLabel,
|
41
|
+
},
|
42
|
+
animation: !disableAnimation,
|
43
|
+
};
|
44
|
+
this.setChartPositioning(chartConfiguration);
|
45
|
+
|
46
|
+
return chartConfiguration;
|
47
|
+
};
|
48
|
+
|
49
|
+
this.getPlotOptionsConfig = function () {
|
50
|
+
const plotOptions = {
|
51
|
+
series: {
|
52
|
+
animation: !disableAnimation,
|
53
|
+
dataLabels: {
|
54
|
+
allowOverlap: additionOptions && additionOptions.label_pie ? additionOptions.label_pie.overlap : false,
|
55
|
+
enabled: additionOptions && additionOptions.label_pie ? additionOptions.label_pie.show : false,
|
56
|
+
formatter: highchartsRenderer.pieDataLabelFormatter(pivotData, opts, true),
|
57
|
+
style: highchartsRenderer.getDataLabelsStyle(additionOptions),
|
58
|
+
},
|
59
|
+
showInLegend: true,
|
60
|
+
innerSize: '75%',
|
61
|
+
states: {
|
62
|
+
hover: {
|
63
|
+
halo: {
|
64
|
+
size: 0,
|
65
|
+
},
|
66
|
+
},
|
67
|
+
},
|
68
|
+
},
|
69
|
+
};
|
70
|
+
plotOptions.series = highchartsRenderer.getDataLabelsOptions(additionOptions, plotOptions.series);
|
71
|
+
|
72
|
+
return plotOptions;
|
73
|
+
};
|
74
|
+
|
75
|
+
this.getColorSettings = function () {
|
76
|
+
return additionOptions && additionOptions.chart
|
77
|
+
? highchartsRenderer.getColorsWithOffset(additionOptions.chart.colors_offset)
|
78
|
+
: undefined;
|
79
|
+
};
|
80
|
+
|
81
|
+
this.getTooltipConfig = function () {
|
82
|
+
return {
|
83
|
+
headerFormat: '',
|
84
|
+
pointFormatter: highchartsRenderer.pieDrillDownFormatterToTooltip(pivotData, opts),
|
85
|
+
};
|
86
|
+
};
|
87
|
+
|
88
|
+
this.drawTotalLabel = function () {
|
89
|
+
const chart = this;
|
90
|
+
const series = chart.series[0];
|
91
|
+
|
92
|
+
const aggTotal = pivotData.getAggregator([], []);
|
93
|
+
const formattedValue =
|
94
|
+
additionOptions && additionOptions.customTotalValueFormatFn
|
95
|
+
? additionOptions.customTotalValueFormatFn(series.total)
|
96
|
+
: aggTotal.format(series.total, true);
|
97
|
+
|
98
|
+
if (totalLabel) {
|
99
|
+
totalLabel.destroy();
|
100
|
+
}
|
101
|
+
|
102
|
+
totalLabel = chart.renderer
|
103
|
+
.text(
|
104
|
+
`<tspan
|
105
|
+
style="font-size: ${series.center[2] / 12}px; font-weight: 600; fill: #333333;">
|
106
|
+
${formattedValue}
|
107
|
+
</tspan>
|
108
|
+
<tspan
|
109
|
+
dy="${series.center[2] / 8}"
|
110
|
+
x="0"
|
111
|
+
style="font-size: ${series.center[2] / 16}px; fill: #6D6E6F;">
|
112
|
+
${(additionOptions.total_value_label && additionOptions.total_value_label.total_value_label_text) || 'Total'}
|
113
|
+
</tspan>`,
|
114
|
+
)
|
115
|
+
.css({
|
116
|
+
textAnchor: 'middle',
|
117
|
+
dominantBaseline: 'text-before-edge',
|
118
|
+
})
|
119
|
+
.attr('y', '0')
|
120
|
+
.add();
|
121
|
+
|
122
|
+
const rect = totalLabel.element.getBoundingClientRect();
|
123
|
+
const x = series.center[0] + chart.plotLeft;
|
124
|
+
const y = chart.plotTop + series.center[1] - rect.height / 2;
|
125
|
+
|
126
|
+
totalLabel.attr({ x, y });
|
127
|
+
};
|
128
|
+
|
129
|
+
this.setDrilldownConfig = function (chartConfig) {
|
130
|
+
if (drilldownFunc) {
|
131
|
+
chartConfig.drilldown = {};
|
132
|
+
} else if (!pivotData.isDrillDownDisabled) {
|
133
|
+
chartConfig.drilldown = highchartsRenderer.ptCreateDrillDownSeriesToDrilldownChart(
|
134
|
+
pivotData,
|
135
|
+
chartConfig,
|
136
|
+
additionOptions,
|
137
|
+
opts,
|
138
|
+
);
|
139
|
+
} else {
|
140
|
+
chartConfig.drilldown = highchartsRenderer.getDataLabelsStylesForDrillDown(additionOptions);
|
141
|
+
}
|
142
|
+
};
|
143
|
+
|
144
|
+
this.setChartPositioning = function (chart) {
|
145
|
+
const chartPositioning = additionOptions.chart_position;
|
146
|
+
if (!!chartPositioning) {
|
147
|
+
Object.assign(chart, {
|
148
|
+
margin: [
|
149
|
+
chartPositioning.margin_top,
|
150
|
+
chartPositioning.margin_right,
|
151
|
+
chartPositioning.margin_bottom,
|
152
|
+
chartPositioning.margin_left,
|
153
|
+
],
|
154
|
+
spacingTop: chartPositioning.spacing_top,
|
155
|
+
spacingBottom: chartPositioning.spacing_bottom,
|
156
|
+
spacingLeft: chartPositioning.spacing_left,
|
157
|
+
spacingRight: chartPositioning.spacing_right,
|
158
|
+
});
|
159
|
+
}
|
160
|
+
};
|
161
|
+
}
|
162
|
+
|
163
|
+
module.exports = { DrDonutChart };
|
@@ -0,0 +1,323 @@
|
|
1
|
+
const _ = require('lodash');
|
2
|
+
const helpers = require("../dr-renderer-helpers");
|
3
|
+
const {DrGaugeChart} = require("./dr_gauge_chart");
|
4
|
+
|
5
|
+
const GAUGE_CATEGORIES_SUMMARY_OPTIONS_DEFAULT = {
|
6
|
+
gauge: {
|
7
|
+
background: "#fff",
|
8
|
+
startAngle: -90,
|
9
|
+
endAngle: 90,
|
10
|
+
thickness: 17,
|
11
|
+
tickLength: 0,
|
12
|
+
tickWidth: 0,
|
13
|
+
valueOffset: [0, 0, 0, 0],
|
14
|
+
offset: [12, 8, 12, 8],
|
15
|
+
goalIcon: '',
|
16
|
+
goalIconSize: [0, 0],
|
17
|
+
pivot: {
|
18
|
+
radius: 0,
|
19
|
+
color: "#808080",
|
20
|
+
},
|
21
|
+
colors: {
|
22
|
+
meta: "#333",
|
23
|
+
goal: "#4646CE",
|
24
|
+
},
|
25
|
+
},
|
26
|
+
goal: {
|
27
|
+
title: "Goal",
|
28
|
+
value: 1000000,
|
29
|
+
},
|
30
|
+
isAbsoluteValue: false,
|
31
|
+
segments: [
|
32
|
+
{
|
33
|
+
title: 'Completed',
|
34
|
+
count: 0,
|
35
|
+
isCompletionParameter: true,
|
36
|
+
color: '#037C5A',
|
37
|
+
},
|
38
|
+
{
|
39
|
+
title: 'Overdue',
|
40
|
+
count: 0,
|
41
|
+
color: '#BF1D30',
|
42
|
+
},
|
43
|
+
{
|
44
|
+
title: 'Pending',
|
45
|
+
count: 0,
|
46
|
+
color: '#FFA310',
|
47
|
+
},
|
48
|
+
{
|
49
|
+
title: 'Remaining',
|
50
|
+
count: 0,
|
51
|
+
color: '#F0F1F4',
|
52
|
+
}],
|
53
|
+
};
|
54
|
+
|
55
|
+
function DrGaugeCategoriesSummaryChart(pivotData, opts) {
|
56
|
+
this.completionPercentage = 0;
|
57
|
+
|
58
|
+
this.render = function () {
|
59
|
+
return DrGaugeChart.highchartsRenderer.ptCreateElementAndDraw(this.configChart(), opts);
|
60
|
+
};
|
61
|
+
|
62
|
+
this.createPlotBands = function (options) {
|
63
|
+
const {
|
64
|
+
segments,
|
65
|
+
goal: { value: goalValue },
|
66
|
+
gauge: { thickness },
|
67
|
+
} = options;
|
68
|
+
|
69
|
+
let bands = segments.map((item, index) => {
|
70
|
+
return {
|
71
|
+
from: item.from,
|
72
|
+
to: item.to,
|
73
|
+
color: item.color,
|
74
|
+
thickness: thickness,
|
75
|
+
title: item.title,
|
76
|
+
};
|
77
|
+
});
|
78
|
+
|
79
|
+
if (bands.length === 0) {
|
80
|
+
bands = [
|
81
|
+
{
|
82
|
+
from: 0,
|
83
|
+
to: 100,
|
84
|
+
color: '#F0F1F4',
|
85
|
+
thickness: thickness,
|
86
|
+
title: 'None',
|
87
|
+
}
|
88
|
+
]
|
89
|
+
}
|
90
|
+
|
91
|
+
// clamp last segment
|
92
|
+
bands[bands.length - 1].to = Math.max(bands[bands.length - 1].to, goalValue);
|
93
|
+
|
94
|
+
return bands;
|
95
|
+
};
|
96
|
+
|
97
|
+
this.getDefaultValueForChart = function (type, existing_options) {
|
98
|
+
return DrGaugeChart.highchartsRenderer.getDefaultValueForChart(type, existing_options);
|
99
|
+
};
|
100
|
+
|
101
|
+
this.mergeOptions = function (options) {
|
102
|
+
return helpers.mergeDeep(
|
103
|
+
JSON.parse(JSON.stringify(GAUGE_CATEGORIES_SUMMARY_OPTIONS_DEFAULT)),
|
104
|
+
this.getDefaultValueForChart(DrGaugeChart.highchartsRenderer.CHART_TYPES.GAUGE_CHART_CATEGORIES_SUMMARY),
|
105
|
+
options
|
106
|
+
);
|
107
|
+
};
|
108
|
+
|
109
|
+
this.prepareSegments = function (options) {
|
110
|
+
let segmentsSumAggregator = 0;
|
111
|
+
let segmentsOutput = [];
|
112
|
+
for (let i = 0; i < options.segments.length; i++) {
|
113
|
+
let currentSegment = options.segments[i];
|
114
|
+
segmentsOutput.push(
|
115
|
+
{
|
116
|
+
from: segmentsSumAggregator,
|
117
|
+
to: segmentsSumAggregator += currentSegment.count,
|
118
|
+
color: currentSegment.color,
|
119
|
+
name: currentSegment.title,
|
120
|
+
}
|
121
|
+
);
|
122
|
+
}
|
123
|
+
segmentsOutput = segmentsOutput.filter(
|
124
|
+
(segment) => {
|
125
|
+
return segment.from !== segment.to;
|
126
|
+
}
|
127
|
+
);
|
128
|
+
options.segments = segmentsOutput;
|
129
|
+
options.goal = {
|
130
|
+
title: '',
|
131
|
+
value: segmentsSumAggregator,
|
132
|
+
};
|
133
|
+
}
|
134
|
+
|
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);
|
138
|
+
if (totalCount === 0) {
|
139
|
+
return 0;
|
140
|
+
}
|
141
|
+
return Math.round(countOfCompletedItems / totalCount * 100);
|
142
|
+
}
|
143
|
+
|
144
|
+
this.clampValueToPane = function (value, max = this.max, min = this.min) {
|
145
|
+
const correction = Math.abs(max - min) * 0.02;
|
146
|
+
return helpers.clamp(min - correction, value, max + correction);
|
147
|
+
};
|
148
|
+
|
149
|
+
|
150
|
+
this.formatValueLabel = function (value, options) {
|
151
|
+
return `<span style="display: flex; flex-direction: column; align-items: center; gap: 6px; font-size: ${
|
152
|
+
options.label.font_size
|
153
|
+
}px;">
|
154
|
+
<span style="font-weight: 600; font-size: 1.5em; line-height: 1; color: ${options.label.font_color}">
|
155
|
+
${this.completionPercentage}%
|
156
|
+
</span>
|
157
|
+
<span style="font-weight: 600; font-size: 0.75em; line-height: 1; color: ${
|
158
|
+
options.gauge.colors.meta
|
159
|
+
};">Completed</span>
|
160
|
+
</span>`;
|
161
|
+
};
|
162
|
+
|
163
|
+
this.clampValueToPane = function (value, max = this.max, min = this.min) {
|
164
|
+
const correction = Math.abs(max - min) * 0.02;
|
165
|
+
return helpers.clamp(min - correction, value, max + correction);
|
166
|
+
};
|
167
|
+
|
168
|
+
this.createValueLabel = function (chart, options) {
|
169
|
+
const label = chart.renderer.text(this.formatValueLabel(this.value, options), 0, 0, true).add().toFront();
|
170
|
+
|
171
|
+
helpers.removeSVGTextCorrection(label, "yCorr");
|
172
|
+
|
173
|
+
label.attr(DrGaugeChart.getValueLabelPosition(chart, options)).css({
|
174
|
+
transform: "translateX(-50%) translateY(-100%)",
|
175
|
+
});
|
176
|
+
|
177
|
+
return label;
|
178
|
+
};
|
179
|
+
|
180
|
+
|
181
|
+
this.getPaneDimensions = function (chart, options) {
|
182
|
+
const {renderer} = chart;
|
183
|
+
const {offset} = options.gauge;
|
184
|
+
|
185
|
+
const offsetBottom = options.gauge.valueOffset[0] + options.gauge.valueOffset[2] + offset[2];
|
186
|
+
|
187
|
+
const radiuses = [chart.chartWidth / 2 - Math.max(offset[1], offset[3]), chart.chartHeight - offsetBottom - offset[0]];
|
188
|
+
|
189
|
+
radiuses.push((chart.chartWidth / 2 - offset[1]) / Math.sin(Math.abs(Math.PI / 2)));
|
190
|
+
radiuses.push((chart.chartHeight - offsetBottom - offset[0]) / Math.cos(Math.abs(Math.PI / 2)));
|
191
|
+
|
192
|
+
return {
|
193
|
+
radius: Math.min(...radiuses),
|
194
|
+
center: [chart.chartWidth / 2, chart.chartHeight - offsetBottom],
|
195
|
+
};
|
196
|
+
};
|
197
|
+
|
198
|
+
this.setPane = function (chart, options) {
|
199
|
+
const {radius, center} = this.getPaneDimensions(chart, options);
|
200
|
+
chart.pane[0].options.size = 2 * radius;
|
201
|
+
chart.pane[0].options.center = center;
|
202
|
+
chart.yAxis[0].options.plotBands.forEach((band) => {
|
203
|
+
band.outerRadius = radius - (options.gauge.tickLength - options.gauge.thickness) / 2;
|
204
|
+
});
|
205
|
+
};
|
206
|
+
|
207
|
+
this.setCustomElements = function (chart, options) {
|
208
|
+
chart.label = this.createValueLabel(chart, options);
|
209
|
+
chart.startBorder = DrGaugeChart.createBorder(chart, options, "start");
|
210
|
+
chart.endBorder = DrGaugeChart.createBorder(chart, options, "end");
|
211
|
+
};
|
212
|
+
|
213
|
+
this.updateCustomElements = function (chart, options) {
|
214
|
+
chart.startBorder.attr(DrGaugeChart.getBorderPosition(chart, options, "start"));
|
215
|
+
chart.endBorder.attr(DrGaugeChart.getBorderPosition(chart, options, "end"));
|
216
|
+
chart.label.attr(DrGaugeChart.getValueLabelPosition(chart, options));
|
217
|
+
};
|
218
|
+
|
219
|
+
this.moveCustomElementsToFront = function (chart) {
|
220
|
+
chart.startBorder.toFront();
|
221
|
+
chart.endBorder.toFront();
|
222
|
+
};
|
223
|
+
|
224
|
+
this.configChart = function () {
|
225
|
+
return {
|
226
|
+
title: {
|
227
|
+
text: null,
|
228
|
+
},
|
229
|
+
subtitle: null,
|
230
|
+
exporting: {
|
231
|
+
allowHTML: true,
|
232
|
+
},
|
233
|
+
tooltip: {
|
234
|
+
enabled: false,
|
235
|
+
},
|
236
|
+
chart: {
|
237
|
+
type: "gauge",
|
238
|
+
backgroundColor: this.options.gauge.background,
|
239
|
+
plotBackgroundColor: null,
|
240
|
+
plotBackgroundImage: null,
|
241
|
+
plotBorderWidth: 0,
|
242
|
+
plotShadow: false,
|
243
|
+
events: {
|
244
|
+
render: ({target: chart}) => {
|
245
|
+
this.moveCustomElementsToFront(chart);
|
246
|
+
},
|
247
|
+
beforeRedraw: ({target: chart}) => {
|
248
|
+
this.setPane(chart, this.options);
|
249
|
+
this.updateCustomElements(chart, this.options);
|
250
|
+
},
|
251
|
+
beforeRender: ({target: chart}) => {
|
252
|
+
this.setPane(chart, this.options);
|
253
|
+
this.setCustomElements(chart, this.options);
|
254
|
+
}
|
255
|
+
},
|
256
|
+
margin: [0, 0, 0, 0],
|
257
|
+
spacing: [0, 0, 0, 0],
|
258
|
+
},
|
259
|
+
|
260
|
+
pane: {
|
261
|
+
startAngle: -90,
|
262
|
+
endAngle: 90,
|
263
|
+
background: null,
|
264
|
+
center: [0, 0],
|
265
|
+
},
|
266
|
+
|
267
|
+
// the value axis
|
268
|
+
yAxis: {
|
269
|
+
min: this.min,
|
270
|
+
max: this.max,
|
271
|
+
tickPositions: this.ticks,
|
272
|
+
tickPosition: "inside",
|
273
|
+
tickColor: this.options.gauge.background,
|
274
|
+
tickLength: this.options.gauge.tickLength,
|
275
|
+
tickWidth: this.options.gauge.tickWidth,
|
276
|
+
minorTickInterval: null,
|
277
|
+
labels: {
|
278
|
+
enabled: false
|
279
|
+
},
|
280
|
+
lineWidth: 0,
|
281
|
+
plotBands: this.plotBands,
|
282
|
+
},
|
283
|
+
|
284
|
+
series: [
|
285
|
+
{
|
286
|
+
name: null,
|
287
|
+
data: [this.clampValueToPane(this.value)],
|
288
|
+
dataLabels: [
|
289
|
+
{
|
290
|
+
enabled: false,
|
291
|
+
},
|
292
|
+
],
|
293
|
+
dial: {
|
294
|
+
radius: "0",
|
295
|
+
backgroundColor: "rgba(0, 0, 0, 0)",
|
296
|
+
baseWidth: 2 * this.options.gauge.pivot.radius,
|
297
|
+
baseLength: "0%",
|
298
|
+
rearLength: "0%",
|
299
|
+
},
|
300
|
+
pivot: {
|
301
|
+
backgroundColor: "rgba(0, 0, 0, 0)",
|
302
|
+
radius: this.options.gauge.pivot.radius,
|
303
|
+
},
|
304
|
+
},
|
305
|
+
],
|
306
|
+
};
|
307
|
+
};
|
308
|
+
|
309
|
+
|
310
|
+
this.options = this.mergeOptions(opts.chartOptions);
|
311
|
+
this.completionPercentage = this.getCompletionPercentage(this.options);
|
312
|
+
this.prepareSegments(this.options);
|
313
|
+
this.aggregation = pivotData.getAggregator([], []);
|
314
|
+
this.format = this.aggregation.widget_values_format;
|
315
|
+
this.goal = this.options.goal;
|
316
|
+
this.plotBands = this.createPlotBands(this.options);
|
317
|
+
this.ticks = DrGaugeChart.createTicks(this.plotBands, this.options);
|
318
|
+
this.value = DrGaugeChart.getValue(pivotData, opts);
|
319
|
+
this.max = this.ticks[this.ticks.length - 1];
|
320
|
+
this.min = this.ticks[0];
|
321
|
+
}
|
322
|
+
|
323
|
+
module.exports = {DrGaugeCategoriesSummaryChart, GAUGE_CATEGORIES_SUMMARY_OPTIONS_DEFAULT};
|