sea-chart 0.0.84 → 0.0.85

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.
@@ -165,9 +165,11 @@ BaseUtils.getSummaryColumn = (table, chart) => {
165
165
  case CHART_TYPE.LINE:
166
166
  case CHART_TYPE.LINE_GROUP:
167
167
  case CHART_TYPE.AREA:
168
+ case CHART_TYPE.AREA_GROUP:
168
169
  case CHART_TYPE.HORIZONTAL_BAR:
169
170
  case CHART_TYPE.STACKED_HORIZONTAL_BAR:
170
171
  case CHART_TYPE.HORIZONTAL_GROUP_BAR:
172
+ case CHART_TYPE.BAR_STACK:
171
173
  {
172
174
  return getTableColumnByKey(table, y_axis_summary_column_key);
173
175
  }
@@ -253,6 +253,7 @@ async function calculator(chart, value, _ref) {
253
253
  results.push({
254
254
  name: key,
255
255
  value_left: value,
256
+ group_name: summaryColumn.column_name,
256
257
  color: leftSummaryColumn[columnKey].color,
257
258
  value_right: value2,
258
259
  formatted_value_left: formattedValueLeft,
@@ -78,23 +78,27 @@ async function calculator(chart, value, _ref) {
78
78
  }
79
79
  }
80
80
  }
81
+
82
+ // normal case
83
+ const res = Math.abs(currentValues - previousValues) / previousValues;
84
+ let result = Number.parseFloat(res * 100).toFixed(2) + '%';
85
+
86
+ // set result to 0 when currentValues is 0
81
87
  if (!currentValues) {
82
- return {
83
- latest: null,
84
- previous: previousValues || null
85
- };
88
+ result = '--';
89
+ currentValues = 0;
86
90
  }
91
+
92
+ // set result to -- when previousValues is 0
87
93
  if (!previousValues) {
88
- return {
89
- latest: currentValues,
90
- previous: null
91
- };
94
+ result = '--';
95
+ previousValues = 0;
92
96
  }
93
97
  return {
94
98
  latest: currentValues,
95
99
  previous: previousValues,
96
- result: Math.abs(previousValues - currentValues) / previousValues,
97
- type: currentValues > previousValues ? 'up' : 'down'
100
+ result,
101
+ type: currentValues >= previousValues ? 'up' : 'down'
98
102
  };
99
103
  }
100
104
  export default calculator;
@@ -1425,11 +1425,27 @@ SQLStatisticsUtils.trendMapChartSQLResult2JavaScript = (chart, sqlRows, chartSQL
1425
1425
  }
1426
1426
  }
1427
1427
  }
1428
+
1429
+ // normal case
1430
+ const res = Math.abs(compareValue - comparedValue) / comparedValue;
1431
+ let result = Number.parseFloat(res * 100).toFixed(2) + '%';
1432
+
1433
+ // set result to 0 when compareValue is 0
1434
+ if (!compareValue) {
1435
+ result = '--';
1436
+ compareValue = 0;
1437
+ }
1438
+
1439
+ // set result to -- when comparedValue is 0
1440
+ if (!comparedValue) {
1441
+ result = '--';
1442
+ comparedValue = 0;
1443
+ }
1428
1444
  return {
1429
1445
  latest: compareValue,
1430
1446
  previous: comparedValue,
1431
- result: Math.abs(compareValue - comparedValue) / comparedValue,
1432
- type: compareValue > comparedValue ? 'up' : 'down'
1447
+ result,
1448
+ type: compareValue >= comparedValue ? 'up' : 'down'
1433
1449
  };
1434
1450
  };
1435
1451
  SQLStatisticsUtils.sqlResult2JavaScript = (chart, sqlRows, chartSQLMap, columnMap, tables, params) => {
@@ -1818,7 +1834,8 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
1818
1834
  groupbyColumn,
1819
1835
  columnGroupbyColumn,
1820
1836
  summaryColumn,
1821
- chartTableColumns
1837
+ chartTableColumns,
1838
+ summaryColumnsWithMethod
1822
1839
  });
1823
1840
  return;
1824
1841
  }
@@ -1841,7 +1858,8 @@ SQLStatisticsUtils.calculateChart = (chart, value, callback, sqlRows) => {
1841
1858
  groupbyColumn,
1842
1859
  columnGroupbyColumn,
1843
1860
  summaryColumn,
1844
- chartTableColumns
1861
+ chartTableColumns,
1862
+ summaryColumnsWithMethod
1845
1863
  });
1846
1864
  };
1847
1865
  SQLStatisticsUtils.calculateStaticChart = (chart, value, statisticalResult, callback) => {
@@ -1,8 +1,7 @@
1
1
  import _ButtonFormatter from "dtable-ui-component/lib/ButtonFormatter";
2
2
  import _RateFormatter from "dtable-ui-component/lib/RateFormatter";
3
3
  import React from 'react';
4
- import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber, isDateColumn } from 'dtable-utils';
5
- import { LinksUtils } from 'dtable-store';
4
+ import { CellType, FORMULA_RESULT_TYPE, getNumberDisplayString, getDateDisplayString, getCellValueStringResult, isNumber, isDateColumn, isValidLink } from 'dtable-utils';
6
5
  import dayjs from 'dayjs';
7
6
  import cellFormatterFactory from '../components/cell-factory/cell-formatter-factory';
8
7
  import SimpleCellFormatter from '../components/cell-factory/SimpleCellFormatter';
@@ -200,7 +199,7 @@ export const getFormattedCell = function (column, row) {
200
199
  const {
201
200
  data
202
201
  } = column;
203
- if (!LinksUtils.isValidLink(data)) break;
202
+ if (!isValidLink(data)) break;
204
203
 
205
204
  // is default view: row data can get from formula row
206
205
  // is archive view: row data can get form rowdata
@@ -1,7 +1,7 @@
1
1
  import dayjs from 'dayjs';
2
2
  import quarterOfYear from 'dayjs/plugin/quarterOfYear';
3
- import { BaseUtils } from './chart-utils';
4
3
  import { CHART_SUMMARY_TYPE } from '../constants';
4
+ import { BaseUtils } from './chart-utils';
5
5
  dayjs.extend(quarterOfYear);
6
6
  export function getCompareDate(dateGranularity) {
7
7
  const currentDate = dayjs();
@@ -138,7 +138,7 @@ class Area extends ChartComponent {
138
138
  stroke: 0,
139
139
  fillOpacity: 1,
140
140
  opacity: y_axis_show_value ? 1 : 0
141
- });
141
+ }).tooltip(false);
142
142
  const area = this.chart.area().position('name*value').animate({
143
143
  appear: {
144
144
  animation: 'fadeIn',
@@ -156,9 +156,6 @@ class BarGroup extends ChartComponent {
156
156
  easing: 'easeLinear'
157
157
  }
158
158
  }).label(y_axis_show_value ? 'value' : false, {
159
- content: data => {
160
- return data.value;
161
- },
162
159
  style: {
163
160
  fontSize: BaseUtils.getLabelFontSize(label_font_size),
164
161
  fill: theme.labelColor,
@@ -1,7 +1,6 @@
1
1
  import React, { Component } from 'react';
2
2
  import { isNumber } from 'dtable-utils';
3
- // import { Chart } from '../../utils/custom-g2';
4
- import { BaseUtils, isFunction } from '../../utils';
3
+ import { BaseUtils } from '../../utils';
5
4
  import intl from '../../intl';
6
5
  import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_THEME_COLOR } from '../../constants';
7
6
  class BasicNumericCard extends Component {
@@ -268,12 +268,6 @@ class Combination extends ChartComponent {
268
268
  stroke: 0,
269
269
  fillOpacity: 1
270
270
  }).label(display_data ? 'value_right' : false, {
271
- content: data => {
272
- if (this.currentName) {
273
- return data.name === this.currentName ? data.value_right : '';
274
- }
275
- return data.value_right;
276
- },
277
271
  style: {
278
272
  fontSize: BaseUtils.getLabelFontSize(label_font_size),
279
273
  fill: theme.labelColor,
@@ -25,7 +25,7 @@ class HorizontalBarGroup extends HorizontalComponent {
25
25
  display_data
26
26
  } = chart.config;
27
27
  this.chartTopPadding = display_data ? 17 : 0;
28
- const appendPadding = [this.chartTopPadding, 0, 0, 0];
28
+ const appendPadding = [this.chartTopPadding, 30, 0, 0];
29
29
  this.initChart(this.container, {
30
30
  appendPadding
31
31
  });
@@ -108,9 +108,6 @@ class HorizontalBarGroup extends HorizontalComponent {
108
108
  easing: 'easeLinear'
109
109
  }
110
110
  }).label(display_data ? 'value' : false, {
111
- content: data => {
112
- return data.value;
113
- },
114
111
  style: {
115
112
  fontSize: BaseUtils.getLabelFontSize(label_font_size),
116
113
  fill: theme.labelColor,
@@ -58,6 +58,7 @@ const Wrapper = _ref => {
58
58
  groupbyColumn,
59
59
  columnGroupbyColumn,
60
60
  summaryColumn,
61
+ summaryColumnsWithMethod,
61
62
  chartTableColumns
62
63
  } = data;
63
64
  const {
@@ -73,6 +74,7 @@ const Wrapper = _ref => {
73
74
  groupbyColumn,
74
75
  columnGroupbyColumn,
75
76
  summaryColumn,
77
+ summaryColumnsWithMethod,
76
78
  globalTheme,
77
79
  chartColorTheme,
78
80
  toggleRecords: toggleStatisticRecordsDialog
@@ -108,7 +108,7 @@ class LineGroup extends ChartComponent {
108
108
  stroke: 0,
109
109
  fillOpacity: 1,
110
110
  opacity: y_axis_show_value ? 1 : 0
111
- });
111
+ }).tooltip(false);
112
112
 
113
113
  // this.chart.on('tooltip:show', () => {
114
114
  // if (line.styleOption.cfg.opacity === 0.3) return;
@@ -110,7 +110,7 @@ class Line extends ChartComponent {
110
110
  stroke: 0,
111
111
  fillOpacity: 1,
112
112
  opacity: y_axis_show_value ? 1 : 0
113
- });
113
+ }).tooltip(false);
114
114
 
115
115
  // this.chart.on('tooltip:show', () => {
116
116
  // if (line.styleOption.cfg.opacity === 0.3) return;
@@ -81,19 +81,7 @@ class Trend extends Component {
81
81
  color = '#34aa95';
82
82
  icon = '\u2191';
83
83
  }
84
- let resultText = "".concat(Number.parseFloat(result * 100).toFixed(2), "%•").concat(conjunctions).concat(previous);
85
- if (!previous) {
86
- resultText = intl.get('Can_not_compare_with_{var}').replace('{var}', intl.get(conjunctions));
87
- }
88
- if (!previous) {
89
- return /*#__PURE__*/React.createElement("span", {
90
- style: {
91
- fontSize: "".concat(labelFontSize, "px")
92
- }
93
- }, resultText);
94
- }
95
84
  if (labelFontSize <= 12) {
96
- if (!result && result !== 0) return '';
97
85
  return /*#__PURE__*/React.createElement("span", {
98
86
  style: {
99
87
  fontSize: "".concat(labelFontSize, "px"),
@@ -116,7 +104,7 @@ class Trend extends Component {
116
104
  style: {
117
105
  color: "".concat(color)
118
106
  }
119
- }, result || result === 0 ? Number.parseFloat(result * 100).toFixed(2) : '', "%"));
107
+ }, result));
120
108
  }
121
109
  const resultContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
122
110
  style: {
@@ -131,7 +119,7 @@ class Trend extends Component {
131
119
  whiteSpace: 'nowrap',
132
120
  marginRight: '16px'
133
121
  }
134
- }, !result && result !== 0 ? '' : /*#__PURE__*/React.createElement("i", {
122
+ }, /*#__PURE__*/React.createElement("i", {
135
123
  style: {
136
124
  flexShrink: '0',
137
125
  flexBasis: 'auto',
@@ -151,7 +139,7 @@ class Trend extends Component {
151
139
  color: color,
152
140
  marginRight: '0px'
153
141
  }
154
- }, result || result === 0 ? Number.parseFloat(result * 100).toFixed(2) + '%' : '')), /*#__PURE__*/React.createElement("span", {
142
+ }, result)), /*#__PURE__*/React.createElement("span", {
155
143
  style: {
156
144
  color: labelFontColor,
157
145
  fontWeight: labelFontWeight,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.84",
3
+ "version": "0.0.85",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",
@@ -8,7 +8,6 @@
8
8
  "@seafile/seafile-calendar": "^0.0.24",
9
9
  "classnames": "^2.3.2",
10
10
  "dayjs": "1.10.7",
11
- "dtable-store": "^4.3.18",
12
11
  "is-hotkey": "0.2.0",
13
12
  "lodash-es": "^4.17.21",
14
13
  "rc-slider": "^10.5.0",
@@ -100,6 +99,7 @@
100
99
  "css-minimizer-webpack-plugin": "5.0.1",
101
100
  "dotenv": "6.2.0",
102
101
  "dotenv-expand": "5.1.0",
102
+ "dtable-store": "~4.3.18",
103
103
  "ejs": "3.1.8",
104
104
  "eslint": "^6.8.0",
105
105
  "eslint-config-react-app": "^5.0.2",