@oliasoft-open-source/charts-library 2.5.18 → 2.5.19
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 +4 -0
- package/src/components/bar-chart/bar-chart.jsx +4 -0
- package/src/components/line-chart/get-line-chart-scales.js +23 -18
- package/src/components/line-chart/line-chart-consts.js +1 -0
- package/src/components/line-chart/line-chart.jsx +7 -2
- package/src/helpers/chart-border-plugin.js +19 -0
- package/src/helpers/chart-consts.js +1 -1
- package/src/helpers/chart-utils.js +4 -2
package/package.json
CHANGED
package/release-notes.md
CHANGED
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
# Charts Library Release Notes
|
|
2
2
|
|
|
3
|
+
## 2.5.19
|
|
4
|
+
|
|
5
|
+
- Hide irregular major axis ticks ([OW-10088](https://oliasoft.atlassian.net/browse/OW-10088))
|
|
6
|
+
|
|
3
7
|
## 2.5.18
|
|
4
8
|
|
|
5
9
|
- Fixed minor gridlines when last major tick does not reach axis bounds ([OW-10296](https://oliasoft.atlassian.net/browse/OW-10296))
|
|
@@ -37,6 +37,7 @@ import {
|
|
|
37
37
|
AUTO,
|
|
38
38
|
COLORS,
|
|
39
39
|
CUSTOM_LEGEND_PLUGIN_NAME,
|
|
40
|
+
BORDER_COLOR,
|
|
40
41
|
} from '../../helpers/chart-consts';
|
|
41
42
|
import {
|
|
42
43
|
AxisType,
|
|
@@ -226,6 +227,9 @@ const BarChart = (props) => {
|
|
|
226
227
|
.customLegendPlugin && {
|
|
227
228
|
containerID: options.legend.customLegend.customLegendContainerID,
|
|
228
229
|
},
|
|
230
|
+
chartAreaBorder: {
|
|
231
|
+
borderColor: BORDER_COLOR,
|
|
232
|
+
},
|
|
229
233
|
},
|
|
230
234
|
}}
|
|
231
235
|
plugins={getPlugins(graph, options.legend)}
|
|
@@ -38,24 +38,29 @@ const getLineChartAxis = (options, axisType, state, currentScales, i = 0) => {
|
|
|
38
38
|
}
|
|
39
39
|
: {};
|
|
40
40
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
41
|
+
const ticks =
|
|
42
|
+
additionalAxesOptions.chartScaleType === ScaleType.Logarithmic
|
|
43
|
+
? {
|
|
44
|
+
callback: (tick) => {
|
|
45
|
+
return LOGARITHMIC_STEPS.includes(tick)
|
|
46
|
+
? tick.toLocaleString()
|
|
47
|
+
: '';
|
|
48
|
+
},
|
|
49
|
+
}
|
|
50
|
+
: {
|
|
51
|
+
callback(val) {
|
|
52
|
+
const value = this.getLabelForValue(val);
|
|
53
|
+
return value.replaceAll(/,/g, ' ');
|
|
54
|
+
},
|
|
55
|
+
stepSize:
|
|
56
|
+
axisData.stepSize ||
|
|
57
|
+
(axisType === AxisType.Y ? additionalAxesOptions.stepSize : null),
|
|
58
|
+
...truncateAxisNumbersToDigitsCallback,
|
|
59
|
+
};
|
|
60
|
+
return {
|
|
61
|
+
...ticks,
|
|
62
|
+
includeBounds: false, //OW-10088 disable irregular axis ticks
|
|
63
|
+
};
|
|
59
64
|
};
|
|
60
65
|
|
|
61
66
|
return {
|
|
@@ -45,6 +45,7 @@ import {
|
|
|
45
45
|
DEFAULT_HOVER_RADIUS,
|
|
46
46
|
DEFAULT_LINE_POINT_RADIUS,
|
|
47
47
|
DEFAULT_POINT_RADIUS,
|
|
48
|
+
ZOOM_BOX_BACKGROUND_COLOR,
|
|
48
49
|
} from './line-chart-consts';
|
|
49
50
|
|
|
50
51
|
import getAnnotation from '../../helpers/get-chart-annotation';
|
|
@@ -63,6 +64,7 @@ import {
|
|
|
63
64
|
AUTO,
|
|
64
65
|
COLORS,
|
|
65
66
|
CUSTOM_LEGEND_PLUGIN_NAME,
|
|
67
|
+
BORDER_COLOR,
|
|
66
68
|
} from '../../helpers/chart-consts';
|
|
67
69
|
import {
|
|
68
70
|
AxisType,
|
|
@@ -486,8 +488,8 @@ const LineChart = (props) => {
|
|
|
486
488
|
drag: {
|
|
487
489
|
enabled: state.zoomEnabled,
|
|
488
490
|
threshold: 3,
|
|
489
|
-
backgroundColor:
|
|
490
|
-
borderColor:
|
|
491
|
+
backgroundColor: ZOOM_BOX_BACKGROUND_COLOR,
|
|
492
|
+
borderColor: BORDER_COLOR,
|
|
491
493
|
borderWidth: 1,
|
|
492
494
|
},
|
|
493
495
|
onZoomComplete({ chart }) {
|
|
@@ -502,6 +504,9 @@ const LineChart = (props) => {
|
|
|
502
504
|
containerID:
|
|
503
505
|
options.legend.customLegend.customLegendContainerID,
|
|
504
506
|
},
|
|
507
|
+
chartAreaBorder: {
|
|
508
|
+
borderColor: BORDER_COLOR,
|
|
509
|
+
},
|
|
505
510
|
},
|
|
506
511
|
}}
|
|
507
512
|
plugins={getPlugins(graph, legend, state)}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chart border plugin config
|
|
3
|
+
*/
|
|
4
|
+
export const chartAreaBorderPlugin = {
|
|
5
|
+
id: 'chartAreaBorder',
|
|
6
|
+
beforeDraw(chart, args, options) {
|
|
7
|
+
const {
|
|
8
|
+
ctx,
|
|
9
|
+
chartArea: { left, top, width, height },
|
|
10
|
+
} = chart;
|
|
11
|
+
ctx.save();
|
|
12
|
+
ctx.strokeStyle = options.borderColor;
|
|
13
|
+
ctx.lineWidth = options.borderWidth;
|
|
14
|
+
ctx.setLineDash(options.borderDash || []);
|
|
15
|
+
ctx.lineDashOffset = options.borderDashOffset;
|
|
16
|
+
ctx.strokeRect(left, top, width, height);
|
|
17
|
+
ctx.restore();
|
|
18
|
+
},
|
|
19
|
+
};
|
|
@@ -2,9 +2,9 @@ export const BORDER_WIDTH = {
|
|
|
2
2
|
INITIAL: 2,
|
|
3
3
|
HOVERED: 6,
|
|
4
4
|
};
|
|
5
|
+
export const BORDER_COLOR = 'rgba(0,0,0,0.1)';
|
|
5
6
|
|
|
6
7
|
export const ANNOTATION_DASH = [10, 2];
|
|
7
|
-
export const DEFAULT_BORDER_COLOR = 'rgba(0,0,0,0.1)';
|
|
8
8
|
export const DEFAULT_FONT_SIZE = 13;
|
|
9
9
|
export const DEFAULT_FONT_FAMILY = '"Lato", sans-serif';
|
|
10
10
|
export const DEFAULT_COLOR = 'rgba(0,0,0,.87)';
|
|
@@ -3,7 +3,7 @@ import cx from 'classnames';
|
|
|
3
3
|
import { chartMinorGridlinesPlugin } from '../components/line-chart/line-chart.minor-gridlines-plugin';
|
|
4
4
|
import {
|
|
5
5
|
CUSTOM_LEGEND_PLUGIN_NAME,
|
|
6
|
-
|
|
6
|
+
BORDER_COLOR,
|
|
7
7
|
DEFAULT_CHART_NAME,
|
|
8
8
|
DEFAULT_COLOR,
|
|
9
9
|
DEFAULT_FONT_FAMILY,
|
|
@@ -12,6 +12,7 @@ import {
|
|
|
12
12
|
WHITE_COLOR_AS_DECIMAL,
|
|
13
13
|
} from './chart-consts';
|
|
14
14
|
import { AxisType, ChartDirection, Position } from './enums';
|
|
15
|
+
import { chartAreaBorderPlugin } from './chart-border-plugin';
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* @param {import('../components/bar-chart/bar-chart.interface').IBarChartGraph |
|
|
@@ -35,6 +36,7 @@ export const getPlugins = (graph, legend, state = null) => {
|
|
|
35
36
|
...legend.customLegend.customLegendPlugin,
|
|
36
37
|
});
|
|
37
38
|
}
|
|
39
|
+
plugins.push(chartAreaBorderPlugin);
|
|
38
40
|
return plugins;
|
|
39
41
|
};
|
|
40
42
|
|
|
@@ -201,5 +203,5 @@ export const setDefaultTheme = () => {
|
|
|
201
203
|
defaults.font.size = DEFAULT_FONT_SIZE;
|
|
202
204
|
defaults.font.family = DEFAULT_FONT_FAMILY;
|
|
203
205
|
defaults.color = DEFAULT_COLOR;
|
|
204
|
-
defaults.borderColor =
|
|
206
|
+
defaults.borderColor = BORDER_COLOR;
|
|
205
207
|
};
|