amazing-react-charts 1.1.8 → 1.2.0

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.
@@ -3,4 +3,4 @@ import PyramidBarChart from './PyramidBarChart';
3
3
  declare const meta: Meta;
4
4
  export default meta;
5
5
  type Story = StoryObj<typeof PyramidBarChart>;
6
- export declare const pyramidChart: Story;
6
+ export declare const pyramidBarChart: Story;
@@ -0,0 +1,26 @@
1
+ import React from 'react';
2
+ import type { IDefaultChartProps, ToolboxEntryProps, WidthProps } from '../types';
3
+ export interface SeriesData {
4
+ value: number;
5
+ name: string;
6
+ itemStyle?: object;
7
+ tooltipText?: string;
8
+ }
9
+ export interface IProps extends Omit<IDefaultChartProps, 'data'> {
10
+ data: SeriesData[];
11
+ width?: WidthProps;
12
+ style?: object;
13
+ toolboxTooltip?: ToolboxEntryProps;
14
+ custom?: {
15
+ gap?: string | number;
16
+ top?: string | number;
17
+ bottom?: string | number;
18
+ left?: string | number;
19
+ width?: string | number;
20
+ minSize?: string | number;
21
+ maxSize?: string | number;
22
+ };
23
+ labelPosition?: 'inside' | 'top' | 'bottom' | 'left' | 'right' | 'insideLeft' | 'insideRight' | 'insideTop' | 'insideBottom' | 'insideTopLeft' | 'insideBottomLeft' | 'insideTopRight' | 'insideBottomRight';
24
+ }
25
+ declare const PyramidChart: (props: IProps) => React.JSX.Element;
26
+ export default PyramidChart;
@@ -0,0 +1,126 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports["default"] = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+ var _react = _interopRequireWildcard(require("react"));
12
+ var _echartsForReact = _interopRequireDefault(require("echarts-for-react"));
13
+ var _auxiliarFunctions = require("../../lib/auxiliarFunctions");
14
+ var _commonStyles = require("../../commonStyles");
15
+ var _theme = require("flipper-ui/theme");
16
+ 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); }
17
+ 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 && {}.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; }
18
+ 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; }
19
+ 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; }
20
+ var neutral = _theme.theme.colors.neutral;
21
+ var PyramidChart = function PyramidChart(props) {
22
+ var _toolboxTooltip$saveA, _toolboxTooltip$saveA2, _toolboxTooltip$dataV;
23
+ var data = props.data,
24
+ style = props.style,
25
+ custom = props.custom,
26
+ labelPosition = props.labelPosition,
27
+ titleFontSize = props.titleFontSize,
28
+ toolboxTooltip = props.toolboxTooltip,
29
+ titleProps = props.title,
30
+ marginRightToolbox = props.marginRightToolbox;
31
+ var _useState = (0, _react.useState)(false),
32
+ _useState2 = (0, _slicedToArray2["default"])(_useState, 2),
33
+ title = _useState2[0],
34
+ setTitle = _useState2[1];
35
+ (0, _react.useEffect)(function () {
36
+ if (toolboxTooltip !== null && toolboxTooltip !== void 0 && toolboxTooltip.saveAsImageWithTitle) {
37
+ setTitle(false);
38
+ } else {
39
+ setTitle(true);
40
+ }
41
+ }, [toolboxTooltip]);
42
+ var handleShowTitle = function handleShowTitle(show) {
43
+ setTitle(show);
44
+ };
45
+ var myTool = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImageWithTitle) && {
46
+ myTool: (0, _auxiliarFunctions.getSaveAsImageWithTitle)((_toolboxTooltip$saveA = toolboxTooltip.saveAsImageWithTitle.title) !== null && _toolboxTooltip$saveA !== void 0 ? _toolboxTooltip$saveA : '', handleShowTitle)
47
+ };
48
+ var saveAsImage = (toolboxTooltip === null || toolboxTooltip === void 0 ? void 0 : toolboxTooltip.saveAsImage) && {
49
+ saveAsImage: (0, _auxiliarFunctions.getSaveAsImage)((_toolboxTooltip$saveA2 = toolboxTooltip.saveAsImage.title) !== null && _toolboxTooltip$saveA2 !== void 0 ? _toolboxTooltip$saveA2 : '')
50
+ };
51
+ var toolbox = toolboxTooltip && _objectSpread(_objectSpread({}, _commonStyles.TOOLBOX_DEFAULT_PROPS), {}, {
52
+ right: marginRightToolbox || '2%',
53
+ feature: _objectSpread(_objectSpread(_objectSpread({}, myTool), saveAsImage), {}, {
54
+ dataView: toolboxTooltip.dataView && (0, _auxiliarFunctions.getDataView)((_toolboxTooltip$dataV = toolboxTooltip.dataView.title) !== null && _toolboxTooltip$dataV !== void 0 ? _toolboxTooltip$dataV : '')
55
+ })
56
+ });
57
+ var series = [{
58
+ type: 'funnel',
59
+ sort: 'ascending',
60
+ data: data.map(function (item) {
61
+ return {
62
+ value: item.value,
63
+ name: item.name,
64
+ itemStyle: item.itemStyle
65
+ };
66
+ }),
67
+ label: {
68
+ show: true,
69
+ position: labelPosition || 'inside',
70
+ fontWeight: 600
71
+ },
72
+ gap: (custom === null || custom === void 0 ? void 0 : custom.gap) || 2,
73
+ top: (custom === null || custom === void 0 ? void 0 : custom.top) || 20,
74
+ bottom: (custom === null || custom === void 0 ? void 0 : custom.bottom) || 20,
75
+ left: (custom === null || custom === void 0 ? void 0 : custom.left) || '10%',
76
+ width: (custom === null || custom === void 0 ? void 0 : custom.width) || '80%',
77
+ minSize: (custom === null || custom === void 0 ? void 0 : custom.minSize) || '0',
78
+ maxSize: (custom === null || custom === void 0 ? void 0 : custom.maxSize) || '80%'
79
+ }];
80
+ var options = {
81
+ series: series,
82
+ // @ts-expect-error formatter params
83
+ tooltip: {
84
+ trigger: 'item',
85
+ axisPointer: {
86
+ type: 'shadow'
87
+ },
88
+ backgroundColor: "".concat(neutral[200], "99"),
89
+ textStyle: {
90
+ fontSize: 11.5,
91
+ color: neutral[50],
92
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif'
93
+ },
94
+ extraCssText: 'border: none; padding: 6px;',
95
+ formatter: function formatter(params) {
96
+ var dataItem = data.find(function (item) {
97
+ return item.name === params.name;
98
+ });
99
+ return dataItem ? dataItem.tooltipText : params.name;
100
+ }
101
+ },
102
+ title: {
103
+ left: '2%',
104
+ show: title,
105
+ text: titleProps,
106
+ textStyle: {
107
+ fontWeight: 400,
108
+ color: neutral[200],
109
+ fontSize: titleFontSize || 16,
110
+ fontFamily: 'Roboto, Helvetica, Arial, sans-serif'
111
+ }
112
+ },
113
+ toolbox: _objectSpread(_objectSpread({}, toolbox), {}, {
114
+ tooltip: _objectSpread(_objectSpread({}, _commonStyles.TOOLTIP_DEFAULT_PROPS), {}, {
115
+ formatter: function formatter(param) {
116
+ return "<div>".concat(param.title, "</div>");
117
+ }
118
+ })
119
+ })
120
+ };
121
+ return /*#__PURE__*/_react["default"].createElement(_echartsForReact["default"], {
122
+ option: options,
123
+ style: style ? style : _commonStyles.CHART_WIDTH
124
+ });
125
+ };
126
+ var _default = exports["default"] = PyramidChart;
@@ -0,0 +1,6 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import PyramidChart from './PyramidChart';
3
+ declare const meta: Meta;
4
+ export default meta;
5
+ type Story = StoryObj<typeof PyramidChart>;
6
+ export declare const pyramidChart: Story;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "amazing-react-charts",
3
- "version": "1.1.8",
3
+ "version": "1.2.0",
4
4
  "description": "An amazing react charts package based in echarts",
5
5
  "main": "dist/index.js",
6
6
  "license": "MIT",
@@ -33,52 +33,52 @@
33
33
  "echarts-for-react": "3.0.2"
34
34
  },
35
35
  "devDependencies": {
36
- "@babel/cli": "7.25.9",
36
+ "@babel/cli": "7.26.4",
37
37
  "@babel/core": "7.26.0",
38
- "@babel/plugin-transform-modules-commonjs": "7.25.9",
38
+ "@babel/plugin-transform-modules-commonjs": "7.26.3",
39
39
  "@babel/plugin-transform-runtime": "7.25.9",
40
40
  "@babel/preset-env": "7.26.0",
41
- "@babel/preset-react": "7.25.9",
41
+ "@babel/preset-react": "7.26.3",
42
42
  "@babel/preset-typescript": "7.26.0",
43
- "@storybook/addon-essentials": "8.4.5",
43
+ "@storybook/addon-essentials": "8.4.7",
44
44
  "@storybook/addon-webpack5-compiler-babel": "3.0.3",
45
- "@storybook/blocks": "8.4.5",
46
- "@storybook/react": "8.4.5",
47
- "@storybook/react-webpack5": "8.4.5",
48
- "@stylistic/eslint-plugin": "2.11.0",
45
+ "@storybook/blocks": "8.4.7",
46
+ "@storybook/react": "8.4.7",
47
+ "@storybook/react-webpack5": "8.4.7",
48
+ "@stylistic/eslint-plugin": "2.12.1",
49
49
  "@testing-library/dom": "10.4.0",
50
50
  "@testing-library/jest-dom": "6.6.3",
51
- "@testing-library/react": "16.0.1",
51
+ "@testing-library/react": "16.1.0",
52
52
  "@testing-library/user-event": "14.5.2",
53
53
  "@types/jest": "29.5.14",
54
- "@types/node": "22.9.1",
54
+ "@types/node": "22.10.2",
55
55
  "@types/ramda": "0.30.2",
56
56
  "@types/react": "18.3.12",
57
- "@typescript-eslint/eslint-plugin": "8.15.0",
58
- "@typescript-eslint/parser": "8.15.0",
57
+ "@typescript-eslint/eslint-plugin": "8.18.0",
58
+ "@typescript-eslint/parser": "8.18.0",
59
59
  "canvas": "2.11.2",
60
60
  "date-fns": "4.1.0",
61
- "eslint": "9.15.0",
61
+ "eslint": "9.17.0",
62
62
  "eslint-config-prettier": "9.1.0",
63
- "eslint-import-resolver-typescript": "3.6.3",
63
+ "eslint-import-resolver-typescript": "3.7.0",
64
64
  "eslint-plugin-import": "2.31.0",
65
65
  "eslint-plugin-prettier": "5.2.1",
66
66
  "eslint-plugin-react": "7.37.2",
67
- "eslint-plugin-react-hooks": "5.0.0",
68
- "flipper-ui": "0.35.1",
67
+ "eslint-plugin-react-hooks": "5.1.0",
68
+ "flipper-ui": "0.35.2",
69
69
  "jest": "29.7.0",
70
70
  "jest-environment-jsdom": "29.7.0",
71
- "prettier": "3.3.3",
71
+ "prettier": "3.4.2",
72
72
  "ramda": "0.30.1",
73
73
  "react": "18.3.1",
74
74
  "react-dom": "18.3.1",
75
- "storybook": "8.4.5",
75
+ "storybook": "8.4.7",
76
76
  "styled-components": "6.1.13",
77
77
  "ts-jest": "29.2.5",
78
78
  "ts-node": "10.9.2",
79
- "typescript": "5.6.3",
80
- "typescript-eslint": "8.15.0",
81
- "webpack": "5.96.1"
79
+ "typescript": "5.7.2",
80
+ "typescript-eslint": "8.18.0",
81
+ "webpack": "5.97.1"
82
82
  },
83
83
  "peerDependencies": {
84
84
  "date-fns": "^4.0.0",
@@ -0,0 +1 @@
1
+ import '@testing-library/jest-dom';