@oliasoft-open-source/charts-library 3.3.8 → 3.4.0-beta-1

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 (72) hide show
  1. package/dist/declaration.d.ts +15 -0
  2. package/dist/index.d.ts +1 -0
  3. package/dist/index.js +18349 -18611
  4. package/dist/index.js.map +1 -1
  5. package/dist/src/components/bar-chart/bar-chart-default-props.d.ts +69 -0
  6. package/dist/src/components/bar-chart/bar-chart.d.ts +3 -0
  7. package/dist/src/components/bar-chart/bar-chart.interface.d.ts +83 -0
  8. package/dist/src/components/bar-chart/get-bar-chart-data-labels.d.ts +16 -0
  9. package/dist/src/components/bar-chart/get-bar-chart-scales.d.ts +5 -0
  10. package/dist/src/components/bar-chart/get-bar-chart-tooltips.d.ts +15 -0
  11. package/dist/src/components/controls/axes-options/axes-options-interfaces.d.ts +19 -0
  12. package/dist/src/components/line-chart/constants/default-translations.d.ts +24 -0
  13. package/dist/src/components/line-chart/constants/line-chart-consts.d.ts +12 -0
  14. package/dist/src/components/line-chart/controls/axes-options/action-types.d.ts +5 -0
  15. package/dist/src/components/line-chart/controls/axes-options/axes-options-form-state.d.ts +18 -0
  16. package/dist/src/components/line-chart/controls/controls-interfaces.d.ts +34 -0
  17. package/dist/src/components/line-chart/controls/controls-portal.d.ts +2 -0
  18. package/dist/src/components/line-chart/controls/controls.d.ts +6 -0
  19. package/dist/src/components/line-chart/controls/drag-options-interfaces.d.ts +11 -0
  20. package/dist/src/components/line-chart/controls/drag-options.d.ts +5 -0
  21. package/dist/src/components/line-chart/controls/line-options.d.ts +1 -0
  22. package/dist/src/components/line-chart/hooks/hooks.interface.d.ts +13 -0
  23. package/dist/src/components/line-chart/hooks/use-chart-functions.d.ts +23 -0
  24. package/dist/src/components/line-chart/hooks/use-chart-options.d.ts +36 -0
  25. package/dist/src/components/line-chart/hooks/use-toggle-handler.d.ts +10 -0
  26. package/dist/src/components/line-chart/initialize/config.d.ts +12 -0
  27. package/dist/src/components/line-chart/initialize/initialize-line-chart.d.ts +12 -0
  28. package/dist/src/components/line-chart/legend/legend-constants.d.ts +1 -0
  29. package/dist/src/components/line-chart/legend/legend-dropzone.d.ts +3 -0
  30. package/dist/src/components/line-chart/legend/legend-item.d.ts +3 -0
  31. package/dist/src/components/line-chart/legend/legend-panel.d.ts +4 -0
  32. package/dist/src/components/line-chart/legend/legend.d.ts +3 -0
  33. package/dist/src/components/line-chart/line-chart-get-default-props.d.ts +91 -0
  34. package/dist/src/components/line-chart/line-chart.d.ts +3 -0
  35. package/dist/src/components/line-chart/line-chart.interface.d.ts +121 -0
  36. package/dist/src/components/line-chart/plugins/chart-area-text-plugin.d.ts +4 -0
  37. package/dist/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.d.ts +7 -0
  38. package/dist/src/components/line-chart/plugins/plugin-constants.d.ts +11 -0
  39. package/dist/src/components/line-chart/plugins/plugins.interface.d.ts +9 -0
  40. package/dist/src/components/line-chart/state/action-types.d.ts +12 -0
  41. package/dist/src/components/line-chart/state/initial-state.d.ts +18 -0
  42. package/dist/src/components/line-chart/state/line-chart-reducer.d.ts +1 -0
  43. package/dist/src/components/line-chart/state/manage-state-in-local-storage.d.ts +14 -0
  44. package/dist/src/components/line-chart/state/state.interfaces.d.ts +8 -0
  45. package/dist/src/components/line-chart/state/use-chart-state.d.ts +12 -0
  46. package/dist/src/components/line-chart/utils/axis-formatting/axis-formatting.d.ts +1 -0
  47. package/dist/src/components/line-chart/utils/axis-scales/axis-scales.d.ts +10 -0
  48. package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.d.ts +9 -0
  49. package/dist/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.d.ts +11 -0
  50. package/dist/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.d.ts +5 -0
  51. package/dist/src/components/line-chart/utils/generate-line-chart-datasets.d.ts +10 -0
  52. package/dist/src/components/line-chart/utils/get-axes-ranges-from-chart.d.ts +6 -0
  53. package/dist/src/components/line-chart/utils/get-line-chart-data-labels.d.ts +17 -0
  54. package/dist/src/components/line-chart/utils/get-line-chart-scales.d.ts +9 -0
  55. package/dist/src/components/line-chart/utils/get-line-chart-tooltips.d.ts +16 -0
  56. package/dist/src/components/line-chart/utils/line-chart-utils.d.ts +31 -0
  57. package/dist/src/components/line-chart/utils/translations/get-translations.d.ts +7 -0
  58. package/dist/src/components/pie-chart/pie-chart-get-default-props.d.ts +39 -0
  59. package/dist/src/components/pie-chart/pie-chart-utils.d.ts +2 -0
  60. package/dist/src/components/pie-chart/pie-chart.d.ts +9 -0
  61. package/dist/src/components/pie-chart/pie-chart.interface.d.ts +54 -0
  62. package/dist/src/components/scatter-chart/scatter-chart.d.ts +7 -0
  63. package/dist/src/components/scatter-chart/scatter-chart.intefrace.d.ts +28 -0
  64. package/dist/src/helpers/chart-border-plugin.d.ts +7 -0
  65. package/dist/src/helpers/chart-consts.d.ts +32 -0
  66. package/dist/src/helpers/chart-interface.d.ts +85 -0
  67. package/dist/src/helpers/enums.d.ts +86 -0
  68. package/dist/src/helpers/get-chart-annotation.d.ts +12 -0
  69. package/dist/src/helpers/get-draggableData.d.ts +18 -0
  70. package/dist/src/helpers/range/estimate-data-series-have-close-values.d.ts +10 -0
  71. package/dist/src/helpers/range/range.d.ts +33 -0
  72. package/package.json +13 -11
@@ -0,0 +1,86 @@
1
+ /**
2
+ * @enum {string}
3
+ */
4
+ export declare const AxisType: Readonly<{
5
+ X: "x";
6
+ Y: "y";
7
+ }>;
8
+ /**
9
+ * @enum {string}
10
+ */
11
+ export declare const Position: Readonly<{
12
+ Bottom: "bottom";
13
+ Top: "top";
14
+ Left: "left";
15
+ Right: "right";
16
+ TopRight: "top-right";
17
+ TopLeft: "top-left";
18
+ BottomLeft: "bottom-left";
19
+ BottomRight: "bottom-right";
20
+ }>;
21
+ /**
22
+ * @enum {string}
23
+ */
24
+ export declare const ChartType: Readonly<{
25
+ Line: "line";
26
+ Bar: "bar";
27
+ }>;
28
+ /**
29
+ * @enum {string}
30
+ */
31
+ export declare const CursorStyle: Readonly<{
32
+ Pointer: "pointer";
33
+ Initial: "initial";
34
+ }>;
35
+ /**
36
+ * @enum {string}
37
+ */
38
+ export declare const ScaleType: Readonly<{
39
+ Category: "category";
40
+ Linear: "linear";
41
+ Logarithmic: "logarithmic";
42
+ }>;
43
+ /**
44
+ * @enum {string}
45
+ */
46
+ export declare const ChartDirection: Readonly<{
47
+ Vertical: "vertical";
48
+ }>;
49
+ /**
50
+ * @enum {string}
51
+ */
52
+ export declare const TooltipLabel: Readonly<{
53
+ Y: "yLabel";
54
+ X: "xLabel";
55
+ }>;
56
+ export declare const AlignOptions: Readonly<{
57
+ End: "end";
58
+ Start: "start";
59
+ Center: "center";
60
+ Right: "right";
61
+ Left: "left";
62
+ }>;
63
+ export declare const PointType: Readonly<{
64
+ Casing: "casing";
65
+ }>;
66
+ export declare const AnnotationType: Readonly<{
67
+ Box: "box";
68
+ Ellipse: "ellipse";
69
+ Line: "line";
70
+ Text: "text";
71
+ }>;
72
+ export declare const PointStyle: Readonly<{
73
+ Circle: "circle";
74
+ }>;
75
+ export declare const ChartHoverMode: Readonly<{
76
+ Nearest: "nearest";
77
+ }>;
78
+ export declare const PanZoomMode: Readonly<{
79
+ X: "x";
80
+ Y: "y";
81
+ XY: "xy";
82
+ }>;
83
+ export declare const Key: Readonly<{
84
+ Shift: "Shift";
85
+ }>;
86
+ export declare const Events: readonly string[];
@@ -0,0 +1,12 @@
1
+ import { ILineChartOptions } from '../components/line-chart/line-chart.interface';
2
+ import { IInitialState } from './chart-interface';
3
+ /**
4
+ * @param {import('../components/bar-chart/bar-chart.interface').IBarChartOptions |
5
+ * import('../components/line-chart/line-chart.interface').ILineChartOptions} options - chart options object
6
+ * @param {import('./chart-interface').IInitialState} state - chart state object controlled by useReducer or similar
7
+ * @return {{annotations: []}}
8
+ */
9
+ declare const getAnnotation: (options: ILineChartOptions, state: IInitialState) => {
10
+ annotations: {} | null;
11
+ };
12
+ export default getAnnotation;
@@ -0,0 +1,18 @@
1
+ import { ILineChartOptions } from '../components/line-chart/line-chart.interface';
2
+ /**
3
+ * @param {import('./line-chart.interface').ILineChartOptions} options - line chart options object
4
+ */
5
+ declare const getDraggableData: (options: ILineChartOptions) => {
6
+ dragData: {
7
+ dragX: any;
8
+ dragY: any;
9
+ round: any;
10
+ showTooltip: any;
11
+ onDragStart: any;
12
+ onDrag: any;
13
+ onDragEnd: any;
14
+ };
15
+ } | {
16
+ dragData?: undefined;
17
+ };
18
+ export default getDraggableData;
@@ -0,0 +1,10 @@
1
+ /**
2
+ * Estimates whether any of the data series has values that are all close together
3
+ * - checks only the first and last values in each series (i.e. assumes they are ordered)
4
+ * - uses an equality check with tolerance for decimal precision noise
5
+ * - this is just an inexpensive "guesstimate" (full min/max detection can be used afterwards)
6
+ *
7
+ * @param {Array} generatedDatasets chart dataset series with x, y points
8
+ * @return {boolean} - at least one series has values that seem close together
9
+ */
10
+ export declare const estimateDataSeriesHaveCloseValues: (generatedDatasets: Array<any>) => boolean;
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Overrides the default chart.js axis range for some edge-cases:
3
+ * - when no data -> default range
4
+ * - when all values are close to zero -> default range
5
+ * - when all values are close to each other -> custom 5% padding
6
+ * - when autoAxisPadding is set -> custom 5% padding
7
+ * - all other cases fall back to chart.js default behaviour
8
+ *
9
+ * `autoAxisPadding` feature requirements:
10
+ * - specified by Truls and ported by Mark+Oleg
11
+ * - numbers that are equal (within tolerance) shall be presented as a straight line
12
+ * - all other data series shall use 90% of width of axis (5% padding each side)
13
+ * - the padding on each side shall be symmetric
14
+ *
15
+ * @param {object} args
16
+ * @param {array<number|null>} args.data
17
+ * @param {boolean} [args.beginAtZero]
18
+ * @param {boolean>} [args.autoAxisPadding]
19
+ * @returns {object} returns {min, max} pair
20
+ */
21
+ interface IGetuggestedAxisRange {
22
+ data: any;
23
+ beginAtZero: boolean;
24
+ autoAxisPadding: boolean;
25
+ }
26
+ export declare const getSuggestedAxisRange: ({ data, beginAtZero, autoAxisPadding, }: IGetuggestedAxisRange) => {
27
+ min: number;
28
+ max: number;
29
+ } | {
30
+ min: undefined;
31
+ max: undefined;
32
+ };
33
+ export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/charts-library",
3
- "version": "3.3.8",
3
+ "version": "3.4.0-beta-1",
4
4
  "description": "React Chart Library (based on Chart.js and react-chart-js-2)",
5
5
  "homepage": "https://gitlab.com/oliasoft-open-source/charts-library",
6
6
  "bugs": {
@@ -14,27 +14,27 @@
14
14
  "author": "Oliasoft AS and contributors",
15
15
  "main": "./dist/index.js",
16
16
  "module": "./dist/index.js",
17
+ "types": "./dist/index.d.ts",
17
18
  "files": [
18
19
  "dist"
19
20
  ],
20
21
  "scripts": {
21
- "build": "yarn run build:storybook",
22
22
  "build:package": "vite build --config vite.config.mjs",
23
- "build:storybook": "storybook build --quiet --output-dir ./public",
23
+ "build": "yarn build:package && storybook build --quiet --output-dir ./public",
24
24
  "dev:storybook": "storybook dev -p 6006",
25
- "lint:check": "eslint \"**/*.{js,jsx}\"",
26
- "lint:fix": "eslint --fix \"**/*.{js,jsx}\"",
25
+ "lint:check": "eslint \"**/*.{js,jsx,ts,tsx}\"",
26
+ "lint:fix": "eslint --fix \"**/*.{js,jsx,ts,tsx}\"",
27
27
  "prepare": "husky install",
28
- "prettier:check": "prettier --check \"**/*.{js,jsx,json,css,less}\"",
29
- "prettier:fix": "prettier --write \"**/*.{js,jsx,json,css,less}\"",
28
+ "prettier:check": "prettier --check \"**/*.{ts,tsx,js,jsx,json,css,less}\"",
29
+ "prettier:fix": "prettier --write \"**/*.{ts,tsx,js,jsx,json,css,less}\"",
30
30
  "preview:storybook": " http-server ./public -o -p 9002 -c-1",
31
31
  "test": "yarn run prettier:check && yarn run lint:check && yarn run test:unit",
32
32
  "test:unit": "vitest run",
33
33
  "test:unit:coverage": "vitest run --coverage"
34
34
  },
35
35
  "lint-staged": {
36
- "*.js": "eslint --cache --fix",
37
- "*.{js,jsx,json,css,less}": [
36
+ "*.{ts,tsx,js,jsx}": "eslint --cache --fix",
37
+ "*.{ts,tsx,js,jsx,json,css,less}": [
38
38
  "prettier --write"
39
39
  ]
40
40
  },
@@ -57,10 +57,12 @@
57
57
  "@oliasoft-open-source/units": "^3.4.2",
58
58
  "@storybook/addon-actions": "^7.0.18",
59
59
  "@storybook/addon-docs": "^7.0.18",
60
+ "@storybook/addon-mdx-gfm": "^7.0.23",
60
61
  "@storybook/react": "^7.0.18",
61
62
  "@storybook/react-vite": "^7.0.18",
62
63
  "@storybook/testing-library": "^0.0.14-next.2",
63
64
  "@types/react": "^17.0.49",
65
+ "@typescript-eslint/parser": "^5.60.0",
64
66
  "@vitejs/plugin-react-swc": "^3.3.2",
65
67
  "ajv": "^8.12.0",
66
68
  "ajv-errors": "^3.0.0",
@@ -85,7 +87,6 @@
85
87
  "lint-staged": "^13.0.3",
86
88
  "lodash": "^4.17.21",
87
89
  "prettier": "2.7.1",
88
- "prop-types": "^15",
89
90
  "react": "^17",
90
91
  "react-dom": "^17",
91
92
  "rollup-plugin-peer-deps-external": "^2.2.4",
@@ -93,6 +94,8 @@
93
94
  "storybook-dark-mode": "^3.0.0",
94
95
  "vite": "^4.3.9",
95
96
  "vite-plugin-css-injected-by-js": "^3.1.1",
97
+ "vite-plugin-dts": "2.3.0",
98
+ "vite-tsconfig-paths": "^4.2.0",
96
99
  "vitest": "^0.32.0"
97
100
  },
98
101
  "peerDependencies": {
@@ -101,7 +104,6 @@
101
104
  "classnames": "^2.3.2",
102
105
  "immer": "^10.0.2",
103
106
  "lodash": "^4.17.21",
104
- "prop-types": "^15",
105
107
  "react": "^17",
106
108
  "react-dom": "^17"
107
109
  }