@datarailsshared/dr_renderer 1.5.131 → 1.5.146
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 +1 -1
- package/src/charts/dr_gauge_chart.js +1 -1
- package/src/dr-renderer-helpers.js +0 -7
- package/src/highcharts_renderer.js +14 -53
- package/src/index.d.ts +6 -0
- package/src/options/builders.js +24 -25
- package/src/options/index.js +21 -25
- package/src/options/presets.js +22 -23
- package/src/types/options/builders.d.ts +3 -8
- package/src/types/options/index.d.ts +3 -8
- package/src/types/options/presets.d.ts +3 -8
- package/tests/dr_gauge_chart.test.js +9 -11
- package/tests/highcharts_renderer.test.js +23 -90
- package/tests/options-builder.test.js +77 -89
package/package.json
CHANGED
|
@@ -771,7 +771,7 @@ DrGaugeChart.getGoalTitleText = function(options) {
|
|
|
771
771
|
}
|
|
772
772
|
|
|
773
773
|
DrGaugeChart.dynamicGoalFeatureEnabled = function() {
|
|
774
|
-
return DrGaugeChart.highchartsRenderer.
|
|
774
|
+
return DrGaugeChart.highchartsRenderer.environment.enableGaugeDynamicGoal;
|
|
775
775
|
}
|
|
776
776
|
|
|
777
777
|
module.exports = { DrGaugeChart, GAUGE_OPTIONS_DEFAULT };
|
|
@@ -70,12 +70,6 @@ function isShowingEmptyValues(additionOptions) {
|
|
|
70
70
|
}
|
|
71
71
|
|
|
72
72
|
const DELIMER = ' , '
|
|
73
|
-
const FEATURES = {
|
|
74
|
-
ENABLE_NEW_WIDGET_VALUE_FORMATTING: 'enable_new_widget_value_formatting',
|
|
75
|
-
MULTIPLE_DIMENSION_TAGS: 'multiple_dimension_tags',
|
|
76
|
-
USE_NEW_SCENARIO_TAG: 'use_new_scenario_tag',
|
|
77
|
-
ENABLE_GAUGE_DYNAMIC_GOAL: 'enable_gauge_dynamic_goal',
|
|
78
|
-
}
|
|
79
73
|
|
|
80
74
|
module.exports = {
|
|
81
75
|
capitalize,
|
|
@@ -85,6 +79,5 @@ module.exports = {
|
|
|
85
79
|
removeSVGTextCorrection,
|
|
86
80
|
disableLegendInteractionIfRequired,
|
|
87
81
|
isShowingEmptyValues,
|
|
88
|
-
FEATURES,
|
|
89
82
|
DELIMER
|
|
90
83
|
}
|
|
@@ -72,10 +72,11 @@ const CHART_AXIS_DEFAULT_LABEL = 'Axis (Category)';
|
|
|
72
72
|
|
|
73
73
|
const CHART_LEGEND_DEFAULT_LABEL = 'Legend (Series)';
|
|
74
74
|
|
|
75
|
-
const FEATURES = helpers.FEATURES;
|
|
76
|
-
|
|
77
75
|
const TICKS_COUNT = 5;
|
|
78
76
|
|
|
77
|
+
/**
|
|
78
|
+
* @param {EnvironmentOptions} envOptions
|
|
79
|
+
*/
|
|
79
80
|
let getHighchartsRenderer = function ($, document, Highcharts, default_colors, highchartsRenderer,
|
|
80
81
|
DataFormatter, lodash, moment_lib, isNewAngular, envOptions) {
|
|
81
82
|
|
|
@@ -116,7 +117,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
116
117
|
DrGaugeChart.highchartsRenderer = highchartsRenderer;
|
|
117
118
|
lodash.assign(highchartsRenderer, HIGHCHARTS_CONSTANTS);
|
|
118
119
|
|
|
119
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = false;
|
|
120
120
|
let disableAnimation = false;
|
|
121
121
|
const environment = envOptions || {};
|
|
122
122
|
highchartsRenderer.environment = environment;
|
|
@@ -327,14 +327,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
327
327
|
};
|
|
328
328
|
};
|
|
329
329
|
|
|
330
|
-
highchartsRenderer.hasFeature = function(featureFlagKey) {
|
|
331
|
-
return lodash.includes(highchartsRenderer.features || [], featureFlagKey);
|
|
332
|
-
}
|
|
333
|
-
highchartsRenderer.setFeatures = function(features) {
|
|
334
|
-
highchartsRenderer.features = features || [];
|
|
335
|
-
highchartsRenderer.enabledNewWidgetValueFormatting = highchartsRenderer.hasFeature(FEATURES.ENABLE_NEW_WIDGET_VALUE_FORMATTING);
|
|
336
|
-
}
|
|
337
|
-
highchartsRenderer.setFeatures(lodash.get(environment, 'features', []));
|
|
338
330
|
disableAnimation = !!lodash.get(environment, 'disable_animation', false);
|
|
339
331
|
|
|
340
332
|
// fix issue of use tootip.stickOnContact with tooltip.outside , source: https://github.com/highcharts/highcharts/pull/15960
|
|
@@ -4006,7 +3998,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4006
3998
|
calculated_formats: calculated_info.formats,
|
|
4007
3999
|
isChangeable: false,
|
|
4008
4000
|
push: function (record) {
|
|
4009
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
|
4001
|
+
if (highchartsRenderer.environment.enabledNewWidgetValueFormatting) {
|
|
4010
4002
|
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
|
4011
4003
|
}
|
|
4012
4004
|
|
|
@@ -4175,7 +4167,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4175
4167
|
var val = parseFloat(record[attr]);
|
|
4176
4168
|
|
|
4177
4169
|
if (!isNaN(val)) {
|
|
4178
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
|
4170
|
+
if (highchartsRenderer.environment.enabledNewWidgetValueFormatting) {
|
|
4179
4171
|
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
|
4180
4172
|
}
|
|
4181
4173
|
|
|
@@ -4270,7 +4262,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4270
4262
|
var ref, x;
|
|
4271
4263
|
x = parseFloat(record[attr]);
|
|
4272
4264
|
if (!isNaN(x)) {
|
|
4273
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
|
4265
|
+
if (highchartsRenderer.environment.enabledNewWidgetValueFormatting) {
|
|
4274
4266
|
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
|
4275
4267
|
}
|
|
4276
4268
|
|
|
@@ -4363,7 +4355,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4363
4355
|
var ref, x;
|
|
4364
4356
|
x = parseFloat(record[attr]);
|
|
4365
4357
|
if (!isNaN(x)) {
|
|
4366
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
|
4358
|
+
if (highchartsRenderer.environment.enabledNewWidgetValueFormatting) {
|
|
4367
4359
|
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
|
4368
4360
|
}
|
|
4369
4361
|
|
|
@@ -4457,7 +4449,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
4457
4449
|
var ref, x;
|
|
4458
4450
|
x = parseFloat(record[attr]);
|
|
4459
4451
|
if (!isNaN(x)) {
|
|
4460
|
-
if (highchartsRenderer.enabledNewWidgetValueFormatting) {
|
|
4452
|
+
if (highchartsRenderer.environment.enabledNewWidgetValueFormatting) {
|
|
4461
4453
|
record.formats = highchartsRenderer.getRecordFormats(render_options, record['DR_Values']);
|
|
4462
4454
|
}
|
|
4463
4455
|
|
|
@@ -5164,7 +5156,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5164
5156
|
ob.is_calculated = template_field.is_calculated;
|
|
5165
5157
|
ob.values = [];
|
|
5166
5158
|
ob.new_name = highchartsRenderer.getFieldName(ob.name);
|
|
5167
|
-
ob.name_class = highchartsRenderer.getFieldColorClass(template_field);
|
|
5168
5159
|
ob.date_field_before_split = template_field.date_field_before_split;
|
|
5169
5160
|
ob.mandatory = template_field.mandatory;
|
|
5170
5161
|
ob.category = template_field.category;
|
|
@@ -5185,35 +5176,6 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
5185
5176
|
return tooltip.length ? tooltip.join('\n\n') : highchartsRenderer.getFieldName(highchartsRenderer.decodeFunc(field.name));
|
|
5186
5177
|
};
|
|
5187
5178
|
|
|
5188
|
-
highchartsRenderer.isSystemField = function (field) {
|
|
5189
|
-
const dynamicSystemFields = [];
|
|
5190
|
-
|
|
5191
|
-
const areMultipleAndScenarioTags = highchartsRenderer.hasFeature(FEATURES.MULTIPLE_DIMENSION_TAGS)
|
|
5192
|
-
&& highchartsRenderer.hasFeature(FEATURES.USE_NEW_SCENARIO_TAG);
|
|
5193
|
-
|
|
5194
|
-
if (areMultipleAndScenarioTags) {
|
|
5195
|
-
dynamicSystemFields.push('Scenario', 'Budget Cycle');
|
|
5196
|
-
}
|
|
5197
|
-
|
|
5198
|
-
const regexDelimer = '|';
|
|
5199
|
-
const dynamicSystemFieldsRegex = dynamicSystemFields.length ? dynamicSystemFields.join(regexDelimer) + regexDelimer : '';
|
|
5200
|
-
var regex = new RegExp(`^(${dynamicSystemFieldsRegex}Calc_Model_Name|Calc_Model_ID|Parent_Name|Parent_Id|FileBox_ID|FileBox_Name|DataMapper_Name|Doc_ID|Doc_version|Label|Submission_Date|User|table_id|Latest_In_Dim|Tab_name|CP_Name|DT_.+|VT_.+|System_.+)$`, "m");
|
|
5201
|
-
|
|
5202
|
-
return (field.category && field.category.includes("")) || regex.test(field.name)
|
|
5203
|
-
};
|
|
5204
|
-
|
|
5205
|
-
highchartsRenderer.getFieldColorClass = function (field) {
|
|
5206
|
-
let ret = "green_field"
|
|
5207
|
-
if (highchartsRenderer.isSystemField(field)) {
|
|
5208
|
-
ret = "blue_filed";
|
|
5209
|
-
}
|
|
5210
|
-
if (field.mandatory) {
|
|
5211
|
-
ret += ' mandatoryfieldborder ';
|
|
5212
|
-
|
|
5213
|
-
}
|
|
5214
|
-
return ret;
|
|
5215
|
-
};
|
|
5216
|
-
|
|
5217
5179
|
highchartsRenderer.decodeTemplates = function (templates) {
|
|
5218
5180
|
lodash.forEach(templates, function (template) {
|
|
5219
5181
|
template.name = highchartsRenderer.decodeFunc(template.name);
|
|
@@ -6143,8 +6105,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6143
6105
|
|
|
6144
6106
|
highchartsRenderer.suboptions = optionsBuilders.createDefaultSuboptions({
|
|
6145
6107
|
CHART_TYPES: highchartsRenderer.CHART_TYPES,
|
|
6146
|
-
|
|
6147
|
-
ENABLE_GAUGE_DYNAMIC_GOAL: FEATURES.ENABLE_GAUGE_DYNAMIC_GOAL,
|
|
6108
|
+
enableGaugeDynamicGoal: highchartsRenderer.environment.enableGaugeDynamicGoal,
|
|
6148
6109
|
defaultGaugeSegments: GAUGE_OPTIONS_DEFAULT.segments,
|
|
6149
6110
|
});
|
|
6150
6111
|
|
|
@@ -6404,9 +6365,9 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6404
6365
|
[highchartsRenderer.CHART_TYPES.GAUGE_CHART_ENHANCED]: {
|
|
6405
6366
|
name: 'Gauge chart',
|
|
6406
6367
|
categoryLabel: 'Gauge',
|
|
6407
|
-
displayLabelInEditor: highchartsRenderer.
|
|
6408
|
-
label: highchartsRenderer.
|
|
6409
|
-
title: highchartsRenderer.
|
|
6368
|
+
displayLabelInEditor: highchartsRenderer.environment.enableGaugeDynamicGoal,
|
|
6369
|
+
label: highchartsRenderer.environment.enableGaugeDynamicGoal ? 'Static goal' : 'Gauge',
|
|
6370
|
+
title: highchartsRenderer.environment.enableGaugeDynamicGoal
|
|
6410
6371
|
? 'Measures progress toward a goal or a KPI.'
|
|
6411
6372
|
: 'Track actual performance against targets from your budget or forecast files.',
|
|
6412
6373
|
axisName: 'X-Axis',
|
|
@@ -6929,7 +6890,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
6929
6890
|
highchartsRenderer.suboptions["gauge_segments"],
|
|
6930
6891
|
highchartsRenderer.suboptions["gauge_is_absolute"],
|
|
6931
6892
|
],
|
|
6932
|
-
hidden: !highchartsRenderer.
|
|
6893
|
+
hidden: !highchartsRenderer.environment.enableGaugeDynamicGoal,
|
|
6933
6894
|
},
|
|
6934
6895
|
]
|
|
6935
6896
|
},
|
|
@@ -8222,7 +8183,7 @@ let getHighchartsRenderer = function ($, document, Highcharts, default_colors, h
|
|
|
8222
8183
|
// In all other cases we are applying format from editor panel to both of them (specification: DR-20955)
|
|
8223
8184
|
highchartsRenderer.isUsingWidgetValuesFormat = function (pivotData, render_options, widget_values_format) {
|
|
8224
8185
|
const { isSecondaryAxis, isCustomFormat } = highchartsRenderer.checkFormats(render_options, widget_values_format);
|
|
8225
|
-
return !highchartsRenderer.enabledNewWidgetValueFormatting || !highchartsRenderer.isChartWithMultiValues(pivotData) || !isSecondaryAxis || isCustomFormat;
|
|
8186
|
+
return !highchartsRenderer.environment.enabledNewWidgetValueFormatting || !highchartsRenderer.isChartWithMultiValues(pivotData) || !isSecondaryAxis || isCustomFormat;
|
|
8226
8187
|
}
|
|
8227
8188
|
|
|
8228
8189
|
highchartsRenderer.isFormattingNumberAxis = function (pivotData) {
|
package/src/index.d.ts
CHANGED
|
@@ -39,6 +39,12 @@ declare namespace DrRenderFactory {
|
|
|
39
39
|
fiscal_year_starts_from?: number;
|
|
40
40
|
fiscal_year_back?: boolean;
|
|
41
41
|
enableStackedPercentCharts?: boolean;
|
|
42
|
+
|
|
43
|
+
/** TODO: remove in DR-42736 */
|
|
44
|
+
enabledNewWidgetValueFormatting?: boolean;
|
|
45
|
+
|
|
46
|
+
/** Allow specifying custom gauge goal title */
|
|
47
|
+
enableGaugeDynamicGoal?: boolean;
|
|
42
48
|
}
|
|
43
49
|
|
|
44
50
|
interface Factory {
|
package/src/options/builders.js
CHANGED
|
@@ -56,10 +56,10 @@ const LABEL_PIE_DISABLED_CONDITION = {
|
|
|
56
56
|
*/
|
|
57
57
|
const TOOLTIP_DISABLED_CONDITION = {
|
|
58
58
|
disabled_str: '!{var}.show_out_of_x_axis && !{var}.show_out_of_data_series && !{var}.show_value && !{var}.show_x_axis && !{var}.show_data_series',
|
|
59
|
-
disabled_fn: (value) => !value.show_out_of_x_axis
|
|
60
|
-
&& !value.show_out_of_data_series
|
|
61
|
-
&& !value.show_value
|
|
62
|
-
&& !value.show_x_axis
|
|
59
|
+
disabled_fn: (value) => !value.show_out_of_x_axis
|
|
60
|
+
&& !value.show_out_of_data_series
|
|
61
|
+
&& !value.show_value
|
|
62
|
+
&& !value.show_x_axis
|
|
63
63
|
&& !value.show_data_series,
|
|
64
64
|
};
|
|
65
65
|
|
|
@@ -217,8 +217,8 @@ const createSuboption = (categoryType, categoryLabel, elements, options = {}) =>
|
|
|
217
217
|
* @param {LabelOptions} value - Current option values
|
|
218
218
|
*/
|
|
219
219
|
const labelValueClickFn = (value) => {
|
|
220
|
-
value.show = value.show
|
|
221
|
-
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value
|
|
220
|
+
value.show = value.show
|
|
221
|
+
? value.show_out_of_x_axis || value.show_out_of_data_series || value.show_value
|
|
222
222
|
: value.show;
|
|
223
223
|
};
|
|
224
224
|
|
|
@@ -227,8 +227,8 @@ const labelValueClickFn = (value) => {
|
|
|
227
227
|
* @param {LabelPieOptions} value - Current option values
|
|
228
228
|
*/
|
|
229
229
|
const labelPieClickFn = (value) => {
|
|
230
|
-
value.show = value.show
|
|
231
|
-
? value.show_percentage_in_labels || value.show_value_in_labels
|
|
230
|
+
value.show = value.show
|
|
231
|
+
? value.show_percentage_in_labels || value.show_value_in_labels
|
|
232
232
|
: value.show;
|
|
233
233
|
};
|
|
234
234
|
|
|
@@ -247,8 +247,8 @@ const tooltipClickFn = (value) => {
|
|
|
247
247
|
* @param {TooltipPieOptions} value - Current option values
|
|
248
248
|
*/
|
|
249
249
|
const tooltipPieClickFn = (value) => {
|
|
250
|
-
value.show = value.show
|
|
251
|
-
? value.show_percentage || value.show_value
|
|
250
|
+
value.show = value.show
|
|
251
|
+
? value.show_percentage || value.show_value
|
|
252
252
|
: value.show;
|
|
253
253
|
};
|
|
254
254
|
|
|
@@ -299,8 +299,7 @@ const withLabelPie = () => createSuboption('label_pie', 'Label', [
|
|
|
299
299
|
/**
|
|
300
300
|
* Label gauge configuration options.
|
|
301
301
|
* @typedef {Object} LabelGaugeConfig
|
|
302
|
-
* @property {
|
|
303
|
-
* @property {string} [ENABLE_GAUGE_DYNAMIC_GOAL] - Feature flag name
|
|
302
|
+
* @property {boolean} [enableGaugeDynamicGoal] - Allow specifying custom gauge goal title
|
|
304
303
|
*/
|
|
305
304
|
|
|
306
305
|
/**
|
|
@@ -309,8 +308,8 @@ const withLabelPie = () => createSuboption('label_pie', 'Label', [
|
|
|
309
308
|
* @returns {SuboptionDefinition}
|
|
310
309
|
*/
|
|
311
310
|
const withLabelGauge = (config = {}) => {
|
|
312
|
-
const {
|
|
313
|
-
|
|
311
|
+
const { enableGaugeDynamicGoal } = config;
|
|
312
|
+
|
|
314
313
|
return createSuboption('label', 'Label', [
|
|
315
314
|
GAUGE_SHOW_TOGGLE,
|
|
316
315
|
...createLabelStyleGroup({ fontSize: 16, fontColor: '#333' }),
|
|
@@ -320,7 +319,7 @@ const withLabelGauge = (config = {}) => {
|
|
|
320
319
|
createCheckbox('show_goal_name', 'Show Goal label', true),
|
|
321
320
|
createInput('goal_name', 'Goal name', 'Goal', {
|
|
322
321
|
show_in_one_row: true,
|
|
323
|
-
showFn: () => !!
|
|
322
|
+
showFn: () => !!enableGaugeDynamicGoal,
|
|
324
323
|
}),
|
|
325
324
|
]);
|
|
326
325
|
};
|
|
@@ -491,7 +490,7 @@ const withTableOptions = () => {
|
|
|
491
490
|
*/
|
|
492
491
|
const withTableOptionsTranspose = (config = {}) => {
|
|
493
492
|
const { CHART_TYPES } = config;
|
|
494
|
-
|
|
493
|
+
|
|
495
494
|
return createSuboption('table_options', 'Table', [
|
|
496
495
|
createInput('table_colors_offset', 'Colors offset', 0),
|
|
497
496
|
createCheckbox('show_column_total', 'Column totals', true),
|
|
@@ -878,7 +877,7 @@ module.exports = {
|
|
|
878
877
|
LABEL_PIE_DISABLED_CONDITION,
|
|
879
878
|
TOOLTIP_DISABLED_CONDITION,
|
|
880
879
|
TOOLTIP_PIE_DISABLED_CONDITION,
|
|
881
|
-
|
|
880
|
+
|
|
882
881
|
// Reusable elements
|
|
883
882
|
LABEL_SHOW_TOGGLE,
|
|
884
883
|
LABEL_PIE_SHOW_TOGGLE,
|
|
@@ -886,39 +885,39 @@ module.exports = {
|
|
|
886
885
|
TOOLTIP_SHOW_TOGGLE,
|
|
887
886
|
TOOLTIP_PIE_SHOW_TOGGLE,
|
|
888
887
|
GAUGE_SHOW_TOGGLE,
|
|
889
|
-
|
|
888
|
+
|
|
890
889
|
// Helper
|
|
891
890
|
createSuboption,
|
|
892
|
-
|
|
891
|
+
|
|
893
892
|
// Label builders
|
|
894
893
|
withLabel,
|
|
895
894
|
withLabelPie,
|
|
896
895
|
withLabelGauge,
|
|
897
896
|
withLabelWithPercentage,
|
|
898
897
|
withLabelWithPercentagePercentStacked,
|
|
899
|
-
|
|
898
|
+
|
|
900
899
|
// Tooltip builders
|
|
901
900
|
withTooltip,
|
|
902
901
|
withTooltipPie,
|
|
903
902
|
withTooltipGauge,
|
|
904
|
-
|
|
903
|
+
|
|
905
904
|
// Axis builders
|
|
906
905
|
withAxisY,
|
|
907
906
|
withAxisYPercentStacked,
|
|
908
907
|
withAxisX,
|
|
909
|
-
|
|
908
|
+
|
|
910
909
|
// Table builders
|
|
911
910
|
withTableOptions,
|
|
912
911
|
withTableOptionsTranspose,
|
|
913
912
|
withTableOptionsGauge,
|
|
914
913
|
withTableDesignOptions,
|
|
915
|
-
|
|
914
|
+
|
|
916
915
|
// Chart config builders
|
|
917
916
|
withChart,
|
|
918
917
|
withChartGrid,
|
|
919
918
|
withChartForecast,
|
|
920
919
|
withChartPosition,
|
|
921
|
-
|
|
920
|
+
|
|
922
921
|
// Other builders
|
|
923
922
|
withWidgetLibrary,
|
|
924
923
|
withSubtitle,
|
|
@@ -935,7 +934,7 @@ module.exports = {
|
|
|
935
934
|
withGaugeGoal,
|
|
936
935
|
withGaugeSegments,
|
|
937
936
|
withGaugeIsAbsolute,
|
|
938
|
-
|
|
937
|
+
|
|
939
938
|
// Click handlers (exported for testing)
|
|
940
939
|
labelValueClickFn,
|
|
941
940
|
labelPieClickFn,
|
package/src/options/index.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @fileoverview Chart Options Builder API
|
|
3
|
-
*
|
|
3
|
+
*
|
|
4
4
|
* This module provides a functional builder pattern for creating chart suboption
|
|
5
5
|
* configurations. It allows for composable, reusable option definitions with
|
|
6
6
|
* full type support.
|
|
7
|
-
*
|
|
7
|
+
*
|
|
8
8
|
* @module @datarailsshared/dr_renderer/options
|
|
9
|
-
*
|
|
9
|
+
*
|
|
10
10
|
* @example
|
|
11
11
|
* // Import builders
|
|
12
12
|
* const { withLabel, withTooltip, buildSuboptions } = require('@datarailsshared/dr_renderer').options;
|
|
13
|
-
*
|
|
13
|
+
*
|
|
14
14
|
* // Build custom suboptions
|
|
15
15
|
* const suboptions = buildSuboptions([withLabel, withTooltip]);
|
|
16
|
-
*
|
|
16
|
+
*
|
|
17
17
|
* @example
|
|
18
18
|
* // Get preset for a chart type
|
|
19
19
|
* const { getPresetForChart, buildSuboptionsForChart } = require('@datarailsshared/dr_renderer').options;
|
|
20
|
-
*
|
|
20
|
+
*
|
|
21
21
|
* const columnChartOptions = buildSuboptionsForChart('column-chart');
|
|
22
22
|
*/
|
|
23
23
|
|
|
@@ -51,8 +51,7 @@ const helpers = require('./helpers');
|
|
|
51
51
|
* Configuration for createDefaultSuboptions.
|
|
52
52
|
* @typedef {Object} CreateDefaultSuboptionsConfig
|
|
53
53
|
* @property {import('./constants').ChartTypesMap} [CHART_TYPES] - Chart types enum (for table options)
|
|
54
|
-
* @property {
|
|
55
|
-
* @property {string} [ENABLE_GAUGE_DYNAMIC_GOAL] - Feature flag name for gauge dynamic goal
|
|
54
|
+
* @property {boolean} [enableGaugeDynamicGoal] - Allow specifying custom gauge goal title
|
|
56
55
|
* @property {import('./builders').GaugeSegment[]} [defaultGaugeSegments] - Default gauge segments array
|
|
57
56
|
*/
|
|
58
57
|
|
|
@@ -79,10 +78,7 @@ const createDefaultSuboptions = (config = {}) => ({
|
|
|
79
78
|
'chart_position': builders.withChartPosition(),
|
|
80
79
|
'label': builders.withLabel(),
|
|
81
80
|
'label_pie': builders.withLabelPie(),
|
|
82
|
-
'label_gauge': builders.withLabelGauge({
|
|
83
|
-
hasFeature: config.hasFeature,
|
|
84
|
-
ENABLE_GAUGE_DYNAMIC_GOAL: config.ENABLE_GAUGE_DYNAMIC_GOAL
|
|
85
|
-
}),
|
|
81
|
+
'label_gauge': builders.withLabelGauge({ enableGaugeDynamicGoal: config.enableGaugeDynamicGoal }),
|
|
86
82
|
'label_with_percentage': builders.withLabelWithPercentage(),
|
|
87
83
|
'label_with_percentage_percent_stacked': builders.withLabelWithPercentagePercentStacked(),
|
|
88
84
|
'axisY': builders.withAxisY(),
|
|
@@ -118,7 +114,7 @@ module.exports = {
|
|
|
118
114
|
LABEL_DEFAULT_OPTIONS: constants.LABEL_DEFAULT_OPTIONS,
|
|
119
115
|
SUBOPTIONS_FONT_SIZE_VALUES: constants.SUBOPTIONS_FONT_SIZE_VALUES,
|
|
120
116
|
DEFAULT_CATEGORY_CLASS: constants.DEFAULT_CATEGORY_CLASS,
|
|
121
|
-
|
|
117
|
+
|
|
122
118
|
// Element factories
|
|
123
119
|
createToggle: elements.createToggle,
|
|
124
120
|
createCheckbox: elements.createCheckbox,
|
|
@@ -132,36 +128,36 @@ module.exports = {
|
|
|
132
128
|
createFontStylingGroup: elements.createFontStylingGroup,
|
|
133
129
|
createLabelStyleGroup: elements.createLabelStyleGroup,
|
|
134
130
|
createTooltipStyleGroup: elements.createTooltipStyleGroup,
|
|
135
|
-
|
|
131
|
+
|
|
136
132
|
// Label builders
|
|
137
133
|
withLabel: builders.withLabel,
|
|
138
134
|
withLabelPie: builders.withLabelPie,
|
|
139
135
|
withLabelGauge: builders.withLabelGauge,
|
|
140
136
|
withLabelWithPercentage: builders.withLabelWithPercentage,
|
|
141
137
|
withLabelWithPercentagePercentStacked: builders.withLabelWithPercentagePercentStacked,
|
|
142
|
-
|
|
138
|
+
|
|
143
139
|
// Tooltip builders
|
|
144
140
|
withTooltip: builders.withTooltip,
|
|
145
141
|
withTooltipPie: builders.withTooltipPie,
|
|
146
142
|
withTooltipGauge: builders.withTooltipGauge,
|
|
147
|
-
|
|
143
|
+
|
|
148
144
|
// Axis builders
|
|
149
145
|
withAxisY: builders.withAxisY,
|
|
150
146
|
withAxisYPercentStacked: builders.withAxisYPercentStacked,
|
|
151
147
|
withAxisX: builders.withAxisX,
|
|
152
|
-
|
|
148
|
+
|
|
153
149
|
// Table builders
|
|
154
150
|
withTableOptions: builders.withTableOptions,
|
|
155
151
|
withTableOptionsTranspose: builders.withTableOptionsTranspose,
|
|
156
152
|
withTableOptionsGauge: builders.withTableOptionsGauge,
|
|
157
153
|
withTableDesignOptions: builders.withTableDesignOptions,
|
|
158
|
-
|
|
154
|
+
|
|
159
155
|
// Chart config builders
|
|
160
156
|
withChart: builders.withChart,
|
|
161
157
|
withChartGrid: builders.withChartGrid,
|
|
162
158
|
withChartForecast: builders.withChartForecast,
|
|
163
159
|
withChartPosition: builders.withChartPosition,
|
|
164
|
-
|
|
160
|
+
|
|
165
161
|
// Other builders
|
|
166
162
|
withWidgetLibrary: builders.withWidgetLibrary,
|
|
167
163
|
withSubtitle: builders.withSubtitle,
|
|
@@ -178,16 +174,16 @@ module.exports = {
|
|
|
178
174
|
withGaugeGoal: builders.withGaugeGoal,
|
|
179
175
|
withGaugeSegments: builders.withGaugeSegments,
|
|
180
176
|
withGaugeIsAbsolute: builders.withGaugeIsAbsolute,
|
|
181
|
-
|
|
177
|
+
|
|
182
178
|
// Helper function
|
|
183
179
|
createSuboption: builders.createSuboption,
|
|
184
|
-
|
|
180
|
+
|
|
185
181
|
// Reusable disabled conditions
|
|
186
182
|
LABEL_DISABLED_CONDITION: builders.LABEL_DISABLED_CONDITION,
|
|
187
183
|
LABEL_PIE_DISABLED_CONDITION: builders.LABEL_PIE_DISABLED_CONDITION,
|
|
188
184
|
TOOLTIP_DISABLED_CONDITION: builders.TOOLTIP_DISABLED_CONDITION,
|
|
189
185
|
TOOLTIP_PIE_DISABLED_CONDITION: builders.TOOLTIP_PIE_DISABLED_CONDITION,
|
|
190
|
-
|
|
186
|
+
|
|
191
187
|
// Reusable elements
|
|
192
188
|
LABEL_SHOW_TOGGLE: builders.LABEL_SHOW_TOGGLE,
|
|
193
189
|
LABEL_PIE_SHOW_TOGGLE: builders.LABEL_PIE_SHOW_TOGGLE,
|
|
@@ -195,7 +191,7 @@ module.exports = {
|
|
|
195
191
|
TOOLTIP_SHOW_TOGGLE: builders.TOOLTIP_SHOW_TOGGLE,
|
|
196
192
|
TOOLTIP_PIE_SHOW_TOGGLE: builders.TOOLTIP_PIE_SHOW_TOGGLE,
|
|
197
193
|
GAUGE_SHOW_TOGGLE: builders.GAUGE_SHOW_TOGGLE,
|
|
198
|
-
|
|
194
|
+
|
|
199
195
|
// Presets and utilities
|
|
200
196
|
CHART_TYPES: constants.CHART_TYPES,
|
|
201
197
|
CHART_PRESETS: presets.CHART_PRESETS,
|
|
@@ -206,10 +202,10 @@ module.exports = {
|
|
|
206
202
|
buildSuboptions: presets.buildSuboptions,
|
|
207
203
|
getChartTypes: presets.getChartTypes,
|
|
208
204
|
hasPreset: presets.hasPreset,
|
|
209
|
-
|
|
205
|
+
|
|
210
206
|
// Helpers
|
|
211
207
|
chartHasVerticalDataLabelsOption: helpers.chartHasVerticalDataLabelsOption,
|
|
212
|
-
|
|
208
|
+
|
|
213
209
|
// Factory functions
|
|
214
210
|
createDefaultSuboptions,
|
|
215
211
|
};
|