sea-chart 1.1.112 → 1.1.114

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.
@@ -147,6 +147,7 @@ const de = {
147
147
  "Execution_time_of_the_query_exceeds_the_limit": "Le temps d'exécution de la requête dépasse la limite. Les données ne peuvent pas être chargées.",
148
148
  "There_are_some_problems_with_the_filters": "Die Filterbedingungen sind abnormal. Bitte setzen sie die Filterbedingungen in den Ansichtseinstellungen zurück.",
149
149
  "Please_complete_the_chart_configuration_first": "Configure chart in element settings",
150
+ "The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations": "The chart settings are invalid. Please contact the administrator for relevant configurations",
150
151
  "Not_used": "Nicht verwendet",
151
152
  "Select_field": "Feld auswählen",
152
153
  "Display_total": "Gesamtwert anzeigen",
@@ -147,6 +147,7 @@ const en = {
147
147
  "Execution_time_of_the_query_exceeds_the_limit": "Execution time of the query exceeds the limit. Data cannot be loaded.",
148
148
  "There_are_some_problems_with_the_filters": "There are some problems with the filters.",
149
149
  "Please_complete_the_chart_configuration_first": "Configure chart in element settings",
150
+ "The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations": "The chart settings are invalid. Please contact the administrator for relevant configurations",
150
151
  "Not_used": "Not used",
151
152
  "Select_field": "Select field",
152
153
  "Display_total": "Display total",
@@ -147,6 +147,7 @@ const es = {
147
147
  "Execution_time_of_the_query_exceeds_the_limit": "Execution time of the query exceeds the limit. Data cannot be loaded.",
148
148
  "There_are_some_problems_with_the_filters": "There are some problems with the filters.",
149
149
  "Please_complete_the_chart_configuration_first": "Configure chart in element settings",
150
+ "The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations": "The chart settings are invalid. Please contact the administrator for relevant configurations",
150
151
  "Not_used": "Not used",
151
152
  "Select_field": "Select field",
152
153
  "Display_total": "Display total",
@@ -147,6 +147,7 @@ const fr = {
147
147
  "Execution_time_of_the_query_exceeds_the_limit": "Le temps d'exécution de la requête dépasse la limite. Les données ne peuvent pas être chargées.",
148
148
  "There_are_some_problems_with_the_filters": "Les conditions de filtrage sont anormales. Veuillez réinitialiser les conditions de filtrage dans les paramètres de vue.",
149
149
  "Please_complete_the_chart_configuration_first": "Configure chart in element settings",
150
+ "The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations": "The chart settings are invalid. Please contact the administrator for relevant configurations",
150
151
  "Not_used": "Ne pas utilisé",
151
152
  "Select_field": "Sélectionner un champ",
152
153
  "Display_total": "Afficher le total",
@@ -147,6 +147,7 @@ const pt = {
147
147
  "Execution_time_of_the_query_exceeds_the_limit": "Execution time of the query exceeds the limit. Data cannot be loaded.",
148
148
  "There_are_some_problems_with_the_filters": "There are some problems with the filters.",
149
149
  "Please_complete_the_chart_configuration_first": "Configure chart in element settings",
150
+ "The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations": "The chart settings are invalid. Please contact the administrator for relevant configurations",
150
151
  "Not_used": "Not used",
151
152
  "Select_field": "Select field",
152
153
  "Display_total": "Display total",
@@ -147,6 +147,7 @@ const ru = {
147
147
  "Execution_time_of_the_query_exceeds_the_limit": "Execution time of the query exceeds the limit. Data cannot be loaded.",
148
148
  "There_are_some_problems_with_the_filters": "There are some problems with the filters.",
149
149
  "Please_complete_the_chart_configuration_first": "Configure chart in element settings",
150
+ "The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations": "The chart settings are invalid. Please contact the administrator for relevant configurations",
150
151
  "Not_used": "Not used",
151
152
  "Select_field": "Select field",
152
153
  "Display_total": "Display total",
@@ -147,6 +147,7 @@ const zh_CN = {
147
147
  "Execution_time_of_the_query_exceeds_the_limit": "查询的执行时间超出限制。无法加载数据。",
148
148
  "There_are_some_problems_with_the_filters": "过滤器有一些问题。",
149
149
  "Please_complete_the_chart_configuration_first": "在元素设置中配置图表",
150
+ "The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations": "图表设置无效,请联系管理员进行相关配置",
150
151
  "Not_used": "不使用",
151
152
  "Select_field": "选择字段",
152
153
  "Display_total": "显示总计",
@@ -46,7 +46,14 @@ const DataFilter = _ref => {
46
46
  let availableFilters = [];
47
47
  // some of the filters of TABLE_ELEMENT maybe one of the hidden columns, so we need to filter them out
48
48
  if (shown_column_keys && type === CHART_TYPE.TABLE_ELEMENT) {
49
- availableFilters = validFilters === null || validFilters === void 0 ? void 0 : validFilters.filter(filter => shown_column_keys.includes(filter.column_key));
49
+ availableFilters = validFilters === null || validFilters === void 0 ? void 0 : validFilters.filter(filter => {
50
+ // For filter groups, check if any sub-filter references shown columns
51
+ if (filter.filters) {
52
+ return filter.filters.some(subFilter => shown_column_keys.includes(subFilter.column_key));
53
+ }
54
+ // For regular filters, check directly
55
+ return shown_column_keys.includes(filter.column_key);
56
+ });
50
57
  } else {
51
58
  availableFilters = validFilters;
52
59
  }
@@ -149,7 +149,7 @@ BaseUtils.isValidExistChart = (tables, chart) => {
149
149
  // "key" and "column_key" are both exists currently, "column_key" is defined in public component, to avoid bugs, better not to change "column_key" to "key"
150
150
  summaryColumnKey = config.summary_columns[0].key || config.summary_columns[0].column_key;
151
151
  }
152
- const summaryType = config.summary_type || config.y_axis_summary_type || config.horizontal_axis_summary_type;
152
+ const summaryType = _BaseUtils.getSummaryType(config);
153
153
  if (summaryType === CHART_SUMMARY_TYPE.ADVANCED && !summaryColumnKey) return false;
154
154
  if (summaryColumnKey) {
155
155
  return getTableColumnByKey(table, summaryColumnKey);
@@ -1145,6 +1145,32 @@ BaseUtils.convertConfig = config => {
1145
1145
  }
1146
1146
  return config;
1147
1147
  };
1148
+ BaseUtils.getSummaryType = config => {
1149
+ switch (config.type) {
1150
+ case CHART_TYPE.HORIZONTAL_BAR:
1151
+ case CHART_TYPE.HORIZONTAL_GROUP_BAR:
1152
+ case CHART_TYPE.STACKED_HORIZONTAL_BAR:
1153
+ {
1154
+ return config.horizontal_axis_summary_type;
1155
+ }
1156
+ case CHART_TYPE.BAR:
1157
+ case CHART_TYPE.BAR_GROUP:
1158
+ case CHART_TYPE.BAR_STACK:
1159
+ case CHART_TYPE.LINE:
1160
+ case CHART_TYPE.LINE_GROUP:
1161
+ case CHART_TYPE.AREA:
1162
+ case CHART_TYPE.AREA_GROUP:
1163
+ case CHART_TYPE.SCATTER:
1164
+ {
1165
+ return config.y_axis_summary_type;
1166
+ }
1167
+ case CHART_TYPE.TABLE:
1168
+ default:
1169
+ {
1170
+ return config.summary_type;
1171
+ }
1172
+ }
1173
+ };
1148
1174
  BaseUtils.getGroupLabel = (cellValue, formulaRow, column, dateGranularity, geoGranularity, value) => {
1149
1175
  let {
1150
1176
  type,
@@ -9,7 +9,9 @@ import OriginalDataUtils from './original-data-utils';
9
9
  class ChartUtils {}
10
10
  ChartUtils.calculateChart = async (chart, value, callback) => {
11
11
  if (!BaseUtils.isValidExistChart(value.tables, chart)) {
12
- const tip_message = 'Please_complete_the_chart_configuration_first';
12
+ const roleId = context.getSetting('roleId');
13
+ const isEditAppPage = context.getSetting('isEditAppPage');
14
+ const tip_message = !roleId && !isEditAppPage ? 'The_chart_settings_are_invalid_please_contact_the_administrator_for_relevant_configurations' : 'Please_complete_the_chart_configuration_first';
13
15
  return callback && callback('', tip_message, null);
14
16
  }
15
17
  const id = uniqueId();
@@ -20,7 +20,10 @@ async function calculator(chart, value, _ref) {
20
20
  const selectedColumn2 = getTableColumnByKey(selectedTable, total_value_column_key);
21
21
  const statRows = await getViewRows(selectedView, selectedTable);
22
22
  if (statRows.length === 0) {
23
- return 0;
23
+ return {
24
+ value: 0,
25
+ rows: []
26
+ };
24
27
  }
25
28
  const isNumericColumn1 = selectedColumn1 && isNumericColumn(selectedColumn1);
26
29
  const isNumericColumn2 = selectedColumn2 && isNumericColumn(selectedColumn2);
@@ -55,8 +58,14 @@ async function calculator(chart, value, _ref) {
55
58
  result2 = BaseUtils.getSummaryResult(numberList2, total_value_column_summary_method);
56
59
  }
57
60
  if (result2 === 0) {
58
- return 0;
61
+ return {
62
+ value: 0,
63
+ rows: statRows
64
+ };
59
65
  }
60
- return result1 / result2;
66
+ return {
67
+ value: result1 / result2,
68
+ rows: statRows
69
+ };
61
70
  }
62
71
  export default calculator;
@@ -85,7 +85,7 @@ async function calculator(chart, value, _ref) {
85
85
  const {
86
86
  compareDate,
87
87
  comparedDate
88
- } = getCompareDate(date_granularity);
88
+ } = getCompareDate(date_granularity, 'base');
89
89
  currentValues = resultMap.get(compareDate);
90
90
  previousValues = resultMap.get(comparedDate);
91
91
  currentPeriodRows = rowsMap.get(compareDate) || [];
@@ -1600,7 +1600,7 @@ SQLStatisticsUtils.trendMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
1600
1600
  const {
1601
1601
  compareDate,
1602
1602
  comparedDate
1603
- } = getCompareDate(date_granularity);
1603
+ } = getCompareDate(date_granularity, 'app');
1604
1604
  for (const item of sqlRows) {
1605
1605
  if (!item[sqlGroupbyColumnKey]) continue;
1606
1606
  const currentDate = item[sqlGroupbyColumnKey] + '';
@@ -13,7 +13,7 @@ const dayOfWeekMap = {
13
13
  'Friday': 5,
14
14
  'Saturday': 6
15
15
  };
16
- export function getCompareDate(dateGranularity) {
16
+ export function getCompareDate(dateGranularity, source) {
17
17
  const currentDate = dayjs();
18
18
  switch (dateGranularity) {
19
19
  case CHART_SUMMARY_TYPE.DAY:
@@ -28,7 +28,7 @@ export function getCompareDate(dateGranularity) {
28
28
  case CHART_SUMMARY_TYPE.WEEK:
29
29
  {
30
30
  var _dayOfWeekMap$firstDa;
31
- const firstDayOfWeek = getFirstDayOfWeekForGroupby('app');
31
+ const firstDayOfWeek = getFirstDayOfWeekForGroupby(source);
32
32
  const startDayIndex = (_dayOfWeekMap$firstDa = dayOfWeekMap[firstDayOfWeek]) !== null && _dayOfWeekMap$firstDa !== void 0 ? _dayOfWeekMap$firstDa : 0; // default to Sunday
33
33
  const currentWeek = dayjs().day(startDayIndex);
34
34
  const compareDate = dayjs(currentWeek).subtract(1, 'weeks').format('YYYY-MM-DD');
@@ -11,6 +11,22 @@ const textAlignPositionMap = {
11
11
  class Dashboard extends Component {
12
12
  constructor() {
13
13
  super(...arguments);
14
+ this.handleClickNumber = () => {
15
+ const {
16
+ toggleRecords,
17
+ result
18
+ } = this.props;
19
+ if (!toggleRecords) return;
20
+ if (typeof result === 'object' && result !== null && result.rows) {
21
+ toggleRecords({
22
+ rows: result.rows
23
+ });
24
+ } else {
25
+ toggleRecords({
26
+ isQueryBySql: true
27
+ });
28
+ }
29
+ };
14
30
  this.componentDidMount = () => {
15
31
  this.drawChart();
16
32
  };
@@ -23,7 +39,7 @@ class Dashboard extends Component {
23
39
  customRender
24
40
  } = this.props;
25
41
  const theme = CHART_THEME_COLOR[globalTheme];
26
- const value = isNumber(result) ? result : 0;
42
+ const value = typeof result === 'object' && result !== null ? isNumber(result.value) ? result.value : 0 : isNumber(result) ? result : 0;
27
43
  const {
28
44
  config
29
45
  } = chart;
@@ -43,9 +59,6 @@ class Dashboard extends Component {
43
59
  width: '100%',
44
60
  height: '100%'
45
61
  });
46
- this.chart.on('interval:click', e => {
47
- this.props.toggleRecords(e.data.data);
48
- });
49
62
  registerShape('point', 'pointer', {
50
63
  draw(cfg, container) {
51
64
  const group = container.addGroup();
@@ -156,20 +169,32 @@ class Dashboard extends Component {
156
169
  if (shownDotPos > -1 && shownDotPos < `${shownValue}`.length - 2) {
157
170
  shownValue = shownValue.toFixed(1);
158
171
  }
159
- this.chart.annotation().text({
172
+
173
+ // render numeric value as clickable HTML to exclusively trigger drill-down when clicking the number
174
+ const numberFontSize = font_size || (canvasStyle.height > 240 ? 36 : 16);
175
+ const numberColor = font_color || theme.textColor;
176
+ const numberFontWeight = font_weight || 'bold';
177
+ const numberTextAlign = text_align || 'center';
178
+ this.chart.annotation().html({
160
179
  position: [textAlignPositionMap[text_align] || '50%', '90%'],
161
- content: `${shownValue} %`,
162
- style: {
163
- fontSize: font_size || (canvasStyle.height > 240 ? 36 : 16),
164
- fill: font_color || theme.textColor,
165
- fontWeight: font_weight || 'bold',
166
- textAlign: 'center'
167
- },
180
+ html: () => `<div class="sea-chart-dashboard-number" style="width:100%;text-align:${numberTextAlign};">
181
+ <span class="dashboard-number"
182
+ style="cursor:pointer;font-size:${numberFontSize}px;color:${numberColor};font-weight:${numberFontWeight};">
183
+ ${shownValue} %
184
+ </span>
185
+ </div>`,
168
186
  offsetY: 0
169
187
  });
170
188
  isFunction(customRender) && customRender(this.chart);
171
189
  this.chart.render();
172
190
  this.container.title = `${data[0].value * 10} %`;
191
+ try {
192
+ var _this$container;
193
+ const numberEl = (_this$container = this.container) === null || _this$container === void 0 ? void 0 : _this$container.querySelector('.dashboard-number');
194
+ numberEl && numberEl.addEventListener('click', this.handleClickNumber);
195
+ } catch (e) {
196
+ console.error(e);
197
+ }
173
198
  };
174
199
  }
175
200
  componentDidUpdate(prevProps) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "1.1.112",
3
+ "version": "1.1.114",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",