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.
Files changed (75) hide show
  1. package/dist/components/color-setting/color-group-selector.js +1 -0
  2. package/dist/components/types-dialog/index.js +2 -2
  3. package/dist/constants/common-constants.js +3 -0
  4. package/dist/constants/index.js +3 -0
  5. package/dist/context.js +9 -6
  6. package/dist/index.js +4 -1
  7. package/dist/locale/lang/en.js +1 -0
  8. package/dist/locale/lang/zh_CN.js +1 -0
  9. package/dist/model/chart.js +4 -0
  10. package/dist/settings/advance-bar-settings/style-settings.js +2 -0
  11. package/dist/settings/bar-settings/style-settings.js +2 -0
  12. package/dist/settings/basic-number-card/data-settings.js +3 -0
  13. package/dist/settings/combination-settings/style-settings.js +3 -0
  14. package/dist/settings/completeness-settings/data-settings/completion-settings.js +2 -0
  15. package/dist/settings/dashboard-settings/data-settings.js +3 -0
  16. package/dist/settings/horizontal-bar-settings/data-settings.js +2 -0
  17. package/dist/settings/index.js +3 -2
  18. package/dist/settings/map-settings/components/location-field-selector.js +1 -0
  19. package/dist/settings/map-settings/components/map-level-selector.js +1 -0
  20. package/dist/settings/map-settings/components/map-province-city-selector.js +2 -0
  21. package/dist/settings/map-settings/map-style-settings.js +1 -0
  22. package/dist/settings/pie-settings/style-settings.js +2 -0
  23. package/dist/settings/table-settings/data-settings.js +1 -0
  24. package/dist/settings/time-comparison-settings/style-settings.js +2 -0
  25. package/dist/settings/widgets/basic-summary/index.js +3 -0
  26. package/dist/settings/widgets/common-data-settings.js +1 -1
  27. package/dist/settings/widgets/date-summary-item.js +2 -0
  28. package/dist/settings/widgets/group-by.js +3 -0
  29. package/dist/settings/widgets/numeric-summary-item.js +2 -0
  30. package/dist/settings/widgets/select-table/index.js +1 -1
  31. package/dist/settings/widgets/select-view/index.js +1 -1
  32. package/dist/settings/widgets/summary-method-setting.js +2 -0
  33. package/dist/settings/widgets/summary-settings.js +4 -1
  34. package/dist/settings/widgets/y-axis-group-settings.js +1 -0
  35. package/dist/utils/chart-utils/base-utils.js +34 -9
  36. package/dist/utils/chart-utils/index.js +1 -1
  37. package/dist/utils/chart-utils/original-data-utils/basic-chart-calculator.js +69 -16
  38. package/dist/utils/chart-utils/original-data-utils/card-calculator.js +2 -2
  39. package/dist/utils/chart-utils/original-data-utils/combination-calculator.js +9 -9
  40. package/dist/utils/chart-utils/original-data-utils/compare-bar-chart-calculator.js +2 -2
  41. package/dist/utils/chart-utils/original-data-utils/completeness-calculator.js +10 -10
  42. package/dist/utils/chart-utils/original-data-utils/dashboard-calculator.js +4 -4
  43. package/dist/utils/chart-utils/original-data-utils/index.js +3 -3
  44. package/dist/utils/chart-utils/original-data-utils/mirror-calculator.js +6 -6
  45. package/dist/utils/chart-utils/original-data-utils/pivot-table-calculator.js +3 -3
  46. package/dist/utils/chart-utils/original-data-utils/scatter-calculator.js +9 -9
  47. package/dist/utils/chart-utils/original-data-utils/trend-calculator.js +5 -5
  48. package/dist/utils/chart-utils/sql-statistics-utils.js +17 -6
  49. package/dist/utils/event-bus.js +28 -0
  50. package/dist/utils/row-utils.js +1 -1
  51. package/dist/utils/sql/chart-data-sql.js +17 -4
  52. package/dist/utils/sql/column-2-sql-column.js +7 -1
  53. package/dist/view/index.css +1 -1
  54. package/dist/view/index.js +49 -7
  55. package/dist/view/wrapper/area.js +16 -9
  56. package/dist/view/wrapper/bar-custom.js +8 -9
  57. package/dist/view/wrapper/bar-group.js +7 -4
  58. package/dist/view/wrapper/bar.js +8 -6
  59. package/dist/view/wrapper/basic-number-card.js +3 -2
  60. package/dist/view/wrapper/chart-component.js +6 -2
  61. package/dist/view/wrapper/combination.js +7 -7
  62. package/dist/view/wrapper/compare.js +18 -17
  63. package/dist/view/wrapper/completeness.js +8 -5
  64. package/dist/view/wrapper/dashboard.js +3 -1
  65. package/dist/view/wrapper/horizontal-bar-group.js +7 -4
  66. package/dist/view/wrapper/horizontal-bar.js +8 -6
  67. package/dist/view/wrapper/index.js +6 -3
  68. package/dist/view/wrapper/line-group.js +13 -5
  69. package/dist/view/wrapper/line.js +8 -6
  70. package/dist/view/wrapper/pie.js +12 -6
  71. package/dist/view/wrapper/ring.js +14 -7
  72. package/dist/view/wrapper/scatter.js +7 -4
  73. package/dist/view/wrapper/treemap.js +5 -2
  74. package/dist/view/wrapper/trend.js +124 -54
  75. package/package.json +1 -1
@@ -1,50 +1,11 @@
1
1
  import React, { Component } from 'react';
2
2
  import classNames from 'classnames';
3
- import { Chart } from '../../utils/custom-g2';
4
3
  import { BaseUtils } from '../../utils';
5
4
  import intl from '../../intl';
6
- import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_SUMMARY_TYPE } from '../../constants';
5
+ import { BASIC_NUMBER_CARD_CALCULATION_METHOD, EMPTY_NAME, CHART_SUMMARY_TYPE, CHART_THEME_COLOR } from '../../constants';
7
6
  class Trend extends Component {
8
7
  constructor() {
9
8
  super(...arguments);
10
- this.componentDidMount = () => {
11
- this.drawChart();
12
- };
13
- this.drawChart = () => {
14
- const {
15
- theme,
16
- chart,
17
- result
18
- } = this.props;
19
- this.chart = new Chart({
20
- container: this.container,
21
- autoFit: true,
22
- width: '100%',
23
- height: '100%'
24
- });
25
- const {
26
- config
27
- } = chart;
28
- const {
29
- summary_method,
30
- num_font_size,
31
- num_font_color,
32
- num_font_weight,
33
- num_text_align,
34
- card_label_font_size: label_font_size,
35
- label_font_color,
36
- label_text_align,
37
- label_font_weight
38
- } = config;
39
- const latest = result && result.latest;
40
- const content = summary_method === CHART_SUMMARY_TYPE.Distinct_values ? latest : this.formatData(latest);
41
- const labelContent = this.createLabelContent(result, label_text_align, label_font_size, label_font_color, label_font_weight);
42
- this.chart.annotation().html({
43
- container: this.container,
44
- html: "\n <div style=\"color:".concat(theme.cardColor, "; width: 100%; height: 100%; position: relative\">\n <p class=\"text-content\" style=\" position:absolute; width: 100%; top: calc((100% - 22px)/2); transform: translateY(-50%); font-size: ").concat(num_font_size, "px; margin: -8px 0 2px 0; text-align: ").concat(num_text_align, "; font-weight:").concat(num_font_weight, "; color:").concat(num_font_color, "\">").concat(content, "</p>\n <p class=\"label-content\" style=\"position:absolute; width: 100%; bottom: 0px; margin: 0;\">").concat(labelContent, "</p>\n </div>\n ")
45
- });
46
- this.chart.render();
47
- };
48
9
  this.formatData = data => {
49
10
  if (!data && data !== 0) return intl.get(EMPTY_NAME);
50
11
  const {
@@ -115,38 +76,147 @@ class Trend extends Component {
115
76
  previous
116
77
  } = data || {};
117
78
  let color = '#fa5757',
118
- icon = '&darr;';
79
+ icon = '\u2193';
119
80
  if (type === 'up') {
120
81
  color = '#34aa95';
121
- icon = '&uarr;';
82
+ icon = '\u2191';
122
83
  }
123
84
  let resultText = "".concat(Number.parseFloat(result * 100).toFixed(2), "%&#8226;").concat(conjunctions).concat(previous);
124
85
  if (!previous) {
125
86
  resultText = intl.get('Can_not_compare_with_{var}').replace('{var}', intl.get(conjunctions));
126
87
  }
127
88
  if (!previous) {
128
- return "<span style='font-size: ".concat(labelFontSize, "px'>").concat(resultText, "</span>");
89
+ return /*#__PURE__*/React.createElement("span", {
90
+ style: {
91
+ fontSize: "".concat(labelFontSize, "px")
92
+ }
93
+ }, resultText);
129
94
  }
130
95
  if (labelFontSize <= 12) {
131
96
  if (!result) return '';
132
- return "<span style='font-size: ".concat(labelFontSize, "px; width: 100%;'>\n <i \n style='color: ").concat(color, "; \n display: inline-block; \n width: ").concat(1.5 * labelFontSize, "px; \n height: ").concat(1.5 * labelFontSize, "px; \n line-height: ").concat(1.5 * labelFontSize, "px; \n border-radius: 50%; \n background-color: ").concat(color, "26;\n text-align: center;\n margin-right: 8px;\n font-weight: bold;\n '>\n ").concat(icon, "\n </i>\n <span style='color: ").concat(color, "'>").concat(result ? Number.parseFloat(result * 100).toFixed(2) : '', "%</span>\n </span>");
97
+ return /*#__PURE__*/React.createElement("span", {
98
+ style: {
99
+ fontSize: "".concat(labelFontSize, "px"),
100
+ width: '100%'
101
+ }
102
+ }, /*#__PURE__*/React.createElement("i", {
103
+ style: {
104
+ color: "".concat(color),
105
+ display: 'inline-block',
106
+ width: "".concat(1.5 * labelFontSize, "px"),
107
+ height: "".concat(1.5 * labelFontSize, "px"),
108
+ lineHeight: "".concat(1.5 * labelFontSize, "px"),
109
+ borderRadius: '50%',
110
+ backgroundColor: "".concat(color, "26"),
111
+ textAlign: 'center',
112
+ marginRight: '8px',
113
+ fontWeight: 'bold'
114
+ }
115
+ }, icon), /*#__PURE__*/React.createElement("span", {
116
+ style: {
117
+ color: "".concat(color)
118
+ }
119
+ }, result ? Number.parseFloat(result * 100).toFixed(2) : '', "%"));
133
120
  }
134
- const resultContent = "\n <span style='display: flex; flex-wrap:wrap; justify-content:".concat(label_text_align, "; font-size: ").concat(labelFontSize, "px; width: 100%;'>\n <span style=\"white-space:nowrap\"> ").concat(!result ? '' : "\n <i \n style='\n flex-shrink:0;\n flex-basis:auto;\n color: ".concat(color, "; \n display: inline-block; \n width: ").concat(1.5 * labelFontSize, "px; \n height: ").concat(1.5 * labelFontSize, "px; \n line-height: ").concat(1.5 * labelFontSize, "px; \n border-radius: 50%; \n background-color: ").concat(color, "26;\n text-align: center;\n margin-right: 8px;\n font-weight: bold;\n '\n >\n ").concat(icon, "\n </i>"), "<span style='color: ").concat(color, "; margin-right: 0px '>\n ").concat(result ? Number.parseFloat(result * 100).toFixed(2) + '%' : '', "\n </span></span><span style=\"color:").concat(labelFontColor, "; font-weight:").concat(labelFontWeight, "; white-space:nowrap; margin-left: 16px \">\n ").concat(conjunctions, " \n ").concat(this.formatData(previous), "\n </span>\n </span>\n ");
121
+ const resultContent = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement("span", {
122
+ style: {
123
+ display: 'flex',
124
+ flexWrap: 'wrap',
125
+ justifyContent: label_text_align,
126
+ fontSize: "".concat(labelFontSize, "px"),
127
+ width: '100%'
128
+ }
129
+ }, /*#__PURE__*/React.createElement("span", {
130
+ style: {
131
+ whiteSpace: 'nowrap'
132
+ }
133
+ }, !result ? '' : /*#__PURE__*/React.createElement("i", {
134
+ style: {
135
+ flexShrink: '0',
136
+ flexBasis: 'auto',
137
+ color: color,
138
+ display: 'inline-block',
139
+ width: "".concat(1.5 * labelFontSize, "px"),
140
+ height: "".concat(1.5 * labelFontSize, "px"),
141
+ lineHeight: "".concat(1.5 * labelFontSize, "px"),
142
+ borderRadius: '50%',
143
+ backgroundColor: "".concat(color, "26"),
144
+ textAlign: 'center',
145
+ marginRight: '8px',
146
+ fontWeight: 'bold'
147
+ }
148
+ }, " ", icon, " "), /*#__PURE__*/React.createElement("span", {
149
+ style: {
150
+ color: color,
151
+ marginRight: '0px'
152
+ }
153
+ }, result ? Number.parseFloat(result * 100).toFixed(2) + '%' : '')), /*#__PURE__*/React.createElement("span", {
154
+ style: {
155
+ color: labelFontColor,
156
+ fontWeight: labelFontWeight,
157
+ whiteSpace: 'nowrap',
158
+ marginLeft: '16px'
159
+ }
160
+ }, conjunctions, this.formatData(previous))));
135
161
  return resultContent;
136
162
  };
137
163
  }
138
- componentDidUpdate(prevProps) {
139
- if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
140
- this.chart && this.chart.destroy();
141
- this.drawChart();
142
- }
143
- }
144
164
  render() {
145
- // const { chart } = this.props;
165
+ const {
166
+ globalTheme,
167
+ chart,
168
+ result
169
+ } = this.props;
170
+ const theme = CHART_THEME_COLOR[globalTheme];
171
+ const {
172
+ config
173
+ } = chart;
174
+ const {
175
+ summary_method,
176
+ num_font_size,
177
+ num_font_color,
178
+ num_font_weight,
179
+ num_text_align,
180
+ card_label_font_size: label_font_size = 14,
181
+ label_font_color,
182
+ label_text_align,
183
+ label_font_weight
184
+ } = config;
185
+ const latest = result && result.latest;
186
+ const content = summary_method === CHART_SUMMARY_TYPE.Distinct_values ? latest : this.formatData(latest);
187
+ const labelContent = this.createLabelContent(result, label_text_align, label_font_size, label_font_color, label_font_weight);
146
188
  return /*#__PURE__*/React.createElement("div", {
147
- ref: ref => this.container = ref,
189
+ id: this.id,
148
190
  className: classNames('sea-chart-container', 'plugin-number-card-trend')
149
- });
191
+ }, /*#__PURE__*/React.createElement("div", {
192
+ style: {
193
+ color: theme.cardColor,
194
+ width: '100%',
195
+ height: '100%',
196
+ position: 'relative'
197
+ }
198
+ }, /*#__PURE__*/React.createElement("p", {
199
+ className: "text-content",
200
+ style: {
201
+ position: 'absolute',
202
+ width: '100%',
203
+ top: 'calc((100% - 25px)/2)',
204
+ transform: 'translateY(-50%)',
205
+ fontSize: "".concat(num_font_size, "px"),
206
+ margin: '-8px 0 2px 0',
207
+ textAlign: "".concat(num_text_align),
208
+ fontWeight: "".concat(num_font_weight),
209
+ color: "".concat(num_font_color)
210
+ }
211
+ }, content), /*#__PURE__*/React.createElement("p", {
212
+ className: "label-content",
213
+ style: {
214
+ position: 'absolute',
215
+ width: '100%',
216
+ bottom: '0px',
217
+ margin: '0'
218
+ }
219
+ }, labelContent)));
150
220
  }
151
221
  }
152
222
  export default Trend;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.48",
3
+ "version": "0.0.49",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",