sea-chart 1.1.37 → 1.1.39

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.
@@ -31,8 +31,9 @@ const StyleSettings = _ref => {
31
31
  });
32
32
  }, [chart, onChange]);
33
33
  const modifyStyleSettings = useCallback(update => {
34
+ const styleConfig = chart.style_config || {};
34
35
  const newUpdate = {
35
- ...chart.style_config,
36
+ ...styleConfig,
36
37
  ...update
37
38
  };
38
39
  onChange({
@@ -40,9 +41,7 @@ const StyleSettings = _ref => {
40
41
  });
41
42
  }, [chart.style_config, onChange]);
42
43
  const modifyTitle = useCallback(title => {
43
- const {
44
- style_config
45
- } = chart;
44
+ const style_config = chart.style_config || {};
46
45
  const update = style_config ? {
47
46
  ...style_config,
48
47
  title
@@ -54,10 +53,11 @@ const StyleSettings = _ref => {
54
53
  });
55
54
  }, [chart, onChange]);
56
55
  const renderTitleSettings = useCallback(() => {
57
- const {
56
+ let {
58
57
  style_config,
59
58
  config
60
59
  } = chart;
60
+ if (!style_config) style_config = {};
61
61
  const {
62
62
  type
63
63
  } = config;
@@ -413,7 +413,7 @@ BaseUtils.isChartSortChange = (preChartElement, curChartElement) => {
413
413
  BaseUtils.isChartStyleChanged = (prevElement, currElement) => {
414
414
  const prevStyleConfig = prevElement && prevElement.style_config;
415
415
  const currStyleConfig = currElement && currElement.style_config;
416
- if (prevStyleConfig.display_goal_line !== currStyleConfig.display_goal_line && (!currStyleConfig.goal_lable || !currStyleConfig.goal_value)) {
416
+ if ((prevStyleConfig === null || prevStyleConfig === void 0 ? void 0 : prevStyleConfig.display_goal_line) !== (currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.display_goal_line) && (!(currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.goal_lable) || !(currStyleConfig === null || currStyleConfig === void 0 ? void 0 : currStyleConfig.goal_value))) {
417
417
  return false;
418
418
  }
419
419
  if (!prevStyleConfig && !currStyleConfig) {
@@ -9,11 +9,12 @@ const Title = _ref => {
9
9
  className
10
10
  } = _ref;
11
11
  const getTitleStyle = useCallback(() => {
12
+ var _chart$style_config, _chart$style_config2;
12
13
  let style = {
13
14
  fontSize: "".concat(DEFAULT_CHART_TITLE_FONT_SIZE, "px"),
14
15
  fontWeight: DEFAULT_CHART_FONT_WEIGHT
15
16
  };
16
- if (!chart || !chart.style_config || !chart.style_config.title) {
17
+ if (!chart || !chart.style_config || !((_chart$style_config = chart.style_config) === null || _chart$style_config === void 0 ? void 0 : _chart$style_config.title)) {
17
18
  return style;
18
19
  }
19
20
  const {
@@ -21,7 +22,7 @@ const Title = _ref => {
21
22
  font_weight,
22
23
  font_color,
23
24
  horizontal_align
24
- } = chart.style_config.title;
25
+ } = (_chart$style_config2 = chart.style_config) === null || _chart$style_config2 === void 0 ? void 0 : _chart$style_config2.title;
25
26
  if (isNumber(font_size)) {
26
27
  style.fontSize = font_size < 0 ? 0 : "".concat(font_size, "px");
27
28
  }
@@ -84,7 +84,7 @@ class Area extends ChartComponent {
84
84
  display_goal_line,
85
85
  goal_label,
86
86
  goal_value
87
- } = chart.style_config;
87
+ } = chart.style_config || {};
88
88
  const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
89
89
 
90
90
  const newData = this.getChartGroupData(data);
@@ -85,7 +85,7 @@ class BarCustom extends ChartComponent {
85
85
  display_goal_line,
86
86
  goal_value,
87
87
  goal_label
88
- } = chart.style_config;
88
+ } = chart.style_config || {};
89
89
  const displayData = display_each_block_data;
90
90
  this.chart.scale('group_name', {
91
91
  type: 'cat'
@@ -88,7 +88,7 @@ class BarGroup extends ChartComponent {
88
88
  display_goal_line,
89
89
  goal_value,
90
90
  goal_label
91
- } = chart.style_config;
91
+ } = chart.style_config || {};
92
92
  const theme = CHART_THEME_COLOR[globalTheme];
93
93
  const isGroup = type === CHART_TYPE.BAR_GROUP;
94
94
  const newData = this.getChartGroupData(data);
@@ -73,9 +73,9 @@ class Bar extends ChartComponent {
73
73
  display_goal_line,
74
74
  goal_value,
75
75
  goal_label
76
- } = chart.style_config;
76
+ } = chart.style_config || {};
77
77
  // y-axis label width:6 + 10
78
- const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
78
+ const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
79
79
  const singleBarWidth = Math.round(chartWidth / (2 * data.length));
80
80
  const singleBarRadius = Math.min(singleBarWidth / 5, 10);
81
81
  let chartBarColor = y_axis_label_color || CHART_STYLE_COLORS[0];
@@ -55,7 +55,7 @@ class Combination extends ChartComponent {
55
55
  display_goal_line,
56
56
  goal_value,
57
57
  goal_label
58
- } = chart.style_config;
58
+ } = chart.style_config || {};
59
59
  this.chart = new Chart({
60
60
  container: this.container,
61
61
  autoFit: true,
@@ -66,7 +66,7 @@ class Combination extends ChartComponent {
66
66
  const isSmooth = line_type === CHART_LINE_TYPES[1] || !line_type;
67
67
 
68
68
  // y-axis label width:6 + 10
69
- const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
69
+ const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
70
70
  const nameCountMap = data.reduce((acc, cur) => {
71
71
  if (!acc[cur.name]) {
72
72
  acc[cur.name] = 1;
@@ -69,8 +69,8 @@ class LineGroup extends ChartComponent {
69
69
  display_goal_line,
70
70
  goal_label,
71
71
  goal_value
72
- } = chart.style_config;
73
- const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
72
+ } = chart.style_config || {};
73
+ const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
74
74
 
75
75
  const useSingleSelectColumnColor = (columnGroupbyColumn === null || columnGroupbyColumn === void 0 ? void 0 : columnGroupbyColumn.type) === CellType.SINGLE_SELECT && color_theme === SUPPORT_SINGLE_SELECT_THEMES_OPTIONS.SINGLE_SELECT_COLUMN_COLORS;
76
76
  useSingleSelectColumnColor ? this.setSingleSelectColorMap(data) : this.setColorMap(data, chartColorTheme);
@@ -66,12 +66,12 @@ class Line extends ChartComponent {
66
66
  color_option
67
67
  // y_axis_label_color_rules
68
68
  } = chart.config;
69
- const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
69
+ const chartWidth = this.chart.width - 6 - 10; // 10 is y-axis number width and 6 is gap between number and y axis line
70
70
  const {
71
71
  display_goal_line,
72
72
  goal_label,
73
73
  goal_value
74
- } = chart.style_config;
74
+ } = chart.style_config || {};
75
75
  let chartBarColor;
76
76
  // default color
77
77
  chartBarColor = CHART_STYLE_COLORS[0];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "1.1.37",
3
+ "version": "1.1.39",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",