@oliasoft-open-source/charts-library 3.3.6-beta-5 → 3.3.6

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 (99) hide show
  1. package/dist/index.js +39230 -0
  2. package/dist/index.js.map +1 -0
  3. package/package.json +6 -1
  4. package/index.js +0 -14
  5. package/release-notes.md +0 -378
  6. package/src/assets/circle.svg +0 -1
  7. package/src/assets/icons/line-and-point.svg +0 -1
  8. package/src/assets/icons/line-only.svg +0 -1
  9. package/src/assets/icons/list-hide.svg +0 -1
  10. package/src/assets/icons/point-only.svg +0 -1
  11. package/src/assets/rect.svg +0 -1
  12. package/src/assets/rectRot.svg +0 -1
  13. package/src/assets/triangle.svg +0 -1
  14. package/src/components/bar-chart/bar-chart-prop-types.js +0 -209
  15. package/src/components/bar-chart/bar-chart.interface.ts +0 -98
  16. package/src/components/bar-chart/bar-chart.jsx +0 -247
  17. package/src/components/bar-chart/bar-chart.module.less +0 -61
  18. package/src/components/bar-chart/get-bar-chart-data-labels.js +0 -42
  19. package/src/components/bar-chart/get-bar-chart-scales.js +0 -138
  20. package/src/components/bar-chart/get-bar-chart-tooltips.js +0 -102
  21. package/src/components/controls/axes-options/axes-options.jsx +0 -271
  22. package/src/components/line-chart/constants/default-translations.js +0 -24
  23. package/src/components/line-chart/constants/line-chart-consts.js +0 -12
  24. package/src/components/line-chart/controls/axes-options/action-types.js +0 -5
  25. package/src/components/line-chart/controls/axes-options/axes-options-form-state.js +0 -97
  26. package/src/components/line-chart/controls/controls-portal.jsx +0 -12
  27. package/src/components/line-chart/controls/controls.jsx +0 -176
  28. package/src/components/line-chart/controls/controls.module.less +0 -12
  29. package/src/components/line-chart/controls/drag-options.jsx +0 -124
  30. package/src/components/line-chart/controls/line-options.jsx +0 -64
  31. package/src/components/line-chart/hooks/use-chart-functions.js +0 -261
  32. package/src/components/line-chart/hooks/use-chart-options.js +0 -181
  33. package/src/components/line-chart/hooks/use-chart-plugins.js +0 -35
  34. package/src/components/line-chart/hooks/use-toggle-handler.js +0 -33
  35. package/src/components/line-chart/initialize/config.js +0 -23
  36. package/src/components/line-chart/initialize/initialize-line-chart.js +0 -25
  37. package/src/components/line-chart/legend/legend-constants.js +0 -1
  38. package/src/components/line-chart/legend/legend-dropzone.jsx +0 -74
  39. package/src/components/line-chart/legend/legend-item.jsx +0 -105
  40. package/src/components/line-chart/legend/legend-panel.jsx +0 -86
  41. package/src/components/line-chart/legend/legend.jsx +0 -54
  42. package/src/components/line-chart/legend/legend.module.less +0 -192
  43. package/src/components/line-chart/line-chart-prop-types.js +0 -298
  44. package/src/components/line-chart/line-chart.interface.ts +0 -128
  45. package/src/components/line-chart/line-chart.jsx +0 -180
  46. package/src/components/line-chart/line-chart.module.less +0 -78
  47. package/src/components/line-chart/plugins/chart-area-text-plugin.js +0 -246
  48. package/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.js +0 -88
  49. package/src/components/line-chart/plugins/plugin-constants.js +0 -11
  50. package/src/components/line-chart/state/action-types.js +0 -12
  51. package/src/components/line-chart/state/initial-state.js +0 -89
  52. package/src/components/line-chart/state/line-chart-reducer.js +0 -101
  53. package/src/components/line-chart/state/manage-state-in-local-storage.js +0 -86
  54. package/src/components/line-chart/state/use-chart-state.js +0 -141
  55. package/src/components/line-chart/utils/axis-formatting/axis-formatting.js +0 -69
  56. package/src/components/line-chart/utils/axis-scales/axis-scales.js +0 -165
  57. package/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.js +0 -13
  58. package/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.js +0 -20
  59. package/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.js +0 -25
  60. package/src/components/line-chart/utils/generate-line-chart-datasets.js +0 -122
  61. package/src/components/line-chart/utils/get-axes-ranges-from-chart.js +0 -13
  62. package/src/components/line-chart/utils/get-line-chart-data-labels.js +0 -21
  63. package/src/components/line-chart/utils/get-line-chart-scales.js +0 -117
  64. package/src/components/line-chart/utils/get-line-chart-tooltips.js +0 -94
  65. package/src/components/line-chart/utils/line-chart-utils.js +0 -62
  66. package/src/components/line-chart/utils/translations/get-translations.js +0 -17
  67. package/src/components/pie-chart/pie-chart-prop-types.js +0 -111
  68. package/src/components/pie-chart/pie-chart-utils.js +0 -32
  69. package/src/components/pie-chart/pie-chart.interface.ts +0 -61
  70. package/src/components/pie-chart/pie-chart.jsx +0 -458
  71. package/src/components/pie-chart/pie-chart.module.less +0 -61
  72. package/src/components/scatter-chart/scatter-chart.intefrace.ts +0 -33
  73. package/src/components/scatter-chart/scatter-chart.jsx +0 -21
  74. package/src/components/scatter-chart/scatter-chart.module.less +0 -4
  75. package/src/helpers/chart-border-plugin.js +0 -19
  76. package/src/helpers/chart-consts.js +0 -64
  77. package/src/helpers/chart-interface.ts +0 -94
  78. package/src/helpers/chart-utils.js +0 -178
  79. package/src/helpers/container.jsx +0 -60
  80. package/src/helpers/disabled-context.js +0 -8
  81. package/src/helpers/enums.js +0 -107
  82. package/src/helpers/get-chart-annotation.js +0 -102
  83. package/src/helpers/get-custom-legend-plugin-example.js +0 -80
  84. package/src/helpers/get-draggableData.js +0 -32
  85. package/src/helpers/range/estimate-data-series-have-close-values.js +0 -54
  86. package/src/helpers/range/range.js +0 -100
  87. package/src/helpers/text.js +0 -6
  88. package/src/style/external.less +0 -4
  89. package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
  90. package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
  91. package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
  92. package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
  93. package/src/style/fonts.less +0 -27
  94. package/src/style/global.less +0 -43
  95. package/src/style/reset/reset.less +0 -28
  96. package/src/style/shared.less +0 -11
  97. package/src/style/variables.less +0 -91
  98. package/vite.config.mjs +0 -49
  99. package/vitest.config.mjs +0 -8
@@ -1,54 +0,0 @@
1
- import { isCloseTo } from '@oliasoft-open-source/units';
2
- import { MAX_DECIMAL_DIFF } from '../chart-consts';
3
- /**
4
- * Estimates whether any of the data series has values that are all close together
5
- * - checks only the first and last values in each series (i.e. assumes they are ordered)
6
- * - uses an equality check with tolerance for decimal precision noise
7
- * - this is just an inexpensive "guesstimate" (full min/max detection can be used afterwards)
8
- *
9
- * @param {Array} generatedDatasets chart dataset series with x, y points
10
- * @return {boolean} - at least one series has values that seem close together
11
- */
12
- export const estimateDataSeriesHaveCloseValues = (generatedDatasets) => {
13
- if (!Array.isArray(generatedDatasets) || !generatedDatasets.length) {
14
- return false;
15
- }
16
- const axesFirstLast = generatedDatasets.reduce((acc, dataset) => {
17
- const xAxisId = dataset?.xAxisID ?? 'defaultX';
18
- const yAxisId = dataset?.yAxisID ?? 'defaultY';
19
- const data = dataset?.data;
20
- if (data && data.length) {
21
- const { x: xFirstCurrent, y: yFirstCurrent } = data?.[0] ?? {};
22
- const { x: xLastCurrent, y: yLastCurrent } = data.at(-1) ?? {};
23
- const xFirstAcc = acc?.[xAxisId]?.xFirst ?? xFirstCurrent;
24
- const xLastAcc = acc?.[xAxisId]?.xLast ?? xLastCurrent;
25
- const yFirstAcc = acc?.[yAxisId]?.yFirst ?? yFirstCurrent;
26
- const yLastAcc = acc?.[yAxisId]?.yLast ?? yLastCurrent;
27
- const xFirst = Math.min(xFirstCurrent, xFirstAcc);
28
- const xLast = Math.max(xLastCurrent, xLastAcc);
29
- const yFirst = Math.min(yFirstCurrent, yFirstAcc);
30
- const yLast = Math.max(yLastCurrent, yLastAcc);
31
- acc = {
32
- ...acc,
33
- [xAxisId]: {
34
- ...acc[xAxisId],
35
- xFirst,
36
- xLast,
37
- },
38
- [yAxisId]: {
39
- yFirst,
40
- yLast,
41
- },
42
- };
43
- }
44
- return acc;
45
- }, {});
46
- return Object.values(axesFirstLast).some(
47
- ({ xFirst, xLast, yFirst, yLast }) => {
48
- return (
49
- isCloseTo(xFirst, xLast, { absoluteDiff: MAX_DECIMAL_DIFF }) ||
50
- isCloseTo(yFirst, yLast, { absoluteDiff: MAX_DECIMAL_DIFF })
51
- );
52
- },
53
- );
54
- };
@@ -1,100 +0,0 @@
1
- import { round, isCloseTo } from '@oliasoft-open-source/units';
2
- import { DECIMAL_POINT_TOLERANCE, MAX_DECIMAL_DIFF } from '../chart-consts';
3
-
4
- const whiteSpacePercentage = 0.05; // relative amount of white space on each "side" of the data points
5
-
6
- const defaultRange = { min: -1, max: 1 };
7
-
8
- /**
9
- * Overrides the default chart.js axis range for some edge-cases:
10
- * - when no data -> default range
11
- * - when all values are close to zero -> default range
12
- * - when all values are close to each other -> custom 5% padding
13
- * - when autoAxisPadding is set -> custom 5% padding
14
- * - all other cases fall back to chart.js default behaviour
15
- *
16
- * `autoAxisPadding` feature requirements:
17
- * - specified by Truls and ported by Mark+Oleg
18
- * - numbers that are equal (within tolerance) shall be presented as a straight line
19
- * - all other data series shall use 90% of width of axis (5% padding each side)
20
- * - the padding on each side shall be symmetric
21
- *
22
- * @param {object} args
23
- * @param {array<number|null>} args.data
24
- * @param {boolean} [args.beginAtZero]
25
- * @param {boolean>} [args.autoAxisPadding]
26
- * @returns {object} returns {min, max} pair
27
- */
28
- export const getSuggestedAxisRange = ({
29
- data,
30
- beginAtZero = false,
31
- autoAxisPadding = false,
32
- }) => {
33
- const dataMin = Math.min(
34
- ...data.filter((v) => v !== null && v !== undefined && !isNaN(v)),
35
- );
36
- const dataMax = Math.max(
37
- ...data.filter((v) => v !== null && v !== undefined && !isNaN(v)),
38
- );
39
- const isNegative = Math.sign(dataMin) === -1 || Math.sign(dataMax) === -1;
40
- const isCloseToZeroWithTolerance =
41
- isCloseTo(dataMin, 0, { absoluteDiff: MAX_DECIMAL_DIFF }) &&
42
- isCloseTo(dataMax, 0, { absoluteDiff: MAX_DECIMAL_DIFF });
43
-
44
- /*
45
- Use default range upon no data or when all values are close to 0
46
- */
47
- if (!data.length || isCloseToZeroWithTolerance) {
48
- return defaultRange;
49
- }
50
-
51
- /*
52
- When all values are close to the same, always add some padding OW-4327
53
- */
54
-
55
- if (isCloseTo(dataMin, dataMax, { absoluteDiff: MAX_DECIMAL_DIFF })) {
56
- const point = dataMax;
57
- const padding = point * whiteSpacePercentage;
58
- const minAxisValue = beginAtZero && !isNegative ? 0 : point - padding;
59
- const maxAxisValue = beginAtZero && isNegative ? 0 : point + padding;
60
- const roundedMinAxisValue = round(maxAxisValue, DECIMAL_POINT_TOLERANCE);
61
- const roundedMaxAxisValue = round(minAxisValue, DECIMAL_POINT_TOLERANCE);
62
- return {
63
- min: roundedMinAxisValue < 0 ? roundedMinAxisValue : roundedMaxAxisValue,
64
- max: roundedMaxAxisValue < 0 ? roundedMaxAxisValue : roundedMinAxisValue,
65
- };
66
- }
67
-
68
- /*
69
- Else fall back to native chart.js implementation when autoAxisPadding is off
70
- */
71
- if (!autoAxisPadding) {
72
- return {
73
- min: undefined,
74
- max: undefined,
75
- };
76
- }
77
-
78
- /*
79
- Else use custom auto scaling with 5% padding (only when autoAxisPadding is set)
80
- */
81
- const rangeBeginAtZero = dataMin === 0 || dataMax === 0 || beginAtZero;
82
- const positiveAndNegative =
83
- Math.sign(dataMin) === -1 && Math.sign(dataMax) === 1;
84
-
85
- const range = Math.abs(dataMax - dataMin);
86
- const padding = autoAxisPadding ? range * whiteSpacePercentage : 0;
87
- const minAxisValue =
88
- !positiveAndNegative && rangeBeginAtZero && beginAtZero && !isNegative
89
- ? 0
90
- : dataMin - padding;
91
- const maxAxisValue =
92
- !positiveAndNegative && rangeBeginAtZero && beginAtZero && isNegative
93
- ? 0
94
- : dataMax + padding;
95
-
96
- return {
97
- min: round(minAxisValue, DECIMAL_POINT_TOLERANCE),
98
- max: round(maxAxisValue, DECIMAL_POINT_TOLERANCE),
99
- };
100
- };
@@ -1,6 +0,0 @@
1
- export const getTextWidth = (text, font) => {
2
- const element = document.createElement('canvas');
3
- const context = element.getContext('2d');
4
- context.font = font;
5
- return context.measureText(text).width;
6
- };
@@ -1,4 +0,0 @@
1
- @import './fonts.less';
2
- @import './reset/reset.less';
3
-
4
- @import '../components/button/button.module.less';
@@ -1,27 +0,0 @@
1
- @font-face {
2
- font-family: 'Lato';
3
- font-weight: normal;
4
- font-style: normal;
5
- src: url('./fonts/lato/Lato-Regular.woff2') format('woff2');
6
- }
7
-
8
- @font-face {
9
- font-family: 'Lato';
10
- font-weight: bold;
11
- font-style: normal;
12
- src: url('./fonts/lato/Lato-Bold.woff2') format('woff2');
13
- }
14
-
15
- @font-face {
16
- font-family: 'Lato';
17
- font-weight: normal;
18
- font-style: italic;
19
- src: url('./fonts/lato/Lato-Italic.woff2') format('woff2');
20
- }
21
-
22
- @font-face {
23
- font-family: 'Lato';
24
- font-weight: bold;
25
- font-style: italic;
26
- src: url('./fonts/lato/Lato-BoldItalic.woff2') format('woff2');
27
- }
@@ -1,43 +0,0 @@
1
- @import './variables.less';
2
- @import './fonts.less';
3
- @import './reset/reset.less';
4
-
5
- html {
6
- font-size: 14px;
7
- }
8
-
9
- body {
10
- color: rgba(0, 0, 0, 0.87);
11
- line-height: 1.4285em;
12
- font-family: @default_font;
13
- font-size: 14px;
14
- }
15
-
16
- h1,
17
- h2,
18
- h3,
19
- h4,
20
- h5 {
21
- line-height: 1.285714em;
22
- margin: 0 0 1rem;
23
- }
24
-
25
- p,
26
- ul,
27
- ol {
28
- margin: 0 0 1rem;
29
- line-height: 1.4285em;
30
-
31
- &:last-child {
32
- margin-bottom: 0;
33
- }
34
- }
35
-
36
- ul,
37
- ol {
38
- padding-left: 1.5em;
39
- }
40
-
41
- a {
42
- text-decoration: none;
43
- }
@@ -1,28 +0,0 @@
1
- @import '~normalize.css/normalize.css';
2
-
3
- /* Border-Box */
4
- *,
5
- *:before,
6
- *:after {
7
- box-sizing: inherit;
8
- }
9
- html {
10
- box-sizing: border-box;
11
- }
12
-
13
- /* iPad Input Shadows */
14
- input[type='text'],
15
- input[type='email'],
16
- input[type='search'],
17
- input[type='password'] {
18
- -webkit-appearance: none;
19
- -moz-appearance: none; /* mobile firefox too! */
20
- }
21
-
22
- /* FF dotted border outlines */
23
- :focus {
24
- outline: none !important;
25
- }
26
- ::-moz-focus-inner {
27
- border: 0 !important;
28
- }
@@ -1,11 +0,0 @@
1
- /*
2
- This file has shared variables that are re-used in other LESS files/modules
3
- Only use simple variables in this file
4
- */
5
-
6
- // Brand guidelines
7
- @colorPrimary: #eb6429;
8
- @colorError: #e14c4c;
9
- @colorWarning: #e2bd27;
10
- @colorSuccess: #3bbb3b;
11
- @colorInfo: #29a7eb;
@@ -1,91 +0,0 @@
1
- @import './shared.less';
2
-
3
- @default_font: 'Lato', sans-serif;
4
-
5
- /*
6
- LAYOUT
7
- */
8
-
9
- @topbar_height: 60px;
10
- @sidebar_width: 300px;
11
- @sidebar_width_collapsed: 70px;
12
-
13
- /*
14
- CARDS
15
- */
16
-
17
- @card_border_radius: 4px;
18
- @card_border_color: #d5d7d9;
19
- @card_header_bg_color: #f7f7f7;
20
- @card_padding_x: 15px;
21
- @card_padding_y: 10px;
22
-
23
- /*
24
- INPUTS
25
- */
26
-
27
- @input_height: 38px;
28
- @input_height_small: 24px;
29
- @input_font_size_small: 12px;
30
- @input_padding_x: 14px;
31
- @input_padding_y: 9.5px;
32
- @input_padding_small_x: 7px;
33
- @input_padding_small_y: 3.5px;
34
- @input_border_radius: 4px;
35
-
36
- /*
37
- COLOR
38
- */
39
-
40
- // Text
41
- @colorTextDefault: rgba(0, 0, 0, 0.87);
42
- @colorTextMuted: #7d7b7a;
43
- @colorTextFaint: #acabab;
44
- @colorTextError: hsl(hue(@colorError), 40%, 50%);
45
- @colorTextWarning: hsl(hue(@colorWarning), 40%, 50%);
46
- @colorTextSuccess: hsl(hue(@colorSuccess), 40%, 50%);
47
- @colorTextPrimary: @colorPrimary;
48
-
49
- :root {
50
- --color-text-default: @colorTextDefault;
51
- --color-text-muted: @colorTextMuted;
52
- --color-text-faint: @colorTextFaint;
53
- --color-text-error: @colorTextError;
54
- --color-text-warning: @colorTextWarning;
55
- --color-text-success: @colorTextSuccess;
56
- --color-text-primary: @colorTextPrimary;
57
- }
58
-
59
- // Buttons
60
- @col_btn_default: white;
61
- @col_btn_primary: @colorPrimary;
62
- @col_btn_danger: @colorError;
63
- @col_btn_success: @colorSuccess;
64
-
65
- // Inputs
66
- @input_border_color: rgba(34, 36, 38, 0.15);
67
- @input_border_color_hover: rgba(34, 36, 38, 0.35);
68
- @input_border_color_focus: hsl(hue(@colorInfo), 40%, 60%);
69
- @input_background_error: hsl(hue(@colorError), 40%, 97%);
70
- @input_border_color_error: hsl(hue(@colorError), 40%, 70%);
71
- @input_color_error: @colorTextError;
72
- @input_background_warning: hsl(hue(@colorWarning), 40%, 97%);
73
- @input_border_color_warning: hsl(hue(@colorWarning), 40%, 70%);
74
- @input_color_warning: @colorTextWarning;
75
- @input_color_placeholder: #c0c0c0;
76
- @input_background_disabled: #ecedef;
77
-
78
- /*
79
- Z-INDEX
80
- */
81
-
82
- @zindex_topbar_alert: 98;
83
- @zindex_drawer: 99;
84
- @zindex_topbar: 101;
85
- @zindex_dimmer: 1000;
86
- @zindex_modal: 2000;
87
- //We need react-laag layers to appear above modals
88
- //Tooltips need to be above dropdown layers
89
- @zindex_popover: 2001;
90
- @zindex_dropdown: 2002;
91
- @zindex_tooltip: 2003;
package/vite.config.mjs DELETED
@@ -1,49 +0,0 @@
1
- import react from '@vitejs/plugin-react-swc';
2
- import cssInjectedByJsPlugin from 'vite-plugin-css-injected-by-js'
3
- import peerDeepExternal from 'rollup-plugin-peer-deps-external';
4
- import path from 'path';
5
-
6
- // https://vitejs.dev/config/
7
- export default () => {
8
- const root = process.cwd();
9
-
10
- return {
11
- base: '/',
12
- root,
13
- assetsInclude: ['**/*.md'],
14
- define: {
15
- globalThis: 'globalThis',
16
- },
17
- publicDir: false,
18
- emptyOutDir: true,
19
- server: {
20
- port: 9001,
21
- host: true,
22
- },
23
- build: {
24
- outDir: 'dist',
25
- minify: false,
26
- sourcemap: true,
27
- lib: {
28
- entry: 'index.js',
29
- formats: ['es'],
30
- fileName: () => 'index.js',
31
- },
32
- rollupOptions: {
33
- plugins: [peerDeepExternal()],
34
- },
35
- },
36
- resolve: {
37
- alias: {
38
- '~components': path.resolve(__dirname, './src/components'),
39
- '~helpers': path.resolve(__dirname, './src/helpers'),
40
- '~style': path.resolve(__dirname, './src/style'),
41
- '~vendor': path.resolve(__dirname, './src/vendor'),
42
- },
43
- },
44
- plugins: [
45
- react(),
46
- cssInjectedByJsPlugin({topExecutionPriority: false}),
47
- ],
48
- };
49
- };
package/vitest.config.mjs DELETED
@@ -1,8 +0,0 @@
1
- import { defineConfig } from 'vitest/config';
2
-
3
- export default defineConfig({
4
- test: {
5
- globals: true,
6
- environment: 'jsdom',
7
- },
8
- });