sea-chart 0.0.19 → 0.0.21

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 (41) hide show
  1. package/dist/constants/index.js +4 -1
  2. package/dist/locale/lang/de.js +4 -1
  3. package/dist/locale/lang/en.js +6 -1
  4. package/dist/locale/lang/es.js +4 -1
  5. package/dist/locale/lang/fr.js +4 -1
  6. package/dist/locale/lang/pt.js +4 -1
  7. package/dist/locale/lang/ru.js +4 -1
  8. package/dist/locale/lang/zh_CN.js +9 -4
  9. package/dist/model/area-group.js +4 -2
  10. package/dist/model/area.js +3 -2
  11. package/dist/model/basic-number-card.js +5 -1
  12. package/dist/model/line-group.js +3 -2
  13. package/dist/model/line.js +3 -2
  14. package/dist/settings/advance-bar-settings/style-settings.js +8 -2
  15. package/dist/settings/bar-settings/style-settings.js +10 -3
  16. package/dist/settings/basic-number-card/style-settings.js +48 -3
  17. package/dist/settings/widgets/select-line-type/index.css +0 -0
  18. package/dist/settings/widgets/select-line-type/index.js +27 -0
  19. package/dist/view/index.css +16 -6
  20. package/dist/view/index.js +7 -5
  21. package/dist/view/wrapper/area.js +77 -41
  22. package/dist/view/wrapper/bar-custom.js +2 -2
  23. package/dist/view/wrapper/bar-group.js +2 -2
  24. package/dist/view/wrapper/bar.js +2 -2
  25. package/dist/view/wrapper/basic-number-card.js +6 -33
  26. package/dist/view/wrapper/chart-component.js +49 -3
  27. package/dist/view/wrapper/combination.js +1 -1
  28. package/dist/view/wrapper/compare.js +1 -1
  29. package/dist/view/wrapper/completeness.js +2 -2
  30. package/dist/view/wrapper/dashboard.js +1 -1
  31. package/dist/view/wrapper/horizontal-bar-group.js +2 -2
  32. package/dist/view/wrapper/horizontal-bar.js +4 -10
  33. package/dist/view/wrapper/line-group.js +64 -48
  34. package/dist/view/wrapper/line.js +69 -64
  35. package/dist/view/wrapper/map.js +1 -1
  36. package/dist/view/wrapper/pie.js +1 -1
  37. package/dist/view/wrapper/ring.js +2 -2
  38. package/dist/view/wrapper/scatter.js +1 -1
  39. package/dist/view/wrapper/treemap.js +1 -1
  40. package/dist/view/wrapper/world-map.js +1 -1
  41. package/package.json +1 -1
@@ -1,9 +1,11 @@
1
1
  import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
+ import { getTableById, getTableColumnByKey } from 'dtable-utils';
4
5
  import { BaseUtils, isFunction } from '../../utils';
5
- import ChartComponent from './chart-component';
6
6
  import intl from '../../intl';
7
+ import { CHART_LINE_TYPES, CHART_SUMMARY_SHOW, CHART_SUMMARY_TYPE } from '../../constants';
8
+ import ChartComponent from './chart-component';
7
9
  class Line extends ChartComponent {
8
10
  constructor(props) {
9
11
  super(props);
@@ -14,7 +16,7 @@ class Line extends ChartComponent {
14
16
  const {
15
17
  y_axis_show_value
16
18
  } = chart.config;
17
- const appendPadding = [y_axis_show_value ? 47 : 30, 0, 0, 0];
19
+ const appendPadding = [y_axis_show_value ? 17 : 0, 0, 0, 0];
18
20
  this.initChart(this.container, {
19
21
  appendPadding
20
22
  });
@@ -45,95 +47,97 @@ class Line extends ChartComponent {
45
47
  const {
46
48
  chart,
47
49
  theme,
48
- themeName
50
+ themeName,
51
+ summaryColumn
49
52
  } = this.props;
50
53
  const {
51
54
  y_axis_label_color,
52
55
  y_axis_show_value,
53
- label_font_size
56
+ label_font_size,
57
+ line_type,
58
+ y_axis_column_key,
59
+ y_axis_summary_type,
60
+ y_axis_summary_method
54
61
  } = chart.config;
55
62
  let chartBarColor = y_axis_label_color || '#5B8FF9';
56
63
  if (themeName) {
57
64
  chartBarColor = BaseUtils.getCurrentTheme(themeName).colors[0];
58
65
  }
59
66
  this.drawLabels(data);
67
+ const isSmooth = line_type === CHART_LINE_TYPES[1];
60
68
 
61
69
  // set Coord type
62
70
  this.chart.coordinate('rect');
63
- this.chart.line().label(y_axis_show_value ? 'value' : false, {
71
+ const line = this.chart.line().label(y_axis_show_value ? 'value' : false, {
64
72
  style: {
65
73
  fontSize: BaseUtils.getLabelFontSize(label_font_size),
66
- fill: theme.textColor
74
+ fill: theme.labelColor
67
75
  }
68
- }).position('name*value').color(chartBarColor);
69
- this.chart.point().position('name*value').color(chartBarColor).shape('circle').size(3).style({
70
- lineWidth: 1,
71
- stroke: '#fff'
76
+ }).animate({
77
+ appear: {
78
+ animation: 'fadeIn',
79
+ duration: 1000,
80
+ easing: 'easeLinear'
81
+ }
82
+ }).position('name*value').color(chartBarColor).shape(isSmooth ? 'smooth' : 'line').style({
83
+ lineWidth: 3,
84
+ opacity: 1
85
+ }).tooltip('name*value', (name, value) => {
86
+ return {
87
+ title: y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT ? intl.get('Amount') : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]),
88
+ value: BaseUtils.getSummaryValueDisplayString(summaryColumn, value, y_axis_summary_method),
89
+ name
90
+ };
72
91
  });
73
- this.chart.tooltip({
74
- showCrosshairs: true,
75
- showTitle: true,
76
- containerTpl: '<div class="g2-tooltip"> <div class="g2-tooltip-title"></div> <div class="g2-tooltip-list"></div></div>',
77
- itemTpl: '<li class="tooltip-item"> <span>{value}</span> <span class="tooltip-item-left"><span class="tooltip-item-rect" style="background-color:{color}"></span> <span>{title}</span></span> </li>',
78
- domStyles: {
79
- 'g2-tooltip': {
80
- borderRadius: '3px',
81
- backgroundColor: '#fff',
82
- padding: '16px',
83
- width: '180px',
84
- border: '1px solid #E2E2E2'
85
- },
86
- 'g2-tooltip-title': {
87
- color: '#333333',
88
- fontSize: '14px',
89
- marginTop: '-1px'
90
- },
91
- 'tooltip-item': {
92
- display: 'flex',
93
- width: '100%',
94
- justifyContent: 'space-between',
95
- marginTop: '8px',
96
- color: '#333333',
97
- fontSize: '12px'
98
- },
99
- 'tooltip-item-left': {
100
- display: 'flex',
101
- justifyContent: 'space-between',
102
- alignItem: 'center'
103
- },
104
- 'tooltip-item-rect': {
105
- display: 'inline-block',
106
- width: '12px',
107
- height: '12px',
108
- borderRadius: '2px',
109
- marginRight: '8px'
92
+ let point;
93
+ if (y_axis_show_value) {
94
+ point = this.chart.point().position('name*value').color(chartBarColor).animate({
95
+ appear: {
96
+ animation: 'fadeIn',
97
+ duration: 1000,
98
+ easing: 'easeLinear'
110
99
  }
111
- },
112
- shared: true
100
+ }).shape('circle').size(4).style({
101
+ stroke: 0,
102
+ fillOpacity: 1
103
+ });
104
+ }
105
+ this.chart.on('tooltip:show', () => {
106
+ if (line.styleOption.cfg.opacity === 0.3) return;
107
+ line.style({
108
+ opacity: 0.3,
109
+ lineWidth: 3
110
+ });
111
+ if (point) point.style({
112
+ fillOpacity: 0.3,
113
+ stroke: 0
114
+ });
115
+ this.chart.render();
113
116
  });
117
+ this.chart.on('tooltip:hide', () => {
118
+ if (line.styleOption.cfg.opacity === 1) return;
119
+ line.style({
120
+ opacity: 1,
121
+ lineWidth: 3
122
+ });
123
+ if (point) point.style({
124
+ fillOpacity: 1,
125
+ stroke: 0
126
+ });
127
+ this.chart.render();
128
+ });
129
+ this.setToolTipForLine();
114
130
  this.setNameLabelAndTooltip(theme, this.labelCount);
115
131
  this.setValueLabel(theme);
116
- this.chart.theme({
117
- geometries: {
118
- point: {
119
- circle: {
120
- active: {
121
- style: {
122
- stroke: 'rgba(0, 0, 0, 0)',
123
- r: 4
124
- }
125
- }
126
- }
127
- }
128
- }
129
- });
130
132
  };
131
133
  this.chart = null;
134
+ this.needRenderAxisLabel = true;
132
135
  }
133
136
  componentDidMount() {
134
137
  this.createChart();
135
138
  this.drawChart();
136
139
  this.renderAxisLabel(this.props.chart, this.props.tables);
140
+ super.componentDidMount();
137
141
  }
138
142
  componentDidUpdate(prevProps) {
139
143
  if (BaseUtils.shouldChartComponentUpdate(prevProps, this.props)) {
@@ -145,13 +149,14 @@ class Line extends ChartComponent {
145
149
  }
146
150
  componentWillUnmount() {
147
151
  this.chart && this.chart.destroy();
152
+ super.componentWillUnmount();
148
153
  }
149
154
  render() {
150
155
  const {
151
156
  chart
152
157
  } = this.props;
153
158
  return /*#__PURE__*/React.createElement("div", {
154
- className: classnames('sea-chart-container w-100', {
159
+ className: classnames('sea-chart-container ', {
155
160
  'show-x-axis-label': this.isShowXAxisLabel(chart),
156
161
  'show-y-axis-label': this.isShowYAxisLabel(chart)
157
162
  }),
@@ -316,7 +316,7 @@ export default function Map(props) {
316
316
  return /*#__PURE__*/React.createElement(React.Fragment, null, isLoading && /*#__PURE__*/React.createElement("div", {
317
317
  className: 'statistic-chart-loading-container'
318
318
  }, /*#__PURE__*/React.createElement(Loading, null)), /*#__PURE__*/React.createElement("div", {
319
- className: classnames('sea-chart-container w-100'),
319
+ className: classnames('sea-chart-container '),
320
320
  ref: chartContainerRef
321
321
  }));
322
322
  }
@@ -169,7 +169,7 @@ class Pie extends ChartComponent {
169
169
  }
170
170
  render() {
171
171
  return /*#__PURE__*/React.createElement("div", {
172
- className: "sea-chart-container w-100",
172
+ className: "sea-chart-container ",
173
173
  ref: ref => this.container = ref
174
174
  });
175
175
  }
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import { CHART_LABEL_POSITIONS, CHART_LABEL_FORMATS } from '../../constants';
4
4
  import { BaseUtils, isFunction } from '../../utils';
5
- import ChartComponent from './chart-component';
6
5
  import intl from '../../intl';
6
+ import ChartComponent from './chart-component';
7
7
  class Ring extends ChartComponent {
8
8
  constructor(props) {
9
9
  var _this;
@@ -248,7 +248,7 @@ class Ring extends ChartComponent {
248
248
  }
249
249
  render() {
250
250
  return /*#__PURE__*/React.createElement("div", {
251
- className: "sea-chart-container w-100",
251
+ className: "sea-chart-container ",
252
252
  ref: ref => this.container = ref
253
253
  });
254
254
  }
@@ -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 w-100', {
124
+ className: classnames('sea-chart-container ', {
125
125
  'show-x-axis-label': showXLabel,
126
126
  'show-y-axis-label': showYLabel
127
127
  }),
@@ -171,7 +171,7 @@ class Treemap extends ChartComponent {
171
171
  }
172
172
  render() {
173
173
  return /*#__PURE__*/React.createElement("div", {
174
- className: "sea-chart-container w-100",
174
+ className: "sea-chart-container ",
175
175
  ref: ref => this.container = ref
176
176
  });
177
177
  }
@@ -334,7 +334,7 @@ class WorldMap extends ChartComponent {
334
334
  }
335
335
  render() {
336
336
  return /*#__PURE__*/React.createElement("div", {
337
- className: "sea-chart-container w-100",
337
+ className: "sea-chart-container ",
338
338
  ref: ref => this.container = ref
339
339
  });
340
340
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.19",
3
+ "version": "0.0.21",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",