@oliasoft-open-source/charts-library 2.5.5 → 2.5.7
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.
- package/package.json +1 -1
- package/release-notes.md +8 -0
- package/src/components/bar-chart/bar-chart.jsx +0 -1
- package/src/components/controls/controls.jsx +1 -1
- package/src/components/line-chart/datalabels-alignment/get-datalabels-position.js +5 -4
- package/src/components/line-chart/get-line-chart-data-labels.js +5 -5
- package/src/components/line-chart/line-chart.jsx +0 -3
- package/src/components/line-chart/line-chart.stories.jsx +9 -0
- package/src/components/pie-chart/pie-chart.jsx +0 -1
- package/src/helpers/enums.js +2 -0
- package/src/components/line-chart/datalabels-alignment/set-chart-line-datalabels-alignment.js +0 -19
package/package.json
CHANGED
package/release-notes.md
CHANGED
|
@@ -37,7 +37,7 @@ const Controls = ({
|
|
|
37
37
|
return (
|
|
38
38
|
<>
|
|
39
39
|
<div className={styles.controls}>
|
|
40
|
-
|
|
40
|
+
{headerComponent || <Text bold>{chart.options.title}</Text>}
|
|
41
41
|
<div className={styles.buttons}>
|
|
42
42
|
{!showTable && (
|
|
43
43
|
<>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { getCondition } from './get-alignment-condition';
|
|
2
2
|
import { getAlignmentData } from './get-alignment-data';
|
|
3
|
+
import { AlignOptions } from '../../../helpers/enums';
|
|
3
4
|
|
|
4
5
|
/** returning position depends on condition
|
|
5
6
|
*
|
|
@@ -15,10 +16,10 @@ export const getPosition = () => {
|
|
|
15
16
|
} = getCondition(x, y, left, right, bottom);
|
|
16
17
|
|
|
17
18
|
return (
|
|
18
|
-
(overLeftSide &&
|
|
19
|
-
(overRightSide &&
|
|
20
|
-
(overBottomSide &&
|
|
21
|
-
|
|
19
|
+
(overLeftSide && AlignOptions.Right) ||
|
|
20
|
+
(overRightSide && AlignOptions.Left) ||
|
|
21
|
+
(overBottomSide && AlignOptions.End) ||
|
|
22
|
+
AlignOptions.Start
|
|
22
23
|
);
|
|
23
24
|
};
|
|
24
25
|
};
|
|
@@ -1,17 +1,17 @@
|
|
|
1
1
|
import { AUTO } from '../../helpers/chart-consts';
|
|
2
|
-
import {
|
|
2
|
+
import { getPosition } from './datalabels-alignment/get-datalabels-position';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
|
+
* adjusts the position of the label depends on chart area
|
|
6
|
+
*
|
|
5
7
|
* @param {import('./line-chart.interface').ILineChartOptions} options - line chart options object
|
|
8
|
+
* @return {object} - returning position, if label exist in datasets item
|
|
6
9
|
*/
|
|
7
10
|
const getLineChartDataLabels = (options) => {
|
|
8
11
|
return options.graph.showDataLabels
|
|
9
12
|
? {
|
|
10
13
|
display: AUTO,
|
|
11
|
-
align: (
|
|
12
|
-
context.dataset.pointType === PointType.Casing
|
|
13
|
-
? AlignOptions.Start
|
|
14
|
-
: AlignOptions.End,
|
|
14
|
+
align: getPosition(),
|
|
15
15
|
formatter: (value, context) =>
|
|
16
16
|
context.dataset.data[context.dataIndex].label || '',
|
|
17
17
|
}
|
|
@@ -70,7 +70,6 @@ import {
|
|
|
70
70
|
PanZoomMode,
|
|
71
71
|
PointStyle,
|
|
72
72
|
} from '../../helpers/enums';
|
|
73
|
-
import { setDataLabelsAlignment } from './datalabels-alignment/set-chart-line-datalabels-alignment';
|
|
74
73
|
|
|
75
74
|
ChartJS.register(
|
|
76
75
|
LinearScale,
|
|
@@ -232,7 +231,6 @@ const LineChart = (props) => {
|
|
|
232
231
|
: DEFAULT_LINE_POINT_RADIUS,
|
|
233
232
|
pointHoverRadius,
|
|
234
233
|
pointHitRadius: line.pointHitRadius || pointHoverRadius,
|
|
235
|
-
datalabels: setDataLabelsAlignment(options),
|
|
236
234
|
};
|
|
237
235
|
});
|
|
238
236
|
return generatedDatasets;
|
|
@@ -435,7 +433,6 @@ const LineChart = (props) => {
|
|
|
435
433
|
options={{
|
|
436
434
|
onClick,
|
|
437
435
|
onHover,
|
|
438
|
-
resizeDelay: 50,
|
|
439
436
|
maintainAspectRatio: chartStyling.maintainAspectRatio,
|
|
440
437
|
aspectRatio: chartStyling.squareAspectRatio ? 1 : null, // 1 equals square aspect ratio
|
|
441
438
|
animation: {
|
|
@@ -522,6 +522,15 @@ export const HeaderComponent = (args) => {
|
|
|
522
522
|
);
|
|
523
523
|
};
|
|
524
524
|
|
|
525
|
+
export const HeaderComponentFullWidth = Template.bind({});
|
|
526
|
+
HeaderComponentFullWidth.args = {
|
|
527
|
+
headerComponent: (
|
|
528
|
+
<div style={{ flexGrow: 1, minWidth: 150 }}>
|
|
529
|
+
<Slider max={100} min={0} onChange={() => {}} showArrows value={50} />
|
|
530
|
+
</div>
|
|
531
|
+
),
|
|
532
|
+
};
|
|
533
|
+
|
|
525
534
|
export const SubheaderComponent = Template.bind({});
|
|
526
535
|
SubheaderComponent.args = {
|
|
527
536
|
subheaderComponent: (
|
package/src/helpers/enums.js
CHANGED
package/src/components/line-chart/datalabels-alignment/set-chart-line-datalabels-alignment.js
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import { getPosition } from './get-datalabels-position';
|
|
2
|
-
|
|
3
|
-
/** adjusts the position of the label depends on chart area
|
|
4
|
-
*
|
|
5
|
-
* @param {import('../components/bar-chart/bar-chart.interface').IBarChartOptions |
|
|
6
|
-
* import('../components/line-chart/line-chart.interface').ILineChartOptions} options - chart options object
|
|
7
|
-
* @return {object} - returning position, if label exist in datasets item
|
|
8
|
-
*/
|
|
9
|
-
export const setDataLabelsAlignment = (options) => {
|
|
10
|
-
const { graph = {} } = options || {};
|
|
11
|
-
const { showDataLabels = false } = graph;
|
|
12
|
-
|
|
13
|
-
return showDataLabels
|
|
14
|
-
? {
|
|
15
|
-
display: true,
|
|
16
|
-
align: getPosition(),
|
|
17
|
-
}
|
|
18
|
-
: {};
|
|
19
|
-
};
|