@oliasoft-open-source/charts-library 2.6.0 → 2.6.2-beta-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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/charts-library",
3
- "version": "2.6.0",
3
+ "version": "2.6.2-beta-0",
4
4
  "description": "React Chart Library (based on Chart.js and react-chart-js-2)",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/release-notes.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Charts Library Release Notes
2
2
 
3
+ ## 2.6.2
4
+
5
+ - Fix asis range update correctly ([OW-10534](https://oliasoft.atlassian.net/browse/OW-10534), and [OW-10457](https://oliasoft.atlassian.net/browse/OW-10457))
6
+
7
+ ## 2.6.1
8
+
9
+ - Added Box and Ellipse annotations ([OW-10519](https://oliasoft.atlassian.net/browse/OW-10519))
10
+
3
11
  ## 2.6.0
4
12
 
5
13
  - Add support for optional `autoAxisPadding` prop, which autoscales 5% padding around data ([OW-10398](https://oliasoft.atlassian.net/browse/OW-10398))
@@ -31,7 +39,7 @@
31
39
 
32
40
  ## 2.5.21
33
41
 
34
- - Revert changes from `2.5.12` / [OW-10320](https://oliasoft.atlassian.net/browse/OW-10320)
42
+ - Revert changes from `2.5.12` / [OW-10320](https://oliasoft.atlassian.net/browse/OW-10320)
35
43
  - Changing thousands separators broke decimal separators in some locales
36
44
  - Resolves [OW-10320](https://oliasoft.atlassian.net/browse/OW-10320)
37
45
 
@@ -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
  }),
@@ -145,7 +145,7 @@ const LineChart = (props) => {
145
145
  payload: { axes },
146
146
  });
147
147
  }
148
- }, [props.chart.options.additionalAxesOptions.range]);
148
+ }, [props.chart.options]);
149
149
 
150
150
  useEffect(() => {
151
151
  if (chartOptions.enablePan !== true) {
@@ -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
- endValue: number
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
- backgroundColor: color,
47
- content: curr?.label,
48
- enabled: false,
49
- position: Position.Top,
50
- },
51
- borderColor: color,
52
- borderWidth: BORDER_WIDTH.INITIAL,
53
- borderDash: ANNOTATION_DASH,
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
  }, {});