@oliasoft-open-source/charts-library 2.6.0 → 2.6.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.
package/package.json
CHANGED
package/release-notes.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Charts Library Release Notes
|
|
2
2
|
|
|
3
|
+
## 2.6.1
|
|
4
|
+
|
|
5
|
+
- Added Box and Ellipse annotations ([OW-10519](https://oliasoft.atlassian.net/browse/OW-10519))
|
|
6
|
+
|
|
3
7
|
## 2.6.0
|
|
4
8
|
|
|
5
9
|
- Add support for optional `autoAxisPadding` prop, which autoscales 5% padding around data ([OW-10398](https://oliasoft.atlassian.net/browse/OW-10398))
|
|
@@ -31,7 +35,7 @@
|
|
|
31
35
|
|
|
32
36
|
## 2.5.21
|
|
33
37
|
|
|
34
|
-
- Revert changes from `2.5.12` / [OW-10320](https://oliasoft.atlassian.net/browse/OW-10320)
|
|
38
|
+
- Revert changes from `2.5.12` / [OW-10320](https://oliasoft.atlassian.net/browse/OW-10320)
|
|
35
39
|
- Changing thousands separators broke decimal separators in some locales
|
|
36
40
|
- Resolves [OW-10320](https://oliasoft.atlassian.net/browse/OW-10320)
|
|
37
41
|
|
|
@@ -71,11 +71,17 @@ export const LineChartPropTypes = {
|
|
|
71
71
|
controlAnnotation: PropTypes.bool,
|
|
72
72
|
annotationsData: PropTypes.arrayOf(
|
|
73
73
|
PropTypes.shape({
|
|
74
|
+
adjustScaleRange: PropTypes.bool,
|
|
74
75
|
annotationAxis: PropTypes.oneOf(['x', 'y']),
|
|
75
|
-
label: PropTypes.string,
|
|
76
76
|
color: PropTypes.string,
|
|
77
|
-
value: PropTypes.number,
|
|
78
77
|
endValue: PropTypes.number,
|
|
78
|
+
label: PropTypes.string,
|
|
79
|
+
type: PropTypes.string,
|
|
80
|
+
value: PropTypes.number,
|
|
81
|
+
xMin: PropTypes.number,
|
|
82
|
+
xMax: PropTypes.number,
|
|
83
|
+
yMin: PropTypes.number,
|
|
84
|
+
yMax: PropTypes.number,
|
|
79
85
|
}),
|
|
80
86
|
),
|
|
81
87
|
}),
|
|
@@ -1,11 +1,17 @@
|
|
|
1
1
|
import { Plugin } from "chart.js";
|
|
2
2
|
|
|
3
3
|
export interface IChartAnnotationsData {
|
|
4
|
+
adjustScaleRange: boolean;
|
|
4
5
|
annotationAxis: 'x' | 'y';
|
|
5
|
-
label: string;
|
|
6
6
|
color: string;
|
|
7
|
+
endValue: number;
|
|
8
|
+
label: string;
|
|
9
|
+
type: string;
|
|
7
10
|
value: number;
|
|
8
|
-
|
|
11
|
+
xMin: number,
|
|
12
|
+
xMax: number,
|
|
13
|
+
yMin: number,
|
|
14
|
+
yMax: number,
|
|
9
15
|
};
|
|
10
16
|
|
|
11
17
|
export interface ILabelAnnotation {
|
|
@@ -6,14 +6,14 @@ const annotationEnter = ({ element }, { chart }) => {
|
|
|
6
6
|
element.options.label.xAdjust = chart.chartArea.left;
|
|
7
7
|
}
|
|
8
8
|
element.options.borderWidth = BORDER_WIDTH.HOVERED;
|
|
9
|
-
element.options.label.enabled = true;
|
|
9
|
+
if (element.options.label) element.options.label.enabled = true;
|
|
10
10
|
chart.draw();
|
|
11
11
|
chart.canvas.style.cursor = CursorStyle.Pointer;
|
|
12
12
|
};
|
|
13
13
|
|
|
14
14
|
const annotationLeave = ({ element }, { chart }) => {
|
|
15
15
|
element.options.borderWidth = BORDER_WIDTH.INITIAL;
|
|
16
|
-
element.options.label.enabled = false;
|
|
16
|
+
if (element.options.label) element.options.label.enabled = false;
|
|
17
17
|
chart.draw();
|
|
18
18
|
chart.canvas.style.cursor = CursorStyle.Initial;
|
|
19
19
|
};
|
|
@@ -37,27 +37,49 @@ const generateAnnotations = (options, state) => {
|
|
|
37
37
|
};
|
|
38
38
|
|
|
39
39
|
const color = curr?.color || COLORS[i];
|
|
40
|
+
const type = curr?.type || 'line';
|
|
41
|
+
const adjustScaleRange = curr?.adjustScaleRange;
|
|
42
|
+
const borderColor = type === 'line' ? color : 'transparent';
|
|
43
|
+
const borderWidth = type === 'line' ? BORDER_WIDTH.INITIAL : 0;
|
|
44
|
+
const borderDash = ANNOTATION_DASH;
|
|
45
|
+
|
|
46
|
+
const label =
|
|
47
|
+
type === 'line'
|
|
48
|
+
? {
|
|
49
|
+
backgroundColor: color,
|
|
50
|
+
content: curr?.label,
|
|
51
|
+
enabled: false,
|
|
52
|
+
position: Position.Top,
|
|
53
|
+
}
|
|
54
|
+
: {
|
|
55
|
+
content: curr?.label,
|
|
56
|
+
enabled: true,
|
|
57
|
+
font: { weight: 'normal' },
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
const enter = (context, event) => {
|
|
61
|
+
if (type !== 'line') return;
|
|
62
|
+
annotationEnter(context, event);
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const leave = (context, event) => {
|
|
66
|
+
if (type !== 'line') return;
|
|
67
|
+
annotationLeave(context, event);
|
|
68
|
+
};
|
|
40
69
|
|
|
41
70
|
const annotation = {
|
|
42
71
|
...curr,
|
|
43
72
|
id: `${curr?.label}-${curr?.value}-${i}`,
|
|
44
73
|
scaleID: getScaleId(),
|
|
45
|
-
label
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
type: ChartType.Line,
|
|
55
|
-
enter: (context, event) => {
|
|
56
|
-
annotationEnter(context, event);
|
|
57
|
-
},
|
|
58
|
-
leave: (context, event) => {
|
|
59
|
-
annotationLeave(context, event);
|
|
60
|
-
},
|
|
74
|
+
label,
|
|
75
|
+
backgroundColor: color,
|
|
76
|
+
borderColor,
|
|
77
|
+
borderWidth,
|
|
78
|
+
borderDash,
|
|
79
|
+
type,
|
|
80
|
+
adjustScaleRange,
|
|
81
|
+
enter,
|
|
82
|
+
leave,
|
|
61
83
|
};
|
|
62
84
|
return { ...acc, [`annotation${i + 1}`]: annotation };
|
|
63
85
|
}, {});
|