sea-chart 1.1.82 → 1.1.83

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.
@@ -2,7 +2,7 @@ import React, { useCallback, useMemo, useState, useEffect } from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
4
  import intl from '../intl';
5
- import { settingsContext, DepartmentsContext, GlobalThemeContext } from '../utils/contexts';
5
+ import { settingsContext, DepartmentsContext, GlobalThemeContext, FirstDayOfWeekContext } from '../utils/contexts';
6
6
  import { eventStopPropagation } from '../utils';
7
7
  import { BaseUtils } from '../utils';
8
8
  import { CHART_SETTINGS_TYPE, CHART_SETTINGS } from '../constants';
@@ -22,7 +22,8 @@ const Settings = _ref => {
22
22
  children,
23
23
  departments,
24
24
  globalTheme,
25
- lang
25
+ lang,
26
+ firstDayOfWeek
26
27
  } = _ref;
27
28
  const [type, setType] = useState(CHART_SETTINGS_TYPE.DATA);
28
29
  const [labelColorConfigs, setLabelColorConfigs] = useState([]);
@@ -100,7 +101,11 @@ const Settings = _ref => {
100
101
  }, /*#__PURE__*/React.createElement("div", {
101
102
  id: "sea-chart-settings-content",
102
103
  className: "chart-settings-content"
103
- }, type === CHART_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(DepartmentsContext.Provider, {
104
+ }, type === CHART_SETTINGS_TYPE.DATA && /*#__PURE__*/React.createElement(FirstDayOfWeekContext.Provider, {
105
+ value: {
106
+ firstDayOfWeek
107
+ }
108
+ }, /*#__PURE__*/React.createElement(DepartmentsContext.Provider, {
104
109
  value: {
105
110
  departments
106
111
  }
@@ -109,7 +114,7 @@ const Settings = _ref => {
109
114
  chart: chart,
110
115
  tables: tables,
111
116
  onChange: modifyStatistic
112
- })), type === CHART_SETTINGS_TYPE.CHART_STYLE && /*#__PURE__*/React.createElement(StyleSettings, {
117
+ }))), type === CHART_SETTINGS_TYPE.CHART_STYLE && /*#__PURE__*/React.createElement(StyleSettings, {
113
118
  chart: chart,
114
119
  tables: tables,
115
120
  labelColorConfigs: labelColorConfigs,
@@ -4,7 +4,7 @@ import { getTableById } from 'dtable-utils';
4
4
  import { eventStopPropagation, generatorKey } from '../../../utils';
5
5
  import intl from '../../../intl';
6
6
  import context from '../../../context';
7
- import { DepartmentsContext } from '../../../utils/contexts';
7
+ import { DepartmentsContext, FirstDayOfWeekContext } from '../../../utils/contexts';
8
8
  import { CHART_TYPE } from '../../../constants';
9
9
  import './data-filter.css';
10
10
  const DataFilter = _ref => {
@@ -18,6 +18,9 @@ const DataFilter = _ref => {
18
18
  const {
19
19
  departments
20
20
  } = useContext(DepartmentsContext);
21
+ const {
22
+ firstDayOfWeek
23
+ } = useContext(FirstDayOfWeekContext);
21
24
  const {
22
25
  config
23
26
  } = chart;
@@ -83,7 +86,8 @@ const DataFilter = _ref => {
83
86
  departments: departments,
84
87
  collaborators: collaborators,
85
88
  hidePopover: toggleFilterPopover,
86
- update: updateFilters
89
+ update: updateFilters,
90
+ firstDayOfWeek: firstDayOfWeek
87
91
  })));
88
92
  };
89
93
  export default DataFilter;
@@ -5,7 +5,7 @@ import { getTableById } from 'dtable-utils';
5
5
  import { eventStopPropagation, generatorKey } from '../../../utils';
6
6
  import intl from '../../../intl';
7
7
  import context from '../../../context';
8
- import { DepartmentsContext } from '../../../utils/contexts';
8
+ import { DepartmentsContext, FirstDayOfWeekContext } from '../../../utils/contexts';
9
9
  import './index.css';
10
10
  const DataFilter = _ref => {
11
11
  let {
@@ -17,6 +17,9 @@ const DataFilter = _ref => {
17
17
  const {
18
18
  departments
19
19
  } = useContext(DepartmentsContext);
20
+ const {
21
+ firstDayOfWeek
22
+ } = useContext(FirstDayOfWeekContext);
20
23
  const toggleFilterPopover = useCallback(event => {
21
24
  eventStopPropagation(event);
22
25
  setIsFilterSetterShow(!isFilterSetterShow);
@@ -84,7 +87,8 @@ const DataFilter = _ref => {
84
87
  departments: departments,
85
88
  collaborators: collaborators,
86
89
  hidePopover: toggleFilterPopover,
87
- update: updateFilters
90
+ update: updateFilters,
91
+ firstDayOfWeek: firstDayOfWeek
88
92
  }))) : /*#__PURE__*/React.createElement("div", {
89
93
  id: id,
90
94
  className: "sea-chart-data-filter disabled"
@@ -1,4 +1,7 @@
1
1
  import React from 'react';
2
2
  export const settingsContext = React.createContext('');
3
3
  export const DepartmentsContext = React.createContext([]);
4
- export const GlobalThemeContext = React.createContext({});
4
+ export const GlobalThemeContext = React.createContext({});
5
+ export const FirstDayOfWeekContext = React.createContext({
6
+ firstDayOfWeek: 'Sunday'
7
+ });
@@ -257,7 +257,8 @@ export default class ChartComponent extends Component {
257
257
  const div = document.createElement('div');
258
258
  div.id = yAxisID;
259
259
  div.className = 'chart-axis-label';
260
- if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT) {
260
+ // SCATTER always has y_axis_column_key
261
+ if (y_axis_summary_type === CHART_SUMMARY_TYPE.COUNT && type !== CHART_TYPE.SCATTER) {
261
262
  div.innerHTML = intl.get('Amount');
262
263
  } else {
263
264
  const column = getTableColumnByKey(table, y_axis_column_key) || {};
@@ -297,7 +298,8 @@ export default class ChartComponent extends Component {
297
298
  y_axis_auto_range,
298
299
  y_axis_min,
299
300
  y_axis_max,
300
- y_axis_summary_method
301
+ y_axis_summary_method,
302
+ type
301
303
  } = config;
302
304
  if (summaryColumn) {
303
305
  valueScaleOptions['formatter'] = value => {
@@ -316,12 +318,18 @@ export default class ChartComponent extends Component {
316
318
  // filter the data
317
319
  _this.chart.filterData(data);
318
320
  }
319
- _this.chart.scale({
321
+ const scaleConfig = {
320
322
  name: {
321
323
  type: 'cat'
322
324
  },
323
325
  value: valueScaleOptions
324
- });
326
+ };
327
+ // scatter chart need to set name as linear type,otherwise point will be displayed ramdomly
328
+ if (type === CHART_TYPE.SCATTER) {
329
+ scaleConfig.name.type = 'linear';
330
+ scaleConfig.value.nice = true;
331
+ }
332
+ _this.chart.scale(scaleConfig);
325
333
  };
326
334
  // set axis label and tooltip
327
335
  this.setNameLabelAndTooltip = function () {
@@ -66,17 +66,6 @@ export function Scatter(_ref) {
66
66
  currentChart.chart.coordinate('rect');
67
67
  currentChart.autoAdjustDataOptions(chart, data);
68
68
 
69
- // scatter chart need to set name as linear type,otherwise point will be ramdomly
70
- currentChart.chart.scale({
71
- name: {
72
- type: 'linear',
73
- nice: true
74
- },
75
- value: {
76
- nice: true
77
- }
78
- });
79
-
80
69
  // tooltip template
81
70
  currentChart.chart.tooltip({
82
71
  showTitle: false,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "1.1.82",
3
+ "version": "1.1.83",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",