@oliasoft-open-source/charts-library 4.4.2 → 4.5.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 +157 -74
- package/dist/index.js.map +1 -1
- package/dist/src/components/common/common.interface.d.ts +3 -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 +65 -0
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -22174,6 +22174,139 @@ class HTML5BackendImpl {
|
|
|
22174
22174
|
const HTML5Backend = function createBackend(manager, context, options) {
|
|
22175
22175
|
return new HTML5BackendImpl(manager, context, options);
|
|
22176
22176
|
};
|
|
22177
|
+
const BORDER_WIDTH = {
|
|
22178
|
+
INITIAL: 2,
|
|
22179
|
+
HOVERED: 6,
|
|
22180
|
+
POINT_HOVERED: 8
|
|
22181
|
+
};
|
|
22182
|
+
const BORDER_COLOR = "rgba(0,0,0,0.1)";
|
|
22183
|
+
const ANNOTATION_DASH = [10, 2];
|
|
22184
|
+
const DEFAULT_FONT_SIZE = 12;
|
|
22185
|
+
const DEFAULT_FONT_FAMILY = '"Roobert", "Noto Sans", sans-serif';
|
|
22186
|
+
const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
|
|
22187
|
+
const LEGEND_LABEL_BOX_SIZE = 12;
|
|
22188
|
+
const TOOLTIP_PADDING = 8;
|
|
22189
|
+
const TOOLTIP_BOX_PADDING = 4;
|
|
22190
|
+
const TRANSPARENT = "transparent";
|
|
22191
|
+
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
22192
|
+
const COLORS = [
|
|
22193
|
+
"#3366cc",
|
|
22194
|
+
"#dc3912",
|
|
22195
|
+
"#ff9900",
|
|
22196
|
+
"#109618",
|
|
22197
|
+
"#990099",
|
|
22198
|
+
"#0099c6",
|
|
22199
|
+
"#dd4477",
|
|
22200
|
+
"#66aa00",
|
|
22201
|
+
"#b82e2e",
|
|
22202
|
+
"#316395",
|
|
22203
|
+
"#994499",
|
|
22204
|
+
"#22aa99",
|
|
22205
|
+
"#aaaa11",
|
|
22206
|
+
"#6633cc",
|
|
22207
|
+
"#e67300",
|
|
22208
|
+
"#8b0707",
|
|
22209
|
+
"#651067",
|
|
22210
|
+
"#329262",
|
|
22211
|
+
"#5574a6",
|
|
22212
|
+
"#3b3eac"
|
|
22213
|
+
];
|
|
22214
|
+
const ALPHA_CHANEL = "99";
|
|
22215
|
+
const WHITE_COLOR_AS_DECIMAL = 16777215;
|
|
22216
|
+
const AUTO = "auto";
|
|
22217
|
+
const ANIMATION_DURATION = {
|
|
22218
|
+
NO: 0,
|
|
22219
|
+
SLOW: 400,
|
|
22220
|
+
FAST: 1e3
|
|
22221
|
+
};
|
|
22222
|
+
const DEFAULT_CHART_NAME = "new_chart";
|
|
22223
|
+
const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
|
|
22224
|
+
const DECIMAL_POINT_TOLERANCE = 9;
|
|
22225
|
+
const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
|
|
22226
|
+
const GRADIENT_COLORS = [
|
|
22227
|
+
{ offset: 0, color: "rgba(144,238,144,0.8)" },
|
|
22228
|
+
// Light green
|
|
22229
|
+
{ offset: 0.6, color: "rgba(255,255,224,0.8)" },
|
|
22230
|
+
// Light yellow
|
|
22231
|
+
{ offset: 0.8, color: "rgba(255,255,224,0.8)" },
|
|
22232
|
+
// Light yellow
|
|
22233
|
+
{ offset: 0.92, color: "rgba(255,182,193,0.5)" },
|
|
22234
|
+
// Light red
|
|
22235
|
+
{ offset: 0.99, color: "rgba(255,182,193,0.8)" }
|
|
22236
|
+
// Light red
|
|
22237
|
+
];
|
|
22238
|
+
const findRadii = (points, mainPoint, isXReverse, isYReverse) => {
|
|
22239
|
+
if ((points == null ? void 0 : points.length) === 0) {
|
|
22240
|
+
throw new Error("Array of points is empty");
|
|
22241
|
+
}
|
|
22242
|
+
let top2 = mainPoint;
|
|
22243
|
+
let bottom2 = mainPoint;
|
|
22244
|
+
let left2 = mainPoint;
|
|
22245
|
+
let right2 = mainPoint;
|
|
22246
|
+
for (const point of points) {
|
|
22247
|
+
if (isYReverse ? point.y < top2.y : point.y > top2.y) {
|
|
22248
|
+
top2 = point;
|
|
22249
|
+
}
|
|
22250
|
+
if (isYReverse ? point.y > bottom2.y : point.y < bottom2.y) {
|
|
22251
|
+
bottom2 = point;
|
|
22252
|
+
}
|
|
22253
|
+
if (isXReverse ? point.x > left2.x : point.x < left2.x) {
|
|
22254
|
+
left2 = point;
|
|
22255
|
+
}
|
|
22256
|
+
if (isXReverse ? point.x < right2.x : point.x > right2.x) {
|
|
22257
|
+
right2 = point;
|
|
22258
|
+
}
|
|
22259
|
+
}
|
|
22260
|
+
const radiusX = Math.abs(right2.x - left2.x) / 2;
|
|
22261
|
+
const radiusY = Math.abs(bottom2.y - top2.y) / 2;
|
|
22262
|
+
return { radiusX, radiusY };
|
|
22263
|
+
};
|
|
22264
|
+
const ellipsisAnnotationPlugin = {
|
|
22265
|
+
id: "ellipsisAnnotationPlugin",
|
|
22266
|
+
afterDraw: (chart2) => {
|
|
22267
|
+
var _a2, _b2, _c2, _d2;
|
|
22268
|
+
const {
|
|
22269
|
+
ctx,
|
|
22270
|
+
scales: { x: x2, y: y2 },
|
|
22271
|
+
data: { datasets },
|
|
22272
|
+
options
|
|
22273
|
+
} = chart2;
|
|
22274
|
+
const isXReverse = ((_b2 = (_a2 = options == null ? void 0 : options.scales) == null ? void 0 : _a2.x) == null ? void 0 : _b2.reverse) || false;
|
|
22275
|
+
const isYReverse = ((_d2 = (_c2 = options == null ? void 0 : options.scales) == null ? void 0 : _c2.y) == null ? void 0 : _d2.reverse) || false;
|
|
22276
|
+
datasets.forEach((dataset) => {
|
|
22277
|
+
dataset.data.forEach((item) => {
|
|
22278
|
+
if (item.ellipsePoints && item.ellipsePoints.length) {
|
|
22279
|
+
const centerX = x2.getPixelForValue(item.x);
|
|
22280
|
+
const centerY = y2.getPixelForValue(item.y);
|
|
22281
|
+
const points = item.ellipsePoints.map((point) => ({
|
|
22282
|
+
x: x2.getPixelForValue(point.x),
|
|
22283
|
+
y: y2.getPixelForValue(point.y)
|
|
22284
|
+
}));
|
|
22285
|
+
const mainPoint = { x: centerX, y: centerY };
|
|
22286
|
+
const { radiusX, radiusY } = findRadii(
|
|
22287
|
+
points,
|
|
22288
|
+
mainPoint,
|
|
22289
|
+
isXReverse,
|
|
22290
|
+
isYReverse
|
|
22291
|
+
);
|
|
22292
|
+
const rotationAngle = item.ellipseRotation * Math.PI / 180;
|
|
22293
|
+
ctx.beginPath();
|
|
22294
|
+
ctx.ellipse(
|
|
22295
|
+
centerX,
|
|
22296
|
+
centerY,
|
|
22297
|
+
radiusX,
|
|
22298
|
+
radiusY,
|
|
22299
|
+
rotationAngle,
|
|
22300
|
+
0,
|
|
22301
|
+
2 * Math.PI
|
|
22302
|
+
);
|
|
22303
|
+
ctx.strokeStyle = (dataset == null ? void 0 : dataset.borderColor) ?? DEFAULT_COLOR;
|
|
22304
|
+
ctx.stroke();
|
|
22305
|
+
}
|
|
22306
|
+
});
|
|
22307
|
+
});
|
|
22308
|
+
}
|
|
22309
|
+
};
|
|
22177
22310
|
const chart$3 = "_chart_e3qdd_1";
|
|
22178
22311
|
const canvas$1 = "_canvas_e3qdd_11";
|
|
22179
22312
|
const fixedHeight$3 = "_fixedHeight_e3qdd_20";
|
|
@@ -22467,67 +22600,6 @@ const chartMinorGridlinesPlugin = {
|
|
|
22467
22600
|
Object.keys(scales).forEach((id) => drawMinorTicksForScale(scales[id]));
|
|
22468
22601
|
}
|
|
22469
22602
|
};
|
|
22470
|
-
const BORDER_WIDTH = {
|
|
22471
|
-
INITIAL: 2,
|
|
22472
|
-
HOVERED: 6,
|
|
22473
|
-
POINT_HOVERED: 8
|
|
22474
|
-
};
|
|
22475
|
-
const BORDER_COLOR = "rgba(0,0,0,0.1)";
|
|
22476
|
-
const ANNOTATION_DASH = [10, 2];
|
|
22477
|
-
const DEFAULT_FONT_SIZE = 12;
|
|
22478
|
-
const DEFAULT_FONT_FAMILY = '"Roobert", "Noto Sans", sans-serif';
|
|
22479
|
-
const DEFAULT_COLOR = "hsl(60, 10.34482759%, 12.5%)";
|
|
22480
|
-
const LEGEND_LABEL_BOX_SIZE = 12;
|
|
22481
|
-
const TOOLTIP_PADDING = 8;
|
|
22482
|
-
const TOOLTIP_BOX_PADDING = 4;
|
|
22483
|
-
const TRANSPARENT = "transparent";
|
|
22484
|
-
const LOGARITHMIC_STEPS = [1, 10, 100, 1e3, 1e4];
|
|
22485
|
-
const COLORS = [
|
|
22486
|
-
"#3366cc",
|
|
22487
|
-
"#dc3912",
|
|
22488
|
-
"#ff9900",
|
|
22489
|
-
"#109618",
|
|
22490
|
-
"#990099",
|
|
22491
|
-
"#0099c6",
|
|
22492
|
-
"#dd4477",
|
|
22493
|
-
"#66aa00",
|
|
22494
|
-
"#b82e2e",
|
|
22495
|
-
"#316395",
|
|
22496
|
-
"#994499",
|
|
22497
|
-
"#22aa99",
|
|
22498
|
-
"#aaaa11",
|
|
22499
|
-
"#6633cc",
|
|
22500
|
-
"#e67300",
|
|
22501
|
-
"#8b0707",
|
|
22502
|
-
"#651067",
|
|
22503
|
-
"#329262",
|
|
22504
|
-
"#5574a6",
|
|
22505
|
-
"#3b3eac"
|
|
22506
|
-
];
|
|
22507
|
-
const ALPHA_CHANEL = "99";
|
|
22508
|
-
const WHITE_COLOR_AS_DECIMAL = 16777215;
|
|
22509
|
-
const AUTO = "auto";
|
|
22510
|
-
const ANIMATION_DURATION = {
|
|
22511
|
-
NO: 0,
|
|
22512
|
-
SLOW: 400,
|
|
22513
|
-
FAST: 1e3
|
|
22514
|
-
};
|
|
22515
|
-
const DEFAULT_CHART_NAME = "new_chart";
|
|
22516
|
-
const CUSTOM_LEGEND_PLUGIN_NAME = "htmlLegend";
|
|
22517
|
-
const DECIMAL_POINT_TOLERANCE = 9;
|
|
22518
|
-
const MAX_DECIMAL_DIFF = 1 / 10 ** DECIMAL_POINT_TOLERANCE;
|
|
22519
|
-
const GRADIENT_COLORS = [
|
|
22520
|
-
{ offset: 0, color: "rgba(144,238,144,0.8)" },
|
|
22521
|
-
// Light green
|
|
22522
|
-
{ offset: 0.6, color: "rgba(255,255,224,0.8)" },
|
|
22523
|
-
// Light yellow
|
|
22524
|
-
{ offset: 0.8, color: "rgba(255,255,224,0.8)" },
|
|
22525
|
-
// Light yellow
|
|
22526
|
-
{ offset: 0.92, color: "rgba(255,182,193,0.5)" },
|
|
22527
|
-
// Light red
|
|
22528
|
-
{ offset: 0.99, color: "rgba(255,182,193,0.8)" }
|
|
22529
|
-
// Light red
|
|
22530
|
-
];
|
|
22531
22603
|
const chartAreaBorderPlugin = {
|
|
22532
22604
|
id: "chartAreaBorder",
|
|
22533
22605
|
beforeDraw(chart2, _2, options) {
|
|
@@ -25420,9 +25492,13 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25420
25492
|
const borderColor = {
|
|
25421
25493
|
[AnnotationType.LINE]: color2,
|
|
25422
25494
|
[AnnotationType.POINT]: color2,
|
|
25423
|
-
[AnnotationType.BOX]: color2
|
|
25495
|
+
[AnnotationType.BOX]: color2,
|
|
25496
|
+
[AnnotationType.ELLIPSE]: color2
|
|
25424
25497
|
}[type] || TRANSPARENT;
|
|
25425
|
-
const borderWidth =
|
|
25498
|
+
const borderWidth = {
|
|
25499
|
+
[AnnotationType.LINE]: BORDER_WIDTH.INITIAL,
|
|
25500
|
+
[AnnotationType.ELLIPSE]: (ann == null ? void 0 : ann.borderWidth) ?? 0
|
|
25501
|
+
}[type] ?? 0;
|
|
25426
25502
|
const borderDash = type === AnnotationType.LINE ? ANNOTATION_DASH : void 0;
|
|
25427
25503
|
const defLabel = {
|
|
25428
25504
|
content: ann == null ? void 0 : ann.label,
|
|
@@ -25488,15 +25564,17 @@ const generateAnnotations = (annotationsData) => {
|
|
|
25488
25564
|
const onDragStart = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragStart) ? ann == null ? void 0 : ann.onDragStart(cord, annotation2) : void 0;
|
|
25489
25565
|
const onDrag = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDrag) ? ann == null ? void 0 : ann.onDrag(cord, annotation2) : void 0;
|
|
25490
25566
|
const onDragEnd = () => (cord, annotation2) => (ann == null ? void 0 : ann.onDragEnd) ? ann == null ? void 0 : ann.onDragEnd(cord, annotation2) : void 0;
|
|
25567
|
+
const rotation = ann.rotation * Math.PI / 180;
|
|
25491
25568
|
return {
|
|
25492
25569
|
...ann,
|
|
25493
25570
|
drawTime: "afterDraw",
|
|
25494
25571
|
display: ann == null ? void 0 : ann.display,
|
|
25495
25572
|
annotationIndex: idx,
|
|
25496
25573
|
id: `${ann == null ? void 0 : ann.label}-${ann == null ? void 0 : ann.value}-${idx}`,
|
|
25574
|
+
rotation,
|
|
25497
25575
|
scaleID,
|
|
25498
25576
|
label,
|
|
25499
|
-
backgroundColor: color2,
|
|
25577
|
+
backgroundColor: (ann == null ? void 0 : ann.backgroundColor) ?? color2,
|
|
25500
25578
|
borderColor,
|
|
25501
25579
|
borderWidth,
|
|
25502
25580
|
borderDash,
|
|
@@ -26302,16 +26380,20 @@ const annotationDraggerPlugin = {
|
|
|
26302
26380
|
);
|
|
26303
26381
|
});
|
|
26304
26382
|
canvas2.addEventListener(MouseEvents.MOUSEMOVE, (event) => {
|
|
26305
|
-
|
|
26306
|
-
|
|
26307
|
-
|
|
26308
|
-
|
|
26309
|
-
|
|
26310
|
-
|
|
26311
|
-
|
|
26312
|
-
|
|
26313
|
-
|
|
26383
|
+
const handleAnnotationMouseMoveDebounce = debounce$3(
|
|
26384
|
+
() => handleAnnotationMouseMove(
|
|
26385
|
+
event,
|
|
26386
|
+
canvas2,
|
|
26387
|
+
typedScales,
|
|
26388
|
+
isDragging2,
|
|
26389
|
+
activeAnnotation,
|
|
26390
|
+
dragStartX,
|
|
26391
|
+
dragStartY,
|
|
26392
|
+
chart2
|
|
26393
|
+
),
|
|
26394
|
+
5
|
|
26314
26395
|
);
|
|
26396
|
+
handleAnnotationMouseMoveDebounce();
|
|
26315
26397
|
});
|
|
26316
26398
|
canvas2.addEventListener(MouseEvents.MOUSEUP, () => {
|
|
26317
26399
|
handleAnnotationMouseUp(
|
|
@@ -26837,7 +26919,8 @@ Chart$2.register(
|
|
|
26837
26919
|
plugin,
|
|
26838
26920
|
annotation,
|
|
26839
26921
|
chartAreaTextPlugin,
|
|
26840
|
-
annotationDraggerPlugin
|
|
26922
|
+
annotationDraggerPlugin,
|
|
26923
|
+
ellipsisAnnotationPlugin
|
|
26841
26924
|
);
|
|
26842
26925
|
const LineChart = (props) => {
|
|
26843
26926
|
var _a2, _b2;
|