@oliasoft-open-source/charts-library 2.17.6 → 2.18.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 (84) hide show
  1. package/package.json +26 -34
  2. package/index.js +0 -14
  3. package/release-notes.md +0 -310
  4. package/src/assets/icons/line-and-point.svg +0 -1
  5. package/src/assets/icons/line-only.svg +0 -1
  6. package/src/assets/icons/list-hide.svg +0 -1
  7. package/src/assets/icons/point-only.svg +0 -1
  8. package/src/components/bar-chart/bar-chart-prop-types.js +0 -209
  9. package/src/components/bar-chart/bar-chart.interface.ts +0 -91
  10. package/src/components/bar-chart/bar-chart.jsx +0 -247
  11. package/src/components/bar-chart/bar-chart.module.less +0 -61
  12. package/src/components/bar-chart/get-bar-chart-data-labels.js +0 -42
  13. package/src/components/bar-chart/get-bar-chart-scales.js +0 -123
  14. package/src/components/bar-chart/get-bar-chart-tooltips.js +0 -102
  15. package/src/components/controls/axes-options/axes-options.jsx +0 -270
  16. package/src/components/line-chart/constants/default-translations.js +0 -24
  17. package/src/components/line-chart/constants/line-chart-consts.js +0 -12
  18. package/src/components/line-chart/controls/axes-options/action-types.js +0 -5
  19. package/src/components/line-chart/controls/axes-options/axes-options-form-state.js +0 -97
  20. package/src/components/line-chart/controls/controls.jsx +0 -174
  21. package/src/components/line-chart/controls/controls.module.less +0 -12
  22. package/src/components/line-chart/controls/drag-options.jsx +0 -112
  23. package/src/components/line-chart/controls/legend-options.jsx +0 -36
  24. package/src/components/line-chart/controls/line-options.jsx +0 -64
  25. package/src/components/line-chart/hooks/use-chart-functions.js +0 -257
  26. package/src/components/line-chart/hooks/use-chart-options.js +0 -181
  27. package/src/components/line-chart/hooks/use-chart-plugins.js +0 -35
  28. package/src/components/line-chart/hooks/use-toggle-handler.js +0 -33
  29. package/src/components/line-chart/initialize/config.js +0 -23
  30. package/src/components/line-chart/initialize/initialize-line-chart.js +0 -25
  31. package/src/components/line-chart/line-chart-prop-types.js +0 -292
  32. package/src/components/line-chart/line-chart.interface.ts +0 -121
  33. package/src/components/line-chart/line-chart.jsx +0 -161
  34. package/src/components/line-chart/line-chart.module.less +0 -77
  35. package/src/components/line-chart/plugins/chart-area-text-plugin.js +0 -246
  36. package/src/components/line-chart/plugins/line-chart.minor-gridlines-plugin.js +0 -88
  37. package/src/components/line-chart/plugins/plugin-constants.js +0 -11
  38. package/src/components/line-chart/state/action-types.js +0 -12
  39. package/src/components/line-chart/state/initial-state.js +0 -89
  40. package/src/components/line-chart/state/line-chart-reducer.js +0 -100
  41. package/src/components/line-chart/state/manage-state-in-local-storage.js +0 -86
  42. package/src/components/line-chart/state/use-chart-state.js +0 -141
  43. package/src/components/line-chart/utils/axis-scales/axis-scales.js +0 -165
  44. package/src/components/line-chart/utils/datalabels-alignment/get-alignment-condition.js +0 -13
  45. package/src/components/line-chart/utils/datalabels-alignment/get-alignment-data.js +0 -20
  46. package/src/components/line-chart/utils/datalabels-alignment/get-datalabels-position.js +0 -25
  47. package/src/components/line-chart/utils/generate-line-chart-datasets.js +0 -114
  48. package/src/components/line-chart/utils/get-axes-ranges-from-chart.js +0 -13
  49. package/src/components/line-chart/utils/get-line-chart-data-labels.js +0 -21
  50. package/src/components/line-chart/utils/get-line-chart-scales.js +0 -120
  51. package/src/components/line-chart/utils/get-line-chart-tooltips.js +0 -94
  52. package/src/components/line-chart/utils/line-chart-utils.js +0 -77
  53. package/src/components/line-chart/utils/translations/get-translations.js +0 -17
  54. package/src/components/pie-chart/pie-chart-prop-types.js +0 -111
  55. package/src/components/pie-chart/pie-chart-utils.js +0 -32
  56. package/src/components/pie-chart/pie-chart.interface.ts +0 -61
  57. package/src/components/pie-chart/pie-chart.jsx +0 -450
  58. package/src/components/pie-chart/pie-chart.module.less +0 -61
  59. package/src/components/scatter-chart/scatter-chart.intefrace.ts +0 -33
  60. package/src/components/scatter-chart/scatter-chart.jsx +0 -21
  61. package/src/components/scatter-chart/scatter-chart.module.less +0 -4
  62. package/src/helpers/chart-border-plugin.js +0 -19
  63. package/src/helpers/chart-consts.js +0 -64
  64. package/src/helpers/chart-interface.ts +0 -94
  65. package/src/helpers/chart-utils.js +0 -182
  66. package/src/helpers/container.jsx +0 -60
  67. package/src/helpers/disabled-context.js +0 -8
  68. package/src/helpers/enums.js +0 -96
  69. package/src/helpers/get-chart-annotation.js +0 -106
  70. package/src/helpers/get-custom-legend-plugin-example.js +0 -80
  71. package/src/helpers/get-draggableData.js +0 -32
  72. package/src/helpers/range/estimate-data-series-have-close-values.js +0 -54
  73. package/src/helpers/range/range.js +0 -100
  74. package/src/helpers/text.js +0 -6
  75. package/src/style/external.less +0 -4
  76. package/src/style/fonts/lato/Lato-Bold.woff2 +0 -0
  77. package/src/style/fonts/lato/Lato-BoldItalic.woff2 +0 -0
  78. package/src/style/fonts/lato/Lato-Italic.woff2 +0 -0
  79. package/src/style/fonts/lato/Lato-Regular.woff2 +0 -0
  80. package/src/style/fonts.less +0 -27
  81. package/src/style/global.less +0 -43
  82. package/src/style/reset/reset.less +0 -28
  83. package/src/style/shared.less +0 -11
  84. package/src/style/variables.less +0 -91
@@ -1,94 +0,0 @@
1
- import { ChartHoverMode, Position, TooltipLabel } from '../../../helpers/enums';
2
- import {
3
- afterLabelCallback,
4
- getTooltipLabel,
5
- } from '../../../helpers/chart-utils';
6
-
7
- /**
8
- * @param {import('../line-chart.interface').ILineChartOptions} options - line chart options object
9
- */
10
- const getLineChartToolTips = (options) => {
11
- const getTooltipLabels = (dataset) => {
12
- const xIndex = dataset.xAxisID?.length > 1 ? dataset.xAxisID[1] - 1 : 0;
13
- const yIndex = dataset.yAxisID?.length > 1 ? dataset.yAxisID[1] - 1 : 0;
14
- const xAxis = options.axes.x[xIndex];
15
- const yAxis = options.axes.y[yIndex];
16
-
17
- if (options.axes.x[0].position === Position.Top) {
18
- return {
19
- titleAxisLabel: yAxis?.label || '',
20
- valueAxisLabel: xAxis?.label || '',
21
- titleLabel: TooltipLabel.Y,
22
- valueLabel: TooltipLabel.X,
23
- };
24
- } else {
25
- return {
26
- titleAxisLabel: xAxis?.label || '',
27
- valueAxisLabel: yAxis?.label || '',
28
- titleLabel: TooltipLabel.X,
29
- valueLabel: TooltipLabel.Y,
30
- };
31
- }
32
- };
33
-
34
- const titleCallback = (tooltipItem, data) => {
35
- const labels = getTooltipLabels(tooltipItem[0].dataset);
36
- const { titleLabel, titleAxisLabel } = labels;
37
-
38
- const formattedValue =
39
- titleLabel === TooltipLabel.Y
40
- ? tooltipItem[0].parsed.y
41
- : tooltipItem[0].parsed.x;
42
- const roundedValue =
43
- Math.abs(formattedValue) < 1
44
- ? formattedValue.toPrecision(3)
45
- : formattedValue.toFixed(2);
46
-
47
- return `${roundedValue} ${titleAxisLabel}`;
48
- };
49
-
50
- const labelCallback = (tooltipItem) => {
51
- const { showLabelsInTooltips, hideSimulationName } = options.tooltip;
52
- let label = tooltipItem.dataset.label || '';
53
- const labels = getTooltipLabels(tooltipItem.dataset);
54
- const { valueLabel, valueAxisLabel } = labels;
55
-
56
- const getTooltipItemValue = () => {
57
- const labelNumber =
58
- valueLabel === TooltipLabel.X
59
- ? tooltipItem.parsed.x
60
- : tooltipItem.parsed.y;
61
- return Math.abs(labelNumber) < 1
62
- ? labelNumber.toPrecision(3)
63
- : labelNumber.toFixed(3);
64
- };
65
-
66
- const splitValueAxisLabel = valueAxisLabel.split(' ');
67
- const newValueAxisLabel = hideSimulationName
68
- ? splitValueAxisLabel[splitValueAxisLabel.length - 1]
69
- : valueAxisLabel;
70
-
71
- const tooltipItemValue = getTooltipItemValue();
72
- const valAxisLabel =
73
- label === valueAxisLabel || valueAxisLabel.includes(label)
74
- ? ''
75
- : newValueAxisLabel;
76
- const tooltipLabel = getTooltipLabel(tooltipItem, showLabelsInTooltips);
77
-
78
- return `${label}: ${tooltipItemValue} ${valAxisLabel}${tooltipLabel}`;
79
- };
80
-
81
- return {
82
- enabled: options.tooltip.tooltips,
83
- mode: ChartHoverMode.Nearest,
84
- intersect: true,
85
- padding: 8,
86
- callbacks: {
87
- title: titleCallback,
88
- label: labelCallback,
89
- afterLabel: afterLabelCallback,
90
- },
91
- };
92
- };
93
-
94
- export default getLineChartToolTips;
@@ -1,77 +0,0 @@
1
- import { toNum as toNumber } from '@oliasoft-open-source/units';
2
-
3
- export const toNum = (value) => {
4
- const asNumber = toNumber(value);
5
- return value === '' || isNaN(asNumber) ? '' : asNumber;
6
- };
7
-
8
- export const isLessThanMax = (value, max) => {
9
- return (
10
- value === undefined || max === undefined || Number(value) < Number(max)
11
- );
12
- };
13
-
14
- export const isGreaterThanMin = (value, min) => {
15
- return (
16
- value === undefined || min === undefined || Number(value) > Number(min)
17
- );
18
- };
19
-
20
- /**
21
- * Truncates a number to the specified decimal digits.
22
- * Truncate refers to shaving digits off a number without rounding it.
23
- * @param {Number} number
24
- * @param {Number} digits
25
- * @returns {Number}
26
- */
27
- export const truncateDecimals = (number, digits) => {
28
- const multiplier = 10 ** digits;
29
- const adjustedNum = number * multiplier;
30
- const truncatedNum = Math[adjustedNum < 0 ? 'ceil' : 'floor'](adjustedNum);
31
-
32
- return truncatedNum / multiplier;
33
- };
34
-
35
- /**
36
- *
37
- * @param {'x'|'y'} axisType
38
- * @param {number} [index] - axis index; optional, 0 by default
39
- * @param {boolean} [hasMultiAxes] - optional, false by default
40
- * @return {string} - e.g. x if chart has singular axes; x1, x2 - in case of multiple axes
41
- */
42
- export const generateAxisId = (axisType, index = 0, hasMultiAxes = false) => {
43
- const i = hasMultiAxes ? index + 1 : '';
44
- return `${axisType}${i}`;
45
- };
46
-
47
- /**
48
- Get axis type from a key string.
49
- @param {string} string - The key string to extract from.
50
- @returns {string} e.g. x1 => x
51
- */
52
- export const getAxisTypeFromKey = (string) => {
53
- return string.match(/[^0-9/]+/gi)[0];
54
- };
55
-
56
- /**
57
- * Generates a key based on an array of values. The key changes
58
- * if any of the values in the array change.
59
- *
60
- * @param {Array} values - The array of values to base the key on.
61
- * @returns {String} The key.
62
- */
63
- export const generateKey = (values) => {
64
- const key = values.join('');
65
- return key;
66
- };
67
-
68
- /**
69
- * Checks if a value is a primitive value (which includes strings, numbers, booleans, and null).
70
- * @param {*} value - The value to check.
71
- * @returns {boolean} - Returns true if the value is a primitive value, otherwise false.
72
- */
73
- export const isPrimitiveValue = (value) =>
74
- typeof value === 'string' ||
75
- typeof value === 'number' ||
76
- typeof value === 'boolean' ||
77
- value === null;
@@ -1,17 +0,0 @@
1
- import { defaultTranslations } from '../../constants/default-translations';
2
-
3
- /**
4
- * Merges custom getTranslations with the default getTranslations.
5
- * If a custom translation is provided for a key, it will override the default one.
6
- * @param {object} translations - Custom getTranslations.
7
- * @returns {object} - The resulting getTranslations object, containing both default and custom getTranslations.
8
- */
9
- export const getTranslations = (translations = {}) => {
10
- return Object.keys(defaultTranslations).reduce(
11
- (acc, key) => ({
12
- ...acc,
13
- [key]: translations[key] || defaultTranslations[key],
14
- }),
15
- {},
16
- );
17
- };
@@ -1,111 +0,0 @@
1
- import PropTypes from 'prop-types';
2
-
3
- export const PieChartPropTypes = {
4
- chart: PropTypes.shape({
5
- testId: PropTypes.string,
6
- data: PropTypes.shape({
7
- labels: PropTypes.arrayOf(PropTypes.string),
8
- datasets: PropTypes.arrayOf(PropTypes.object).isRequired,
9
- }).isRequired,
10
- options: PropTypes.shape({
11
- title: PropTypes.oneOfType([
12
- PropTypes.string,
13
- PropTypes.arrayOf(PropTypes.string),
14
- ]),
15
- chartStyling: PropTypes.shape({
16
- width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
17
- height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
18
- maintainAspectRatio: PropTypes.bool,
19
- staticChartHeight: PropTypes.bool,
20
- performanceMode: PropTypes.bool,
21
- }),
22
- tooltip: PropTypes.shape({
23
- tooltips: PropTypes.bool,
24
- showLabelsInTooltips: PropTypes.bool,
25
- }),
26
- graph: PropTypes.shape({
27
- showDataLabels: PropTypes.bool,
28
- stacked: PropTypes.bool,
29
- cutout: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
30
- }),
31
- legend: PropTypes.shape({
32
- display: PropTypes.bool,
33
- position: PropTypes.oneOf(['top', 'bottom', 'right']),
34
- align: PropTypes.oneOf(['start', 'center', 'end']),
35
- useDataset: PropTypes.bool,
36
- }),
37
- chartOptions: PropTypes.shape({
38
- enableZoom: PropTypes.bool,
39
- enablePan: PropTypes.bool,
40
- }),
41
- interactions: PropTypes.shape({
42
- onLegendClick: PropTypes.func,
43
- onPieHover: PropTypes.func,
44
- onPieUnhover: PropTypes.func,
45
- }),
46
- }),
47
- }).isRequired,
48
- };
49
-
50
- export const getDefaultProps = (props) => {
51
- // Add missing nested objects
52
- props.chart.options = props.chart.options || {};
53
- props.chart.options.chartStyling = props.chart.options.chartStyling || {};
54
- props.chart.options.tooltip = props.chart.options.tooltip || {};
55
- props.chart.options.graph = props.chart.options.graph || {};
56
- props.chart.options.legend = props.chart.options.legend || {};
57
- props.chart.options.chartOptions = props.chart.options.chartOptions || {};
58
- props.chart.options.interactions = props.chart.options.interactions || {};
59
- // Set defaults for missing properties
60
- const chart = {
61
- testId: props.chart.testId ?? null,
62
- data: props.chart.data,
63
- options: {
64
- title: props.chart.options.title || '',
65
- chartStyling: {
66
- width: props.chart.options.chartStyling.width,
67
- height: props.chart.options.chartStyling.height,
68
- maintainAspectRatio:
69
- props.chart.options.chartStyling.maintainAspectRatio || false,
70
- staticChartHeight:
71
- props.chart.options.chartStyling.staticChartHeight || false,
72
- performanceMode:
73
- props.chart.options.chartStyling.performanceMode != null
74
- ? props.chart.options.chartStyling.performanceMode
75
- : true,
76
- },
77
- tooltip: {
78
- tooltips:
79
- props.chart.options.tooltip.tooltips != null
80
- ? props.chart.options.tooltip.tooltips
81
- : true,
82
- showLabelsInTooltips:
83
- props.chart.options.tooltip.showLabelsInTooltips || false,
84
- },
85
- graph: {
86
- showDataLabels: props.chart.options.graph.showDataLabels || false,
87
- stacked: props.chart.options.graph.stacked || false,
88
- cutout: props.chart.options.graph.cutout || 0,
89
- },
90
- legend: {
91
- display:
92
- props.chart.options.legend.display != null
93
- ? props.chart.options.legend.display
94
- : true,
95
- useDataset: props.chart.options.legend.useDataset || false,
96
- position: props.chart.options.legend.position || 'bottom',
97
- align: props.chart.options.legend.align || 'center',
98
- },
99
- chartOptions: {
100
- enableZoom: props.chart.options.chartOptions.enableZoom || false,
101
- enablePan: props.chart.options.chartOptions.enablePan || false,
102
- },
103
- interactions: {
104
- onLegendClick: props.chart.options.interactions.onLegendClick,
105
- onPieHover: props.chart.options.interactions.onPieHover,
106
- onPieUnhover: props.chart.options.interactions.onPieUnhover,
107
- },
108
- },
109
- };
110
- return chart;
111
- };
@@ -1,32 +0,0 @@
1
- export const colors = [
2
- '#3366cc',
3
- '#dc3912',
4
- '#ff9900',
5
- '#109618',
6
- '#990099',
7
- '#0099c6',
8
- '#dd4477',
9
- '#66aa00',
10
- '#b82e2e',
11
- '#316395',
12
- '#994499',
13
- '#22aa99',
14
- '#aaaa11',
15
- '#6633cc',
16
- '#e67300',
17
- '#8b0707',
18
- '#651067',
19
- '#329262',
20
- '#5574a6',
21
- '#3b3eac',
22
- ];
23
-
24
- export const generateRandomColor = () => {
25
- const color = `#${Math.floor(Math.random() * 16777215).toString(16)}`;
26
- if (colors.includes(color)) {
27
- return generateRandomColor();
28
- } else {
29
- colors.push(color);
30
- return color;
31
- }
32
- };
@@ -1,61 +0,0 @@
1
- export interface IChartInteractions {
2
- onLegendClick: () => any;
3
- onPointHover: () => any;
4
- onPointUnhover: () => any;
5
- }
6
-
7
- export interface IChartOptions {
8
- enableZoom: boolean;
9
- enablePan: boolean;
10
- }
11
-
12
- export interface IChartLegend {
13
- display: boolean;
14
- position: 'top' | 'bottom' | 'right';
15
- align: 'start' | 'center' | 'end';
16
- useDataset: boolean;
17
- }
18
-
19
- export interface IChartGraph {
20
- showDataLabels: boolean;
21
- stacked: boolean;
22
- cutout: number | string;
23
- }
24
-
25
- export interface IChartTooltip {
26
- tooltips: boolean;
27
- showLabelsInTooltips: boolean;
28
- }
29
-
30
- export interface IChartStyling {
31
- width: number | string;
32
- height: number | string;
33
- maintainAspectRatio: boolean;
34
- staticChartHeight: boolean;
35
- performanceMode: boolean;
36
- }
37
-
38
- export interface IOptions {
39
- title: string | string[];
40
- chartStyling: IChartStyling;
41
- tooltip: IChartTooltip;
42
- graph: IChartGraph;
43
- legend: IChartLegend;
44
- chartOptions: IChartOptions;
45
- interactions: IChartInteractions;
46
- }
47
-
48
- export interface IChartData {
49
- labels: string;
50
- datasets: any[];
51
- }
52
-
53
- export interface IChartData {
54
- testId: string | null;
55
- data: IChartData;
56
- options: IOptions;
57
- }
58
-
59
- export interface IPieChartProps {
60
- chart: IChartData;
61
- }