@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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oliasoft-open-source/charts-library",
3
- "version": "2.5.5",
3
+ "version": "2.5.7",
4
4
  "description": "React Chart Library (based on Chart.js and react-chart-js-2)",
5
5
  "main": "index.js",
6
6
  "files": [
package/release-notes.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Charts Library Release Notes
2
2
 
3
+ ## 2.5.7
4
+
5
+ - Allow stretchy headerComponent in controls
6
+
7
+ ## 2.5.6
8
+
9
+ - Removed resizeDelay, fixed double data labels set position
10
+
3
11
  ## 2.5.5
4
12
 
5
13
  - Removed empty label annotations
@@ -199,7 +199,6 @@ const BarChart = (props) => {
199
199
  options={{
200
200
  onClick,
201
201
  onHover,
202
- resizeDelay: 50,
203
202
  indexAxis: isVertical(options.direction) ? AxisType.X : AxisType.Y,
204
203
  maintainAspectRatio: chartStyling.maintainAspectRatio,
205
204
  animation: {
@@ -37,7 +37,7 @@ const Controls = ({
37
37
  return (
38
38
  <>
39
39
  <div className={styles.controls}>
40
- <div>{headerComponent || <Text bold>{chart.options.title}</Text>}</div>
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 && 'right') ||
19
- (overRightSide && 'left') ||
20
- (overBottomSide && 'end') ||
21
- 'start'
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 { AlignOptions, PointType } from '../../helpers/enums';
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: (context) =>
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: (
@@ -413,7 +413,6 @@ const PieChart = (props) => {
413
413
  animationDuration: options.chartStyling.performanceMode ? 0 : 400,
414
414
  },
415
415
  onHover,
416
- resizeDelay: 50,
417
416
  elements: {
418
417
  pie: {
419
418
  pointStyle: 'circle',
@@ -60,6 +60,8 @@ export const AlignOptions = Object.freeze({
60
60
  End: 'end',
61
61
  Start: 'start',
62
62
  Center: 'center',
63
+ Right: 'right',
64
+ Left: 'left',
63
65
  });
64
66
 
65
67
  export const PointType = Object.freeze({
@@ -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
- };