amazing-react-charts 1.0.5 → 1.0.7

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 (36) hide show
  1. package/core/area-chart/AreaChart.js +21 -10
  2. package/core/audiometry-chart/AudiometryChart.d.ts +1 -1
  3. package/core/audiometry-chart/AudiometryChart.js +10 -10
  4. package/core/coordinate-line-chart/CoordinateLineChart.js +16 -15
  5. package/core/diverging-stacked-bar-chart/DivergingStackedBarChart.js +20 -11
  6. package/core/donut-chart/DonutChart.d.ts +1 -1
  7. package/core/donut-chart/DonutChart.js +11 -10
  8. package/core/forecast-area-chart/ForecastAreaChart.js +20 -18
  9. package/core/horizontal-bar-chart/HorizontalBarChart.js +29 -19
  10. package/core/line-chart/LineChart.d.ts +0 -1
  11. package/core/line-chart/LineChart.js +19 -10
  12. package/core/multipurpose-chart/MultipurposeChart.js +18 -15
  13. package/core/pictorial-chart/PictorialChart.js +2 -1
  14. package/core/pie-chart/PieChart.d.ts +1 -1
  15. package/core/pie-chart/PieChart.js +10 -9
  16. package/core/pyramid-bar-chart/PyramidBarChart.js +20 -10
  17. package/core/radar-chart/RadarChart.js +1 -1
  18. package/core/stacked-bar-chart/StackedBarChart.js +29 -23
  19. package/core/vertical-bar-chart/VerticalBarChart.js +16 -12
  20. package/lib/auxiliarFunctions.js +22 -13
  21. package/package.json +32 -21
  22. package/test/area-chart.spec.d.ts +1 -0
  23. package/test/audiometry-chart.spec.d.ts +1 -0
  24. package/test/coordinate-line-chart.spec.d.ts +1 -0
  25. package/test/diverging-stacked-bar-chart.spec.d.ts +1 -0
  26. package/test/donut-chart.spec.d.ts +1 -0
  27. package/test/forecast-area-chart.spec.d.ts +1 -0
  28. package/test/horizontal-bar-chart.spec.d.ts +1 -0
  29. package/test/line-chart.spec.d.ts +1 -0
  30. package/test/multipurpose-chart.spec.d.ts +1 -0
  31. package/test/pictorial-chart.spec.d.ts +1 -0
  32. package/test/pie-chart.spec.d.ts +1 -0
  33. package/test/pyramid-bar-chart.spec.d.ts +1 -0
  34. package/test/radar-chart.spec.d.ts +1 -0
  35. package/test/stacked-bar-chart.spec.d.ts +1 -0
  36. package/test/vertical-bar-chart.spec.d.ts +1 -0
@@ -14,6 +14,7 @@ var _commonStyles = require("../../commonStyles");
14
14
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
15
15
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
16
16
  var AreaChart = function AreaChart(props) {
17
+ var _toolboxTooltip$saveA, _toolboxTooltip$dataV;
17
18
  var data = props.data,
18
19
  xType = props.xType,
19
20
  color = props.color,
@@ -49,7 +50,7 @@ var AreaChart = function AreaChart(props) {
49
50
  };
50
51
  var formatLabel = function formatLabel(chartValues) {
51
52
  var data = chartValues.data;
52
- return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)).toString() + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(Number(data), yComplement).toString();
53
+ return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)).toString() + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(Number(data), yComplement !== null && yComplement !== void 0 ? yComplement : '').toString();
53
54
  };
54
55
  var dinamicData = function dinamicData(item, charts) {
55
56
  var isTime = yType === 'time' ? 3400 : 4500;
@@ -78,19 +79,19 @@ var AreaChart = function AreaChart(props) {
78
79
  });
79
80
  };
80
81
  var formatSingleTooltip = function formatSingleTooltip(chartValues) {
81
- var label = tooltipProps.label,
82
- result = tooltipProps.result;
82
+ var label = tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.label;
83
+ var result = tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.result;
83
84
  var _chartValues$ = chartValues[0],
84
85
  axisValueLabel = _chartValues$.axisValueLabel,
85
86
  data = _chartValues$.data;
86
87
  var complement = tooltipComplement ? tooltipComplement : '';
87
- var values = yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)) + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(Number(data), yComplement);
88
- return "".concat(label, ": ").concat((0, _auxiliarFunctions.formatTooltip)(axisValueLabel, dateFormat), " <br>\n ").concat(result, ": ").concat(values, " <br> \n ").concat(complement);
88
+ var values = yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)) + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(Number(data), yComplement !== null && yComplement !== void 0 ? yComplement : '');
89
+ return "".concat(label, ": ").concat((0, _auxiliarFunctions.formatTooltip)(axisValueLabel, dateFormat), " <br>\n ").concat(result, ": ").concat(values, " <br>\n ").concat(complement);
89
90
  };
90
91
  var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
91
92
  feature: {
92
- saveAsImage: toolboxTooltip && toolboxTooltip.saveAsImage && (0, _auxiliarFunctions.getSaveAsImage)(toolboxTooltip.saveAsImage.title),
93
- dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)(toolboxTooltip.dataView.title)
93
+ saveAsImage: toolboxTooltip.saveAsImage && (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : ''),
94
+ dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
94
95
  }
95
96
  });
96
97
  var zoomEvent = {
@@ -115,6 +116,8 @@ var AreaChart = function AreaChart(props) {
115
116
  }
116
117
  }] : [];
117
118
  var options = {
119
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
120
+ // @ts-ignore
118
121
  series: [{
119
122
  type: 'line',
120
123
  data: yData,
@@ -123,7 +126,15 @@ var AreaChart = function AreaChart(props) {
123
126
  if (typeof yComplement === 'function' && (0, _typeof2["default"])(item) === 'object') {
124
127
  return yComplement(item.data);
125
128
  }
126
- typeof yComplement === 'function' ? yComplement : formatLabel;
129
+ if (typeof yComplement === 'function') {
130
+ return yComplement;
131
+ }
132
+
133
+ // this can't be returned
134
+ // it breaks the labels
135
+ // eslint-disable-next-line @stylistic/max-len
136
+ // eslint-disable-next-line @typescript-eslint/no-unused-expressions
137
+ formatLabel;
127
138
  },
128
139
  show: true,
129
140
  position: 'top',
@@ -169,7 +180,7 @@ var AreaChart = function AreaChart(props) {
169
180
  },
170
181
  axisLabel: {
171
182
  formatter: function formatter(item) {
172
- return xType === 'time' ? (0, _auxiliarFunctions.formatTime)(item, (0, _auxiliarFunctions.getDateFormatType)(dateFormat)) : item;
183
+ return xType === 'time' ? (0, _auxiliarFunctions.formatTime)(item, (0, _auxiliarFunctions.getDateFormatType)(dateFormat || 'yyyy-MM')) : item;
173
184
  },
174
185
  rotate: rotateLabel || 0,
175
186
  fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
@@ -191,7 +202,7 @@ var AreaChart = function AreaChart(props) {
191
202
  axisLabel: {
192
203
  margin: yType === 'time' ? 16 : 14,
193
204
  formatter: function formatter(item) {
194
- return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(item) + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(item, yComplement).toString();
205
+ return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(item) + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(item, yComplement !== null && yComplement !== void 0 ? yComplement : '').toString();
195
206
  },
196
207
  fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
197
208
  fontSize: fontLabelSize || 11.5,
@@ -8,7 +8,7 @@ export interface IProps extends Omit<IDefaultChartProps, 'data'> {
8
8
  colors?: string[];
9
9
  legendsPosition?: 'top' | 'bottom';
10
10
  legendGap?: number;
11
- legendType: 'scroll' | 'plain';
11
+ legendType?: 'scroll' | 'plain';
12
12
  legends?: TSimpleLegend[];
13
13
  legendPadding?: number;
14
14
  legendItemWidth?: number;
@@ -22,6 +22,7 @@ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbol
22
22
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
23
23
  var X_FIXED_DATA = ['.25', '.5', '1', '2', '3', '4', '6', '8'];
24
24
  var AudiometryChart = function AudiometryChart(props) {
25
+ var _toolboxTooltip$saveA, _toolboxTooltip$saveA2, _toolboxTooltip$dataV;
25
26
  var _useState = (0, _react.useState)(false),
26
27
  _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
27
28
  title = _useState2[0],
@@ -50,7 +51,7 @@ var AudiometryChart = function AudiometryChart(props) {
50
51
  height: height || 400
51
52
  };
52
53
  (0, _react.useEffect)(function () {
53
- if (toolboxTooltip && toolboxTooltip.saveAsImageWithTitle) {
54
+ if (toolboxTooltip !== null && toolboxTooltip !== void 0 && toolboxTooltip.saveAsImageWithTitle) {
54
55
  setTitle(false);
55
56
  } else {
56
57
  setTitle(true);
@@ -96,15 +97,15 @@ var AudiometryChart = function AudiometryChart(props) {
96
97
  } : {};
97
98
  }, X_FIXED_DATA, item);
98
99
  };
99
- var myTool = toolboxTooltip && toolboxTooltip.saveAsImageWithTitle && {
100
- myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)(toolboxTooltip.saveAsImageWithTitle.title, handleShowTitle)
100
+ var myTool = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImageWithTitle) && {
101
+ myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImageWithTitle.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : '', handleShowTitle)
101
102
  };
102
- var saveAsImage = toolboxTooltip && toolboxTooltip.saveAsImage && {
103
- saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)(toolboxTooltip.saveAsImage.title)
103
+ var saveAsImage = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImage) && {
104
+ saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA2 = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA2 !== void 0 ? _toolboxTooltip$saveA2 : '')
104
105
  };
105
106
  var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
106
107
  feature: _objectSpread(_objectSpread(_objectSpread({}, myTool), saveAsImage), {}, {
107
- dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)(toolboxTooltip.dataView.title)
108
+ dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
108
109
  })
109
110
  });
110
111
  var tooltip = {
@@ -127,7 +128,7 @@ var AudiometryChart = function AudiometryChart(props) {
127
128
  });
128
129
  var removedUndefinedMarks = (0, _map["default"])(function (item) {
129
130
  return (0, _filter["default"])(function (serie) {
130
- return (serie === null || serie === void 0 ? void 0 : serie.value) !== null;
131
+ return serie.value !== undefined;
131
132
  }, item.data);
132
133
  }, seriesMarks);
133
134
  var marksWithTypes = (0, _map["default"])(function (item) {
@@ -137,7 +138,7 @@ var AudiometryChart = function AudiometryChart(props) {
137
138
  data: item
138
139
  };
139
140
  }, removedUndefinedMarks.filter(function (item) {
140
- return (item === null || item === void 0 ? void 0 : item.length) > 0;
141
+ return item.length > 0;
141
142
  }));
142
143
  var seriesData = data.map(function (item) {
143
144
  return {
@@ -175,9 +176,8 @@ var AudiometryChart = function AudiometryChart(props) {
175
176
  }
176
177
  };
177
178
  var dataWithNames = [].concat((0, _toConsumableArray2["default"])(marksWithTypes), (0, _toConsumableArray2["default"])(seriesData)).map(function (item, index) {
178
- var _legends$index;
179
179
  return _objectSpread(_objectSpread({}, item), {}, {
180
- name: (legends === null || legends === void 0 ? void 0 : legends.length) > 0 ? (_legends$index = legends[index]) === null || _legends$index === void 0 ? void 0 : _legends$index.name : 'audiometry-' + index
180
+ name: legends && legends.length > 0 ? legends[index].name : 'audiometry-' + index
181
181
  });
182
182
  });
183
183
  var options = {
@@ -32,6 +32,7 @@ var toTuples = function toTuples(args) {
32
32
  }, args);
33
33
  };
34
34
  var CoordinateLineChart = function CoordinateLineChart(props) {
35
+ var _toolboxTooltip$saveA, _toolboxTooltip$saveA2, _toolboxTooltip$dataV, _legendNames$, _legendNames$2, _legendNames$3, _legendNames$4, _legendNames$5, _legendNames$6;
35
36
  var coordinates = props.coordinates,
36
37
  colors = props.colors,
37
38
  height = props.height,
@@ -54,7 +55,7 @@ var CoordinateLineChart = function CoordinateLineChart(props) {
54
55
  pos = _coordinates[2];
55
56
  var WIDTH_STYLE = getWidthStyle(width, height);
56
57
  (0, _react.useEffect)(function () {
57
- if (toolboxTooltip && toolboxTooltip.saveAsImageWithTitle) {
58
+ if (toolboxTooltip !== null && toolboxTooltip !== void 0 && toolboxTooltip.saveAsImageWithTitle) {
58
59
  setTitle(false);
59
60
  } else {
60
61
  setTitle(true);
@@ -63,15 +64,15 @@ var CoordinateLineChart = function CoordinateLineChart(props) {
63
64
  var handleShowTitle = function handleShowTitle(show) {
64
65
  setTitle(show);
65
66
  };
66
- var myTool = toolboxTooltip && toolboxTooltip.saveAsImageWithTitle && {
67
- myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)(toolboxTooltip.saveAsImageWithTitle.title, handleShowTitle)
67
+ var myTool = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImageWithTitle) && {
68
+ myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImageWithTitle.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : '', handleShowTitle)
68
69
  };
69
- var saveAsImage = toolboxTooltip && toolboxTooltip.saveAsImage && {
70
- saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)(toolboxTooltip.saveAsImage.title)
70
+ var saveAsImage = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImage) && {
71
+ saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA2 = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA2 !== void 0 ? _toolboxTooltip$saveA2 : '')
71
72
  };
72
73
  var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
73
74
  feature: _objectSpread(_objectSpread(_objectSpread({}, myTool), saveAsImage), {}, {
74
- dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)(toolboxTooltip.dataView.title)
75
+ dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
75
76
  })
76
77
  });
77
78
  var reference = toTuples(ref);
@@ -83,7 +84,7 @@ var CoordinateLineChart = function CoordinateLineChart(props) {
83
84
  var options = {
84
85
  color: colors,
85
86
  series: [{
86
- name: legendNames[0] || '',
87
+ name: (_legendNames$ = legendNames === null || legendNames === void 0 ? void 0 : legendNames[0]) !== null && _legendNames$ !== void 0 ? _legendNames$ : '',
87
88
  showSymbol: false,
88
89
  type: 'line',
89
90
  data: reference,
@@ -93,13 +94,13 @@ var CoordinateLineChart = function CoordinateLineChart(props) {
93
94
  type: 'dashed'
94
95
  }
95
96
  }, {
96
- name: legendNames[1] || '',
97
+ name: (_legendNames$2 = legendNames === null || legendNames === void 0 ? void 0 : legendNames[1]) !== null && _legendNames$2 !== void 0 ? _legendNames$2 : '',
97
98
  showSymbol: false,
98
99
  type: 'line',
99
100
  data: preRespiratory,
100
101
  smooth: true
101
102
  }, {
102
- name: legendNames[2] || '',
103
+ name: (_legendNames$3 = legendNames === null || legendNames === void 0 ? void 0 : legendNames[2]) !== null && _legendNames$3 !== void 0 ? _legendNames$3 : '',
103
104
  showSymbol: false,
104
105
  type: 'line',
105
106
  data: posResporatory,
@@ -107,13 +108,13 @@ var CoordinateLineChart = function CoordinateLineChart(props) {
107
108
  }],
108
109
  yAxis: {
109
110
  type: 'value',
110
- name: coordinateNames.y,
111
+ name: coordinateNames === null || coordinateNames === void 0 ? void 0 : coordinateNames.y,
111
112
  nameTextStyle: {
112
113
  fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
113
114
  color: '#000000'
114
115
  },
115
116
  nameGap: 10,
116
- min: -yRangeValues || 0,
117
+ min: yRangeValues ? -yRangeValues : 0,
117
118
  max: yRangeValues || 8,
118
119
  interval: 2,
119
120
  axisTick: {
@@ -139,7 +140,7 @@ var CoordinateLineChart = function CoordinateLineChart(props) {
139
140
  },
140
141
  xAxis: {
141
142
  type: 'value',
142
- name: coordinateNames.x,
143
+ name: coordinateNames === null || coordinateNames === void 0 ? void 0 : coordinateNames.x,
143
144
  nameTextStyle: {
144
145
  verticalAlign: 'top',
145
146
  padding: getPadding(yRangeValues),
@@ -174,13 +175,13 @@ var CoordinateLineChart = function CoordinateLineChart(props) {
174
175
  legend: {
175
176
  top: legendPosition !== null && legendPosition !== void 0 ? legendPosition : 26,
176
177
  data: [{
177
- name: legendNames[0] || '',
178
+ name: (_legendNames$4 = legendNames === null || legendNames === void 0 ? void 0 : legendNames[0]) !== null && _legendNames$4 !== void 0 ? _legendNames$4 : '',
178
179
  icon: _commonStyles.DASHED_LINE_ICON
179
180
  }, {
180
- name: legendNames[1] || '',
181
+ name: (_legendNames$5 = legendNames === null || legendNames === void 0 ? void 0 : legendNames[1]) !== null && _legendNames$5 !== void 0 ? _legendNames$5 : '',
181
182
  icon: _commonStyles.STRAIGHT_LINE_ICON
182
183
  }, {
183
- name: legendNames[2] || '',
184
+ name: (_legendNames$6 = legendNames === null || legendNames === void 0 ? void 0 : legendNames[2]) !== null && _legendNames$6 !== void 0 ? _legendNames$6 : '',
184
185
  icon: _commonStyles.STRAIGHT_LINE_ICON
185
186
  }],
186
187
  itemGap: 30,
@@ -20,12 +20,13 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
20
20
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
21
21
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
22
22
  var clickBar = exports.clickBar = function clickBar(item) {
23
- if (item && 'data' in item && 'value' in item.data) {
23
+ if ('data' in item && 'value' in item.data) {
24
24
  var value = item.data.value;
25
25
  window.alert(value);
26
26
  }
27
27
  };
28
28
  var DivergingStackedBarChart = function DivergingStackedBarChart(props) {
29
+ var _toolboxTooltip$saveA, _toolboxTooltip$saveA2, _toolboxTooltip$dataV;
29
30
  var data = props.data,
30
31
  width = props.width,
31
32
  legendType = props.legendType,
@@ -48,7 +49,7 @@ var DivergingStackedBarChart = function DivergingStackedBarChart(props) {
48
49
  click: onClickBar
49
50
  };
50
51
  (0, _react.useEffect)(function () {
51
- if (toolboxTooltip && toolboxTooltip.saveAsImageWithTitle) {
52
+ if (toolboxTooltip !== null && toolboxTooltip !== void 0 && toolboxTooltip.saveAsImageWithTitle) {
52
53
  setTitle(false);
53
54
  } else {
54
55
  setTitle(true);
@@ -57,6 +58,7 @@ var DivergingStackedBarChart = function DivergingStackedBarChart(props) {
57
58
  (0, _react.useEffect)(function () {
58
59
  data.seriesData.map( /*#__PURE__*/function () {
59
60
  var _ref = (0, _asyncToGenerator2["default"])( /*#__PURE__*/_regenerator["default"].mark(function _callee(item) {
61
+ var _item$label;
60
62
  var rich;
61
63
  return _regenerator["default"].wrap(function _callee$(_context) {
62
64
  while (1) switch (_context.prev = _context.next) {
@@ -69,7 +71,7 @@ var DivergingStackedBarChart = function DivergingStackedBarChart(props) {
69
71
  case 2:
70
72
  _context.t0 = _defineProperty2["default"];
71
73
  _context.t1 = {};
72
- _context.t2 = (0, _auxiliarFunctions.changeSpaceForUnderline)(item.label);
74
+ _context.t2 = (0, _auxiliarFunctions.changeSpaceForUnderline)((_item$label = item.label) !== null && _item$label !== void 0 ? _item$label : '');
73
75
  _context.next = 7;
74
76
  return (0, _auxiliarFunctions.convertImageToBase64FromUrl)(item.image);
75
77
  case 7:
@@ -83,7 +85,8 @@ var DivergingStackedBarChart = function DivergingStackedBarChart(props) {
83
85
  };
84
86
  rich = (0, _context.t0)(_context.t1, _context.t2, _context.t5);
85
87
  if (!richData.find(function (itemRich) {
86
- return (0, _auxiliarFunctions.changeSpaceForUnderline)(item.label) in itemRich;
88
+ var _item$label2;
89
+ return (0, _auxiliarFunctions.changeSpaceForUnderline)((_item$label2 = item.label) !== null && _item$label2 !== void 0 ? _item$label2 : '') in itemRich;
87
90
  })) {
88
91
  setRichDate(function (state) {
89
92
  return [].concat((0, _toConsumableArray2["default"])(state), [rich]);
@@ -99,20 +102,22 @@ var DivergingStackedBarChart = function DivergingStackedBarChart(props) {
99
102
  return _ref.apply(this, arguments);
100
103
  };
101
104
  }());
105
+ // it doesn't need the missing dependency
106
+ // eslint-disable-next-line react-hooks/exhaustive-deps
102
107
  }, [richData]);
103
108
  var handleShowTitle = function handleShowTitle(show) {
104
109
  setTitle(show);
105
110
  };
106
- var myTool = toolboxTooltip && toolboxTooltip.saveAsImageWithTitle && {
107
- myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)(toolboxTooltip.saveAsImageWithTitle.title, handleShowTitle)
111
+ var myTool = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImageWithTitle) && {
112
+ myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImageWithTitle.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : '', handleShowTitle)
108
113
  };
109
- var saveAsImage = toolboxTooltip && toolboxTooltip.saveAsImage && {
110
- saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)(toolboxTooltip.saveAsImage.title)
114
+ var saveAsImage = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImage) && {
115
+ saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA2 = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA2 !== void 0 ? _toolboxTooltip$saveA2 : '')
111
116
  };
112
117
  var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
113
118
  right: marginRightToolbox || '8.7%',
114
119
  feature: _objectSpread(_objectSpread(_objectSpread({}, myTool), saveAsImage), {}, {
115
- dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)(toolboxTooltip.dataView.title)
120
+ dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
116
121
  })
117
122
  });
118
123
  var exportToCSV = function exportToCSV() {
@@ -180,7 +185,8 @@ var DivergingStackedBarChart = function DivergingStackedBarChart(props) {
180
185
  },
181
186
  title: {
182
187
  left: legendType === 'scroll' ? '0.1%' : '4%',
183
- top: legendType === 'scroll' && '5.7%',
188
+ // top: legendType === 'scroll' && '5.7%',
189
+ top: legendType,
184
190
  show: title,
185
191
  text: titleProps,
186
192
  textAlign: 'left',
@@ -227,7 +233,10 @@ var DivergingStackedBarChart = function DivergingStackedBarChart(props) {
227
233
  return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
228
234
  style: _commonStyles.CHART_WIDTH,
229
235
  opts: (0, _auxiliarFunctions.getWidthOpts)(width || 'auto'),
230
- option: options,
236
+ option: options
237
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
238
+ // @ts-ignore
239
+ ,
231
240
  onEvents: clickEvent
232
241
  }), props.showCSVDownload && /*#__PURE__*/_react["default"].createElement(_commonStyles.CsvDownloadButtonStyle, {
233
242
  onClick: exportToCSV
@@ -6,5 +6,5 @@ export interface IDonutProps extends IProps {
6
6
  centerPieValueFontSize?: number;
7
7
  selectedMode?: boolean;
8
8
  }
9
- export declare const DonutChart: (props: IDonutProps) => React.JSX.Element;
9
+ declare const DonutChart: (props: IDonutProps) => React.JSX.Element;
10
10
  export default DonutChart;
@@ -5,7 +5,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports["default"] = exports.DonutChart = void 0;
8
+ exports["default"] = void 0;
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
10
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
11
  var _react = _interopRequireWildcard(require("react"));
@@ -18,7 +18,8 @@ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return
18
18
  function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
19
19
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
20
20
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
21
- var DonutChart = exports.DonutChart = function DonutChart(props) {
21
+ var DonutChart = function DonutChart(props) {
22
+ var _toolboxTooltip$saveA, _toolboxTooltip$saveA2, _toolboxTooltip$dataV;
22
23
  var titleProps = props.title,
23
24
  resultFormatType = props.resultFormatType,
24
25
  toolboxTooltip = props.toolboxTooltip,
@@ -41,7 +42,7 @@ var DonutChart = exports.DonutChart = function DonutChart(props) {
41
42
  title = _useState2[0],
42
43
  setTitle = _useState2[1];
43
44
  (0, _react.useEffect)(function () {
44
- if (toolboxTooltip && toolboxTooltip.saveAsImageWithTitle) {
45
+ if (toolboxTooltip !== null && toolboxTooltip !== void 0 && toolboxTooltip.saveAsImageWithTitle) {
45
46
  setTitle(false);
46
47
  } else {
47
48
  setTitle(true);
@@ -50,15 +51,15 @@ var DonutChart = exports.DonutChart = function DonutChart(props) {
50
51
  var handleShowTitle = function handleShowTitle(show) {
51
52
  setTitle(show);
52
53
  };
53
- var myTool = toolboxTooltip && toolboxTooltip.saveAsImageWithTitle && {
54
- myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)(toolboxTooltip.saveAsImageWithTitle.title, handleShowTitle)
54
+ var myTool = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImageWithTitle) && {
55
+ myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImageWithTitle.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : '', handleShowTitle)
55
56
  };
56
- var saveAsImage = toolboxTooltip && toolboxTooltip.saveAsImage && {
57
- saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)(toolboxTooltip.saveAsImage.title)
57
+ var saveAsImage = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImage) && {
58
+ saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA2 = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA2 !== void 0 ? _toolboxTooltip$saveA2 : '')
58
59
  };
59
60
  var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
60
61
  feature: _objectSpread(_objectSpread(_objectSpread({}, myTool), saveAsImage), {}, {
61
- dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)(toolboxTooltip.dataView.title)
62
+ dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
62
63
  })
63
64
  });
64
65
  var xData = (0, _map["default"])(function (item) {
@@ -74,8 +75,8 @@ var DonutChart = exports.DonutChart = function DonutChart(props) {
74
75
  var percent = (0, _auxiliarFunctions.getPercentage)(value, totalValues);
75
76
  var valueWithPercent = resultFormatType === 'percent' ? value + ' (' + percent + '%)' : value;
76
77
  var valueToShow = typeof resultFormatType === 'function' ? resultFormatType(value) : valueWithPercent;
77
- var label = tooltip && tooltip.label ? tooltip.label + ': ' + name + '<br>' : '';
78
- var result = tooltip && tooltip.result ? marker + tooltip.result + ': ' + valueToShow : '';
78
+ var label = tooltip !== null && tooltip !== void 0 && tooltip.label ? tooltip.label + ': ' + name + '<br>' : '';
79
+ var result = tooltip !== null && tooltip !== void 0 && tooltip.result ? marker + tooltip.result + ': ' + valueToShow : '';
79
80
  return tooltip ? label + result : marker + name + ': ' + valueToShow;
80
81
  };
81
82
  var formatDonutLabel = function formatDonutLabel(value) {
@@ -17,6 +17,7 @@ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e;
17
17
  function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
18
18
  function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2["default"])(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
19
19
  var ForecastAreaChart = function ForecastAreaChart(props) {
20
+ var _toolboxTooltip$saveA, _toolboxTooltip$dataV;
20
21
  var data = props.data,
21
22
  xType = props.xType,
22
23
  color = props.color,
@@ -42,7 +43,7 @@ var ForecastAreaChart = function ForecastAreaChart(props) {
42
43
  });
43
44
  var formatLabel = function formatLabel(chartValues) {
44
45
  var data = chartValues.data;
45
- return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)).toString() : (0, _auxiliarFunctions.takeLabelComplement)(Number(Number(data).toFixed(2)), yComplement).toString();
46
+ return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)).toString() : (0, _auxiliarFunctions.takeLabelComplement)(Number(Number(data).toFixed(2)), yComplement !== null && yComplement !== void 0 ? yComplement : '').toString();
46
47
  };
47
48
  var dinamicData = function dinamicData(item, charts) {
48
49
  var dataRange = item.end - item.start;
@@ -82,20 +83,20 @@ var ForecastAreaChart = function ForecastAreaChart(props) {
82
83
  label = _ref2.label,
83
84
  result = _ref2.result;
84
85
  var complement = tooltipComplement ? tooltipComplement : '';
85
- var values = yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)) : (0, _auxiliarFunctions.takeLabelComplement)(Number(Number(data).toFixed(2)), yComplement);
86
+ var values = yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)) : (0, _auxiliarFunctions.takeLabelComplement)(Number(Number(data).toFixed(2)), yComplement !== null && yComplement !== void 0 ? yComplement : '');
86
87
  return "".concat(label, ": ").concat((0, _auxiliarFunctions.formatTooltipWithHours)(axisValueLabel), " <br>\n ").concat(result, ": ").concat(values, " <br>\n ").concat(complement);
87
88
  };
88
89
  var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
89
90
  showTitle: false,
90
91
  right: '9.52%',
91
92
  feature: {
92
- saveAsImage: toolboxTooltip.saveAsImage && (0, _auxiliarFunctions.getSaveAsImage)(toolboxTooltip.saveAsImage.title),
93
- dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)(toolboxTooltip.dataView.title)
93
+ saveAsImage: toolboxTooltip.saveAsImage && (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : ''),
94
+ dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
94
95
  }
95
96
  });
96
97
  var scrollable = xData.length > 5 ? [{
97
98
  type: 'inside',
98
- startValue: lineMarkValue - 2,
99
+ startValue: lineMarkValue && lineMarkValue - 2,
99
100
  endValue: lineMarkValue,
100
101
  zoomLock: true,
101
102
  zoomOnMouseWheel: 'shift'
@@ -103,13 +104,15 @@ var ForecastAreaChart = function ForecastAreaChart(props) {
103
104
  bottom: 10,
104
105
  show: true,
105
106
  type: 'slider',
106
- startValue: lineMarkValue - 1,
107
- endValue: lineMarkValue + 3,
107
+ startValue: lineMarkValue && lineMarkValue - 1,
108
+ endValue: lineMarkValue && lineMarkValue + 3,
108
109
  labelFormatter: function labelFormatter(_, item) {
109
110
  return (0, _auxiliarFunctions.formatTime)(item, 'dd/MM/yyyy');
110
111
  }
111
112
  }] : [];
112
113
  var options = {
114
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
115
+ // @ts-ignore
113
116
  series: [{
114
117
  type: 'line',
115
118
  name: forecastChartLegends ? forecastChartLegends.forecast : '',
@@ -138,17 +141,14 @@ var ForecastAreaChart = function ForecastAreaChart(props) {
138
141
  silent: true,
139
142
  symbol: '',
140
143
  label: {
141
- formatter: forecastChartLegends.lineMark,
144
+ formatter: forecastChartLegends === null || forecastChartLegends === void 0 ? void 0 : forecastChartLegends.lineMark,
142
145
  show: true,
143
146
  color: lineMarkColor || '#000000'
144
147
  },
145
148
  animation: false,
146
149
  data: [{
147
- name: forecastChartLegends.lineMark || 'markLine',
148
- // eslint-disable-next-line @stylistic/max-len
149
- // eslint-disable-next-line @typescript-eslint/ban-ts-comment
150
- // @ts-ignore TODO: remove this XGH
151
- xAxis: xData[lineMarkValue - 1].toString()
150
+ name: (forecastChartLegends === null || forecastChartLegends === void 0 ? void 0 : forecastChartLegends.lineMark) || 'markLine',
151
+ xAxis: lineMarkValue && xData[lineMarkValue - 1].toString()
152
152
  }],
153
153
  lineStyle: {
154
154
  width: 1,
@@ -165,8 +165,8 @@ var ForecastAreaChart = function ForecastAreaChart(props) {
165
165
  }
166
166
  }, {
167
167
  type: 'line',
168
- name: forecastChartLegends.current || '',
169
- data: (0, _take["default"])(lineMarkValue, yData),
168
+ name: (forecastChartLegends === null || forecastChartLegends === void 0 ? void 0 : forecastChartLegends.current) || '',
169
+ data: lineMarkValue && (0, _take["default"])(lineMarkValue, yData),
170
170
  label: {
171
171
  formatter: typeof yComplement === 'function' ? yComplement.toString() : formatLabel,
172
172
  show: false,
@@ -224,7 +224,7 @@ var ForecastAreaChart = function ForecastAreaChart(props) {
224
224
  axisLabel: {
225
225
  margin: yType === 'time' ? 16 : 14,
226
226
  formatter: function formatter(item) {
227
- return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(item)).toString() : (0, _auxiliarFunctions.takeLabelComplement)(Number(item.toFixed(2)), yComplement).toString();
227
+ return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(item)).toString() : (0, _auxiliarFunctions.takeLabelComplement)(Number(item.toFixed(2)), yComplement !== null && yComplement !== void 0 ? yComplement : '').toString();
228
228
  },
229
229
  fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
230
230
  fontSize: fontLabelSize || 11.5,
@@ -250,10 +250,12 @@ var ForecastAreaChart = function ForecastAreaChart(props) {
250
250
  }), {}, {
251
251
  show: true
252
252
  }),
253
+ // eslint-disable-next-line @typescript-eslint/ban-ts-comment
254
+ // @ts-ignore
253
255
  legend: {
254
256
  top: 20,
255
257
  selectedMode: false,
256
- data: [forecastChartLegends.current, forecastChartLegends.forecast],
258
+ data: [forecastChartLegends === null || forecastChartLegends === void 0 ? void 0 : forecastChartLegends.current, forecastChartLegends === null || forecastChartLegends === void 0 ? void 0 : forecastChartLegends.forecast],
257
259
  itemGap: 30,
258
260
  textStyle: {
259
261
  fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
@@ -273,7 +275,7 @@ var ForecastAreaChart = function ForecastAreaChart(props) {
273
275
  color: '#000000'
274
276
  }
275
277
  },
276
- tooltip: tooltipProps && {
278
+ tooltip: {
277
279
  formatter: formatSingleTooltip,
278
280
  trigger: 'axis',
279
281
  backgroundColor: '#00000099',