sea-chart 0.0.48 → 0.0.49
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/dist/components/color-setting/color-group-selector.js +1 -0
- package/dist/components/types-dialog/index.js +2 -2
- package/dist/constants/common-constants.js +3 -0
- package/dist/constants/index.js +3 -0
- package/dist/context.js +9 -6
- package/dist/index.js +4 -1
- package/dist/locale/lang/en.js +1 -0
- package/dist/locale/lang/zh_CN.js +1 -0
- package/dist/model/chart.js +4 -0
- package/dist/settings/advance-bar-settings/style-settings.js +2 -0
- package/dist/settings/bar-settings/style-settings.js +2 -0
- package/dist/settings/basic-number-card/data-settings.js +3 -0
- package/dist/settings/combination-settings/style-settings.js +3 -0
- package/dist/settings/completeness-settings/data-settings/completion-settings.js +2 -0
- package/dist/settings/dashboard-settings/data-settings.js +3 -0
- package/dist/settings/horizontal-bar-settings/data-settings.js +2 -0
- package/dist/settings/index.js +3 -2
- package/dist/settings/map-settings/components/location-field-selector.js +1 -0
- package/dist/settings/map-settings/components/map-level-selector.js +1 -0
- package/dist/settings/map-settings/components/map-province-city-selector.js +2 -0
- package/dist/settings/map-settings/map-style-settings.js +1 -0
- package/dist/settings/pie-settings/style-settings.js +2 -0
- package/dist/settings/table-settings/data-settings.js +1 -0
- package/dist/settings/time-comparison-settings/style-settings.js +2 -0
- package/dist/settings/widgets/basic-summary/index.js +3 -0
- package/dist/settings/widgets/common-data-settings.js +1 -1
- package/dist/settings/widgets/date-summary-item.js +2 -0
- package/dist/settings/widgets/group-by.js +3 -0
- package/dist/settings/widgets/numeric-summary-item.js +2 -0
- package/dist/settings/widgets/select-table/index.js +1 -1
- package/dist/settings/widgets/select-view/index.js +1 -1
- package/dist/settings/widgets/summary-method-setting.js +2 -0
- package/dist/settings/widgets/summary-settings.js +4 -1
- package/dist/settings/widgets/y-axis-group-settings.js +1 -0
- package/dist/utils/chart-utils/base-utils.js +34 -9
- package/dist/utils/chart-utils/index.js +1 -1
- package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +69 -16
- package/dist/utils/chart-utils/original-data-utils/card-calculator.js +2 -2
- package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +9 -9
- package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +2 -2
- package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +10 -10
- package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +4 -4
- package/dist/utils/chart-utils/original-data-utils/index.js +3 -3
- package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +6 -6
- package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +3 -3
- package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +9 -9
- package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +5 -5
- package/dist/utils/chart-utils/sql-statistics-utils.js +17 -6
- package/dist/utils/event-bus.js +28 -0
- package/dist/utils/row-utils.js +1 -1
- package/dist/utils/sql/chart-data-sql.js +17 -4
- package/dist/utils/sql/column-2-sql-column.js +7 -1
- package/dist/view/index.css +1 -1
- package/dist/view/index.js +49 -7
- package/dist/view/wrapper/area.js +16 -9
- package/dist/view/wrapper/bar-custom.js +8 -9
- package/dist/view/wrapper/bar-group.js +7 -4
- package/dist/view/wrapper/bar.js +8 -6
- package/dist/view/wrapper/basic-number-card.js +3 -2
- package/dist/view/wrapper/chart-component.js +6 -2
- package/dist/view/wrapper/combination.js +7 -7
- package/dist/view/wrapper/compare.js +18 -17
- package/dist/view/wrapper/completeness.js +8 -5
- package/dist/view/wrapper/dashboard.js +3 -1
- package/dist/view/wrapper/horizontal-bar-group.js +7 -4
- package/dist/view/wrapper/horizontal-bar.js +8 -6
- package/dist/view/wrapper/index.js +6 -3
- package/dist/view/wrapper/line-group.js +13 -5
- package/dist/view/wrapper/line.js +8 -6
- package/dist/view/wrapper/pie.js +12 -6
- package/dist/view/wrapper/ring.js +14 -7
- package/dist/view/wrapper/scatter.js +7 -4
- package/dist/view/wrapper/treemap.js +5 -2
- package/dist/view/wrapper/trend.js +124 -54
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
var _BaseUtils;
|
|
2
2
|
import shallowEqual from 'shallowequal';
|
|
3
3
|
import dayjs from 'dayjs';
|
|
4
|
-
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, getDateDisplayString, getNumberDisplayString, getOption, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, isNumericColumn, isDateColumn, sortText, sortNumber, sortDate, sortSingleSelect, sortFormula, getColumnOptions, DateUtils, getGeolocationDisplayString, getFormulaDisplayString } from 'dtable-utils';
|
|
4
|
+
import { CellType, COLLABORATOR_COLUMN_TYPES, FORMULA_COLUMN_TYPES_MAP, FORMULA_RESULT_TYPE, getDateDisplayString, getNumberDisplayString, getOption, getPrecisionNumber, getTableById, getTableColumnByKey, isNumber, isNumericColumn, isDateColumn, sortText, sortNumber, sortDate, sortSingleSelect, sortFormula, getColumnOptions, DateUtils, getGeolocationDisplayString, getFormulaDisplayString, isArchiveView, getViewById } from 'dtable-utils';
|
|
5
5
|
import { PIE_CHART_COLORS, CHART_SUMMARY_TYPE, CHART_SUPPORT_SORT_COLUMNS, CHART_TYPE, CHART_STYLE_SETTING_KEYS, DEFAULT_LABEL_FONT_SIZE, DEFAULT_NUMBER_FORMAT_OBJECT, X_AXIS_IS_GROUPBY_COLUMN_KEY_CHART_TYPES, STYLE_COLORS, CHART_DATA_SORT_TYPE, CHART_Y_GROUP_TYPE } from '../../constants';
|
|
6
6
|
import { getClientFormulaDisplayString } from '../cell-format-utils';
|
|
7
7
|
import { getKnownCollaboratorByEmail, generateDefaultUser, getUsers } from '../collaborator-utils';
|
|
@@ -107,7 +107,10 @@ BaseUtils.isValidExistChart = (tables, chart) => {
|
|
|
107
107
|
const isExist = _BaseUtils.isValidCombinationChart(config, table);
|
|
108
108
|
if (!isExist) return false;
|
|
109
109
|
} else {
|
|
110
|
-
|
|
110
|
+
let summaryColumnKey = config.summary_column_key || config.y_axis_summary_column_key || config.horizontal_axis_column_key;
|
|
111
|
+
if ([CHART_TYPE.TABLE].includes(config.type) && config.column_groupby_multiple_numeric_column && (config === null || config === void 0 ? void 0 : config.summary_columns.length) > 0) {
|
|
112
|
+
summaryColumnKey = config.summary_columns[0].key;
|
|
113
|
+
}
|
|
111
114
|
const summaryType = config.summary_type || config.y_axis_summary_type || config.horizontal_axis_summary_type;
|
|
112
115
|
if (summaryType === CHART_SUMMARY_TYPE.ADVANCED && !summaryColumnKey) return false;
|
|
113
116
|
if (summaryColumnKey) {
|
|
@@ -357,6 +360,21 @@ BaseUtils.isChartTypeChange = (preChartElement, curChartElement) => {
|
|
|
357
360
|
if (elementType !== curChartElement.config.type) return true;
|
|
358
361
|
return false;
|
|
359
362
|
};
|
|
363
|
+
BaseUtils.isChartViewChange = (preChartElement, curChartElement) => {
|
|
364
|
+
var _preChartElement$conf, _curChartElement$conf;
|
|
365
|
+
const elementView = (_preChartElement$conf = preChartElement.config) === null || _preChartElement$conf === void 0 ? void 0 : _preChartElement$conf.view_id;
|
|
366
|
+
if (elementView !== ((_curChartElement$conf = curChartElement.config) === null || _curChartElement$conf === void 0 ? void 0 : _curChartElement$conf.view_id)) return true;
|
|
367
|
+
return false;
|
|
368
|
+
};
|
|
369
|
+
BaseUtils.isArchiveView = (chart, tables) => {
|
|
370
|
+
const {
|
|
371
|
+
table_id,
|
|
372
|
+
view_id
|
|
373
|
+
} = chart;
|
|
374
|
+
const table = getTableById(tables, table_id);
|
|
375
|
+
const view = getViewById(table === null || table === void 0 ? void 0 : table.views, view_id);
|
|
376
|
+
return view && isArchiveView(view);
|
|
377
|
+
};
|
|
360
378
|
BaseUtils.isChartSortChange = (preChartElement, curChartElement) => {
|
|
361
379
|
return preChartElement.config.sort_type !== curChartElement.config.sort_type;
|
|
362
380
|
};
|
|
@@ -390,6 +408,10 @@ BaseUtils.shouldChartComponentUpdate = (prevProps, currentProps) => {
|
|
|
390
408
|
// columnGroupbyColumn's data、type changed or not exist
|
|
391
409
|
!shallowEqual(prevProps.summaryColumn, currentProps.summaryColumn) ||
|
|
392
410
|
// summaryColumn's data、type changed or not exist
|
|
411
|
+
!shallowEqual(prevProps.globalTheme, currentProps.globalTheme) ||
|
|
412
|
+
// global theme changed
|
|
413
|
+
!shallowEqual(prevProps.chartColorTheme, currentProps.chartColorTheme) ||
|
|
414
|
+
// chart color theme changed
|
|
393
415
|
_BaseUtils._isChartDataChange(prevProps, currentProps) || _BaseUtils.isChartStyleChanged(prevProps.chart, currentProps.chart);
|
|
394
416
|
};
|
|
395
417
|
BaseUtils._isCombinationDataChange = (prevResult, currentResult) => {
|
|
@@ -482,25 +504,28 @@ BaseUtils.getPieColorSet = (tables, chart, result) => {
|
|
|
482
504
|
});
|
|
483
505
|
return backgroundColor;
|
|
484
506
|
};
|
|
485
|
-
BaseUtils.getPieColor = (column, index, data) => {
|
|
507
|
+
BaseUtils.getPieColor = (column, index, data, currentTheme) => {
|
|
486
508
|
let {
|
|
487
509
|
type: columnType,
|
|
488
510
|
data: columnData
|
|
489
511
|
} = column;
|
|
512
|
+
const {
|
|
513
|
+
colors
|
|
514
|
+
} = currentTheme;
|
|
490
515
|
if (columnType === 'single-select' || columnType === 'multiple-select') {
|
|
491
516
|
if (columnData && columnData.options) {
|
|
492
517
|
const selectedItem = columnData.options.find(item => {
|
|
493
|
-
return item.name === data.name;
|
|
518
|
+
return item.name === data.name.trim();
|
|
494
519
|
}) || {};
|
|
495
520
|
return selectedItem.color || '#dbdbdb';
|
|
496
521
|
}
|
|
497
522
|
} else {
|
|
498
|
-
const pieChartColorsLength =
|
|
523
|
+
const pieChartColorsLength = colors.length - 1;
|
|
499
524
|
const newIndex = index > pieChartColorsLength ? index % pieChartColorsLength : index;
|
|
500
|
-
return
|
|
525
|
+
return colors[newIndex];
|
|
501
526
|
}
|
|
502
527
|
};
|
|
503
|
-
BaseUtils.formatPieChartData = (data, chart, tables) => {
|
|
528
|
+
BaseUtils.formatPieChartData = (data, chart, tables, currentTheme) => {
|
|
504
529
|
if (!Array.isArray(data) || data.length === 0 || !chart) {
|
|
505
530
|
return {
|
|
506
531
|
data: [],
|
|
@@ -529,7 +554,7 @@ BaseUtils.formatPieChartData = (data, chart, tables) => {
|
|
|
529
554
|
item.name = item.name + ' ';
|
|
530
555
|
if (value >= threshold) {
|
|
531
556
|
item.percent = String(Number.parseFloat(value / sum * 100).toFixed(1)) + '%';
|
|
532
|
-
const color = _BaseUtils.getPieColor(column, index, item);
|
|
557
|
+
const color = _BaseUtils.getPieColor(column, index, item, currentTheme);
|
|
533
558
|
item.color = color;
|
|
534
559
|
colorSet.push(color);
|
|
535
560
|
filteredData.push(item);
|
|
@@ -969,7 +994,7 @@ BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGr
|
|
|
969
994
|
type,
|
|
970
995
|
key,
|
|
971
996
|
data
|
|
972
|
-
} = column;
|
|
997
|
+
} = column || {};
|
|
973
998
|
switch (type) {
|
|
974
999
|
case CellType.TEXT:
|
|
975
1000
|
{
|
|
@@ -55,7 +55,7 @@ ChartUtils.calculateStaticChart = (chart, value, statisticalResult, callback) =>
|
|
|
55
55
|
data_sources: dataSources
|
|
56
56
|
} = statisticalResult;
|
|
57
57
|
if (dataSources === OriginalDataUtils.dataSources) {
|
|
58
|
-
OriginalDataUtils.
|
|
58
|
+
OriginalDataUtils.calculateChart(chart, value, callback);
|
|
59
59
|
return;
|
|
60
60
|
}
|
|
61
61
|
SQLStatisticsUtils.calculateStaticChart(chart, value, statisticalResult, callback);
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import dayjs from 'dayjs';
|
|
1
2
|
import { CellType, DATE_COLUMN_OPTIONS, FORMULA_COLUMN_TYPES_MAP, getTableById, getViewById, getTableColumnByKey } from 'dtable-utils';
|
|
2
3
|
import { CHART_SUMMARY_TYPE, CHART_TYPE, Y_AXIS_TYPE_PREFIX } from '../../../constants';
|
|
3
4
|
import { getColorFromSingleSelectColumn } from '../../column-utils';
|
|
@@ -23,7 +24,7 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
23
24
|
let groupby_date_granularity;
|
|
24
25
|
let include_empty;
|
|
25
26
|
let groupby_geolocation_granularity;
|
|
26
|
-
if (chart.type === CHART_TYPE.PIE || chart.type === CHART_TYPE.RING || chart.type === CHART_TYPE.
|
|
27
|
+
if (chart.type === CHART_TYPE.PIE || chart.type === CHART_TYPE.RING || chart.type === CHART_TYPE.TREE_MAP) {
|
|
27
28
|
groupby_column_key = chart.groupby_column_key;
|
|
28
29
|
summary_type = chart.summary_type;
|
|
29
30
|
summary_method = chart.summary_method;
|
|
@@ -31,14 +32,27 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
31
32
|
groupby_date_granularity = chart.groupby_date_granularity;
|
|
32
33
|
include_empty = chart.groupby_include_empty_cells;
|
|
33
34
|
groupby_geolocation_granularity = chart.groupby_geolocation_granularity;
|
|
35
|
+
} else if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR].includes(chart.type)) {
|
|
36
|
+
groupby_column_key = chart.vertical_axis_column_key;
|
|
37
|
+
summary_type = chart.horizontal_axis_summary_type;
|
|
38
|
+
summary_method = chart.horizontal_axis_summary_method;
|
|
39
|
+
summary_column_key = chart.horizontal_axis_column_key;
|
|
40
|
+
groupby_date_granularity = chart.vertical_axis_date_granularity;
|
|
41
|
+
groupby_geolocation_granularity = chart.vertical_axis_geolocation_granularity;
|
|
42
|
+
include_empty = chart.vertical_axis_include_empty;
|
|
43
|
+
} else if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
44
|
+
groupby_column_key = chart.time_column_key;
|
|
45
|
+
summary_type = chart.summary_type;
|
|
46
|
+
summary_method = chart.summary_method;
|
|
47
|
+
summary_column_key = chart.summary_column_key;
|
|
34
48
|
} else {
|
|
35
49
|
groupby_column_key = chart.x_axis_column_key;
|
|
36
50
|
summary_type = chart.y_axis_summary_type;
|
|
37
51
|
summary_method = chart.y_axis_summary_method;
|
|
38
|
-
summary_column_key = chart.
|
|
52
|
+
summary_column_key = chart.y_axis_summary_column_key;
|
|
39
53
|
groupby_date_granularity = chart.x_axis_date_granularity;
|
|
40
54
|
groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
41
|
-
include_empty = chart.
|
|
55
|
+
include_empty = chart.x_axis_include_empty_cells;
|
|
42
56
|
}
|
|
43
57
|
const table = getTableById(value.tables, table_id);
|
|
44
58
|
const view = table && getViewById(table.views, view_id);
|
|
@@ -55,6 +69,9 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
55
69
|
} = groupbyColumn;
|
|
56
70
|
if (DATE_COLUMN_OPTIONS.includes(groupby_column_type) && !groupby_date_granularity) {
|
|
57
71
|
groupby_date_granularity = CHART_SUMMARY_TYPE.MONTH;
|
|
72
|
+
if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
73
|
+
groupby_date_granularity = CHART_SUMMARY_TYPE.DAY;
|
|
74
|
+
}
|
|
58
75
|
}
|
|
59
76
|
if (groupby_column_type === CellType.GEOLOCATION && !groupby_geolocation_granularity) {
|
|
60
77
|
groupby_geolocation_granularity = CHART_SUMMARY_TYPE.PROVINCE;
|
|
@@ -72,6 +89,33 @@ async function calculateBasicChart(chart, value, _ref) {
|
|
|
72
89
|
results.forEach(item => {
|
|
73
90
|
item.name = getFormattedLabel(groupbyColumn, item.name, value.collaborators);
|
|
74
91
|
});
|
|
92
|
+
if ([CHART_TYPE.HEAT_MAP].includes(chart.type)) {
|
|
93
|
+
let data = [];
|
|
94
|
+
let years = [];
|
|
95
|
+
results.forEach(item => {
|
|
96
|
+
if (!item.name) {
|
|
97
|
+
data.push(item);
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
const year = dayjs(item.name).year();
|
|
101
|
+
data.push({
|
|
102
|
+
...item,
|
|
103
|
+
year
|
|
104
|
+
});
|
|
105
|
+
if (years.indexOf(year) < 0) {
|
|
106
|
+
years.push(year);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
data.sort((current, next) => {
|
|
110
|
+
if (current.year > next.year) return -1;
|
|
111
|
+
if (current.year < next.year) return 1;
|
|
112
|
+
return 0;
|
|
113
|
+
});
|
|
114
|
+
return {
|
|
115
|
+
data,
|
|
116
|
+
years
|
|
117
|
+
};
|
|
118
|
+
}
|
|
75
119
|
return results;
|
|
76
120
|
}
|
|
77
121
|
async function calculateGroupingChart(chart, value, _ref2) {
|
|
@@ -79,23 +123,32 @@ async function calculateGroupingChart(chart, value, _ref2) {
|
|
|
79
123
|
getViewRows,
|
|
80
124
|
getTableFormulaResults
|
|
81
125
|
} = _ref2;
|
|
82
|
-
|
|
126
|
+
let {
|
|
83
127
|
table_id,
|
|
84
128
|
view_id,
|
|
85
129
|
x_axis_column_key,
|
|
86
|
-
|
|
87
|
-
|
|
130
|
+
x_axis_include_empty_cells,
|
|
131
|
+
y_axis_summary_column_key,
|
|
88
132
|
y_axis_summary_type,
|
|
89
133
|
y_axis_summary_method,
|
|
90
134
|
column_groupby_multiple_numeric_column
|
|
91
135
|
} = chart;
|
|
92
|
-
|
|
136
|
+
let groupby_column_key = x_axis_column_key;
|
|
93
137
|
const column_groupby_column_key = chart.column_groupby_column_key;
|
|
94
138
|
const column_groupby_date_granularity = chart.column_groupby_date_granularity;
|
|
95
139
|
const column_groupby_geolocation_granularity = chart.column_groupby_geolocation_granularity;
|
|
96
140
|
let groupby_date_granularity = chart.x_axis_date_granularity;
|
|
97
141
|
let groupby_geolocation_granularity = chart.x_axis_geolocation_granularity;
|
|
98
|
-
let column_groupby_numeric_columns = chart.
|
|
142
|
+
let column_groupby_numeric_columns = chart.summary_columns || [];
|
|
143
|
+
if ([CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(chart.type)) {
|
|
144
|
+
groupby_column_key = chart.vertical_axis_column_key;
|
|
145
|
+
groupby_date_granularity = chart.vertical_axis_date_granularity;
|
|
146
|
+
groupby_geolocation_granularity = chart.vertical_axis_geolocation_granularity;
|
|
147
|
+
x_axis_include_empty_cells = chart.vertical_axis_include_empty;
|
|
148
|
+
y_axis_summary_column_key = chart.horizontal_axis_column_key;
|
|
149
|
+
y_axis_summary_type = chart.horizontal_axis_summary_type;
|
|
150
|
+
y_axis_summary_method = chart.horizontal_axis_summary_method;
|
|
151
|
+
}
|
|
99
152
|
const table = getTableById(value.tables, table_id);
|
|
100
153
|
const view = table && getViewById(table.views, view_id);
|
|
101
154
|
if (!view) {
|
|
@@ -117,7 +170,7 @@ async function calculateGroupingChart(chart, value, _ref2) {
|
|
|
117
170
|
const yAxisType = null;
|
|
118
171
|
const statRows = await getViewRows(view, table);
|
|
119
172
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
120
|
-
let results = getGroupingChartResults(statRows, formulaRows, groupbyColumn,
|
|
173
|
+
let results = getGroupingChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty_cells, groupby_date_granularity, groupby_geolocation_granularity, column_groupby_column_key, column_groupby_date_granularity, column_groupby_geolocation_granularity, y_axis_summary_column_key, y_axis_summary_type, y_axis_summary_method, column_groupby_multiple_numeric_column, column_groupby_numeric_columns, yAxisType, table, value);
|
|
121
174
|
BaseUtils.sortCharts(results, groupbyColumn, 'name');
|
|
122
175
|
results = results.map(result => {
|
|
123
176
|
return {
|
|
@@ -321,9 +374,9 @@ async function calculateGeolocationBasicChart(chart, value, _ref3) {
|
|
|
321
374
|
type,
|
|
322
375
|
table_id,
|
|
323
376
|
view_id,
|
|
324
|
-
|
|
377
|
+
geo_column_key,
|
|
325
378
|
summary_type,
|
|
326
|
-
|
|
379
|
+
summary_column_key,
|
|
327
380
|
summary_method
|
|
328
381
|
} = chart;
|
|
329
382
|
const table = getTableById(value.tables, table_id);
|
|
@@ -331,7 +384,7 @@ async function calculateGeolocationBasicChart(chart, value, _ref3) {
|
|
|
331
384
|
if (!view) {
|
|
332
385
|
return;
|
|
333
386
|
}
|
|
334
|
-
const geoColumn =
|
|
387
|
+
const geoColumn = geo_column_key && getTableColumnByKey(table, geo_column_key);
|
|
335
388
|
if (!geoColumn) {
|
|
336
389
|
return;
|
|
337
390
|
}
|
|
@@ -341,7 +394,7 @@ async function calculateGeolocationBasicChart(chart, value, _ref3) {
|
|
|
341
394
|
} else {
|
|
342
395
|
geolocationGranularity = fixGeoGranularity(chart);
|
|
343
396
|
}
|
|
344
|
-
const summaryColumn = getTableColumnByKey(table,
|
|
397
|
+
const summaryColumn = getTableColumnByKey(table, summary_column_key);
|
|
345
398
|
const statRows = await getViewRows(view, table);
|
|
346
399
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
347
400
|
const geoColumnType = geoColumn.type;
|
|
@@ -391,7 +444,7 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
391
444
|
x_axis_column_key,
|
|
392
445
|
x_axis_date_granularity,
|
|
393
446
|
x_axis_geolocation_granularity,
|
|
394
|
-
|
|
447
|
+
x_axis_include_empty_cells,
|
|
395
448
|
y_axises
|
|
396
449
|
} = statItem;
|
|
397
450
|
const table = getTableById(value.tables, table_id);
|
|
@@ -435,7 +488,7 @@ async function calculateCustomBar(statItem, value, _ref4) {
|
|
|
435
488
|
column_key: summary_column_key,
|
|
436
489
|
summary_method
|
|
437
490
|
} = numericSummaryColumn;
|
|
438
|
-
const currentResults = getGroupbyNumericColumnsChartResults(statRows, formulaRows, groupbyColumn,
|
|
491
|
+
const currentResults = getGroupbyNumericColumnsChartResults(statRows, formulaRows, groupbyColumn, x_axis_include_empty_cells, groupbyDateGranularity, groupbyGeolocationGranularity, summary_column_key, columnGroupbyDateGranularity, columnGroupbyGeolocationGranularity, CHART_SUMMARY_TYPE.ADVANCED, summary_method, yAxisType, table, value);
|
|
439
492
|
results = results.concat(currentResults);
|
|
440
493
|
});
|
|
441
494
|
}
|
|
@@ -463,7 +516,7 @@ function calculator(chart, value, _ref5) {
|
|
|
463
516
|
getTableFormulaResults
|
|
464
517
|
});
|
|
465
518
|
}
|
|
466
|
-
if (type === CHART_TYPE.
|
|
519
|
+
if (type === CHART_TYPE.BAR_CUSTOM) {
|
|
467
520
|
return calculateCustomBar(chart, value, {
|
|
468
521
|
getViewRows,
|
|
469
522
|
getTableFormulaResults
|
|
@@ -9,12 +9,12 @@ async function calculator(chart, dtableValue, _ref) {
|
|
|
9
9
|
const {
|
|
10
10
|
table_id,
|
|
11
11
|
view_id,
|
|
12
|
-
|
|
12
|
+
numeric_column_key,
|
|
13
13
|
summary_method
|
|
14
14
|
} = chart;
|
|
15
15
|
const selectedTable = getTableById(dtableValue.tables, table_id);
|
|
16
16
|
const selectedView = selectedTable && getViewById(selectedTable.views, view_id);
|
|
17
|
-
const selectedColumn = getTableColumnByKey(selectedTable,
|
|
17
|
+
const selectedColumn = getTableColumnByKey(selectedTable, numeric_column_key);
|
|
18
18
|
const _isNumericColumn = selectedColumn && isNumericColumn(selectedColumn);
|
|
19
19
|
const statRows = await getViewRows(selectedView, selectedTable);
|
|
20
20
|
const formulaRows = _isNumericColumn ? await getTableFormulaResults(selectedTable, statRows) : {};
|
|
@@ -12,7 +12,7 @@ async function calculator(chart, value, _ref) {
|
|
|
12
12
|
table_id,
|
|
13
13
|
view_id,
|
|
14
14
|
x_axis_column_key,
|
|
15
|
-
|
|
15
|
+
x_axis_include_empty_cells,
|
|
16
16
|
x_axis_date_granularity: groupby_date_granularity,
|
|
17
17
|
x_axis_geolocation_granularity: groupby_geolocation_granularity,
|
|
18
18
|
y_axis_left_summary_column,
|
|
@@ -84,13 +84,13 @@ async function calculator(chart, value, _ref) {
|
|
|
84
84
|
leftResultMap.set(name, currentValue);
|
|
85
85
|
});
|
|
86
86
|
}
|
|
87
|
-
if (label.length === 0 &&
|
|
87
|
+
if (label.length === 0 && x_axis_include_empty_cells) {
|
|
88
88
|
let currentValue = leftResultMap.get(null) || 0;
|
|
89
89
|
currentValue += 1;
|
|
90
90
|
leftResultMap.set(null, currentValue);
|
|
91
91
|
}
|
|
92
92
|
} else {
|
|
93
|
-
if (
|
|
93
|
+
if (x_axis_include_empty_cells || label) {
|
|
94
94
|
let currentLabelCount = leftResultMap.get(label) || 0;
|
|
95
95
|
currentLabelCount = currentLabelCount + 1;
|
|
96
96
|
leftResultMap.set(label, currentLabelCount);
|
|
@@ -116,7 +116,7 @@ async function calculator(chart, value, _ref) {
|
|
|
116
116
|
leftResultMap.set(name, currentLabelMap);
|
|
117
117
|
});
|
|
118
118
|
}
|
|
119
|
-
if (label.length === 0 &&
|
|
119
|
+
if (label.length === 0 && x_axis_include_empty_cells) {
|
|
120
120
|
let currentValue = leftResultMap.get(null) || {};
|
|
121
121
|
leftSummaryColumnKeys.forEach(key => {
|
|
122
122
|
const cellValue = getCellValue(row, formulaRow, {
|
|
@@ -132,7 +132,7 @@ async function calculator(chart, value, _ref) {
|
|
|
132
132
|
leftResultMap.set(null, currentValue);
|
|
133
133
|
}
|
|
134
134
|
} else {
|
|
135
|
-
if (
|
|
135
|
+
if (x_axis_include_empty_cells || label) {
|
|
136
136
|
const currentValue = leftResultMap.get(label) || {};
|
|
137
137
|
leftSummaryColumnKeys.forEach(key => {
|
|
138
138
|
const cellValue = getCellValue(row, formulaRow, {
|
|
@@ -160,13 +160,13 @@ async function calculator(chart, value, _ref) {
|
|
|
160
160
|
rightResultMap.set(name, currentValue);
|
|
161
161
|
});
|
|
162
162
|
}
|
|
163
|
-
if (label.length === 0 &&
|
|
163
|
+
if (label.length === 0 && x_axis_include_empty_cells) {
|
|
164
164
|
let currentValue = rightResultMap.get(null) || 0;
|
|
165
165
|
currentValue += 1;
|
|
166
166
|
rightResultMap.set(null, currentValue);
|
|
167
167
|
}
|
|
168
168
|
} else {
|
|
169
|
-
if (
|
|
169
|
+
if (x_axis_include_empty_cells || label) {
|
|
170
170
|
let currentLabelCount = rightResultMap.get(label) || 0;
|
|
171
171
|
currentLabelCount = currentLabelCount + 1;
|
|
172
172
|
rightResultMap.set(label, currentLabelCount);
|
|
@@ -185,7 +185,7 @@ async function calculator(chart, value, _ref) {
|
|
|
185
185
|
rightResultMap.set(name, currentLabelList);
|
|
186
186
|
});
|
|
187
187
|
}
|
|
188
|
-
if (label.length === 0 &&
|
|
188
|
+
if (label.length === 0 && x_axis_include_empty_cells) {
|
|
189
189
|
let currentValue = rightResultMap.get(null) || [];
|
|
190
190
|
if (isNumber(cellValue)) {
|
|
191
191
|
currentValue.push(cellValue);
|
|
@@ -193,7 +193,7 @@ async function calculator(chart, value, _ref) {
|
|
|
193
193
|
rightResultMap.set(null, currentValue);
|
|
194
194
|
}
|
|
195
195
|
} else {
|
|
196
|
-
if (
|
|
196
|
+
if (x_axis_include_empty_cells || label) {
|
|
197
197
|
const currentLabelList = rightResultMap.get(label) || [];
|
|
198
198
|
if (isNumber(cellValue)) {
|
|
199
199
|
currentLabelList.push(cellValue);
|
|
@@ -13,7 +13,7 @@ async function calculator(chart, value, _ref) {
|
|
|
13
13
|
x_axis_column_key,
|
|
14
14
|
y_axis_summary_type,
|
|
15
15
|
y_axis_summary_method,
|
|
16
|
-
|
|
16
|
+
y_axis_summary_column_key,
|
|
17
17
|
x_axis_date_granularity,
|
|
18
18
|
x_axis_date_range_start,
|
|
19
19
|
x_axis_date_range_end,
|
|
@@ -32,7 +32,7 @@ async function calculator(chart, value, _ref) {
|
|
|
32
32
|
if (!groupbyColumn) {
|
|
33
33
|
return [];
|
|
34
34
|
}
|
|
35
|
-
const summaryColumn = getTableColumnByKey(table,
|
|
35
|
+
const summaryColumn = getTableColumnByKey(table, y_axis_summary_column_key) || {};
|
|
36
36
|
const statRows = await getViewRows(view, table);
|
|
37
37
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
38
38
|
const dateRangeResultMap = new Map();
|
|
@@ -11,10 +11,10 @@ async function calculator(chart, value, _ref) {
|
|
|
11
11
|
const {
|
|
12
12
|
table_id,
|
|
13
13
|
view_id,
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
14
|
+
groupby_column_key,
|
|
15
|
+
completed_column_key,
|
|
16
|
+
target_column_key,
|
|
17
|
+
column_groupby_column_key,
|
|
18
18
|
date_granularity,
|
|
19
19
|
geolocation_granularity
|
|
20
20
|
} = chart;
|
|
@@ -23,17 +23,17 @@ async function calculator(chart, value, _ref) {
|
|
|
23
23
|
if (!view) {
|
|
24
24
|
return [];
|
|
25
25
|
}
|
|
26
|
-
const nameColumn = getTableColumnByKey(table,
|
|
26
|
+
const nameColumn = getTableColumnByKey(table, groupby_column_key);
|
|
27
27
|
if (!nameColumn) return [];
|
|
28
28
|
const statRows = await getViewRows(view, table);
|
|
29
29
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
30
|
-
const groupColumn = getTableColumnByKey(table,
|
|
30
|
+
const groupColumn = getTableColumnByKey(table, column_groupby_column_key);
|
|
31
31
|
const isColumnDataAsAnArray = isArrayCellValue(nameColumn);
|
|
32
32
|
const isGroupChart = !!groupColumn;
|
|
33
33
|
let result = [];
|
|
34
34
|
if (!isGroupChart) {
|
|
35
|
-
const completedColumn = getTableColumnByKey(table,
|
|
36
|
-
const targetColumn = getTableColumnByKey(table,
|
|
35
|
+
const completedColumn = getTableColumnByKey(table, completed_column_key);
|
|
36
|
+
const targetColumn = getTableColumnByKey(table, target_column_key);
|
|
37
37
|
let labelCountMap = {};
|
|
38
38
|
let labels = [];
|
|
39
39
|
statRows.forEach(row => {
|
|
@@ -96,8 +96,8 @@ async function calculator(chart, value, _ref) {
|
|
|
96
96
|
}
|
|
97
97
|
});
|
|
98
98
|
} else {
|
|
99
|
-
const completedColumn = getTableColumnByKey(table,
|
|
100
|
-
const targetColumn = getTableColumnByKey(table,
|
|
99
|
+
const completedColumn = getTableColumnByKey(table, completed_column_key);
|
|
100
|
+
const targetColumn = getTableColumnByKey(table, target_column_key);
|
|
101
101
|
let labelCountMap = {};
|
|
102
102
|
let colorMap = {};
|
|
103
103
|
let labelGroups = [];
|
|
@@ -9,15 +9,15 @@ async function calculator(chart, value, _ref) {
|
|
|
9
9
|
const {
|
|
10
10
|
table_id,
|
|
11
11
|
view_id,
|
|
12
|
-
|
|
12
|
+
target_value_column_key,
|
|
13
13
|
target_value_column_summary_method,
|
|
14
|
-
|
|
14
|
+
total_value_column_key,
|
|
15
15
|
total_value_column_summary_method
|
|
16
16
|
} = chart;
|
|
17
17
|
const selectedTable = getTableById(value.tables, table_id);
|
|
18
18
|
const selectedView = selectedTable && getViewById(selectedTable.views, view_id);
|
|
19
|
-
const selectedColumn1 = getTableColumnByKey(selectedTable,
|
|
20
|
-
const selectedColumn2 = getTableColumnByKey(selectedTable,
|
|
19
|
+
const selectedColumn1 = getTableColumnByKey(selectedTable, target_value_column_key);
|
|
20
|
+
const selectedColumn2 = getTableColumnByKey(selectedTable, total_value_column_key);
|
|
21
21
|
const statRows = await getViewRows(selectedView, selectedTable);
|
|
22
22
|
if (statRows.length === 0) {
|
|
23
23
|
return 0;
|
|
@@ -1,5 +1,8 @@
|
|
|
1
1
|
var _OriginalDataUtils;
|
|
2
2
|
import { getTableById, getViewById } from 'dtable-utils';
|
|
3
|
+
import { CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES } from '../../../constants';
|
|
4
|
+
import BaseUtils from '../base-utils';
|
|
5
|
+
import context from '../../../context';
|
|
3
6
|
import PivotTableCalculator from './pivot-table-calculator';
|
|
4
7
|
import BasicChartCalculator from './basic-chart-calculator';
|
|
5
8
|
import CompareBarCalculator from './compare-bar-chart-calculator';
|
|
@@ -10,9 +13,6 @@ import MirrorCalculator from './mirror-calculator';
|
|
|
10
13
|
import CardCalculator from './card-calculator';
|
|
11
14
|
import TrendCalculator from './trend-calculator';
|
|
12
15
|
import DashboardCalculator from './dashboard-calculator';
|
|
13
|
-
import { CHART_TYPE, SUPPORT_DATA_SORT_CHART_TYPES } from '../../../constants';
|
|
14
|
-
import BaseUtils from '../base-utils';
|
|
15
|
-
import context from '../../../context';
|
|
16
16
|
const BASIC_CHART = 'basic_chart';
|
|
17
17
|
const calculatorMap = {
|
|
18
18
|
[CHART_TYPE.TABLE]: PivotTableCalculator,
|
|
@@ -60,19 +60,19 @@ async function calculator(chart, dtableValue, _ref) {
|
|
|
60
60
|
const {
|
|
61
61
|
table_id,
|
|
62
62
|
view_id,
|
|
63
|
-
|
|
63
|
+
column_key,
|
|
64
64
|
summary_type,
|
|
65
|
-
|
|
65
|
+
summary_column_key,
|
|
66
66
|
summary_method,
|
|
67
|
-
|
|
67
|
+
group_column_key
|
|
68
68
|
} = chart;
|
|
69
69
|
const table = getTableById(dtableValue.tables, table_id);
|
|
70
70
|
const view = table && getViewById(table.views, view_id);
|
|
71
|
-
const columnItem = getTableColumnByKey(table,
|
|
71
|
+
const columnItem = getTableColumnByKey(table, column_key);
|
|
72
72
|
const rows = await getViewRows(view, table);
|
|
73
73
|
const formulaRows = await getTableFormulaResults(table, rows);
|
|
74
|
-
const groupColumn = getTableColumnByKey(table,
|
|
75
|
-
const numericColumn =
|
|
74
|
+
const groupColumn = getTableColumnByKey(table, group_column_key);
|
|
75
|
+
const numericColumn = summary_column_key && getTableColumnByKey(table, summary_column_key);
|
|
76
76
|
const groupItems = getGroupItems(rows, groupColumn);
|
|
77
77
|
if (groupColumn.length === 0) return;
|
|
78
78
|
let result = {};
|
|
@@ -18,7 +18,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
18
18
|
groupby_include_empty_cells: include_empty,
|
|
19
19
|
groupby_date_granularity,
|
|
20
20
|
groupby_geolocation_granularity,
|
|
21
|
-
|
|
21
|
+
summary_columns
|
|
22
22
|
} = chart;
|
|
23
23
|
const table = getTableById(value.tables, table_id);
|
|
24
24
|
const view = table && getViewById(table.views, view_id);
|
|
@@ -54,7 +54,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
54
54
|
}
|
|
55
55
|
}
|
|
56
56
|
});
|
|
57
|
-
const summary_columns_option_keys = Array.isArray(
|
|
57
|
+
const summary_columns_option_keys = Array.isArray(summary_columns) ? summary_columns.map(option => option.key) : [];
|
|
58
58
|
const statisticColumnKeys = [summary_column_key, ...summary_columns_option_keys];
|
|
59
59
|
const validStatisticColumnKeys = statisticColumnKeys;
|
|
60
60
|
let statisticColumns = validStatisticColumnKeys.map(key => {
|
|
@@ -66,7 +66,7 @@ async function calculateOneDimensionTable(chart, value, _ref) {
|
|
|
66
66
|
if (statisticColumns.length > 0) {
|
|
67
67
|
statisticColumns[0].method = summary_method;
|
|
68
68
|
}
|
|
69
|
-
Array.isArray(
|
|
69
|
+
Array.isArray(summary_columns) && summary_columns.forEach((option, index) => {
|
|
70
70
|
if (statisticColumns[index + 1]) {
|
|
71
71
|
statisticColumns[index + 1].method = option.method;
|
|
72
72
|
}
|
|
@@ -35,18 +35,18 @@ async function calculator(chart, value, _ref) {
|
|
|
35
35
|
const {
|
|
36
36
|
table_id,
|
|
37
37
|
view_id,
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
x_axis_column_key,
|
|
39
|
+
y_axis_column_key,
|
|
40
|
+
column_groupby_column_key
|
|
41
41
|
} = chart;
|
|
42
42
|
const table = getTableById(value.tables, table_id);
|
|
43
43
|
const view = table && getViewById(table.views, view_id);
|
|
44
44
|
if (!view) {
|
|
45
45
|
return [];
|
|
46
46
|
}
|
|
47
|
-
const selectedXAxisColumn = getTableColumnByKey(table,
|
|
48
|
-
const selectedYAxisColumn = getTableColumnByKey(table,
|
|
49
|
-
const selectedGroupColumn = getTableColumnByKey(table,
|
|
47
|
+
const selectedXAxisColumn = getTableColumnByKey(table, x_axis_column_key);
|
|
48
|
+
const selectedYAxisColumn = getTableColumnByKey(table, y_axis_column_key);
|
|
49
|
+
const selectedGroupColumn = getTableColumnByKey(table, column_groupby_column_key);
|
|
50
50
|
const statRows = await getViewRows(view, table);
|
|
51
51
|
const formulaRows = await getTableFormulaResults(table, statRows);
|
|
52
52
|
const data = [];
|
|
@@ -62,9 +62,9 @@ async function calculator(chart, value, _ref) {
|
|
|
62
62
|
const name = getColumnValue(row, formulaRow, selectedGroupColumn, value);
|
|
63
63
|
const nameIndex = data.findIndex(r => r.name === name && r.x_axis === x_axis && r.y_axis === y_axis);
|
|
64
64
|
const dataItem = {
|
|
65
|
-
x_axis,
|
|
66
|
-
y_axis,
|
|
67
|
-
|
|
65
|
+
name: x_axis,
|
|
66
|
+
value: y_axis,
|
|
67
|
+
groupby: name
|
|
68
68
|
};
|
|
69
69
|
updateBasicChartRows(data, nameIndex, name, dataItem, row);
|
|
70
70
|
});
|
|
@@ -14,19 +14,19 @@ async function calculator(chart, value, _ref) {
|
|
|
14
14
|
const {
|
|
15
15
|
table_id,
|
|
16
16
|
view_id,
|
|
17
|
-
|
|
17
|
+
date_column_key,
|
|
18
18
|
date_granularity,
|
|
19
|
-
|
|
19
|
+
summary_column_key,
|
|
20
20
|
summary_type,
|
|
21
21
|
summary_method
|
|
22
22
|
} = chart;
|
|
23
23
|
const selectedTable = getTableById(value.tables, table_id);
|
|
24
24
|
const selectedView = selectedTable && getViewById(selectedTable.views, view_id);
|
|
25
|
-
const selectedColumn = getTableColumnByKey(selectedTable,
|
|
25
|
+
const selectedColumn = getTableColumnByKey(selectedTable, date_column_key);
|
|
26
26
|
const resultMap = new Map();
|
|
27
27
|
let formulaRows = {};
|
|
28
28
|
const rows = await getViewRows(selectedView, selectedTable);
|
|
29
|
-
const numericColumn = getTableColumnByKey(selectedTable,
|
|
29
|
+
const numericColumn = getTableColumnByKey(selectedTable, summary_column_key);
|
|
30
30
|
if (summary_type === CHART_SUMMARY_TYPE.ADVANCED) {
|
|
31
31
|
if (FORMULA_COLUMN_TYPES_MAP[numericColumn.type]) {
|
|
32
32
|
formulaRows = await getTableFormulaResults(selectedTable, rows);
|
|
@@ -59,7 +59,7 @@ async function calculator(chart, value, _ref) {
|
|
|
59
59
|
const {
|
|
60
60
|
compareValue: value1,
|
|
61
61
|
comparedValue: value2
|
|
62
|
-
} = summaryDurationResult(resultMap, date_granularity, summary_type,
|
|
62
|
+
} = summaryDurationResult(resultMap, date_granularity, summary_type, summary_column_key, false);
|
|
63
63
|
currentValues = value1;
|
|
64
64
|
previousValues = value2;
|
|
65
65
|
} else {
|