@oliasoft-open-source/charts-library 4.3.0-beta-3 → 4.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/dist/index.js +57 -32
- package/dist/index.js.map +1 -1
- package/dist/src/components/bar-chart/bar-chart.interface.d.ts +6 -2
- package/dist/src/components/bar-chart/bar-chart.stories.d.ts +41 -0
- package/dist/src/components/common/helpers/chart-consts.d.ts +1 -0
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +7 -14
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22218,6 +22218,9 @@ const reducer$1 = (state, action) => {
|
|
|
22218
22218
|
if (draft.enableDragPoints) {
|
|
22219
22219
|
draft.enableDragPoints = false;
|
|
22220
22220
|
}
|
|
22221
|
+
if (draft.enableDragAnnotation) {
|
|
22222
|
+
draft.enableDragAnnotation = false;
|
|
22223
|
+
}
|
|
22221
22224
|
break;
|
|
22222
22225
|
}
|
|
22223
22226
|
case TOGGLE_PAN: {
|
|
@@ -22228,6 +22231,9 @@ const reducer$1 = (state, action) => {
|
|
|
22228
22231
|
if (draft.enableDragPoints) {
|
|
22229
22232
|
draft.enableDragPoints = false;
|
|
22230
22233
|
}
|
|
22234
|
+
if (draft.enableDragAnnotation) {
|
|
22235
|
+
draft.enableDragAnnotation = false;
|
|
22236
|
+
}
|
|
22231
22237
|
break;
|
|
22232
22238
|
}
|
|
22233
22239
|
case TOGGLE_POINTS: {
|
|
@@ -22272,6 +22278,9 @@ const reducer$1 = (state, action) => {
|
|
|
22272
22278
|
if (draft.zoomEnabled) {
|
|
22273
22279
|
draft.zoomEnabled = false;
|
|
22274
22280
|
}
|
|
22281
|
+
if (draft.enableDragAnnotation) {
|
|
22282
|
+
draft.enableDragAnnotation = false;
|
|
22283
|
+
}
|
|
22275
22284
|
break;
|
|
22276
22285
|
}
|
|
22277
22286
|
case TOGGLE_DRAG_ANNOTATION: {
|
|
@@ -22285,7 +22294,8 @@ const reducer$1 = (state, action) => {
|
|
|
22285
22294
|
break;
|
|
22286
22295
|
}
|
|
22287
22296
|
case DISABLE_DRAG_OPTIONS: {
|
|
22288
|
-
if (draft.enableDragPoints || draft.panEnabled || draft.zoomEnabled) {
|
|
22297
|
+
if (draft.enableDragAnnotation || draft.enableDragPoints || draft.panEnabled || draft.zoomEnabled) {
|
|
22298
|
+
draft.enableDragAnnotation = false;
|
|
22289
22299
|
draft.enableDragPoints = false;
|
|
22290
22300
|
draft.panEnabled = false;
|
|
22291
22301
|
draft.zoomEnabled = false;
|
|
@@ -22469,6 +22479,7 @@ const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
|
|
|
22469
22479
|
const LEGEND_LABEL_BOX_SIZE = 12;
|
|
22470
22480
|
const TOOLTIP_PADDING = 8;
|
|
22471
22481
|
const TOOLTIP_BOX_PADDING = 4;
|
|
22482
|
+
const TRANSPARENT = "transparent";
|
|
22472
22483
|
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
22473
22484
|
const COLORS = [
|
|
22474
22485
|
"#3366cc",
|
|
@@ -25397,9 +25408,14 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25397
25408
|
[AnnotationType.LINE]: color2,
|
|
25398
25409
|
[AnnotationType.POINT]: color2,
|
|
25399
25410
|
[AnnotationType.BOX]: color2
|
|
25400
|
-
}[type] ||
|
|
25411
|
+
}[type] || TRANSPARENT;
|
|
25401
25412
|
const borderWidth = type === AnnotationType.LINE ? BORDER_WIDTH.INITIAL : 0;
|
|
25402
25413
|
const borderDash = type === AnnotationType.LINE ? ANNOTATION_DASH : void 0;
|
|
25414
|
+
const defLabel = {
|
|
25415
|
+
content: ann == null ? void 0 : ann.label,
|
|
25416
|
+
display: true,
|
|
25417
|
+
font: { weight: "normal" }
|
|
25418
|
+
};
|
|
25403
25419
|
const label = {
|
|
25404
25420
|
[AnnotationType.LINE]: {
|
|
25405
25421
|
backgroundColor: color2,
|
|
@@ -25408,23 +25424,20 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25408
25424
|
position: Position.Top
|
|
25409
25425
|
},
|
|
25410
25426
|
[AnnotationType.POINT]: {
|
|
25411
|
-
backgroundColor: ((_a2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _a2.backgroundColor) ??
|
|
25427
|
+
backgroundColor: ((_a2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _a2.backgroundColor) ?? TRANSPARENT,
|
|
25412
25428
|
content: ann == null ? void 0 : ann.label,
|
|
25413
25429
|
display: !!(ann == null ? void 0 : ann.label),
|
|
25414
25430
|
position: ((_b2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _b2.position) ?? Position.Bottom,
|
|
25415
|
-
color: ((_c2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _c2.color) ??
|
|
25416
|
-
font: ((_d2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _d2.font) ?? `
|
|
25431
|
+
color: ((_c2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _c2.color) ?? DEFAULT_COLOR,
|
|
25432
|
+
font: ((_d2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _d2.font) ?? `12px ${DEFAULT_FONT_FAMILY}`,
|
|
25417
25433
|
borderWidth: BORDER_WIDTH.INITIAL,
|
|
25418
25434
|
padding: 5,
|
|
25419
25435
|
borderRadius: 3,
|
|
25420
|
-
borderColor: ((_e2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _e2.borderColor) ??
|
|
25436
|
+
borderColor: ((_e2 = ann == null ? void 0 : ann.labelConfig) == null ? void 0 : _e2.borderColor) ?? TRANSPARENT
|
|
25421
25437
|
},
|
|
25422
|
-
[AnnotationType.BOX]:
|
|
25423
|
-
|
|
25424
|
-
|
|
25425
|
-
font: { weight: "normal" }
|
|
25426
|
-
}
|
|
25427
|
-
}[type] || "transparent";
|
|
25438
|
+
[AnnotationType.BOX]: defLabel,
|
|
25439
|
+
[AnnotationType.ELLIPSE]: defLabel
|
|
25440
|
+
}[type] || defLabel;
|
|
25428
25441
|
const enter = ({
|
|
25429
25442
|
element
|
|
25430
25443
|
}, {
|
|
@@ -26183,7 +26196,6 @@ const annotationLabel = (ctx, annotations, scales) => {
|
|
|
26183
26196
|
var _a2;
|
|
26184
26197
|
if (annotation2.type === AnnotationType.POINT && !isNil(annotation2 == null ? void 0 : annotation2.label) && ((_a2 = annotation2 == null ? void 0 : annotation2.label) == null ? void 0 : _a2.display)) {
|
|
26185
26198
|
const { content, font, color: color2, position, padding } = (annotation2 == null ? void 0 : annotation2.label) ?? {};
|
|
26186
|
-
console.log(cloneDeep(annotation2));
|
|
26187
26199
|
ctx.save();
|
|
26188
26200
|
ctx.font = font;
|
|
26189
26201
|
ctx.fillStyle = color2;
|
|
@@ -39667,32 +39679,41 @@ const useBarChartConfig = (chartRef, chart2) => {
|
|
|
39667
39679
|
[chartRef, chart2]
|
|
39668
39680
|
);
|
|
39669
39681
|
};
|
|
39682
|
+
const getStackedOptions = (axisType, { stacked, stackedX, stackedY }) => {
|
|
39683
|
+
if (axisType === AxisType.X) {
|
|
39684
|
+
return stackedX ?? stacked;
|
|
39685
|
+
} else if (axisType === AxisType.Y) {
|
|
39686
|
+
return stackedY ?? stacked;
|
|
39687
|
+
}
|
|
39688
|
+
return stacked;
|
|
39689
|
+
};
|
|
39670
39690
|
const getBarChartAxis = ({
|
|
39671
39691
|
chart: chart2,
|
|
39672
39692
|
axisType = AxisType.X,
|
|
39673
39693
|
currentScale,
|
|
39674
39694
|
i: i2
|
|
39675
39695
|
}) => {
|
|
39676
|
-
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2
|
|
39677
|
-
const
|
|
39678
|
-
const
|
|
39696
|
+
var _a2, _b2, _c2, _d2, _e2, _f2, _g2, _h2, _i2;
|
|
39697
|
+
const { data, options } = chart2 ?? {};
|
|
39698
|
+
const isDirectionVertical = isVertical(options.direction);
|
|
39699
|
+
const axisData = currentScale || ((_b2 = (_a2 = options == null ? void 0 : options.axes) == null ? void 0 : _a2[axisType]) == null ? void 0 : _b2[0]);
|
|
39679
39700
|
const isDirectionCompatibleWithAxisType = isDirectionVertical && axisType === AxisType.Y || !isDirectionVertical && axisType === AxisType.X;
|
|
39680
39701
|
const grid = (axisData == null ? void 0 : axisData.gridLines) || {};
|
|
39681
39702
|
const getScaleType = () => {
|
|
39682
|
-
var _a3
|
|
39683
|
-
const scaleType =
|
|
39703
|
+
var _a3;
|
|
39704
|
+
const scaleType = data.labels ? ScaleType.Category : ScaleType.Linear;
|
|
39684
39705
|
const axisWithScale = isDirectionVertical ? AxisType.X : AxisType.Y;
|
|
39685
|
-
return axisType === axisWithScale ? scaleType : (
|
|
39706
|
+
return axisType === axisWithScale ? scaleType : (_a3 = options == null ? void 0 : options.additionalAxesOptions) == null ? void 0 : _a3.chartScaleType;
|
|
39686
39707
|
};
|
|
39687
39708
|
const getReverse = () => {
|
|
39688
|
-
var _a3
|
|
39709
|
+
var _a3;
|
|
39689
39710
|
const axisWithReverse = isDirectionVertical ? AxisType.Y : AxisType.X;
|
|
39690
|
-
return axisType === axisWithReverse ? (
|
|
39711
|
+
return axisType === axisWithReverse ? (_a3 = options == null ? void 0 : options.additionalAxesOptions) == null ? void 0 : _a3.reverse : false;
|
|
39691
39712
|
};
|
|
39692
39713
|
const getTicks = () => {
|
|
39693
|
-
var _a3, _b3
|
|
39694
|
-
const additionalAxesOptions =
|
|
39695
|
-
const ticksConfigFromProps = (
|
|
39714
|
+
var _a3, _b3;
|
|
39715
|
+
const additionalAxesOptions = options == null ? void 0 : options.additionalAxesOptions;
|
|
39716
|
+
const ticksConfigFromProps = (_b3 = (_a3 = options == null ? void 0 : options.scales) == null ? void 0 : _a3[`${i2 === 0 ? axisType : axisType + i2}`]) == null ? void 0 : _b3.ticks;
|
|
39696
39717
|
const isLogarithmic = isDirectionCompatibleWithAxisType && (additionalAxesOptions == null ? void 0 : additionalAxesOptions.chartScaleType) === ScaleType.Logarithmic;
|
|
39697
39718
|
const ticksFormattingCallback = (tick, _2, ticks2) => {
|
|
39698
39719
|
return isLogarithmic ? LOGARITHMIC_STEPS.includes(Number(tick)) ? formatAxisLabelNumbers(tick, ticks2) : "" : formatAxisLabelNumbers(tick, ticks2);
|
|
@@ -39717,14 +39738,14 @@ const getBarChartAxis = ({
|
|
|
39717
39738
|
return {
|
|
39718
39739
|
type: getScaleType(),
|
|
39719
39740
|
position: axisData == null ? void 0 : axisData.position,
|
|
39720
|
-
beginAtZero: (
|
|
39741
|
+
beginAtZero: (_c2 = options == null ? void 0 : options.additionalAxesOptions) == null ? void 0 : _c2.beginAtZero,
|
|
39721
39742
|
reverse: getReverse(),
|
|
39722
|
-
suggestedMax: (
|
|
39723
|
-
suggestedMin: (
|
|
39724
|
-
min: isDirectionCompatibleWithAxisType ? (
|
|
39725
|
-
max: isDirectionCompatibleWithAxisType ? (
|
|
39743
|
+
suggestedMax: (_d2 = options == null ? void 0 : options.additionalAxesOptions) == null ? void 0 : _d2.suggestedMax,
|
|
39744
|
+
suggestedMin: (_e2 = options == null ? void 0 : options.additionalAxesOptions) == null ? void 0 : _e2.suggestedMin,
|
|
39745
|
+
min: isDirectionCompatibleWithAxisType ? (_f2 = options == null ? void 0 : options.additionalAxesOptions) == null ? void 0 : _f2.min : void 0,
|
|
39746
|
+
max: isDirectionCompatibleWithAxisType ? (_g2 = options == null ? void 0 : options.additionalAxesOptions) == null ? void 0 : _g2.max : void 0,
|
|
39726
39747
|
title: {
|
|
39727
|
-
display: ((
|
|
39748
|
+
display: ((_h2 = axisData == null ? void 0 : axisData.label) == null ? void 0 : _h2.length) || ((_i2 = axisData == null ? void 0 : axisData.unit) == null ? void 0 : _i2.length),
|
|
39728
39749
|
text: (axisData == null ? void 0 : axisData.label) || (axisData == null ? void 0 : axisData.unit),
|
|
39729
39750
|
padding: 0
|
|
39730
39751
|
},
|
|
@@ -39732,7 +39753,7 @@ const getBarChartAxis = ({
|
|
|
39732
39753
|
grid: {
|
|
39733
39754
|
...grid
|
|
39734
39755
|
},
|
|
39735
|
-
stacked: (
|
|
39756
|
+
stacked: getStackedOptions(axisType, options == null ? void 0 : options.additionalAxesOptions)
|
|
39736
39757
|
};
|
|
39737
39758
|
};
|
|
39738
39759
|
const getBarChartAxes = (chart2, axisType) => {
|
|
@@ -39952,7 +39973,9 @@ const defaultAdditionalAxesOptions$1 = (options) => ({
|
|
|
39952
39973
|
suggestedMin: options == null ? void 0 : options.suggestedMin,
|
|
39953
39974
|
suggestedMax: options == null ? void 0 : options.suggestedMax,
|
|
39954
39975
|
min: options == null ? void 0 : options.min,
|
|
39955
|
-
max: options == null ? void 0 : options.max
|
|
39976
|
+
max: options == null ? void 0 : options.max,
|
|
39977
|
+
stackedX: options == null ? void 0 : options.stackedX,
|
|
39978
|
+
stackedY: options == null ? void 0 : options.stackedY
|
|
39956
39979
|
});
|
|
39957
39980
|
const defaultChartStyling$1 = (styling) => ({
|
|
39958
39981
|
width: styling == null ? void 0 : styling.width,
|
|
@@ -40031,6 +40054,8 @@ const getDefaultProps$1 = (props) => {
|
|
|
40031
40054
|
};
|
|
40032
40055
|
Chart$2.register(
|
|
40033
40056
|
LinearScale$1,
|
|
40057
|
+
PointElement$1,
|
|
40058
|
+
LineElement$1,
|
|
40034
40059
|
CategoryScale$1,
|
|
40035
40060
|
LogarithmicScale$1,
|
|
40036
40061
|
BarElement$1,
|