amazing-react-charts 1.2.3 → 1.2.5

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 (39) hide show
  1. package/commonStyles.d.ts +26 -2
  2. package/commonStyles.js +37 -14
  3. package/core/area-chart/AreaChart.js +176 -195
  4. package/core/audiometry-chart/AudiometryChart.d.ts +7 -7
  5. package/core/audiometry-chart/AudiometryChart.js +135 -154
  6. package/core/coordinate-line-chart/CoordinateLineChart.d.ts +5 -5
  7. package/core/coordinate-line-chart/CoordinateLineChart.js +156 -169
  8. package/core/diverging-stacked-bar-chart/DivergingStackedBarChart.d.ts +13 -18
  9. package/core/diverging-stacked-bar-chart/DivergingStackedBarChart.js +102 -116
  10. package/core/donut-chart/DonutChart.d.ts +3 -3
  11. package/core/donut-chart/DonutChart.js +109 -116
  12. package/core/forecast-area-chart/ForecastAreaChart.d.ts +1 -1
  13. package/core/forecast-area-chart/ForecastAreaChart.js +181 -204
  14. package/core/gauge-chart/GaugeChart.js +91 -85
  15. package/core/horizontal-bar-chart/HorizontalBarChart.d.ts +1 -6
  16. package/core/horizontal-bar-chart/HorizontalBarChart.js +175 -199
  17. package/core/line-chart/LineChart.d.ts +2 -2
  18. package/core/line-chart/LineChart.js +124 -165
  19. package/core/multipurpose-chart/MultipurposeChart.d.ts +5 -5
  20. package/core/multipurpose-chart/MultipurposeChart.js +94 -129
  21. package/core/pictorial-chart/PictorialChart.js +88 -78
  22. package/core/pie-chart/PieChart.d.ts +10 -10
  23. package/core/pie-chart/PieChart.js +93 -101
  24. package/core/pyramid-bar-chart/PyramidBarChart.d.ts +7 -7
  25. package/core/pyramid-bar-chart/PyramidBarChart.js +108 -112
  26. package/core/pyramid-chart/PyramidChart.d.ts +3 -3
  27. package/core/pyramid-chart/PyramidChart.js +61 -60
  28. package/core/radar-chart/RadarChart.d.ts +1 -1
  29. package/core/radar-chart/RadarChart.js +64 -60
  30. package/core/stacked-bar-chart/StackedBarChart.d.ts +5 -5
  31. package/core/stacked-bar-chart/StackedBarChart.js +191 -220
  32. package/core/types.d.ts +1 -1
  33. package/core/vertical-bar-chart/VerticalBarChart.d.ts +1 -51
  34. package/core/vertical-bar-chart/VerticalBarChart.js +134 -232
  35. package/lib/auxiliarFunctions.d.ts +71 -1
  36. package/lib/auxiliarFunctions.js +83 -1
  37. package/package.json +17 -17
  38. package/index.d.ts +0 -15
  39. package/index.js +0 -111
package/commonStyles.d.ts CHANGED
@@ -10,6 +10,7 @@ export declare const CHART_HEIGHT: {
10
10
  width: string;
11
11
  height: number;
12
12
  };
13
+ export declare const fontFamily = "Roboto, Helvetica, Arial, sans-serif";
13
14
  export declare const TOOLBOX_DEFAULT_PROPS: {
14
15
  showTitle: boolean;
15
16
  right: string;
@@ -19,14 +20,37 @@ export declare const TOOLTIP_DEFAULT_PROPS: {
19
20
  backgroundColor: string;
20
21
  extraCssText: string;
21
22
  textStyle: {
22
- fontFamily: string;
23
23
  fontSize: number;
24
24
  color: string;
25
+ fontFamily: string;
25
26
  };
26
27
  };
28
+ export declare const COMMON_STYLE: {
29
+ fontWeight: number;
30
+ color: string;
31
+ fontFamily: string;
32
+ };
33
+ export declare const LEGEND_STYLE: {
34
+ fontWeight: number;
35
+ color: string;
36
+ fontFamily: string;
37
+ fontSize: number;
38
+ };
39
+ export declare const TITLE_STYLE: {
40
+ fontWeight: number;
41
+ color: string;
42
+ fontFamily: string;
43
+ fontSize: number;
44
+ };
45
+ export declare const AXIS_SPLIT_LINE: {
46
+ type: string;
47
+ opacity: number;
48
+ color: string;
49
+ };
27
50
  export declare const PictorialWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
28
51
  export declare const DonutWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
29
52
  export declare const ChartStorieWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
53
+ export declare const ChartContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
30
54
  export declare const ChartWrapper: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
31
55
  export declare const ChartTitle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLHeadingElement>, HTMLHeadingElement>, never>> & string;
32
56
  export declare const GaugeLegendContainer: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
@@ -35,4 +59,4 @@ export declare const GaugeCircle: import("styled-components/dist/types").IStyled
35
59
  color?: string;
36
60
  }>> & string;
37
61
  export declare const GaugeLegend: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
38
- export declare const CsvDownloadButtonStyle: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
62
+ export declare const CsvDownloadButton: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<import("react").DetailedHTMLProps<import("react").ButtonHTMLAttributes<HTMLButtonElement>, HTMLButtonElement>, never>> & string;
package/commonStyles.js CHANGED
@@ -4,12 +4,17 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.TOOLTIP_DEFAULT_PROPS = exports.TOOLBOX_DEFAULT_PROPS = exports.STRAIGHT_LINE_ICON = exports.PictorialWrapper = exports.MIN_WIDTH = exports.GaugeLegendContent = exports.GaugeLegendContainer = exports.GaugeLegend = exports.GaugeCircle = exports.DonutWrapper = exports.DASHED_LINE_ICON = exports.CsvDownloadButtonStyle = exports.ChartWrapper = exports.ChartTitle = exports.ChartStorieWrapper = exports.CHART_WIDTH = exports.CHART_HEIGHT = void 0;
7
+ exports.fontFamily = exports.TOOLTIP_DEFAULT_PROPS = exports.TOOLBOX_DEFAULT_PROPS = exports.TITLE_STYLE = exports.STRAIGHT_LINE_ICON = exports.PictorialWrapper = exports.MIN_WIDTH = exports.LEGEND_STYLE = exports.GaugeLegendContent = exports.GaugeLegendContainer = exports.GaugeLegend = exports.GaugeCircle = exports.DonutWrapper = exports.DASHED_LINE_ICON = exports.CsvDownloadButton = exports.ChartWrapper = exports.ChartTitle = exports.ChartStorieWrapper = exports.ChartContainer = exports.COMMON_STYLE = exports.CHART_WIDTH = exports.CHART_HEIGHT = exports.AXIS_SPLIT_LINE = void 0;
8
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
10
  var _styledComponents = _interopRequireDefault(require("styled-components"));
10
11
  var _theme = require("flipper-ui/theme");
11
- var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10;
12
- var neutral = _theme.theme.colors.neutral;
12
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11;
13
+ 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; }
14
+ 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; }
15
+ var _theme$colors = _theme.theme.colors,
16
+ gray = _theme$colors.gray,
17
+ neutral = _theme$colors.neutral;
13
18
  var STRAIGHT_LINE_ICON = exports.STRAIGHT_LINE_ICON = 'path://M0 0H25H50V2H25H0V0Z';
14
19
  var DASHED_LINE_ICON = exports.DASHED_LINE_ICON = 'path://M180 1000 l0 -40 200 0 200 0 0 40 0 40 -200 0 -200 0 0 -40z, M810 ' + '1000 l0 -40 200 0 200 0 0 40 0 40 -200 0 -200 0 0 -40zm, M1440 1000 l0 ' + '-40 200 0 200 0 0 40 0 40 -200 0 -200 0 0 -40z';
15
20
  var MIN_WIDTH = exports.MIN_WIDTH = {
@@ -22,6 +27,7 @@ var CHART_HEIGHT = exports.CHART_HEIGHT = {
22
27
  width: '99.9%',
23
28
  height: 300
24
29
  };
30
+ var fontFamily = exports.fontFamily = 'Roboto, Helvetica, Arial, sans-serif';
25
31
  var TOOLBOX_DEFAULT_PROPS = exports.TOOLBOX_DEFAULT_PROPS = {
26
32
  showTitle: false,
27
33
  right: '9.52%'
@@ -29,22 +35,39 @@ var TOOLBOX_DEFAULT_PROPS = exports.TOOLBOX_DEFAULT_PROPS = {
29
35
  var TOOLTIP_DEFAULT_PROPS = exports.TOOLTIP_DEFAULT_PROPS = {
30
36
  show: true,
31
37
  backgroundColor: "".concat(neutral[200], "90"),
32
- extraCssText: 'border: none; padding: 5px;',
38
+ extraCssText: 'border: none; padding: 6px;',
33
39
  textStyle: {
34
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
35
- fontSize: 12,
36
- color: neutral[50]
40
+ fontSize: 11.5,
41
+ color: neutral[50],
42
+ fontFamily: fontFamily
37
43
  }
38
44
  };
45
+ var COMMON_STYLE = exports.COMMON_STYLE = {
46
+ fontWeight: 400,
47
+ color: neutral[200],
48
+ fontFamily: fontFamily
49
+ };
50
+ var LEGEND_STYLE = exports.LEGEND_STYLE = _objectSpread({
51
+ fontSize: 11.5
52
+ }, COMMON_STYLE);
53
+ var TITLE_STYLE = exports.TITLE_STYLE = _objectSpread({
54
+ fontSize: 16
55
+ }, COMMON_STYLE);
56
+ var AXIS_SPLIT_LINE = exports.AXIS_SPLIT_LINE = {
57
+ type: 'dashed',
58
+ opacity: 0.2,
59
+ color: gray[800]
60
+ };
39
61
  var PictorialWrapper = exports.PictorialWrapper = _styledComponents["default"].div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2["default"])(["\n width: 330px;\n margin: 0 auto;\n"])));
40
62
  var DonutWrapper = exports.DonutWrapper = _styledComponents["default"].div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2["default"])(["\n width: 500px;\n margin: 0 auto;\n"])));
41
63
  var ChartStorieWrapper = exports.ChartStorieWrapper = _styledComponents["default"].div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2["default"])(["\n width: 50%;\n margin: 0 auto;\n"])));
42
- var ChartWrapper = exports.ChartWrapper = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n position: relative;\n"])));
43
- var ChartTitle = exports.ChartTitle = _styledComponents["default"].h1(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: Roboto, Helvetica, Arial, sans-serif;\n color: ", ";\n top: 5;\n margin: 0px;\n font-size: 16px;\n font-weight: 400;\n position: absolute;\n"])), neutral[200]);
44
- var GaugeLegendContainer = exports.GaugeLegendContainer = _styledComponents["default"].div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n gap: 16px;\n align-items: center;\n justify-content: center;\n"])));
45
- var GaugeLegendContent = exports.GaugeLegendContent = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 6px;\n font-family: Roboto, Helvetica, Arial, sans-serif;\n"])));
46
- var GaugeCircle = exports.GaugeCircle = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n width: 20px;\n height: 20px;\n margin-bottom: 4px;\n border-radius: 100%;\n background-color: ", ";\n"])), function (props) {
64
+ var ChartContainer = exports.ChartContainer = _styledComponents["default"].div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n"])));
65
+ var ChartWrapper = exports.ChartWrapper = _styledComponents["default"].div(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2["default"])(["\n width: 100%;\n position: relative;\n"])));
66
+ var ChartTitle = exports.ChartTitle = _styledComponents["default"].h1(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2["default"])(["\n font-family: Roboto, Helvetica, Arial, sans-serif;\n color: ", ";\n top: 5;\n margin: 0px;\n font-size: 16px;\n font-weight: 400;\n position: absolute;\n"])), neutral[200]);
67
+ var GaugeLegendContainer = exports.GaugeLegendContainer = _styledComponents["default"].div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n gap: 16px;\n align-items: center;\n justify-content: center;\n"])));
68
+ var GaugeLegendContent = exports.GaugeLegendContent = _styledComponents["default"].div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2["default"])(["\n display: flex;\n flex-direction: column;\n align-items: center;\n gap: 6px;\n font-family: Roboto, Helvetica, Arial, sans-serif;\n"])));
69
+ var GaugeCircle = exports.GaugeCircle = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n width: 20px;\n height: 20px;\n margin-bottom: 4px;\n border-radius: 100%;\n background-color: ", ";\n"])), function (props) {
47
70
  return props.color;
48
71
  });
49
- var GaugeLegend = exports.GaugeLegend = _styledComponents["default"].div(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: 14px;\n"])));
50
- var CsvDownloadButtonStyle = exports.CsvDownloadButtonStyle = _styledComponents["default"].button(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: bold;\n background: ", ";\n text-transform: uppercase;\n border: none;\n width: 40px;\n height: 20px;\n cursor: pointer;\n display: block;\n position: absolute;\n margin-top: -295px;\n margin-left: 80%;\n\n &:hover::after {\n content: 'Save as CSV';\n position: absolute;\n text-transform: none;\n font-weight: lighter;\n top: 123%;\n left: 50%;\n transform: translateX(-50%);\n background-color: ", ";\n opacity: 55%;\n color: ", ";\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 12px;\n height: 19px;\n white-space: nowrap;\n text-align: center;\n display: flex;\n align-items: center;\n }\n"])), neutral[50], neutral[200], neutral[50]);
72
+ var GaugeLegend = exports.GaugeLegend = _styledComponents["default"].div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2["default"])(["\n font-size: 14px;\n"])));
73
+ var CsvDownloadButton = exports.CsvDownloadButton = _styledComponents["default"].button(_templateObject11 || (_templateObject11 = (0, _taggedTemplateLiteral2["default"])(["\n font-weight: bold;\n background: ", ";\n text-transform: uppercase;\n border: none;\n width: 40px;\n height: 20px;\n cursor: pointer;\n display: block;\n position: absolute;\n margin-top: -295px;\n margin-left: 80%;\n\n &:hover::after {\n content: 'Save as CSV';\n position: absolute;\n text-transform: none;\n font-weight: lighter;\n top: 123%;\n left: 50%;\n transform: translateX(-50%);\n background-color: ", ";\n opacity: 55%;\n color: ", ";\n padding: 4px 8px;\n border-radius: 4px;\n font-size: 12px;\n height: 19px;\n white-space: nowrap;\n text-align: center;\n display: flex;\n align-items: center;\n }\n"])), neutral[50], neutral[200], neutral[50]);
@@ -1,62 +1,89 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof3 = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports["default"] = void 0;
8
- var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
9
9
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _typeof2 = _interopRequireDefault(require("@babel/runtime/helpers/typeof"));
10
11
  var _react = _interopRequireDefault(require("react"));
11
- var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
12
+ var _charts = require("echarts/charts");
13
+ var _components = require("echarts/components");
14
+ var echarts = _interopRequireWildcard(require("echarts/core"));
15
+ var _renderers = require("echarts/renderers");
16
+ var _core2 = _interopRequireDefault(require("echarts-for-react/lib/core"));
12
17
  var _auxiliarFunctions = require("../../lib/auxiliarFunctions");
13
18
  var _commonStyles = require("../../commonStyles");
14
19
  var _theme = require("flipper-ui/theme");
20
+ function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
21
+ function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof3(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 && {}.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; }
15
22
  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; }
16
23
  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; }
17
24
  var _theme$colors = _theme.theme.colors,
18
25
  blue = _theme$colors.blue,
19
- gray = _theme$colors.gray,
20
26
  neutral = _theme$colors.neutral;
27
+ echarts.use([_components.GridComponent, _components.TitleComponent, _renderers.CanvasRenderer, _components.LegendComponent, _components.TooltipComponent, _components.ToolboxComponent, _charts.LineChart, _components.DataZoomInsideComponent, _components.DataZoomSliderComponent]);
21
28
  var AreaChart = function AreaChart(props) {
22
29
  var _toolboxTooltip$saveA, _toolboxTooltip$dataV;
23
30
  var data = props.data,
24
- xType = props.xType,
31
+ grid = props.grid,
25
32
  color = props.color,
26
- tooltipProps = props.tooltip,
33
+ width = props.width,
34
+ title = props.title,
27
35
  yType = props.yType,
28
- _props$lineMarkValue = props.lineMarkValue,
29
- lineMarkValue = _props$lineMarkValue === void 0 ? 0 : _props$lineMarkValue,
30
- _props$lineMarkColor = props.lineMarkColor,
31
- lineMarkColor = _props$lineMarkColor === void 0 ? '' : _props$lineMarkColor,
32
- _props$lineMakeName = props.lineMakeName,
33
- lineMakeName = _props$lineMakeName === void 0 ? '' : _props$lineMakeName,
34
- tooltipComplement = props.tooltipComplement,
35
- yComplement = props.yComplement,
36
+ xType = props.xType,
37
+ tooltip = props.tooltip,
36
38
  dateFormat = props.dateFormat,
37
- gridProps = props.grid,
38
- width = props.width,
39
+ yComplement = props.yComplement,
39
40
  rotateLabel = props.rotateLabel,
41
+ scrollStart = props.scrollStart,
40
42
  fontLabelSize = props.fontLabelSize,
41
- titleProps = props.title,
42
43
  toolboxTooltip = props.toolboxTooltip,
43
- scrollStart = props.scrollStart;
44
- var markLine = lineMarkValue && data.map(function () {
45
- return lineMarkValue;
44
+ tooltipComplement = props.tooltipComplement,
45
+ _props$lineMarkName = props.lineMarkName,
46
+ lineMarkName = _props$lineMarkName === void 0 ? '' : _props$lineMarkName,
47
+ _props$lineMarkValue = props.lineMarkValue,
48
+ lineMarkValue = _props$lineMarkValue === void 0 ? 0 : _props$lineMarkValue,
49
+ _props$lineMarkColor = props.lineMarkColor,
50
+ lineMarkColor = _props$lineMarkColor === void 0 ? '' : _props$lineMarkColor;
51
+ var xData = data.map(function (item) {
52
+ return item.label;
46
53
  });
47
- var yData = data.map(function (item) {
54
+ var chartData = data.map(function (item) {
48
55
  return item.result;
49
56
  });
50
- var xData = data.map(function (item) {
51
- return item.label;
57
+ var markLineData = lineMarkValue && xData.map(function () {
58
+ return lineMarkValue;
52
59
  });
53
- var WIDTH_OPTS = {
54
- width: width || 'auto'
55
- };
56
- var formatLabel = function formatLabel(chartValues) {
60
+ var formatDinamicLabel = function formatDinamicLabel(chartValues) {
57
61
  var data = chartValues.data;
58
62
  return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)).toString() + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(Number(data), yComplement !== null && yComplement !== void 0 ? yComplement : '').toString();
59
63
  };
64
+ var formatSingleTooltip = function formatSingleTooltip(chartValues) {
65
+ var _chartValues$ = chartValues[0],
66
+ axisValueLabel = _chartValues$.axisValueLabel,
67
+ data = _chartValues$.data;
68
+ var label = tooltip === null || tooltip === void 0 ? void 0 : tooltip.label;
69
+ var result = tooltip === null || tooltip === void 0 ? void 0 : tooltip.result;
70
+ var complement = tooltipComplement ? tooltipComplement : '';
71
+ var values = yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)) + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(Number(data), yComplement !== null && yComplement !== void 0 ? yComplement : '').toString();
72
+ return "".concat(label, ": ").concat((0, _auxiliarFunctions.formatTooltip)(axisValueLabel, dateFormat), " <br>\n ").concat(result, ": ").concat(values, " <br>\n ").concat(complement);
73
+ };
74
+ var formatLabel = function formatLabel(item) {
75
+ var data = item.data;
76
+ if (typeof yComplement === 'function' && (0, _typeof2["default"])(item) === 'object') {
77
+ return yComplement(item.data);
78
+ }
79
+ if (typeof yComplement === 'function') {
80
+ return yComplement;
81
+ }
82
+ if (yType === 'time') {
83
+ return (0, _auxiliarFunctions.timeConvert)(Number(data)).toString() + 'h';
84
+ }
85
+ return (0, _auxiliarFunctions.takeLabelComplement)(Number(data), '').toString();
86
+ };
60
87
  var dinamicData = function dinamicData(item, charts) {
61
88
  var isTime = yType === 'time' ? 3400 : 4500;
62
89
  var dataRange = item.end - item.start;
@@ -65,12 +92,11 @@ var AreaChart = function AreaChart(props) {
65
92
  return charts.setOption({
66
93
  series: [{
67
94
  label: {
68
- formatter: formatLabel,
69
95
  show: true,
70
- position: 'top',
71
- fontSize: yType === 'time' ? 10 : 11.5,
96
+ distance: 1.1,
72
97
  color: neutral[200],
73
- distance: 1.1
98
+ formatter: formatDinamicLabel,
99
+ fontSize: yType === 'time' ? 10 : 11.5
74
100
  }
75
101
  }]
76
102
  });
@@ -83,22 +109,40 @@ var AreaChart = function AreaChart(props) {
83
109
  }]
84
110
  });
85
111
  };
86
- var formatSingleTooltip = function formatSingleTooltip(chartValues) {
87
- var label = tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.label;
88
- var result = tooltipProps === null || tooltipProps === void 0 ? void 0 : tooltipProps.result;
89
- var _chartValues$ = chartValues[0],
90
- axisValueLabel = _chartValues$.axisValueLabel,
91
- data = _chartValues$.data;
92
- var complement = tooltipComplement ? tooltipComplement : '';
93
- var values = yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(Number(data)) + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(Number(data), yComplement !== null && yComplement !== void 0 ? yComplement : '');
94
- return "".concat(label, ": ").concat((0, _auxiliarFunctions.formatTooltip)(axisValueLabel, dateFormat), " <br>\n ").concat(result, ": ").concat(values, " <br>\n ").concat(complement);
112
+ var series = {
113
+ type: 'line',
114
+ data: chartData,
115
+ label: _objectSpread({
116
+ show: true,
117
+ distance: 1.1,
118
+ formatter: formatLabel,
119
+ fontSize: yType === 'time' ? 10 : 11.5
120
+ }, _commonStyles.COMMON_STYLE),
121
+ itemStyle: {
122
+ color: color
123
+ },
124
+ lineStyle: {
125
+ color: color || blue[800]
126
+ },
127
+ areaStyle: {
128
+ opacity: 0.2,
129
+ color: color || blue[800]
130
+ }
95
131
  };
96
- var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
97
- feature: {
98
- saveAsImage: toolboxTooltip.saveAsImage && (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : ''),
99
- dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
132
+ var seriesMarkLine = {
133
+ type: 'line',
134
+ symbolSize: 0,
135
+ showSymbol: false,
136
+ data: markLineData,
137
+ name: lineMarkName,
138
+ emphasis: {
139
+ scale: false
140
+ },
141
+ lineStyle: {
142
+ width: 2,
143
+ color: lineMarkColor
100
144
  }
101
- });
145
+ };
102
146
  var zoomEvent = {
103
147
  dataZoom: dinamicData
104
148
  };
@@ -106,176 +150,113 @@ var AreaChart = function AreaChart(props) {
106
150
  var tooltipLabelFormat = dateFormat === 'yyyy-MM' ? 'MMM/yy' : 'dd/MM/yyyy';
107
151
  var scrollable = xData.length > arrayInitialSize ? [{
108
152
  type: 'inside',
109
- start: (0, _auxiliarFunctions.getInitialValues)(xData.length, dateFormat, scrollStart),
110
153
  end: 100,
111
154
  zoomLock: true,
112
- zoomOnMouseWheel: 'shift'
155
+ zoomOnMouseWheel: 'shift',
156
+ start: (0, _auxiliarFunctions.getInitialValues)(xData.length, dateFormat, scrollStart)
113
157
  }, {
114
- bottom: 10,
115
- show: true,
116
158
  type: 'slider',
117
- start: (0, _auxiliarFunctions.getInitialValues)(xData.length, dateFormat, scrollStart),
159
+ show: true,
160
+ bottom: 10,
118
161
  end: 100,
162
+ start: (0, _auxiliarFunctions.getInitialValues)(xData.length, dateFormat, scrollStart),
119
163
  labelFormatter: function labelFormatter(_, item) {
120
164
  return (0, _auxiliarFunctions.formatTime)(item, tooltipLabelFormat);
121
165
  }
122
166
  }] : [];
123
- var options = {
124
- // @ts-expect-error fix
125
- series: [{
126
- type: 'line',
127
- data: yData,
128
- label: {
129
- formatter: function formatter(item) {
130
- if (typeof yComplement === 'function' && (0, _typeof2["default"])(item) === 'object') {
131
- return yComplement(item.data);
132
- }
133
- if (typeof yComplement === 'function') {
134
- return yComplement;
135
- }
136
-
137
- // this can't be returned
138
- // it breaks the labels
139
- // eslint-disable-next-line @stylistic/max-len
140
- // eslint-disable-next-line @typescript-eslint/no-unused-expressions
141
- formatLabel;
142
- },
143
- show: true,
144
- position: 'top',
145
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
146
- fontSize: yType === 'time' ? 10 : 11.5,
147
- color: neutral[200],
148
- distance: 1.1
149
- },
150
- lineStyle: {
151
- color: color || blue[800]
152
- },
153
- areaStyle: {
154
- color: color || blue[800],
155
- opacity: 0.2
156
- },
157
- itemStyle: {
158
- color: color
159
- }
160
- }, {
161
- name: lineMakeName,
162
- symbolSize: 0,
163
- showSymbol: false,
164
- type: 'line',
165
- data: markLine,
166
- lineStyle: {
167
- color: lineMarkColor
167
+ var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
168
+ feature: {
169
+ saveAsImage: toolboxTooltip.saveAsImage && (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : ''),
170
+ dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
171
+ }
172
+ });
173
+ var options = function options() {
174
+ return {
175
+ dataZoom: scrollable,
176
+ color: [lineMarkColor],
177
+ series: [series, seriesMarkLine],
178
+ grid: _objectSpread(_objectSpread({}, grid || {
179
+ bottom: 75
180
+ }), {}, {
181
+ show: true
182
+ }),
183
+ title: {
184
+ text: title,
185
+ left: '6.2%',
186
+ textStyle: _objectSpread({}, _commonStyles.TITLE_STYLE)
168
187
  },
169
- emphasis: {
170
- scale: false
171
- }
172
- }],
173
- xAxis: {
174
- type: 'category',
175
- boundaryGap: false,
176
- data: xData,
177
- splitLine: {
178
- show: true,
179
- lineStyle: {
180
- type: 'dashed',
181
- opacity: 0.2,
182
- color: gray[800]
183
- }
188
+ xAxis: {
189
+ type: 'category',
190
+ data: xData,
191
+ boundaryGap: false,
192
+ splitLine: {
193
+ show: true,
194
+ lineStyle: _objectSpread({}, _commonStyles.AXIS_SPLIT_LINE)
195
+ },
196
+ axisLabel: _objectSpread(_objectSpread({}, _commonStyles.COMMON_STYLE), {}, {
197
+ rotate: rotateLabel || 0,
198
+ fontSize: fontLabelSize || 11.5,
199
+ formatter: function formatter(item) {
200
+ return xType === 'time' ? (0, _auxiliarFunctions.formatTime)(item, (0, _auxiliarFunctions.getDateFormatType)(dateFormat || 'yyyy-MM')) : item;
201
+ }
202
+ })
184
203
  },
185
- axisLabel: {
186
- formatter: function formatter(item) {
187
- return xType === 'time' ? (0, _auxiliarFunctions.formatTime)(item, (0, _auxiliarFunctions.getDateFormatType)(dateFormat || 'yyyy-MM')) : item;
204
+ yAxis: {
205
+ type: 'value',
206
+ splitLine: {
207
+ show: true,
208
+ lineStyle: _objectSpread({}, _commonStyles.AXIS_SPLIT_LINE)
188
209
  },
189
- rotate: rotateLabel || 0,
190
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
191
- fontSize: fontLabelSize || 11.5,
192
- color: neutral[200]
193
- }
194
- },
195
- yAxis: {
196
- max: lineMarkValue ? _auxiliarFunctions.fixedDomain : _auxiliarFunctions.getDomain,
197
- type: 'value',
198
- splitLine: {
199
- show: true,
200
- lineStyle: {
210
+ axisTick: {
211
+ show: true
212
+ },
213
+ axisLine: {
214
+ show: true,
201
215
  type: 'dashed',
202
- opacity: 0.2,
203
- color: gray[800]
204
- }
205
- },
206
- axisLabel: {
207
- margin: yType === 'time' ? 16 : 14,
208
- formatter: function formatter(item) {
209
- return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(item) + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(item, yComplement !== null && yComplement !== void 0 ? yComplement : '').toString();
216
+ lineStyle: {
217
+ color: neutral[200]
218
+ }
210
219
  },
211
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
212
- fontSize: fontLabelSize || 11.5,
213
- color: neutral[200]
220
+ axisLabel: _objectSpread(_objectSpread({}, _commonStyles.COMMON_STYLE), {}, {
221
+ fontSize: fontLabelSize || 11.5,
222
+ margin: yType === 'time' ? 16 : 14,
223
+ formatter: function formatter(item) {
224
+ return yType === 'time' ? (0, _auxiliarFunctions.timeConvert)(item) + 'h' : (0, _auxiliarFunctions.takeLabelComplement)(item, yComplement !== null && yComplement !== void 0 ? yComplement : '').toString();
225
+ }
226
+ }),
227
+ max: lineMarkValue ? _auxiliarFunctions.fixedDomain : _auxiliarFunctions.getDomain
214
228
  },
215
- axisLine: {
216
- show: true
229
+ legend: {
230
+ top: 30,
231
+ icon: _commonStyles.STRAIGHT_LINE_ICON,
232
+ textStyle: _objectSpread({}, _commonStyles.COMMON_STYLE)
217
233
  },
218
- axisTick: {
219
- // @ts-expect-error issue
220
- // https://github.com/apache/incubator-echarts/issues/13618
221
- alignWithLabel: true,
222
- show: true
223
- }
224
- },
225
- color: [lineMarkColor],
226
- grid: _objectSpread(_objectSpread({}, gridProps || {
227
- bottom: 75
228
- }), {}, {
229
- show: true
230
- }),
231
- legend: {
232
- icon: _commonStyles.STRAIGHT_LINE_ICON,
233
- top: 30,
234
- data: [lineMakeName],
235
- itemGap: 30,
236
- textStyle: {
237
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
238
- color: neutral[200]
239
- }
240
- },
241
- title: {
242
- left: '6.2%',
243
- show: titleProps !== undefined,
244
- text: titleProps,
245
- textAlign: 'left',
246
- textStyle: {
247
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
248
- fontSize: 16,
249
- fontWeight: 400,
250
- color: neutral[200]
251
- }
252
- },
253
- tooltip: tooltipProps && {
254
- formatter: formatSingleTooltip,
255
- trigger: 'axis',
256
- backgroundColor: "".concat(neutral[200], "99"),
257
- textStyle: {
258
- fontFamily: 'Roboto, Helvetica, Arial, sans-serif',
259
- fontSize: 11.5,
260
- color: neutral[50]
261
- },
262
- extraCssText: 'border: none; padding: 6px;'
263
- },
264
- dataZoom: scrollable,
265
- toolbox: _objectSpread(_objectSpread({}, toolbox), {}, {
266
- tooltip: _objectSpread(_objectSpread({}, _commonStyles.TOOLTIP_DEFAULT_PROPS), {}, {
267
- formatter: function formatter(param) {
268
- return "<div>".concat(param.title, "</div>");
269
- }
234
+ tooltip: tooltip && _objectSpread({
235
+ trigger: 'axis',
236
+ formatter: formatSingleTooltip
237
+ }, _commonStyles.TOOLTIP_DEFAULT_PROPS),
238
+ toolbox: _objectSpread(_objectSpread({}, toolbox), {}, {
239
+ tooltip: _objectSpread(_objectSpread({}, _commonStyles.TOOLTIP_DEFAULT_PROPS), {}, {
240
+ formatter: function formatter(param) {
241
+ return "<div>".concat(param.title, "</div>");
242
+ }
243
+ })
270
244
  })
271
- })
245
+ };
272
246
  };
273
- return /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
274
- lazyUpdate: true,
247
+ return /*#__PURE__*/_react["default"].createElement(_core2["default"], {
275
248
  notMerge: true,
276
- style: _commonStyles.CHART_HEIGHT,
277
- opts: WIDTH_OPTS,
278
- option: options,
249
+ lazyUpdate: true,
250
+ echarts: echarts,
251
+ option: options(),
252
+ style: {
253
+ width: '99.9%',
254
+ height: 300
255
+ },
256
+ opts: {
257
+ renderer: 'canvas',
258
+ width: width !== null && width !== void 0 ? width : 'auto'
259
+ },
279
260
  onEvents: zoomEvent
280
261
  });
281
262
  };
@@ -1,19 +1,19 @@
1
1
  import React from 'react';
2
2
  import type { IDefaultChartProps, TAudiometryDataEntry, AudiometryDataTooltip, LineStyleType, TSimpleLegend } from '../types';
3
3
  export interface IProps extends Omit<IDefaultChartProps, 'data'> {
4
- data: TAudiometryDataEntry[][];
5
4
  height?: number;
6
- lineType?: LineStyleType;
7
- symbolsSize?: number;
8
5
  colors?: string[];
9
- legendsPosition?: 'top' | 'bottom';
10
6
  legendGap?: number;
11
- legendType?: 'scroll' | 'plain';
12
- legends?: TSimpleLegend[];
7
+ symbolsSize?: number;
13
8
  legendPadding?: number;
9
+ tooltipMarker?: boolean;
14
10
  legendItemWidth?: number;
15
11
  legendItemHeight?: number;
16
- tooltipMarker?: boolean;
12
+ lineType?: LineStyleType;
13
+ legends?: TSimpleLegend[];
14
+ data: TAudiometryDataEntry[][];
15
+ legendType?: 'scroll' | 'plain';
16
+ legendsPosition?: 'top' | 'bottom';
17
17
  formatTooltip?(items: AudiometryDataTooltip[]): string;
18
18
  }
19
19
  declare const AudiometryChart: (props: IProps) => React.JSX.Element;