sea-chart 0.0.22 → 0.0.23

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.
@@ -171,7 +171,8 @@ export const CHART_THEME_COLOR = {
171
171
  light: {
172
172
  textColor: '#666666',
173
173
  fontSize: 13,
174
- gridColor: '#e2e2e2',
174
+ gridColor: '#F3F3F3',
175
+ XAxisColor: '#CCCCCC',
175
176
  labelColor: '#999999',
176
177
  cardColor: '#545454',
177
178
  legendTextColor: '#333333',
@@ -79,7 +79,7 @@ BaseUtils.isValidExistChart = (tables, chart) => {
79
79
  if ([CHART_TYPE.BAR, CHART_TYPE.BAR_GROUP, CHART_TYPE.BAR_CUSTOM, CHART_TYPE.BAR_STACK, CHART_TYPE.LINE, CHART_TYPE.LINE_GROUP, CHART_TYPE.AREA, CHART_TYPE.AREA_GROUP].includes(config.type)) {
80
80
  groupByColumnKey = config.x_axis_column_key;
81
81
  }
82
- if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR].includes(config.type)) {
82
+ if ([CHART_TYPE.HORIZONTAL_BAR, CHART_TYPE.HORIZONTAL_GROUP_BAR, CHART_TYPE.STACKED_HORIZONTAL_BAR].includes(config.type)) {
83
83
  groupByColumnKey = config.vertical_axis_column_key;
84
84
  }
85
85
  if ([CHART_TYPE.MAP, CHART_TYPE.MAP_BUBBLE, CHART_TYPE.WORLD_MAP, CHART_TYPE.WORLD_MAP_BUBBLE].includes(config.type)) {
@@ -7,8 +7,9 @@ import { getClientLinkDisplayString } from '../cell-format-utils';
7
7
  import context from '../../context';
8
8
  import { column2SqlColumn } from '../sql/column-2-sql-column';
9
9
  import { formatNumericValue, getFormattedValue, getColumnByKey, getSqlGroup, getSummaryResult } from '../column-utils';
10
- import BaseUtils from './base-utils';
11
10
  import { getCompareDate } from '../trend-utils';
11
+ import intl from '../../intl';
12
+ import BaseUtils from './base-utils';
12
13
  class SQLStatisticsUtils {}
13
14
  _class = SQLStatisticsUtils;
14
15
  SQLStatisticsUtils.dataSources = 'sql_statistics';
@@ -1475,7 +1476,7 @@ SQLStatisticsUtils.completenessSQlResult = (chart, sqlRows, sqlStatistics, table
1475
1476
  if (sqlColumnGroupByColumnKey) {
1476
1477
  targetValue = row["SUM(".concat(target_column.name, ")")];
1477
1478
  completedValue = row["SUM(".concat(completed_column.name, ")")];
1478
- groupby = row[sqlColumnGroupByColumnKey];
1479
+ groupby = row[sqlColumnGroupByColumnKey] || intl.get('Empty');
1479
1480
  } else {
1480
1481
  completedValue = getFormatedKey(row, completed_column);
1481
1482
  targetValue = getFormatedKey(row, target_column);
@@ -1,5 +1,6 @@
1
1
  import PropTypes from 'prop-types';
2
2
  import React from 'react';
3
+ import classNames from 'classnames';
3
4
  import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE } from '../../constants';
4
5
  import intl from '../../intl';
5
6
  import { BaseUtils, isFunction } from '../../utils';
@@ -206,8 +207,14 @@ class Area extends ChartComponent {
206
207
  super.componentWillUnmount();
207
208
  }
208
209
  render() {
210
+ const {
211
+ chart
212
+ } = this.props;
209
213
  return /*#__PURE__*/React.createElement("div", {
210
- className: 'sea-chart-container',
214
+ className: classNames('sea-chart-container', {
215
+ 'show-x-axis-label': this.isShowXAxisLabel(chart),
216
+ 'show-y-axis-label': this.isShowYAxisLabel(chart)
217
+ }),
211
218
  ref: ref => this.container = ref
212
219
  });
213
220
  }
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import DataSet from '@antv/data-set';
4
4
  import { debounce, maxBy } from 'lodash-es';
5
+ import classNames from 'classnames';
5
6
  import intl from '../../intl';
6
7
  import { BaseUtils } from '../../utils/chart-utils';
7
8
  import { EMPTY_NAME } from '../../constants';
@@ -191,8 +192,14 @@ class BarCustom extends ChartComponent {
191
192
  window.removeEventListener('resize', this.handleResize);
192
193
  }
193
194
  render() {
195
+ const {
196
+ chart
197
+ } = this.props;
194
198
  return /*#__PURE__*/React.createElement("div", {
195
- className: 'sea-chart-container ',
199
+ className: classNames('sea-chart-container', {
200
+ 'show-x-axis-label': this.isShowXAxisLabel(chart),
201
+ 'show-y-axis-label': this.isShowYAxisLabel(chart)
202
+ }),
196
203
  ref: ref => this.container = ref
197
204
  });
198
205
  }
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3
3
  import DataSet from '@antv/data-set';
4
4
  import { getNumberDisplayString } from 'dtable-utils';
5
5
  import { debounce, maxBy } from 'lodash-es';
6
+ import classNames from 'classnames';
6
7
  import intl from '../../intl';
7
8
  import { sortDataByGroupSum } from '../../utils/column-utils';
8
9
  import { EMPTY_NAME, CHART_TYPE, CHART_SUMMARY_TYPE, DEFAULT_NUMBER_FORMAT_OBJECT } from '../../constants';
@@ -208,8 +209,14 @@ class BarGroup extends ChartComponent {
208
209
  window.removeEventListener('resize', this.debouncedHandleResize);
209
210
  }
210
211
  render() {
212
+ const {
213
+ chart
214
+ } = this.props;
211
215
  return /*#__PURE__*/React.createElement("div", {
212
- className: 'sea-chart-container',
216
+ className: classNames('sea-chart-container', {
217
+ 'show-x-axis-label': this.isShowXAxisLabel(chart),
218
+ 'show-y-axis-label': this.isShowYAxisLabel(chart)
219
+ }),
213
220
  ref: ref => this.container = ref
214
221
  });
215
222
  }
@@ -1,9 +1,9 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { debounce } from 'lodash-es';
4
- import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, TYPE_COLOR_USING } from '../../constants';
4
+ import classNames from 'classnames';
5
+ import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW } from '../../constants';
5
6
  import { BaseUtils, isFunction } from '../../utils';
6
- import { getConvertedColorRules } from '../../utils/color-utils';
7
7
  import intl from '../../intl';
8
8
  import ChartComponent from './chart-component';
9
9
  class Bar extends ChartComponent {
@@ -67,11 +67,12 @@ class Bar extends ChartComponent {
67
67
  const singleBarRadius = singleBarWidth / 5;
68
68
 
69
69
  // #8B99EA is designed color, don't change it unless design is changed
70
- let chartBarColor = y_axis_label_color || '#8B99EA';
71
- if (themeName) {
72
- chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
73
- }
74
- const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && y_axis_label_color_rules && getConvertedColorRules(y_axis_label_color_rules);
70
+ // let chartBarColor = y_axis_label_color || '#8B99EA';
71
+ // if (themeName) {
72
+ // chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
73
+ // }
74
+ // const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && y_axis_label_color_rules && getConvertedColorRules(y_axis_label_color_rules);
75
+
75
76
  this.drawLabels(data);
76
77
  // set Coord type
77
78
  this.chart.coordinate('rect');
@@ -101,7 +102,6 @@ class Bar extends ChartComponent {
101
102
  // });
102
103
  return {
103
104
  // fill: color || chartBarColor,
104
- fill: chartBarColor,
105
105
  radius: [singleBarRadius, singleBarRadius, 0, 0]
106
106
  };
107
107
  });
@@ -131,8 +131,14 @@ class Bar extends ChartComponent {
131
131
  window.removeEventListener('resize', this.debouncedHandleResize);
132
132
  }
133
133
  render() {
134
+ const {
135
+ chart
136
+ } = this.props;
134
137
  return /*#__PURE__*/React.createElement("div", {
135
- className: 'sea-chart-container ',
138
+ className: classNames('sea-chart-container', {
139
+ 'show-x-axis-label': this.isShowXAxisLabel(chart),
140
+ 'show-y-axis-label': this.isShowYAxisLabel(chart)
141
+ }),
136
142
  ref: ref => this.container = ref
137
143
  });
138
144
  }
@@ -195,11 +195,11 @@ export default class ChartComponent extends Component {
195
195
  div.className = 'chart-axis-label';
196
196
  const column = getTableColumnByKey(table, x_axis_column_key);
197
197
  div.innerHTML = "".concat(column ? column.name : '');
198
- div.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -25px; position: absolute"));
198
+ div.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
199
199
  chartContainer.appendChild(div);
200
200
  }
201
201
  if (xLabel && x_axis_show_label) {
202
- xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -25px; position: absolute"));
202
+ xLabel.setAttribute('style', "color:".concat(textColor, "; width: 100%; text-align: ").concat(x_axis_label_position, "; bottom: -20px; position: absolute"));
203
203
  }
204
204
  if (xLabel && !x_axis_show_label) {
205
205
  xLabel.parentNode.removeChild(xLabel);
@@ -283,12 +283,15 @@ export default class ChartComponent extends Component {
283
283
  if (!_this.chart) return;
284
284
  _this.chart.axis('name', {
285
285
  line: {
286
- style: theme.gridColor
286
+ style: {
287
+ stroke: theme.XAxisColor,
288
+ lineWidth: 1
289
+ }
287
290
  },
288
291
  tickLine: {
289
292
  length: 5,
290
293
  // color of the tick line
291
- stroke: theme.gridColor
294
+ stroke: theme.XAxisColor
292
295
  },
293
296
  label: {
294
297
  style: {
@@ -327,7 +330,8 @@ export default class ChartComponent extends Component {
327
330
  grid: {
328
331
  line: {
329
332
  style: {
330
- stroke: theme.gridColor
333
+ stroke: theme.gridColor,
334
+ lineDash: [8, 3]
331
335
  }
332
336
  }
333
337
  }
@@ -401,13 +405,15 @@ export default class ChartComponent extends Component {
401
405
  },
402
406
  style: style => {
403
407
  // fill legend with stroke color
404
- style.fill = style.stroke;
408
+ if (style.stroke) {
409
+ style.fill = style.stroke;
410
+ }
405
411
  return style;
406
412
  }
407
413
  }
408
414
  });
409
415
  };
410
- this.getToolSettings = () => {
416
+ this.getToolTipSettings = () => {
411
417
  return {
412
418
  showMarkers: false,
413
419
  domStyles: {
@@ -448,11 +454,11 @@ export default class ChartComponent extends Component {
448
454
  };
449
455
  };
450
456
  this.setToolTip = () => {
451
- const settings = this.getToolSettings();
457
+ const settings = this.getToolTipSettings();
452
458
  this.chart.tooltip(settings);
453
459
  };
454
460
  this.setToolTipForLine = () => {
455
- const settings = this.getToolSettings();
461
+ const settings = this.getToolTipSettings();
456
462
  const lineToolTipSettings = {
457
463
  showCrosshairs: true,
458
464
  showTitle: true,
@@ -6,6 +6,7 @@ import intl from '../../intl';
6
6
  import { CHART_STYLE_COLORS, CHART_TYPE } from '../../constants';
7
7
  import ChartComponent from './chart-component';
8
8
  export default function Completeness(props) {
9
+ var _chartRef$current, _chartRef$current2;
9
10
  const chartRef = useRef(null);
10
11
  const chartContainerRef = useRef(null);
11
12
  useEffect(() => {
@@ -77,7 +78,7 @@ export default function Completeness(props) {
77
78
  if (group_name === 'rest') {
78
79
  return '#bdbdbd';
79
80
  }
80
- if (isGroup) {
81
+ if (isGroup && column_groupby_column_key) {
81
82
  return colorMap[groupby];
82
83
  }
83
84
  return CHART_STYLE_COLORS[0];
@@ -156,8 +157,14 @@ export default function Completeness(props) {
156
157
  window.removeEventListener('resize', handleReize);
157
158
  };
158
159
  }, [props]);
160
+ const {
161
+ chart
162
+ } = props;
159
163
  return /*#__PURE__*/React.createElement("div", {
160
- className: classnames('sea-chart-completeness-chart sea-chart-container '),
164
+ className: classnames('sea-chart-completeness-chart sea-chart-container', {
165
+ 'show-x-axis-label': (_chartRef$current = chartRef.current) === null || _chartRef$current === void 0 ? void 0 : _chartRef$current.isShowXAxisLabel(chart),
166
+ 'show-y-axis-label': (_chartRef$current2 = chartRef.current) === null || _chartRef$current2 === void 0 ? void 0 : _chartRef$current2.isShowYAxisLabel(chart)
167
+ }),
161
168
  ref: chartContainerRef
162
169
  });
163
170
  }
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { debounce, maxBy } from 'lodash-es';
4
+ import classNames from 'classnames';
4
5
  import { CHART_TYPE, EMPTY_NAME } from '../../constants';
5
6
  import { BaseUtils, isFunction } from '../../utils';
6
7
  import intl from '../../intl';
@@ -153,8 +154,14 @@ class HorizontalBarGroup extends HorizontalComponent {
153
154
  window.removeEventListener('resize', this.handleResize);
154
155
  }
155
156
  render() {
157
+ const {
158
+ chart
159
+ } = this.props;
156
160
  return /*#__PURE__*/React.createElement("div", {
157
- className: 'sea-chart-container ',
161
+ className: classNames('sea-chart-container', {
162
+ 'show-x-axis-label': this.isShowXAxisLabel(chart),
163
+ 'show-y-axis-label': this.isShowYAxisLabel(chart)
164
+ }),
158
165
  ref: ref => this.container = ref
159
166
  });
160
167
  }
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
- import { debounce } from 'lodash-es';
3
+ import classNames from 'classnames';
4
4
  import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW } from '../../constants';
5
5
  import { BaseUtils, isFunction } from '../../utils';
6
6
  import intl from '../../intl';
@@ -50,6 +50,8 @@ class HorizontalBar extends HorizontalComponent {
50
50
  const {
51
51
  horizontal_axis_summary_type,
52
52
  horizontal_axis_summary_method,
53
+ color_option,
54
+ y_axis_label_color_rules,
53
55
  horizontal_axis_label_color,
54
56
  display_data,
55
57
  label_font_size
@@ -59,10 +61,13 @@ class HorizontalBar extends HorizontalComponent {
59
61
  const chartHeight = this.chart.height - 6 - 10;
60
62
  const singleBarWidth = Math.round(chartHeight / (2 * data.length));
61
63
  const singleBarRadius = singleBarWidth / 5;
62
- let chartBarColor = horizontal_axis_label_color || '#8B99EA';
63
- if (themeName) {
64
- chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
65
- }
64
+
65
+ // let chartBarColor = horizontal_axis_label_color || '#8B99EA';
66
+ // if (themeName) {
67
+ // chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
68
+ // }
69
+ // const colorRules = color_option === TYPE_COLOR_USING.USE_RULES && y_axis_label_color_rules && getConvertedColorRules(y_axis_label_color_rules);
70
+
66
71
  data.reverse();
67
72
  this.drawLabels(data);
68
73
 
@@ -96,7 +101,6 @@ class HorizontalBar extends HorizontalComponent {
96
101
  // });
97
102
  return {
98
103
  // fill: color || chartBarColor,
99
- fill: chartBarColor,
100
104
  radius: [singleBarRadius, singleBarRadius, 0, 0]
101
105
  };
102
106
  });
@@ -125,8 +129,14 @@ class HorizontalBar extends HorizontalComponent {
125
129
  super.componentWillUnmount();
126
130
  }
127
131
  render() {
132
+ const {
133
+ chart
134
+ } = this.props;
128
135
  return /*#__PURE__*/React.createElement("div", {
129
- className: 'sea-chart-container',
136
+ className: classNames('sea-chart-container', {
137
+ 'show-x-axis-label': this.isShowXAxisLabel(chart),
138
+ 'show-y-axis-label': this.isShowYAxisLabel(chart)
139
+ }),
130
140
  ref: ref => this.container = ref
131
141
  });
132
142
  }
@@ -121,7 +121,7 @@ export function Scatter(props) {
121
121
  const showXLabel = chartRef.current.isShowXAxisLabel(chart);
122
122
  const showYLabel = chartRef.current.isShowYAxisLabel(chart);
123
123
  return /*#__PURE__*/React.createElement("div", {
124
- className: classnames('sea-chart-container ', {
124
+ className: classnames('sea-chart-container', {
125
125
  'show-x-axis-label': showXLabel,
126
126
  'show-y-axis-label': showYLabel
127
127
  }),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.22",
3
+ "version": "0.0.23",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",