@oliasoft-open-source/charts-library 4.3.4-beta-1 → 4.4.0-beta-1
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 +132 -54
- package/dist/index.js.map +1 -1
- package/dist/src/components/bar-chart/bar-chart.stories.d.ts +1 -1
- package/dist/src/components/common/common.interface.d.ts +2 -0
- package/dist/src/components/common/helpers/get-chart-annotation.d.ts +1 -0
- package/dist/src/components/common/plugins/ellipsis-annotation-plugin/ellipsis-annotation-plugin.d.ts +5 -0
- package/dist/src/components/line-chart/line-chart.stories.d.ts +66 -2
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22173,6 +22173,127 @@ class HTML5BackendImpl {
|
|
|
22173
22173
|
const HTML5Backend = function createBackend(manager, context, options) {
|
|
22174
22174
|
return new HTML5BackendImpl(manager, context, options);
|
|
22175
22175
|
};
|
|
22176
|
+
const BORDER_WIDTH = {
|
|
22177
|
+
INITIAL: 2,
|
|
22178
|
+
HOVERED: 6,
|
|
22179
|
+
POINT_HOVERED: 8
|
|
22180
|
+
};
|
|
22181
|
+
const BORDER_COLOR = "rgba(0,0,0,0.1)";
|
|
22182
|
+
const ANNOTATION_DASH = [10, 2];
|
|
22183
|
+
const DEFAULT_FONT_SIZE = 12;
|
|
22184
|
+
const DEFAULT_FONT_FAMILY = '"Roobert", "Noto Sans", sans-serif';
|
|
22185
|
+
const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
|
|
22186
|
+
const LEGEND_LABEL_BOX_SIZE = 12;
|
|
22187
|
+
const TOOLTIP_PADDING = 8;
|
|
22188
|
+
const TOOLTIP_BOX_PADDING = 4;
|
|
22189
|
+
const TRANSPARENT = "transparent";
|
|
22190
|
+
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
22191
|
+
const COLORS = [
|
|
22192
|
+
"#3366cc",
|
|
22193
|
+
"#dc3912",
|
|
22194
|
+
"#ff9900",
|
|
22195
|
+
"#109618",
|
|
22196
|
+
"#990099",
|
|
22197
|
+
"#0099c6",
|
|
22198
|
+
"#dd4477",
|
|
22199
|
+
"#66aa00",
|
|
22200
|
+
"#b82e2e",
|
|
22201
|
+
"#316395",
|
|
22202
|
+
"#994499",
|
|
22203
|
+
"#22aa99",
|
|
22204
|
+
"#aaaa11",
|
|
22205
|
+
"#6633cc",
|
|
22206
|
+
"#e67300",
|
|
22207
|
+
"#8b0707",
|
|
22208
|
+
"#651067",
|
|
22209
|
+
"#329262",
|
|
22210
|
+
"#5574a6",
|
|
22211
|
+
"#3b3eac"
|
|
22212
|
+
];
|
|
22213
|
+
const ALPHA_CHANEL = "99";
|
|
22214
|
+
const WHITE_COLOR_AS_DECIMAL = 16777215;
|
|
22215
|
+
const AUTO = "auto";
|
|
22216
|
+
const ANIMATION_DURATION = {
|
|
22217
|
+
NO: 0,
|
|
22218
|
+
SLOW: 400,
|
|
22219
|
+
FAST: 1e3
|
|
22220
|
+
};
|
|
22221
|
+
const DEFAULT_CHART_NAME = "new_chart";
|
|
22222
|
+
const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
|
|
22223
|
+
const DECIMAL_POINT_TOLERANCE = 9;
|
|
22224
|
+
const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
|
|
22225
|
+
const findRadii = (points, mainPoint, isXReverse, isYReverse) => {
|
|
22226
|
+
if ((points == null ? void 0 : points.length) === 0) {
|
|
22227
|
+
throw new Error("Array of points is empty");
|
|
22228
|
+
}
|
|
22229
|
+
let top2 = mainPoint;
|
|
22230
|
+
let bottom2 = mainPoint;
|
|
22231
|
+
let left2 = mainPoint;
|
|
22232
|
+
let right2 = mainPoint;
|
|
22233
|
+
for (const point of points) {
|
|
22234
|
+
if (isYReverse ? point.y < top2.y : point.y > top2.y) {
|
|
22235
|
+
top2 = point;
|
|
22236
|
+
}
|
|
22237
|
+
if (isYReverse ? point.y > bottom2.y : point.y < bottom2.y) {
|
|
22238
|
+
bottom2 = point;
|
|
22239
|
+
}
|
|
22240
|
+
if (isXReverse ? point.x > left2.x : point.x < left2.x) {
|
|
22241
|
+
left2 = point;
|
|
22242
|
+
}
|
|
22243
|
+
if (isXReverse ? point.x < right2.x : point.x > right2.x) {
|
|
22244
|
+
right2 = point;
|
|
22245
|
+
}
|
|
22246
|
+
}
|
|
22247
|
+
const radiusX = Math.abs(right2.x - left2.x) / 2;
|
|
22248
|
+
const radiusY = Math.abs(bottom2.y - top2.y) / 2;
|
|
22249
|
+
return { radiusX, radiusY };
|
|
22250
|
+
};
|
|
22251
|
+
const ellipsisAnnotationPlugin = {
|
|
22252
|
+
id: "ellipsisAnnotationPlugin",
|
|
22253
|
+
afterDraw: (chart2) => {
|
|
22254
|
+
var _a2, _b2, _c2, _d2;
|
|
22255
|
+
const {
|
|
22256
|
+
ctx,
|
|
22257
|
+
scales: { x: x2, y: y2 },
|
|
22258
|
+
data: { datasets },
|
|
22259
|
+
options
|
|
22260
|
+
} = chart2;
|
|
22261
|
+
const isXReverse = ((_b2 = (_a2 = options == null ? void 0 : options.scales) == null ? void 0 : _a2.x) == null ? void 0 : _b2.reverse) || false;
|
|
22262
|
+
const isYReverse = ((_d2 = (_c2 = options == null ? void 0 : options.scales) == null ? void 0 : _c2.y) == null ? void 0 : _d2.reverse) || false;
|
|
22263
|
+
datasets.forEach((dataset) => {
|
|
22264
|
+
dataset.data.forEach((item) => {
|
|
22265
|
+
if (item.ellipsePoints && item.ellipsePoints.length) {
|
|
22266
|
+
const centerX = x2.getPixelForValue(item.x);
|
|
22267
|
+
const centerY = y2.getPixelForValue(item.y);
|
|
22268
|
+
const points = item.ellipsePoints.map((point) => ({
|
|
22269
|
+
x: x2.getPixelForValue(point.x),
|
|
22270
|
+
y: y2.getPixelForValue(point.y)
|
|
22271
|
+
}));
|
|
22272
|
+
const mainPoint = { x: centerX, y: centerY };
|
|
22273
|
+
const { radiusX, radiusY } = findRadii(
|
|
22274
|
+
points,
|
|
22275
|
+
mainPoint,
|
|
22276
|
+
isXReverse,
|
|
22277
|
+
isYReverse
|
|
22278
|
+
);
|
|
22279
|
+
const rotationAngle = item.ellipseRotation * Math.PI / 180;
|
|
22280
|
+
ctx.beginPath();
|
|
22281
|
+
ctx.ellipse(
|
|
22282
|
+
centerX,
|
|
22283
|
+
centerY,
|
|
22284
|
+
radiusX,
|
|
22285
|
+
radiusY,
|
|
22286
|
+
rotationAngle,
|
|
22287
|
+
0,
|
|
22288
|
+
2 * Math.PI
|
|
22289
|
+
);
|
|
22290
|
+
ctx.strokeStyle = (dataset == null ? void 0 : dataset.borderColor) ?? DEFAULT_COLOR;
|
|
22291
|
+
ctx.stroke();
|
|
22292
|
+
}
|
|
22293
|
+
});
|
|
22294
|
+
});
|
|
22295
|
+
}
|
|
22296
|
+
};
|
|
22176
22297
|
const chart$3 = "_chart_e3qdd_1";
|
|
22177
22298
|
const canvas$1 = "_canvas_e3qdd_11";
|
|
22178
22299
|
const fixedHeight$3 = "_fixedHeight_e3qdd_20";
|
|
@@ -22466,55 +22587,6 @@ const chartMinorGridlinesPlugin = {
|
|
|
22466
22587
|
Object.keys(scales).forEach((id) => drawMinorTicksForScale(scales[id]));
|
|
22467
22588
|
}
|
|
22468
22589
|
};
|
|
22469
|
-
const BORDER_WIDTH = {
|
|
22470
|
-
INITIAL: 2,
|
|
22471
|
-
HOVERED: 6,
|
|
22472
|
-
POINT_HOVERED: 8
|
|
22473
|
-
};
|
|
22474
|
-
const BORDER_COLOR = "rgba(0,0,0,0.1)";
|
|
22475
|
-
const ANNOTATION_DASH = [10, 2];
|
|
22476
|
-
const DEFAULT_FONT_SIZE = 12;
|
|
22477
|
-
const DEFAULT_FONT_FAMILY = '"Roobert", "Noto Sans", sans-serif';
|
|
22478
|
-
const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
|
|
22479
|
-
const LEGEND_LABEL_BOX_SIZE = 12;
|
|
22480
|
-
const TOOLTIP_PADDING = 8;
|
|
22481
|
-
const TOOLTIP_BOX_PADDING = 4;
|
|
22482
|
-
const TRANSPARENT = "transparent";
|
|
22483
|
-
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
22484
|
-
const COLORS = [
|
|
22485
|
-
"#3366cc",
|
|
22486
|
-
"#dc3912",
|
|
22487
|
-
"#ff9900",
|
|
22488
|
-
"#109618",
|
|
22489
|
-
"#990099",
|
|
22490
|
-
"#0099c6",
|
|
22491
|
-
"#dd4477",
|
|
22492
|
-
"#66aa00",
|
|
22493
|
-
"#b82e2e",
|
|
22494
|
-
"#316395",
|
|
22495
|
-
"#994499",
|
|
22496
|
-
"#22aa99",
|
|
22497
|
-
"#aaaa11",
|
|
22498
|
-
"#6633cc",
|
|
22499
|
-
"#e67300",
|
|
22500
|
-
"#8b0707",
|
|
22501
|
-
"#651067",
|
|
22502
|
-
"#329262",
|
|
22503
|
-
"#5574a6",
|
|
22504
|
-
"#3b3eac"
|
|
22505
|
-
];
|
|
22506
|
-
const ALPHA_CHANEL = "99";
|
|
22507
|
-
const WHITE_COLOR_AS_DECIMAL = 16777215;
|
|
22508
|
-
const AUTO = "auto";
|
|
22509
|
-
const ANIMATION_DURATION = {
|
|
22510
|
-
NO: 0,
|
|
22511
|
-
SLOW: 400,
|
|
22512
|
-
FAST: 1e3
|
|
22513
|
-
};
|
|
22514
|
-
const DEFAULT_CHART_NAME = "new_chart";
|
|
22515
|
-
const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
|
|
22516
|
-
const DECIMAL_POINT_TOLERANCE = 9;
|
|
22517
|
-
const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
|
|
22518
22590
|
const chartAreaBorderPlugin = {
|
|
22519
22591
|
id: "chartAreaBorder",
|
|
22520
22592
|
beforeDraw(chart2, _2, options) {
|
|
@@ -25407,9 +25479,13 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25407
25479
|
const borderColor = {
|
|
25408
25480
|
[AnnotationType.LINE]: color2,
|
|
25409
25481
|
[AnnotationType.POINT]: color2,
|
|
25410
|
-
[AnnotationType.BOX]: color2
|
|
25482
|
+
[AnnotationType.BOX]: color2,
|
|
25483
|
+
[AnnotationType.ELLIPSE]: color2
|
|
25411
25484
|
}[type] || TRANSPARENT;
|
|
25412
|
-
const borderWidth =
|
|
25485
|
+
const borderWidth = {
|
|
25486
|
+
[AnnotationType.LINE]: BORDER_WIDTH.INITIAL,
|
|
25487
|
+
[AnnotationType.ELLIPSE]: (ann == null ? void 0 : ann.borderWidth) ?? 0
|
|
25488
|
+
}[type] ?? 0;
|
|
25413
25489
|
const borderDash = type === AnnotationType.LINE ? ANNOTATION_DASH : void 0;
|
|
25414
25490
|
const defLabel = {
|
|
25415
25491
|
content: ann == null ? void 0 : ann.label,
|
|
@@ -25477,12 +25553,13 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25477
25553
|
const onDragEnd = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragEnd) ? ann == null ? void 0 : ann.onDragEnd(cord, annotation2) : void 0;
|
|
25478
25554
|
return {
|
|
25479
25555
|
...ann,
|
|
25556
|
+
drawTime: "afterDraw",
|
|
25480
25557
|
display: ann == null ? void 0 : ann.display,
|
|
25481
25558
|
annotationIndex: idx,
|
|
25482
25559
|
id: `${ann == null ? void 0 : ann.label}-${ann == null ? void 0 : ann.value}-${idx}`,
|
|
25483
25560
|
scaleID,
|
|
25484
25561
|
label,
|
|
25485
|
-
backgroundColor: color2,
|
|
25562
|
+
backgroundColor: (ann == null ? void 0 : ann.backgroundColor) ?? color2,
|
|
25486
25563
|
borderColor,
|
|
25487
25564
|
borderWidth,
|
|
25488
25565
|
borderDash,
|
|
@@ -26254,7 +26331,7 @@ const annotationDraggerPlugin = {
|
|
|
26254
26331
|
};
|
|
26255
26332
|
}
|
|
26256
26333
|
},
|
|
26257
|
-
|
|
26334
|
+
afterUpdate(chart2) {
|
|
26258
26335
|
var _a2, _b2, _c2, _d2;
|
|
26259
26336
|
const { canvas: canvas2, scales, hoveredAnnotationId } = chart2;
|
|
26260
26337
|
const pluginOptions = ((_b2 = (_a2 = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a2.plugins) == null ? void 0 : _b2.annotationDraggerPlugin) || {
|
|
@@ -26819,7 +26896,8 @@ Chart$2.register(
|
|
|
26819
26896
|
plugin,
|
|
26820
26897
|
annotation,
|
|
26821
26898
|
chartAreaTextPlugin,
|
|
26822
|
-
annotationDraggerPlugin
|
|
26899
|
+
annotationDraggerPlugin,
|
|
26900
|
+
ellipsisAnnotationPlugin
|
|
26823
26901
|
);
|
|
26824
26902
|
const LineChart = (props) => {
|
|
26825
26903
|
var _a2, _b2;
|