@oliasoft-open-source/charts-library 2.2.1 → 2.3.0
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
|
@@ -64,6 +64,7 @@ export const LineChartPropTypes = {
|
|
|
64
64
|
showMinorGridlines: PropTypes.bool,
|
|
65
65
|
}),
|
|
66
66
|
annotations: PropTypes.shape({
|
|
67
|
+
labelAnnotation: PropTypes.object,
|
|
67
68
|
showAnnotations: PropTypes.bool,
|
|
68
69
|
controlAnnotation: PropTypes.bool,
|
|
69
70
|
annotationsData: PropTypes.arrayOf(
|
|
@@ -166,6 +167,7 @@ export const getDefaultProps = (props) => {
|
|
|
166
167
|
props.chart.options.graph.showMinorGridlines || false,
|
|
167
168
|
},
|
|
168
169
|
annotations: {
|
|
170
|
+
labelAnnotation: props.chart.options.annotations.labelAnnotation || {},
|
|
169
171
|
showAnnotations:
|
|
170
172
|
props.chart.options.annotations.showAnnotations ?? false,
|
|
171
173
|
controlAnnotation:
|
|
@@ -8,10 +8,18 @@ export interface IChartAnnotationsData {
|
|
|
8
8
|
endValue: number
|
|
9
9
|
};
|
|
10
10
|
|
|
11
|
+
export interface ILabelAnnotation {
|
|
12
|
+
content: string[];
|
|
13
|
+
fontSize: number;
|
|
14
|
+
xAdjust: number;
|
|
15
|
+
yAdjust: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
11
18
|
export interface IChartAnnotations {
|
|
12
19
|
showAnnotations: boolean;
|
|
13
20
|
controlAnnotation: boolean;
|
|
14
21
|
annotationsData: IChartAnnotationsData[];
|
|
22
|
+
labelAnnotation: ILabelAnnotation
|
|
15
23
|
}
|
|
16
24
|
|
|
17
25
|
export interface IChartStyling {
|
|
@@ -64,6 +64,36 @@ const generateAnnotations = (options, state) => {
|
|
|
64
64
|
return annotations;
|
|
65
65
|
};
|
|
66
66
|
|
|
67
|
+
/**
|
|
68
|
+
* @param {import('../components/bar-chart/bar-chart.interface').IBarChartOptions |
|
|
69
|
+
* import('../components/line-chart/line-chart.interface').ILineChartOptions} options - chart options object
|
|
70
|
+
* @return {{label1: {}}}
|
|
71
|
+
*/
|
|
72
|
+
const getLabelAnnotation = (options) => {
|
|
73
|
+
const { annotations } = options;
|
|
74
|
+
const isDarkModeOn = options.chartStyling.darkMode || false;
|
|
75
|
+
const {
|
|
76
|
+
content = [],
|
|
77
|
+
xAdjust = -200,
|
|
78
|
+
yAdjust = 120,
|
|
79
|
+
fontSize = 12,
|
|
80
|
+
} = annotations.labelAnnotation;
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
label1: {
|
|
84
|
+
type: 'label',
|
|
85
|
+
xAdjust,
|
|
86
|
+
yAdjust,
|
|
87
|
+
backgroundColor: 'rgba(0, 0, 0, 0)',
|
|
88
|
+
color: isDarkModeOn && 'rgba(255, 255, 255, 1)',
|
|
89
|
+
content,
|
|
90
|
+
font: {
|
|
91
|
+
size: fontSize,
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
|
|
67
97
|
/**
|
|
68
98
|
* @param {import('../components/bar-chart/bar-chart.interface').IBarChartOptions |
|
|
69
99
|
* import('../components/line-chart/line-chart.interface').ILineChartOptions} options - chart options object
|
|
@@ -74,11 +104,16 @@ const getAnnotation = (options, state) => {
|
|
|
74
104
|
const { annotations } = options;
|
|
75
105
|
const isAnnotationShown = annotations?.showAnnotations;
|
|
76
106
|
const isAnnotationDataProvided = annotations?.annotationsData?.length;
|
|
107
|
+
|
|
108
|
+
const formAnnotation = {
|
|
109
|
+
...getLabelAnnotation(options),
|
|
110
|
+
...(isAnnotationShown && isAnnotationDataProvided
|
|
111
|
+
? generateAnnotations(options, state)
|
|
112
|
+
: []),
|
|
113
|
+
};
|
|
114
|
+
|
|
77
115
|
return {
|
|
78
|
-
annotations:
|
|
79
|
-
isAnnotationShown && isAnnotationDataProvided
|
|
80
|
-
? generateAnnotations(options, state)
|
|
81
|
-
: [],
|
|
116
|
+
annotations: formAnnotation,
|
|
82
117
|
};
|
|
83
118
|
};
|
|
84
119
|
export default getAnnotation;
|