@mekari/pixel3-chart 0.0.1-dev.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.
@@ -0,0 +1,655 @@
1
+ "use strict";
2
+ var __create = Object.create;
3
+ var __defProp = Object.defineProperty;
4
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
+ var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
7
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
8
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
9
+ var __export = (target, all) => {
10
+ for (var name in all)
11
+ __defProp(target, name, { get: all[name], enumerable: true });
12
+ };
13
+ var __copyProps = (to, from, except, desc) => {
14
+ if (from && typeof from === "object" || typeof from === "function") {
15
+ for (let key of __getOwnPropNames(from))
16
+ if (!__hasOwnProp.call(to, key) && key !== except)
17
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
18
+ }
19
+ return to;
20
+ };
21
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
22
+ // If the importer is in node compatibility mode or this is not an ESM
23
+ // file that has been converted to a CommonJS file using a Babel-
24
+ // compatible transform (i.e. "__esModule" has not been set), then set
25
+ // "default" to the CommonJS "module.exports" for node compatibility.
26
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
27
+ mod
28
+ ));
29
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
30
+
31
+ // src/modules/chart.hooks.ts
32
+ var chart_hooks_exports = {};
33
+ __export(chart_hooks_exports, {
34
+ useChart: () => useChart
35
+ });
36
+ module.exports = __toCommonJS(chart_hooks_exports);
37
+ var import_vue = require("vue");
38
+ var import_pixel3_utils = require("@mekari/pixel3-utils");
39
+ var import_recipes = require("@mekari/pixel3-styled-system/recipes");
40
+ var import_tokens = require("@mekari/pixel3-styled-system/tokens");
41
+ var import_lodash_es = require("lodash-es");
42
+ var import_color = __toESM(require("color"));
43
+ var import_auto = __toESM(require("chart.js/auto"));
44
+ var import_chartjs_plugin_datalabels = __toESM(require("chartjs-plugin-datalabels"));
45
+ function useChart(props, emit) {
46
+ const {
47
+ id,
48
+ title,
49
+ type,
50
+ widthChart,
51
+ heightChart,
52
+ widthContainer,
53
+ heightContainer,
54
+ data,
55
+ options,
56
+ colorPattern,
57
+ colorStart,
58
+ colorRatio,
59
+ legendPosition,
60
+ legendDirection,
61
+ tooltipMarginTop,
62
+ tooltipMarginLeft,
63
+ isShowDataLabels,
64
+ isHorizontal,
65
+ isStacked,
66
+ isArea,
67
+ isDebug,
68
+ isShowBackgroundHover,
69
+ isShowGaugePointer,
70
+ isMixedChart,
71
+ tooltipOptions
72
+ } = (0, import_vue.toRefs)(props);
73
+ const chart = (0, import_vue.shallowRef)(null);
74
+ const tooltip = (0, import_vue.ref)({
75
+ top: 0,
76
+ left: 0,
77
+ opacity: 0,
78
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
79
+ data: null
80
+ });
81
+ const legend = (0, import_vue.ref)([]);
82
+ const baseColor = (0, import_vue.ref)();
83
+ const chartContainerNode = (0, import_vue.ref)();
84
+ const chartLegendNode = (0, import_vue.ref)();
85
+ const chartCanvasNode = (0, import_vue.ref)();
86
+ const getId = id.value || (0, import_pixel3_utils.getUniqueId)("", "chart").value;
87
+ const isHorizontalBarChart = (0, import_vue.computed)(() => {
88
+ return type.value === "bar" && isHorizontal.value;
89
+ });
90
+ const isCircularChart = (0, import_vue.computed)(() => {
91
+ return type.value === "pie" || type.value === "doughnut";
92
+ });
93
+ const getLegendPosition = (0, import_vue.computed)(() => {
94
+ let position = "column";
95
+ if (legendPosition.value === "right") {
96
+ position = "row";
97
+ }
98
+ if (legendPosition.value === "top") {
99
+ position = "column-reverse";
100
+ }
101
+ if (legendPosition.value === "left") {
102
+ position = "row-reverse";
103
+ }
104
+ return position;
105
+ });
106
+ const getLegendDirection = (0, import_vue.computed)(() => {
107
+ let direction = "flex-start";
108
+ if (legendDirection.value === "center") {
109
+ direction = "center";
110
+ }
111
+ if (legendDirection.value === "right") {
112
+ direction = "flex-end";
113
+ }
114
+ return direction;
115
+ });
116
+ const getOptions = (0, import_vue.computed)(() => {
117
+ const basicOptions = {
118
+ maintainAspectRatio: false,
119
+ responsive: true,
120
+ animation: true,
121
+ cutout: type.value === "doughnut" ? 70 : 0,
122
+ ...isHorizontalBarChart.value && {
123
+ indexAxis: "y"
124
+ },
125
+ interaction: {
126
+ intersect: !isArea.value
127
+ },
128
+ plugins: {
129
+ PluginHtmlLegend: true,
130
+ PluginHoverBackgroundColors: isShowBackgroundHover.value,
131
+ gaugeChartPointer: isShowGaugePointer.value,
132
+ title: {
133
+ display: false
134
+ },
135
+ legend: {
136
+ display: false
137
+ },
138
+ tooltip: {
139
+ enabled: false,
140
+ position: "average",
141
+ external: handleExternalTooltip
142
+ },
143
+ filler: {
144
+ propagate: false
145
+ },
146
+ datalabels: {
147
+ display: isShowDataLabels.value,
148
+ color: "#626B79",
149
+ clamp: true,
150
+ font: {
151
+ size: 10
152
+ },
153
+ labels: {
154
+ value: {
155
+ anchor: "end",
156
+ align: "end"
157
+ }
158
+ }
159
+ }
160
+ },
161
+ elements: {
162
+ bar: {
163
+ backgroundColor: getListColors.value[1],
164
+ borderRadius: "4",
165
+ ...isStacked.value && {
166
+ borderWidth: {
167
+ top: !isHorizontal.value ? 2 : 0,
168
+ right: isHorizontal.value ? 2 : 0
169
+ },
170
+ borderColor: "#FFFFFF"
171
+ }
172
+ },
173
+ line: {
174
+ borderColor: isArea.value ? "#FFFFFF" : getListColors.value[1],
175
+ borderWidth: 2,
176
+ tension: isArea.value ? 0.4 : 0
177
+ },
178
+ point: {
179
+ radius: isArea.value || type.value === "radar" ? 0 : 6,
180
+ borderWidth: 2,
181
+ hoverRadius: isArea.value || type.value === "radar" ? 0 : 6,
182
+ hoverBorderWidth: 2
183
+ },
184
+ arc: {
185
+ backgroundColor: getListColors.value[1],
186
+ borderColor: "#FFFFFF",
187
+ hoverBorderColor: "#FFFFFF"
188
+ }
189
+ },
190
+ scales: {
191
+ x: {
192
+ stacked: isStacked.value,
193
+ border: {
194
+ display: false
195
+ },
196
+ grid: {
197
+ display: false,
198
+ drawOnChartArea: false,
199
+ drawTicks: false
200
+ },
201
+ ticks: {
202
+ display: !isCircularChart.value && type.value !== "radar",
203
+ color: "#626B79"
204
+ }
205
+ },
206
+ y: {
207
+ stacked: isStacked.value,
208
+ border: {
209
+ display: false
210
+ },
211
+ grid: {
212
+ display: !isHorizontal.value,
213
+ drawOnChartArea: !isCircularChart.value && type.value !== "radar",
214
+ drawTicks: false,
215
+ color: "#D0D6DD"
216
+ },
217
+ ticks: {
218
+ display: !isCircularChart.value && type.value !== "radar",
219
+ beginAtZero: true,
220
+ color: "#626B79",
221
+ padding: 8
222
+ }
223
+ },
224
+ ...type.value === "radar" && {
225
+ r: {
226
+ angleLines: {
227
+ display: true,
228
+ color: "#D0D6DD"
229
+ },
230
+ grid: {
231
+ color: "#D0D6DD"
232
+ },
233
+ ticks: {
234
+ color: "#626B79"
235
+ },
236
+ pointLabels: {
237
+ color: "#626B79"
238
+ }
239
+ }
240
+ }
241
+ }
242
+ };
243
+ return (0, import_lodash_es.merge)(basicOptions, options.value);
244
+ });
245
+ const getDataset = (0, import_vue.computed)(() => {
246
+ const datasets = data.value.datasets || [];
247
+ if (type.value === "bar") {
248
+ datasets.forEach((item, index) => {
249
+ item.backgroundColor = item.backgroundColor || handleColorPattern(index);
250
+ item.barPercentage = item.barPercentage || 0.68;
251
+ item.categoryPercentage = item.categoryPercentage || 1;
252
+ });
253
+ }
254
+ if (isCircularChart.value) {
255
+ const backgroundColor = [];
256
+ datasets.forEach((item) => {
257
+ item.data.forEach((_, index) => {
258
+ return backgroundColor.push(handleColorPattern(index));
259
+ });
260
+ item.backgroundColor = item.backgroundColor || backgroundColor;
261
+ });
262
+ }
263
+ if (isArea.value && (type.value === "line" || isMixedChart.value)) {
264
+ datasets.forEach((item, index) => {
265
+ item.fill = "start";
266
+ item.backgroundColor = item.backgroundColor || handleColorPattern(index);
267
+ });
268
+ }
269
+ if (!isArea.value && (type.value === "line" || type.value === "radar" || isMixedChart.value)) {
270
+ const isFading = type.value === "radar";
271
+ datasets.forEach((item, index) => {
272
+ item.backgroundColor = item.backgroundColor || handleColorPattern(index, isFading);
273
+ item.borderColor = item.borderColor || handleColorPattern(index);
274
+ item.pointBackgroundColor = item.pointBackgroundColor || "#FFFFFF";
275
+ });
276
+ }
277
+ return datasets;
278
+ });
279
+ const getListColors = (0, import_vue.computed)(() => {
280
+ return {
281
+ 1: (0, import_tokens.token)("colors.sky.400"),
282
+ 2: (0, import_tokens.token)("colors.sky.100"),
283
+ 3: (0, import_tokens.token)("colors.teal.400"),
284
+ 4: (0, import_tokens.token)("colors.teal.100"),
285
+ 5: (0, import_tokens.token)("colors.violet.400"),
286
+ 6: (0, import_tokens.token)("colors.violet.100"),
287
+ 7: (0, import_tokens.token)("colors.amber.400"),
288
+ 8: (0, import_tokens.token)("colors.amber.100"),
289
+ 9: (0, import_tokens.token)("colors.rose.400"),
290
+ 10: (0, import_tokens.token)("colors.rose.100"),
291
+ 11: (0, import_tokens.token)("colors.stone.400"),
292
+ 12: (0, import_tokens.token)("colors.stone.100"),
293
+ 13: (0, import_tokens.token)("colors.lime.400"),
294
+ 14: (0, import_tokens.token)("colors.lime.100"),
295
+ 15: (0, import_tokens.token)("colors.pink.400"),
296
+ 16: (0, import_tokens.token)("colors.pink.100"),
297
+ 17: (0, import_tokens.token)("colors.apricot.400"),
298
+ 18: (0, import_tokens.token)("colors.apricot.100"),
299
+ 19: (0, import_tokens.token)("colors.aqua.400"),
300
+ 20: (0, import_tokens.token)("colors.aqua.100"),
301
+ 21: (0, import_tokens.token)("colors.leaf.400"),
302
+ 22: (0, import_tokens.token)("colors.leaf.100"),
303
+ 23: (0, import_tokens.token)("colors.fuchsia.400"),
304
+ 24: (0, import_tokens.token)("colors.fuchsia.100")
305
+ };
306
+ });
307
+ const rootAttrs = (0, import_vue.computed)(() => {
308
+ return {
309
+ "data-pixel-component": "MpChart",
310
+ id: getId,
311
+ class: (0, import_recipes.chartSlotRecipe)().root,
312
+ style: {
313
+ width: widthContainer.value
314
+ }
315
+ };
316
+ });
317
+ const chartHeaderAttrs = (0, import_vue.computed)(() => {
318
+ return {
319
+ class: (0, import_recipes.chartSlotRecipe)().chartHeader
320
+ };
321
+ });
322
+ const chartWrapperAttrs = (0, import_vue.computed)(() => {
323
+ return {
324
+ class: (0, import_recipes.chartSlotRecipe)().chartWrapper,
325
+ style: {
326
+ flexDirection: getLegendPosition.value
327
+ }
328
+ };
329
+ });
330
+ const chartContainerAttrs = (0, import_vue.computed)(() => {
331
+ return {
332
+ ref: chartContainerNode,
333
+ id: `chart-container--${getId}`,
334
+ class: (0, import_recipes.chartSlotRecipe)().chartContainer,
335
+ style: {
336
+ width: widthContainer.value,
337
+ height: heightContainer.value
338
+ }
339
+ };
340
+ });
341
+ const canvasContainerAttrs = (0, import_vue.computed)(() => {
342
+ return {
343
+ id: `canvas-container--${getId}`,
344
+ class: (0, import_recipes.chartSlotRecipe)().canvasContainer,
345
+ style: {
346
+ width: widthChart.value,
347
+ height: heightChart.value
348
+ }
349
+ };
350
+ });
351
+ const canvasAttrs = (0, import_vue.computed)(() => {
352
+ return {
353
+ ref: chartCanvasNode,
354
+ id: `canvas-${getId}`,
355
+ ariaLabel: `Piel Chart ${title.value}`,
356
+ role: "img"
357
+ };
358
+ });
359
+ const chartLegendAttrs = (0, import_vue.computed)(() => {
360
+ return {
361
+ ref: chartLegendNode,
362
+ id: `chart-legend--${getId}`,
363
+ class: (0, import_recipes.chartSlotRecipe)().chartLegend,
364
+ style: {
365
+ justifyContent: getLegendDirection.value,
366
+ marginTop: legendPosition.value === "bottom" ? (0, import_tokens.token)("spacing.4") : "0",
367
+ marginBottom: legendPosition.value === "top" ? (0, import_tokens.token)("spacing.4") : "0"
368
+ }
369
+ };
370
+ });
371
+ const legendWrapperAttrs = /* @__PURE__ */ __name((item, index) => {
372
+ return {
373
+ key: index,
374
+ class: (0, import_recipes.chartSlotRecipe)().legendWrapper,
375
+ onClick: () => handleClickLegend(item)
376
+ };
377
+ }, "legendWrapperAttrs");
378
+ const legendBoxAttrs = /* @__PURE__ */ __name((item) => {
379
+ return {
380
+ class: (0, import_recipes.chartSlotRecipe)().legendBox,
381
+ style: {
382
+ width: (0, import_tokens.token)("sizes.3"),
383
+ height: (0, import_tokens.token)("sizes.3"),
384
+ background: item.fillStyle
385
+ }
386
+ };
387
+ }, "legendBoxAttrs");
388
+ const chartTooltipAttrs = (0, import_vue.computed)(() => {
389
+ return {
390
+ class: (0, import_recipes.chartSlotRecipe)().chartTooltip,
391
+ style: {
392
+ top: `${tooltip.value.top}px`,
393
+ left: `${tooltip.value.left}px`,
394
+ opacity: tooltip.value.opacity
395
+ }
396
+ };
397
+ });
398
+ const tooltipWrapperAttrs = (0, import_vue.computed)(() => {
399
+ return {
400
+ class: (0, import_recipes.chartSlotRecipe)().tooltipWrapper
401
+ };
402
+ });
403
+ const tooltipRowAttrs = (0, import_vue.computed)(() => {
404
+ return {
405
+ class: (0, import_recipes.chartSlotRecipe)().tooltipRow
406
+ };
407
+ });
408
+ const tooltipItemAttrs = (0, import_vue.computed)(() => {
409
+ return {
410
+ class: (0, import_recipes.chartSlotRecipe)().tooltipItem
411
+ };
412
+ });
413
+ const tooltipBoxAttrs = (0, import_vue.computed)(() => {
414
+ var _a, _b, _c, _d;
415
+ return {
416
+ class: (0, import_recipes.chartSlotRecipe)().tooltipBox,
417
+ style: {
418
+ backgroundColor: type.value === "line" ? (_b = (_a = tooltip.value.data) == null ? void 0 : _a.labelColors[0]) == null ? void 0 : _b.borderColor : (_d = (_c = tooltip.value.data) == null ? void 0 : _c.labelColors[0]) == null ? void 0 : _d.backgroundColor
419
+ }
420
+ };
421
+ });
422
+ function createChart() {
423
+ if (!chartCanvasNode.value)
424
+ return;
425
+ chart.value = new import_auto.default(chartCanvasNode.value, {
426
+ type: type.value,
427
+ data: {
428
+ labels: typeof data.value.labels === "undefined" ? [] : [...data.value.labels],
429
+ datasets: getDataset.value
430
+ },
431
+ options: getOptions.value,
432
+ plugins: [import_chartjs_plugin_datalabels.default, handleExternalLegend(), hoverBackgroundColors(), gaugeChartPointer()]
433
+ });
434
+ if (isDebug.value) {
435
+ console.log(`[MpChart] The context chart of ${getId} is:`, chart.value);
436
+ }
437
+ }
438
+ __name(createChart, "createChart");
439
+ function destroyChart() {
440
+ var _a;
441
+ (_a = chart.value) == null ? void 0 : _a.destroy();
442
+ }
443
+ __name(destroyChart, "destroyChart");
444
+ function updateChart() {
445
+ destroyChart();
446
+ createChart();
447
+ }
448
+ __name(updateChart, "updateChart");
449
+ function handleExternalTooltip(context) {
450
+ const {
451
+ tooltip: tooltipCtx
452
+ } = context;
453
+ const legendHeight = chartLegendNode.value ? chartLegendNode.value.clientHeight + 16 : tooltipMarginTop.value;
454
+ const extendTopValue = legendPosition.value === "top" ? legendHeight.value : 0;
455
+ const legendWidth = chartLegendNode.value ? chartLegendNode.value.clientWidth : tooltipMarginLeft.value;
456
+ const extendLeftValue = legendPosition.value === "left" ? legendWidth.value : 0;
457
+ const tooltipLeftPosition = tooltipCtx.x - chartContainerNode.value.scrollLeft;
458
+ const tooltipTopPosition = tooltipCtx.y > chartContainerNode.value.scrollTop ? tooltipCtx.caretY - chartContainerNode.value.scrollTop : tooltipCtx.caretY;
459
+ if (tooltipCtx.opacity === 1) {
460
+ tooltip.value = {
461
+ opacity: tooltipCtx.opacity,
462
+ left: tooltipLeftPosition + extendLeftValue + tooltipOptions.value.offsetLeft,
463
+ top: tooltipTopPosition + extendTopValue + tooltipOptions.value.offsetTop,
464
+ data: tooltipCtx
465
+ };
466
+ emit("show-tooltip", context);
467
+ } else {
468
+ tooltip.value.opacity = 0;
469
+ emit("hide-tooltip", context);
470
+ }
471
+ if (isDebug.value) {
472
+ console.log(`[MpChart] The context tooltip of ${getId} is:`, tooltip.value);
473
+ }
474
+ }
475
+ __name(handleExternalTooltip, "handleExternalTooltip");
476
+ function gaugeChartPointer() {
477
+ return {
478
+ id: "gaugeChartPointer",
479
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
480
+ afterDatasetsDraw(chart2, args, options2) {
481
+ const {
482
+ ctx,
483
+ data: data2
484
+ } = chart2;
485
+ const pointerIndexStart = options2.pointerIndexStart || 1;
486
+ const xCenter = chart2.getDatasetMeta(0).data[pointerIndexStart].x;
487
+ const yCenter = chart2.getDatasetMeta(0).data[pointerIndexStart].y;
488
+ const innerRadius = chart2.getDatasetMeta(0).data[pointerIndexStart].innerRadius;
489
+ const outerRadius = chart2.getDatasetMeta(0).data[pointerIndexStart].outerRadius;
490
+ const circumference = chart2.getDatasetMeta(0).data[pointerIndexStart].circumference;
491
+ const halfCircle = circumference / Math.PI / data2.datasets[0].data[pointerIndexStart];
492
+ const pointerRadius = outerRadius - innerRadius - 10;
493
+ const pointerColor = options2.pointerColor || "black";
494
+ const pointerValue = options2.pointerValue || 1;
495
+ const pointerRatio = options2.pointerRatio || 1.47;
496
+ const pointerPosition = halfCircle * pointerValue;
497
+ const pointerAngle = Math.PI * (pointerPosition + pointerRatio);
498
+ ctx.save();
499
+ ctx.translate(xCenter, yCenter);
500
+ ctx.rotate(pointerAngle);
501
+ ctx.beginPath();
502
+ ctx.strokeStyle = "white";
503
+ ctx.fillStyle = pointerColor;
504
+ ctx.lineWidth = 8;
505
+ ctx.shadowColor = "rgba(0, 0, 0, 0.08)";
506
+ ctx.shadowBlur = 8;
507
+ ctx.shadowOffsetX = 6;
508
+ ctx.shadowOffsetY = 6;
509
+ ctx.beginPath();
510
+ ctx.roundRect(0, -outerRadius + 6, pointerRadius, pointerRadius, 100);
511
+ ctx.fill();
512
+ ctx.stroke();
513
+ ctx.restore();
514
+ }
515
+ };
516
+ }
517
+ __name(gaugeChartPointer, "gaugeChartPointer");
518
+ function hoverBackgroundColors() {
519
+ return {
520
+ id: "PluginHoverBackgroundColors",
521
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
522
+ beforeDatasetsDraw(chart2) {
523
+ const {
524
+ ctx,
525
+ tooltip: tooltip2,
526
+ chartArea: {
527
+ top,
528
+ height
529
+ },
530
+ scales: {
531
+ x
532
+ }
533
+ } = chart2;
534
+ if (tooltip2._active[0]) {
535
+ const index = tooltip2._active[0].index;
536
+ const leftStart = x._gridLineItems[index + 1] ? x._gridLineItems[index + 1].x1 : 0;
537
+ const newWidth = x._gridLineItems[0].x1 - x._gridLineItems[1].x1;
538
+ ctx.fillStyle = "rgba(236, 240, 242, 0.6)";
539
+ ctx.fillRect(leftStart, top, newWidth, height);
540
+ }
541
+ }
542
+ };
543
+ }
544
+ __name(hoverBackgroundColors, "hoverBackgroundColors");
545
+ function handleExternalLegend() {
546
+ return {
547
+ id: "PluginHtmlLegend",
548
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
549
+ afterUpdate(chart2) {
550
+ var _a, _b, _c, _d;
551
+ const items = (_d = (_c = (_b = (_a = chart2 == null ? void 0 : chart2.options) == null ? void 0 : _a.plugins) == null ? void 0 : _b.legend) == null ? void 0 : _c.labels) == null ? void 0 : _d.generateLabels(chart2);
552
+ items.forEach((item) => {
553
+ item.chart = chart2;
554
+ item.click = () => {
555
+ if (isCircularChart.value) {
556
+ chart2.toggleDataVisibility(item.index);
557
+ } else {
558
+ chart2.setDatasetVisibility(item.datasetIndex, !chart2.isDatasetVisible(item.datasetIndex));
559
+ }
560
+ chart2.update();
561
+ };
562
+ });
563
+ legend.value = items;
564
+ if (isDebug.value) {
565
+ console.log(`[MpChart] The context legend of ${getId} is:`, legend.value);
566
+ }
567
+ }
568
+ };
569
+ }
570
+ __name(handleExternalLegend, "handleExternalLegend");
571
+ function handleColorPattern(idx, isFading) {
572
+ let color = "";
573
+ const startIndex = colorStart.value - 1;
574
+ const indexColors = Object.keys(getListColors.value);
575
+ const odds = indexColors.filter((number) => {
576
+ return Number(number) % 2 !== 0;
577
+ });
578
+ if (colorPattern.value === "") {
579
+ color = getListColors.value[Number(indexColors[startIndex + idx])];
580
+ }
581
+ if (colorPattern.value === "categorical") {
582
+ const oddsLength = odds.length - startIndex;
583
+ if (idx < oddsLength) {
584
+ color = getListColors.value[Number(odds[startIndex + idx])];
585
+ } else {
586
+ const multiplier = Math.floor(idx / oddsLength);
587
+ const darkenRatio = (colorRatio.value * multiplier).toFixed(1);
588
+ baseColor.value = getListColors.value[Number(odds[startIndex + idx - oddsLength * multiplier])];
589
+ color = (0, import_color.default)(baseColor.value).darken(Number(darkenRatio)).hex();
590
+ }
591
+ }
592
+ if (colorPattern.value === "comparison") {
593
+ color = getListColors.value[Number(indexColors[startIndex + idx])];
594
+ }
595
+ if (colorPattern.value === "dark-shades" || colorPattern.value === "light-shades") {
596
+ if (idx === 0) {
597
+ color = getListColors.value[Number(indexColors[startIndex])];
598
+ } else {
599
+ if (colorPattern.value === "dark-shades") {
600
+ color = (0, import_color.default)(baseColor.value).darken(colorRatio.value).hex();
601
+ }
602
+ if (colorPattern.value === "light-shades") {
603
+ color = (0, import_color.default)(baseColor.value).lighten(colorRatio.value).hex();
604
+ }
605
+ }
606
+ baseColor.value = color;
607
+ }
608
+ color = isFading ? (0, import_color.default)(color).fade(0.5).string() : color;
609
+ return color;
610
+ }
611
+ __name(handleColorPattern, "handleColorPattern");
612
+ function handleClickLegend(item) {
613
+ item.click();
614
+ emit("click-legend", item);
615
+ }
616
+ __name(handleClickLegend, "handleClickLegend");
617
+ (0, import_vue.watch)([() => data.value, () => options.value, () => type.value], ([newData, newOptions, newType]) => {
618
+ if (newData || newOptions || newType) {
619
+ updateChart();
620
+ }
621
+ }, {
622
+ deep: true
623
+ });
624
+ (0, import_vue.onMounted)(() => {
625
+ createChart();
626
+ chartContainerNode.value.scrollTo(0, chartContainerNode.value.scrollHeight);
627
+ });
628
+ (0, import_vue.onUnmounted)(() => {
629
+ destroyChart();
630
+ });
631
+ return {
632
+ rootAttrs,
633
+ chartHeaderAttrs,
634
+ chartWrapperAttrs,
635
+ chartContainerAttrs,
636
+ canvasContainerAttrs,
637
+ canvasAttrs,
638
+ chartLegendAttrs,
639
+ legendWrapperAttrs,
640
+ legendBoxAttrs,
641
+ chartTooltipAttrs,
642
+ tooltipWrapperAttrs,
643
+ tooltipRowAttrs,
644
+ tooltipItemAttrs,
645
+ tooltipBoxAttrs,
646
+ chart,
647
+ legend,
648
+ tooltip
649
+ };
650
+ }
651
+ __name(useChart, "useChart");
652
+ // Annotate the CommonJS export names for ESM import in node:
653
+ 0 && (module.exports = {
654
+ useChart
655
+ });
@@ -0,0 +1,7 @@
1
+ import {
2
+ useChart
3
+ } from "../chunk-5SYLA56O.mjs";
4
+ import "../chunk-QZ7VFGWC.mjs";
5
+ export {
6
+ useChart
7
+ };