sea-chart 0.0.64 → 0.0.65

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.
@@ -39,7 +39,7 @@ const de = {
39
39
  "Auto_range": "Automatische Grenzen",
40
40
  "Select_a_column": "Spalte auswählen",
41
41
  "Summary_method": "Auswertungsmethode",
42
- "Label": "Label",
42
+ "Label": "Beschriftung",
43
43
  "Y-axis(left side)": "Y-Achse (primär)",
44
44
  "Y-axis(right side)": "Y-Achse (sekundär)",
45
45
  "Display_title": "Anzeigetitel",
@@ -64,6 +64,7 @@ const de = {
64
64
  "Column_grouping_field": "Feld für die Gruppierung von Spalten",
65
65
  "Date_range": "Zeitspanne",
66
66
  "Compare_to_date_range": "Mit Zeitspanne vergleichen",
67
+ "Increase": "Zunahme",
67
68
  "Display_increase": "Absolute Veränderung anzeigen",
68
69
  "Display_percentage_increase": "Prozentuale Veränderung anzeigen",
69
70
  "Color": "Farbe",
@@ -82,6 +83,7 @@ const de = {
82
83
  "Calculate_the_number_of_records_in_two_time_periods": "Anzahl der Einträge in zwei Zeitperioden vergleichen",
83
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "Ein Feld verwenden, um die Summe, das Maximum, das Minimum oder den Durchschnitt von Datensätzen in zwei Zeiträumen zu berechnen",
84
85
  "No_options": "Keine Optionen",
86
+ "Alignment": "Alignment",
85
87
  "Text_horizontal_alignment": "Horizontale Ausrichtung des Textes",
86
88
  "Please_input_date": "Datum eingeben",
87
89
  "Filter": "Filtern",
@@ -111,8 +113,8 @@ const de = {
111
113
  "Pie_chart": "Kuchendiagramm",
112
114
  "Basic_pie_chart": "Einfaches Kuchendiagramm",
113
115
  "Ring_chart": "Ringdiagramm",
114
- "Scatter_chart": "Scatter chart",
115
- "Combination_chart": "Combination chart",
116
+ "Scatter_chart": "Streudiagramm",
117
+ "Combination_chart": "Kombiniertes Diagramm",
116
118
  "Map": "Karte",
117
119
  "World_map": "Weltkarte",
118
120
  "World_map_bubble": "Weltkarte (Blasendiagramm)",
@@ -193,12 +195,12 @@ const de = {
193
195
  "Geo_column_not_found": "Geopositionsspalte wurde nicht gefunden.",
194
196
  "Summary_column_not_found": "Die Summenspalte wurde nicht gefunden.",
195
197
  "Total_column_not_found": "Die Gesamtwertspalte wurde nicht gefunden.",
196
- "Total_summary_method_is_not_valid": "Total summary method is not valid",
198
+ "Total_summary_method_is_not_valid": "Die Gesamtauswertungsmethode ist nicht gültig.",
197
199
  "Y_axis_column_not_found": "Die Spalte für die Y-Achse wurde nicht gefunden.",
198
200
  "Numeric_column_not_found": "Die numerische Spalte wurde nicht gefunden.",
199
201
  "Target_column_not_found": "Die Zielspalte wurde nicht gefunden.",
200
202
  "Completed_column_not_found": "Die Fortschrittsspalte wurde nicht gefunden.",
201
- "Target_summary_method_is_not_valid": "Target summary method is not valid",
203
+ "Target_summary_method_is_not_valid": "Die Zielauswertungsmethode ist nicht gültig.",
202
204
  "Grid_size": "Rastergröße",
203
205
  "Grid_distance": "Abstand zwischen den Rastern",
204
206
  "Sun": "So",
@@ -237,12 +239,11 @@ const de = {
237
239
  "Previous_30_days": "Vorherige 30 Tage",
238
240
  "The_day_before_yesterday": "Vorgestern",
239
241
  "Can_not_compare_with_{var}": "Ein Vergleich mit {var} ist nicht möglich.",
240
- "Number_settings": "Zahleinstellungen",
241
- "Label_settings": "Labeleinstellungen",
242
+ "Number": "Number",
242
243
  "polylines": "Polygonzug",
243
244
  "curves": "Kurven",
244
245
  "Line_type": "Linientyp",
245
- "Summarize_description": "Calculate the sum, maximum, minimum or average of records based on a field",
246
+ "Summarize_description": "Die Summe, das Maximum, das Minimum oder den Durchschitt der Einträge basierend auf einem Feld berechnen",
246
247
  "Count_description": "Einträge basierend auf den Dateneinstellungen zählen",
247
248
  "Display_empty_when_data_is_zero": "Wert 0 als leeren Wert anzeigen"
248
249
  };
@@ -64,6 +64,7 @@ const en = {
64
64
  "Column_grouping_field": "Column grouping field",
65
65
  "Date_range": "Date range",
66
66
  "Compare_to_date_range": "Compare to date range",
67
+ "Increase": "Increase",
67
68
  "Display_increase": "Display increase",
68
69
  "Display_percentage_increase": "Display percentage increase",
69
70
  "Color": "Color",
@@ -130,7 +131,6 @@ const en = {
130
131
  "Title": "Title",
131
132
  "Custom_title": "Custom title",
132
133
  "Edit_type": "Edit type",
133
- "All_charts": "All charts",
134
134
  "Cancel": "Cancel",
135
135
  "Submit": "Submit",
136
136
  "There_are_no_statistic_results_yet": "There are no statistic results yet",
@@ -240,13 +240,11 @@ const en = {
240
240
  "The_day_before_yesterday": "The day before yesterday",
241
241
  "Can_not_compare_with_{var}": "Can not compare with {var}",
242
242
  "Number": "Number",
243
- "Label_settings": "Label settings",
244
- 'polylines': 'Polylines',
245
- 'curves': 'Curves',
246
- 'Line_type': 'Line type',
247
- 'Summarize_description': 'Count the sum, maximum, minimum, average, or number of distinct values of records based on a field',
248
- 'Count_description': 'Count the number of records based on data settings',
249
- 'Display_empty_when_data_is_zero': 'Display empty when data is zero',
250
- "Search_records": "Search records"
243
+ "polylines": "Polylines",
244
+ "curves": "Curves",
245
+ "Line_type": "Line type",
246
+ "Summarize_description": "Calculate the sum, maximum, minimum or average of records based on a field",
247
+ "Count_description": "Count the number of records based on data settings",
248
+ "Display_empty_when_data_is_zero": "Display empty when data is zero"
251
249
  };
252
250
  export default en;
@@ -64,6 +64,7 @@ const es = {
64
64
  "Column_grouping_field": "Column grouping field",
65
65
  "Date_range": "Date range",
66
66
  "Compare_to_date_range": "Compare to date range",
67
+ "Increase": "Increase",
67
68
  "Display_increase": "Display increase",
68
69
  "Display_percentage_increase": "Display percentage increase",
69
70
  "Color": "Color",
@@ -82,6 +83,7 @@ const es = {
82
83
  "Calculate_the_number_of_records_in_two_time_periods": "Calculate the number of records in two time periods",
83
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "Use a field to calculate the sum maximum or minimum value of records in two time periods",
84
85
  "No_options": "No options",
86
+ "Alignment": "Alignment",
85
87
  "Text_horizontal_alignment": "Text horizontal alignment",
86
88
  "Please_input_date": "Please input date",
87
89
  "Filter": "Filter",
@@ -237,8 +239,7 @@ const es = {
237
239
  "Previous_30_days": "Previous 30 days",
238
240
  "The_day_before_yesterday": "The day before yesterday",
239
241
  "Can_not_compare_with_{var}": "Can not compare with {var}",
240
- "Number_settings": "Number settings",
241
- "Label_settings": "Label settings",
242
+ "Number": "Number",
242
243
  "polylines": "Polylines",
243
244
  "curves": "Curves",
244
245
  "Line_type": "Line type",
@@ -39,7 +39,7 @@ const fr = {
39
39
  "Auto_range": "Limites automatiques",
40
40
  "Select_a_column": "Sélectionner une colonne",
41
41
  "Summary_method": "Méthode de résumé",
42
- "Label": "Label",
42
+ "Label": "Étiquette",
43
43
  "Y-axis(left side)": "Axe des y (primaire)",
44
44
  "Y-axis(right side)": "Axe des y (secondaire)",
45
45
  "Display_title": "Titre à afficher",
@@ -64,6 +64,7 @@ const fr = {
64
64
  "Column_grouping_field": "Champ pour le groupement de colonnes",
65
65
  "Date_range": "Période",
66
66
  "Compare_to_date_range": "Comparer à une période de temps",
67
+ "Increase": "Augmenter",
67
68
  "Display_increase": "Afficher le changement total",
68
69
  "Display_percentage_increase": "Afficher le changement en pourcentage",
69
70
  "Color": "Couleur",
@@ -82,6 +83,7 @@ const fr = {
82
83
  "Calculate_the_number_of_records_in_two_time_periods": "Calculer le nombre d'enregistrements pour deux périodes de temps",
83
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "Utiliser une colonne pour calculer la somme, le maximum, le minimum ou la moyenne des enregistrements pour deux périodes de temps",
84
85
  "No_options": "Il n'y a pas d'options.",
86
+ "Alignment": "Alignment",
85
87
  "Text_horizontal_alignment": "Alignement de texte horizontal",
86
88
  "Please_input_date": "Veuillez entrer la date",
87
89
  "Filter": "Filtrer",
@@ -111,8 +113,8 @@ const fr = {
111
113
  "Pie_chart": "Graphique circulaire",
112
114
  "Basic_pie_chart": "Graphique circulaire simple",
113
115
  "Ring_chart": "Graphique en anneau",
114
- "Scatter_chart": "Scatter chart",
115
- "Combination_chart": "Combination chart",
116
+ "Scatter_chart": "Graphique en nuage de points",
117
+ "Combination_chart": "Graphique combiné",
116
118
  "Map": "Carte",
117
119
  "World_map": "Planisphère",
118
120
  "World_map_bubble": "Planisphère (Graphique à bulles)",
@@ -193,12 +195,12 @@ const fr = {
193
195
  "Geo_column_not_found": "La colonne géolocalisation n'a pas été trouvée.",
194
196
  "Summary_column_not_found": "La colonne de résumé n'a pas été trouvée.",
195
197
  "Total_column_not_found": "La colonne pour le total n'a pas été trouvée.",
196
- "Total_summary_method_is_not_valid": "Total summary method is not valid",
198
+ "Total_summary_method_is_not_valid": "La méthode de résumé total n'est pas valide.",
197
199
  "Y_axis_column_not_found": "La colonne pour l'axe des y n'a pas été trouvée.",
198
200
  "Numeric_column_not_found": "La colonne numérique n'a pas été trouvée.",
199
201
  "Target_column_not_found": "La colonne cible n'a pas été trouvée",
200
202
  "Completed_column_not_found": "Completed column not found",
201
- "Target_summary_method_is_not_valid": "Target summary method is not valid",
203
+ "Target_summary_method_is_not_valid": "La méthode de résumé cible n'est pas valide.",
202
204
  "Grid_size": "Taille de la grille\n",
203
205
  "Grid_distance": "Ecart entre les grilles",
204
206
  "Sun": "dim.",
@@ -237,12 +239,11 @@ const fr = {
237
239
  "Previous_30_days": "30 jours précédents",
238
240
  "The_day_before_yesterday": "Avant-hier",
239
241
  "Can_not_compare_with_{var}": "Il est impossible de comparer avec {var}.",
240
- "Number_settings": "Paramètres de nombres",
241
- "Label_settings": "Paramètres des étiquettes",
242
+ "Number": "Number",
242
243
  "polylines": "Ligne polygonale",
243
244
  "curves": "Courbes",
244
245
  "Line_type": "Type de ligne",
245
- "Summarize_description": "Calculate the sum, maximum, minimum or average of records based on a field",
246
+ "Summarize_description": "Calculer la somme, le maximum, le minimum our la moyenne pour les enregistrements en fonction d'un champ",
246
247
  "Count_description": "Compter les enregistrements basé sur les paramètres de données",
247
248
  "Display_empty_when_data_is_zero": "Afficher la valeur 0 comme valeur vide"
248
249
  };
@@ -64,6 +64,7 @@ const pt = {
64
64
  "Column_grouping_field": "Column grouping field",
65
65
  "Date_range": "Date range",
66
66
  "Compare_to_date_range": "Compare to date range",
67
+ "Increase": "Increase",
67
68
  "Display_increase": "Display increase",
68
69
  "Display_percentage_increase": "Display percentage increase",
69
70
  "Color": "Color",
@@ -82,6 +83,7 @@ const pt = {
82
83
  "Calculate_the_number_of_records_in_two_time_periods": "Calculate the number of records in two time periods",
83
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "Use a field to calculate the sum maximum or minimum value of records in two time periods",
84
85
  "No_options": "No options",
86
+ "Alignment": "Alignment",
85
87
  "Text_horizontal_alignment": "Text horizontal alignment",
86
88
  "Please_input_date": "Please input date",
87
89
  "Filter": "Filter",
@@ -237,8 +239,7 @@ const pt = {
237
239
  "Previous_30_days": "Previous 30 days",
238
240
  "The_day_before_yesterday": "The day before yesterday",
239
241
  "Can_not_compare_with_{var}": "Can not compare with {var}",
240
- "Number_settings": "Number settings",
241
- "Label_settings": "Label settings",
242
+ "Number": "Number",
242
243
  "polylines": "Polylines",
243
244
  "curves": "Curves",
244
245
  "Line_type": "Line type",
@@ -64,6 +64,7 @@ const ru = {
64
64
  "Column_grouping_field": "Column grouping field",
65
65
  "Date_range": "Date range",
66
66
  "Compare_to_date_range": "Compare to date range",
67
+ "Increase": "Увеличивать",
67
68
  "Display_increase": "Display increase",
68
69
  "Display_percentage_increase": "Display percentage increase",
69
70
  "Color": "Color",
@@ -82,6 +83,7 @@ const ru = {
82
83
  "Calculate_the_number_of_records_in_two_time_periods": "Calculate the number of records in two time periods",
83
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "Use a field to calculate the sum maximum or minimum value of records in two time periods",
84
85
  "No_options": "No options",
86
+ "Alignment": "Alignment",
85
87
  "Text_horizontal_alignment": "Text horizontal alignment",
86
88
  "Please_input_date": "Please input date",
87
89
  "Filter": "Filter",
@@ -237,8 +239,7 @@ const ru = {
237
239
  "Previous_30_days": "Previous 30 days",
238
240
  "The_day_before_yesterday": "The day before yesterday",
239
241
  "Can_not_compare_with_{var}": "Can not compare with {var}",
240
- "Number_settings": "Number settings",
241
- "Label_settings": "Label settings",
242
+ "Number": "Number",
242
243
  "polylines": "Polylines",
243
244
  "curves": "Curves",
244
245
  "Line_type": "Line type",
@@ -64,6 +64,7 @@ const zh_CN = {
64
64
  "Column_grouping_field": "列分组字段",
65
65
  "Date_range": "日期范围",
66
66
  "Compare_to_date_range": "对比日期范围",
67
+ "Increase": "增幅",
67
68
  "Display_increase": "显示增幅",
68
69
  "Display_percentage_increase": "显示百分比增幅",
69
70
  "Color": "颜色",
@@ -82,7 +83,7 @@ const zh_CN = {
82
83
  "Calculate_the_number_of_records_in_two_time_periods": "计算两个时间段的记录数",
83
84
  "Use_a_field_to_calculate_the_sum_maximum_or_minimum_value_of_records_in_two_time_periods": "使用字段计算两个时间段内记录的最大值或最小值之和",
84
85
  "No_options": "没有选项",
85
- "Alignment": "对齐方式",
86
+ "Alignment": "Alignment",
86
87
  "Text_horizontal_alignment": "文本水平对齐",
87
88
  "Please_input_date": "请输入日期",
88
89
  "Filter": "过滤",
@@ -130,7 +131,6 @@ const zh_CN = {
130
131
  "Title": "标题",
131
132
  "Custom_title": "自定义标题",
132
133
  "Edit_type": "编辑类型",
133
- "All_charts": "所有图表",
134
134
  "Cancel": "取消",
135
135
  "Submit": "提交",
136
136
  "There_are_no_statistic_results_yet": "目前还没有统计结果",
@@ -239,14 +239,12 @@ const zh_CN = {
239
239
  "Previous_30_days": "之前 30 天",
240
240
  "The_day_before_yesterday": "前天",
241
241
  "Can_not_compare_with_{var}": "无法和 {var} 比较",
242
- "Number": "数字",
243
- "Label_settings": "标签设置",
244
- 'polylines': '折线',
245
- 'curves': '曲线',
246
- 'Line_type': '线型',
247
- 'Summarize_description': '按照一个字段计算记录的总和、最大值、最小值或者平均值',
248
- 'Count_description': '根据数据设置计算记录数量',
249
- 'Display_empty_when_data_is_zero': '数据为零时留空',
250
- "Search_records": "搜索记录"
242
+ "Number": "Number",
243
+ "polylines": "折线",
244
+ "curves": "曲线",
245
+ "Line_type": "线型",
246
+ "Summarize_description": "按照一个字段计算记录的总和、最大值、最小值或者平均值",
247
+ "Count_description": "根据数据设置计算记录数量",
248
+ "Display_empty_when_data_is_zero": "数据为零时留空"
251
249
  };
252
250
  export default zh_CN;
@@ -7,7 +7,6 @@ import Divider from '../widgets/divider';
7
7
  import GroupBy from '../widgets/group-by';
8
8
  import BasicSummary from '../widgets/basic-summary';
9
9
  import TimePicker from '../widgets/time-picker';
10
- import { eventStopPropagation } from '../../utils';
11
10
  import { CHART_SUMMARY_TYPE, GEOLOCATION_FORMAT_CITY, GEOLOCATION_FORMAT_MAP } from '../../constants';
12
11
  import intl from '../../intl';
13
12
  import '../../assets/css/time-picker.css';
@@ -96,17 +95,16 @@ const DataSettings = _ref => {
96
95
  });
97
96
  }, [chart, onChange]);
98
97
  const onDisplayIncreaseChange = useCallback(event => {
99
- eventStopPropagation(event);
100
- const {
101
- config
102
- } = chart;
103
- const {
104
- display_increase
105
- } = config;
106
98
  onChange && onChange({
107
- display_increase: !display_increase
99
+ display_increase: event.target.checked
108
100
  });
109
- }, [chart, onChange]);
101
+ }, [onChange]);
102
+
103
+ // const [checked, setChecked] = useState(false);
104
+ // function onDisplayIncreaseChange(e) {
105
+ // setChecked(e.target.checked);
106
+ // }
107
+
110
108
  const {
111
109
  table_id,
112
110
  x_axis_column_key,
@@ -167,7 +165,7 @@ const DataSettings = _ref => {
167
165
  tables: tables,
168
166
  onChange: onChange
169
167
  }), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(_DTableSwitch, {
170
- checked: display_increase || false,
168
+ checked: display_increase,
171
169
  placeholder: intl.get('Display_increase'),
172
170
  onChange: onDisplayIncreaseChange
173
171
  }));
@@ -83,10 +83,10 @@ const StyleSettings = _ref => {
83
83
  config
84
84
  } = chart;
85
85
  const {
86
- display_increase_percentage
86
+ display_increase
87
87
  } = config;
88
88
  onChange && onChange({
89
- display_increase_percentage: !display_increase_percentage
89
+ display_increase: !display_increase
90
90
  });
91
91
  }, [chart, onChange]);
92
92
  const onIncreaseDisplayColorChang = useCallback((event, value) => {
@@ -173,8 +173,8 @@ const StyleSettings = _ref => {
173
173
  onMaxChange: onYAxisMaxChange
174
174
  })))
175
175
  }), /*#__PURE__*/React.createElement(Divider, null), /*#__PURE__*/React.createElement(DisplayValuesSettings, {
176
- isShowValueKey: "y_axis_show_value",
177
- isShowValue: y_axis_show_value,
176
+ isShowValueKey: "display_increase_percentage",
177
+ isShowValue: display_increase_percentage,
178
178
  fontSizeKey: "label_font_size",
179
179
  fontSize: label_font_size,
180
180
  onChange: onDisplayValueChange
@@ -310,10 +310,6 @@ class Combination extends ChartComponent {
310
310
  this.chart.on('interval:mouseenter', e => {
311
311
  if (this.isInsideInterval) return;
312
312
  this.isInsideInterval = true;
313
- // point.style({
314
- // stroke: 0,
315
- // fillOpacity: 0.3,
316
- // });
317
313
  interval.style('name*value_left', (name, value) => {
318
314
  const isHovered = value === e.data.data.value_left && name === e.data.data.name;
319
315
  return {
@@ -345,10 +341,6 @@ class Combination extends ChartComponent {
345
341
  this.chart.on('interval:mouseleave', e => {
346
342
  if (!this.isInsideInterval) return;
347
343
  this.isInsideInterval = false;
348
- // point.style({
349
- // stroke: 0,
350
- // fillOpacity: 1,
351
- // });
352
344
  interval.style('name*value_left', (name, value) => {
353
345
  return {
354
346
  fillOpacity: 1,
@@ -385,7 +377,7 @@ class Combination extends ChartComponent {
385
377
  };
386
378
  });
387
379
  this.chart.render(true);
388
- }, 10));
380
+ }, 100));
389
381
  this.chart.on('point:mouseleave', throttle(e => {
390
382
  if (!this.isInsidePoint) return;
391
383
  this.isInsidePoint = false;
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import PropTypes from 'prop-types';
3
3
  import classnames from 'classnames';
4
4
  import { getTableById, getTableColumnByKey, getNumberDisplayString } from 'dtable-utils';
5
+ import { maxBy, throttle } from 'lodash-es';
5
6
  import { CHART_SUMMARY_TYPE, CHART_SUMMARY_SHOW, DEFAULT_NUMBER_FORMAT_OBJECT, EMPTY_NAME, TITLE_AMOUNT, TITLE_INCREASE, CHART_THEME_COLOR } from '../../constants';
6
7
  import { BaseUtils } from '../../utils/chart-utils';
7
8
  import intl from '../../intl';
@@ -51,6 +52,7 @@ class Compare extends ChartComponent {
51
52
  y_axis_summary_type,
52
53
  y_axis_column_key,
53
54
  y_axis_summary_method,
55
+ summaryColumn,
54
56
  display_data,
55
57
  label_font_size,
56
58
  display_increase
@@ -61,10 +63,13 @@ class Compare extends ChartComponent {
61
63
  const summaryColumn = getTableColumnByKey(table, y_axis_column_key) || {};
62
64
  summaryColumnData = summaryColumn.data || DEFAULT_NUMBER_FORMAT_OBJECT;
63
65
  }
66
+
67
+ // x axis
64
68
  const {
65
69
  width
66
70
  } = this.chart.coordinateBBox;
67
71
  const chartData = this.getChartGroupData(data);
72
+ this.labelCount = chartData.length;
68
73
  const ticks = this.getChartDisplayLabels(width, 20, chartData);
69
74
  if (ticks.length > 0) {
70
75
  this.chart.scale('name', {
@@ -80,7 +85,15 @@ class Compare extends ChartComponent {
80
85
  type: 'cat'
81
86
  }
82
87
  });
83
- this.chart.interval().label(display_data ? 'formatted_value' : false, {
88
+
89
+ // set the single bar width and radius
90
+ let singleBarWidth, singleBarRadius;
91
+ // y-axis label width:6 + 10
92
+ const chartWidth = this.chart.width - 6 - 10;
93
+ const maxCountGroup = maxBy(chartData, 'currentGroupCount');
94
+ singleBarWidth = Math.round(chartWidth / (2 * chartData.length * maxCountGroup.currentGroupCount));
95
+ singleBarRadius = Math.min(singleBarWidth / 5, 10);
96
+ const interval = this.chart.interval().label(display_data ? 'formatted_value' : false, {
84
97
  style: {
85
98
  fontSize: BaseUtils.getLabelFontSize(label_font_size),
86
99
  fill: theme.textColor,
@@ -95,23 +108,97 @@ class Compare extends ChartComponent {
95
108
  title: titleContent,
96
109
  name: nameContent
97
110
  };
98
- }).adjust('dodge').state({
111
+ }).adjust({
112
+ type: 'dodge',
113
+ marginRatio: 0
114
+ }).state({
99
115
  active: {
100
116
  style: {
101
117
  stroke: null
102
118
  }
103
119
  }
120
+ }).style({
121
+ radius: [singleBarRadius, singleBarRadius, 0, 0]
104
122
  });
105
- this.setNameLabelAndTooltip(theme, this.labelCount);
106
123
  if (display_increase) {
107
124
  this.drawIncreaseLine({
108
125
  theme
109
126
  });
110
127
  }
111
- this.setAxis(theme);
112
- this.setLegend('group_name', theme);
113
- this.chart.interaction('active-region');
114
- this.chart.removeInteraction('legend-filter');
128
+ this.chart.on('interval:mouseenter', e => {
129
+ if (this.isInsideInterval) return;
130
+ this.isInsideInterval = true;
131
+ this.setToolTipForInterval();
132
+ interval.style('name*value', (name, value) => {
133
+ const isHovered = name === e.data.data.name;
134
+ return {
135
+ fillOpacity: isHovered ? 1 : 0.3,
136
+ radius: [singleBarRadius, singleBarRadius, 0, 0]
137
+ };
138
+ });
139
+ interval.tooltip('name*formatted_value*raw_name', (name, value, raw_name) => {
140
+ const nameContent = !raw_name && typeof raw_name !== 'number' ? intl.get(EMPTY_NAME) : raw_name;
141
+ const titleContent = y_axis_summary_type === 'count' ? intl.get(TITLE_AMOUNT) : intl.get(CHART_SUMMARY_SHOW[y_axis_summary_method]);
142
+ return {
143
+ value,
144
+ title: titleContent,
145
+ name: nameContent
146
+ };
147
+ });
148
+ this.point && this.point.tooltip(false);
149
+ this.chart.render(true);
150
+ });
151
+ this.chart.on('interval:mouseleave', e => {
152
+ if (!this.isInsideInterval) return;
153
+ this.isInsideInterval = false;
154
+ this.setToolTipForLine();
155
+ interval.style('name*value', () => {
156
+ return {
157
+ fillOpacity: 1,
158
+ radius: [singleBarRadius, singleBarRadius, 0, 0]
159
+ };
160
+ });
161
+ this.point && this.point.tooltip('name*increase_value', (name, value) => {
162
+ return {
163
+ title: intl.get(TITLE_INCREASE),
164
+ value: getNumberDisplayString(value || 0, {
165
+ format: 'percent'
166
+ }),
167
+ name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
168
+ };
169
+ });
170
+ interval.tooltip(false);
171
+ this.chart.render(true);
172
+ });
173
+ this.setColorMap(data, chartColorTheme);
174
+ this.formatDataByName(data);
175
+ this.setToolTip(true, summaryColumn, y_axis_summary_method);
176
+ this.setLegend('group_name', theme, 'top-right');
177
+
178
+ // x and y
179
+ this.setNameLabelAndTooltip(theme, this.labelCount);
180
+ this.setValueLabel(theme);
181
+ };
182
+ this.setToolTipForInterval = () => {
183
+ const {
184
+ chart,
185
+ summaryColumn
186
+ } = this.props;
187
+ const {
188
+ y_axis_summary_method
189
+ } = chart.config;
190
+ this.setToolTip(true, summaryColumn, y_axis_summary_method);
191
+ };
192
+ this.setToolTipForLine = () => {
193
+ const {
194
+ chart,
195
+ summaryColumn
196
+ } = this.props;
197
+ const {
198
+ y_axis_summary_method
199
+ } = chart.config;
200
+ const settings = this.getToolTipSettings(false, summaryColumn, y_axis_summary_method);
201
+ this.chart.tooltip(settings);
115
202
  };
116
203
  this.drawIncreaseLine = _ref => {
117
204
  let {
@@ -122,27 +209,35 @@ class Compare extends ChartComponent {
122
209
  } = this.props;
123
210
  const {
124
211
  increase_line_color,
125
- display_increase_percentage
212
+ display_increase_percentage,
213
+ label_font_size
126
214
  } = chart.config;
127
- this.chart.line().position('name*increase_value').size(3).color(increase_line_color || '#fbd44a').shape('smooth').tooltip('name*increase_value', (name, value) => {
128
- return {
129
- title: intl.get(TITLE_INCREASE),
130
- value: getNumberDisplayString(value || 0, {
131
- format: 'percent'
132
- }),
133
- name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
134
- };
135
- });
136
- this.chart.point().label(display_increase_percentage ? 'increase_value' : false, value => {
215
+ this.chart.line().position('name*increase_value').color(increase_line_color || '#fbd44a').shape('smooth').style({
216
+ lineWidth: 2,
217
+ opacity: 1
218
+ }).tooltip(false);
219
+ const point = this.chart.point().label(display_increase_percentage ? 'increase_value' : false, value => {
137
220
  return {
138
221
  content: getNumberDisplayString(value || 0, {
139
222
  format: 'percent'
140
223
  }),
141
224
  style: {
142
- fill: theme.textColor
225
+ fontSize: BaseUtils.getLabelFontSize(label_font_size),
226
+ fill: theme.labelColor,
227
+ stroke: '#fff',
228
+ lineWidth: 1
143
229
  }
144
230
  };
145
- }).color(increase_line_color || '#fbd44a').position('name*increase_value').size(3).tooltip('name*increase_value', (name, value) => {
231
+ }).color(increase_line_color || '#fbd44a').animate({
232
+ appear: {
233
+ animation: 'fadeIn',
234
+ duration: 1000,
235
+ easing: 'easeLinear'
236
+ }
237
+ }).position('name*increase_value').shape('circle').size(3).style({
238
+ stroke: 0,
239
+ fillOpacity: 1
240
+ }).tooltip('name*increase_value', (name, value) => {
146
241
  return {
147
242
  title: intl.get(TITLE_INCREASE),
148
243
  value: getNumberDisplayString(value || 0, {
@@ -151,39 +246,41 @@ class Compare extends ChartComponent {
151
246
  name: !name && typeof name !== 'number' ? intl.get(EMPTY_NAME) : name
152
247
  };
153
248
  });
249
+ this.chart.on('point:mouseenter', throttle(e => {
250
+ if (this.isInsidePoint) return;
251
+ this.isInsidePoint = true;
252
+ point.style('name', name => {
253
+ let r = 3;
254
+ if (name === e.data.data.name) {
255
+ r = 5;
256
+ }
257
+ return {
258
+ r,
259
+ stroke: 0,
260
+ fillOpacity: 1
261
+ };
262
+ });
263
+ this.chart.render(true);
264
+ }, 100));
265
+ this.chart.on('point:mouseleave', throttle(e => {
266
+ if (!this.isInsidePoint) return;
267
+ this.isInsidePoint = false;
268
+ point.style('name', name => {
269
+ let r = 3;
270
+ return {
271
+ r,
272
+ stroke: 0,
273
+ fillOpacity: 1
274
+ };
275
+ });
276
+ this.chart.render(true);
277
+ }, 100));
278
+ this.point = point;
154
279
  this.chart.axis('increase_value', {
155
280
  label: null,
156
281
  grid: null
157
282
  });
158
283
  };
159
- this.setAxis = theme => {
160
- this.chart.axis('name', {
161
- line: {
162
- style: theme.gridColor
163
- },
164
- label: {
165
- autoRotate: true,
166
- style: {
167
- fill: theme.textColor
168
- },
169
- formatter: this.labelFormatter
170
- }
171
- });
172
- this.chart.axis('value', {
173
- label: {
174
- style: {
175
- fill: theme.textColor
176
- }
177
- },
178
- grid: {
179
- line: {
180
- style: {
181
- stroke: theme.gridColor
182
- }
183
- }
184
- }
185
- });
186
- };
187
284
  this.handleAutoRange = (data, summaryColumnData) => {
188
285
  const {
189
286
  chart
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sea-chart",
3
- "version": "0.0.64",
3
+ "version": "0.0.65",
4
4
  "main": "./dist/index.js",
5
5
  "dependencies": {
6
6
  "@antv/data-set": "0.11.8",