apexcharts 8.0.1 → 8.2.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/README.md +14 -8
- package/dist/apexcharts.common.js +2 -2
- package/dist/apexcharts.core.js +2310 -2274
- package/dist/apexcharts.core.min.js +2 -2
- package/dist/apexcharts.esm.js +1367 -1110
- package/dist/apexcharts.full.js +3880 -3531
- package/dist/apexcharts.full.min.js +2 -2
- package/dist/apexcharts.js +3676 -3409
- package/dist/apexcharts.min.js +2 -2
- package/dist/apexcharts.ssr.common.js +2 -2
- package/dist/apexcharts.ssr.esm.js +4114 -3591
- package/dist/area.common.js +2 -2
- package/dist/area.esm.js +25 -67
- package/dist/bar.common.js +2 -2
- package/dist/bar.esm.js +159 -163
- package/dist/bar.js +2 -2
- package/dist/boxPlot.common.js +2 -2
- package/dist/boxPlot.esm.js +125 -106
- package/dist/bubble.common.js +2 -2
- package/dist/bubble.esm.js +25 -67
- package/dist/candlestick.common.js +2 -2
- package/dist/candlestick.esm.js +125 -106
- package/dist/candlestick.js +2 -2
- package/dist/column.common.js +2 -2
- package/dist/column.esm.js +159 -163
- package/dist/core.common.js +2 -2
- package/dist/core.esm.js +2310 -2274
- package/dist/donut.common.js +2 -2
- package/dist/donut.esm.js +100 -78
- package/dist/dumbbell.common.js +2 -2
- package/dist/dumbbell.esm.js +192 -167
- package/dist/features/all.common.js +2 -2
- package/dist/features/all.esm.js +945 -640
- package/dist/features/annotations.common.js +2 -2
- package/dist/features/annotations.esm.js +46 -21
- package/dist/features/annotations.js +2 -2
- package/dist/features/context-menu.common.js +1 -1
- package/dist/features/context-menu.esm.js +1 -1
- package/dist/features/context-menu.js +1 -1
- package/dist/features/drilldown.common.js +2 -2
- package/dist/features/drilldown.esm.js +22 -2
- package/dist/features/drilldown.js +2 -2
- package/dist/features/dumbbell.common.js +2 -2
- package/dist/features/dumbbell.esm.js +34 -5
- package/dist/features/dumbbell.js +2 -2
- package/dist/features/exports.common.js +2 -2
- package/dist/features/exports.esm.js +203 -204
- package/dist/features/exports.js +2 -2
- package/dist/features/facet.common.js +1 -1
- package/dist/features/facet.esm.js +1 -1
- package/dist/features/facet.js +1 -1
- package/dist/features/highlight-filter.common.js +2 -2
- package/dist/features/highlight-filter.esm.js +97 -41
- package/dist/features/highlight-filter.js +2 -2
- package/dist/features/history.common.js +2 -2
- package/dist/features/history.esm.js +4 -3
- package/dist/features/history.js +2 -2
- package/dist/features/ink.common.js +1 -1
- package/dist/features/ink.esm.js +1 -1
- package/dist/features/ink.js +1 -1
- package/dist/features/keyboard.common.js +2 -2
- package/dist/features/keyboard.esm.js +20 -23
- package/dist/features/keyboard.js +2 -2
- package/dist/features/legend.common.js +2 -2
- package/dist/features/legend.esm.js +61 -41
- package/dist/features/legend.js +2 -2
- package/dist/features/link.common.js +2 -2
- package/dist/features/link.esm.js +8 -8
- package/dist/features/link.js +2 -2
- package/dist/features/marks.common.js +2 -2
- package/dist/features/marks.esm.js +1 -1
- package/dist/features/marks.js +1 -1
- package/dist/features/measure.common.js +1 -1
- package/dist/features/measure.esm.js +1 -1
- package/dist/features/measure.js +1 -1
- package/dist/features/morph.common.js +2 -2
- package/dist/features/morph.esm.js +260 -279
- package/dist/features/morph.js +2 -2
- package/dist/features/perspectives.common.js +2 -2
- package/dist/features/perspectives.esm.js +28 -19
- package/dist/features/perspectives.js +2 -2
- package/dist/features/raincloud.common.js +2 -2
- package/dist/features/raincloud.esm.js +54 -36
- package/dist/features/raincloud.js +2 -2
- package/dist/features/renderer-canvas.common.js +1 -1
- package/dist/features/renderer-canvas.esm.js +1 -1
- package/dist/features/renderer-canvas.js +1 -1
- package/dist/features/stats.common.js +2 -2
- package/dist/features/stats.esm.js +66 -18
- package/dist/features/stats.js +2 -2
- package/dist/features/storyboard.common.js +2 -2
- package/dist/features/storyboard.esm.js +24 -15
- package/dist/features/storyboard.js +2 -2
- package/dist/features/streamgraph.common.js +2 -2
- package/dist/features/streamgraph.esm.js +34 -5
- package/dist/features/streamgraph.js +2 -2
- package/dist/features/toolbar.common.js +2 -2
- package/dist/features/toolbar.esm.js +211 -217
- package/dist/features/toolbar.js +2 -2
- package/dist/features/trellis.common.js +2 -2
- package/dist/features/trellis.esm.js +31 -19
- package/dist/features/trellis.js +2 -2
- package/dist/features/waterfall.common.js +2 -2
- package/dist/features/waterfall.esm.js +34 -5
- package/dist/features/waterfall.js +2 -2
- package/dist/features/weave.common.js +2 -2
- package/dist/features/weave.esm.js +290 -48
- package/dist/features/weave.js +2 -2
- package/dist/full.common.js +2 -2
- package/dist/full.esm.js +289 -150
- package/dist/heatmap.common.js +2 -2
- package/dist/heatmap.esm.js +48 -17
- package/dist/heatmap.js +2 -2
- package/dist/histogram.common.js +2 -2
- package/dist/histogram.esm.js +224 -180
- package/dist/icicle.common.js +2 -2
- package/dist/icicle.esm.js +1 -1
- package/dist/icicle.js +1 -1
- package/dist/line.common.js +2 -2
- package/dist/line.esm.js +25 -67
- package/dist/line.js +2 -2
- package/dist/pictograms.common.js +1 -1
- package/dist/pictograms.esm.js +1 -1
- package/dist/pictograms.js +1 -1
- package/dist/pie.common.js +2 -2
- package/dist/pie.esm.js +100 -78
- package/dist/pie.js +2 -2
- package/dist/polarArea.common.js +2 -2
- package/dist/polarArea.esm.js +100 -78
- package/dist/radar.common.js +2 -2
- package/dist/radar.esm.js +8 -5
- package/dist/radar.js +2 -2
- package/dist/radialBar.common.js +2 -2
- package/dist/radialBar.esm.js +166 -133
- package/dist/radialBar.js +2 -2
- package/dist/raincloud.common.js +2 -2
- package/dist/raincloud.esm.js +55 -42
- package/dist/rangeArea.common.js +2 -2
- package/dist/rangeArea.esm.js +25 -67
- package/dist/rangeBar.common.js +2 -2
- package/dist/rangeBar.esm.js +159 -163
- package/dist/scatter.common.js +2 -2
- package/dist/scatter.esm.js +25 -67
- package/dist/streamgraph.common.js +2 -2
- package/dist/streamgraph.esm.js +58 -71
- package/dist/sunburst.common.js +2 -2
- package/dist/sunburst.esm.js +1 -1
- package/dist/sunburst.js +1 -1
- package/dist/treemap.common.js +2 -2
- package/dist/treemap.esm.js +28 -90
- package/dist/treemap.js +2 -2
- package/dist/unit-shapes.common.js +2 -2
- package/dist/unit-shapes.esm.js +1 -1
- package/dist/unit-shapes.js +1 -1
- package/dist/unit.common.js +2 -2
- package/dist/unit.esm.js +30 -6
- package/dist/unit.js +2 -2
- package/dist/violin.common.js +2 -2
- package/dist/violin.esm.js +2 -7
- package/dist/violin.js +2 -2
- package/dist/waterfall.common.js +2 -2
- package/dist/waterfall.esm.js +192 -167
- package/package.json +3 -1
- package/src/apexcharts.js +260 -201
- package/src/charts/Bar.js +16 -5
- package/src/charts/BarStacked.js +42 -88
- package/src/charts/BoxCandleStick.js +1 -7
- package/src/charts/HeatMap.js +73 -16
- package/src/charts/Line.js +21 -71
- package/src/charts/Pie.js +142 -89
- package/src/charts/Radar.js +4 -1
- package/src/charts/Radial.js +91 -63
- package/src/charts/RangeBar.js +1 -7
- package/src/charts/Treemap.js +25 -78
- package/src/charts/Unit.js +28 -10
- package/src/charts/Violin.js +1 -7
- package/src/charts/common/Hierarchy.js +0 -22
- package/src/charts/common/OuterLabels.js +12 -5
- package/src/charts/common/Stats.js +55 -28
- package/src/charts/common/bar/DataLabels.js +94 -83
- package/src/charts/common/bar/Helpers.js +34 -57
- package/src/charts/common/circle/Helpers.js +5 -2
- package/src/charts/common/treemap/Helpers.js +1 -1
- package/src/entries/full.js +0 -17
- package/src/features/link.js +9 -10
- package/src/features/perspectives.js +20 -19
- package/src/features/raincloud.js +51 -53
- package/src/features/stats.js +23 -35
- package/src/libs/Treemap-squared.js +7 -47
- package/src/modules/Animations.js +55 -73
- package/src/modules/Base.js +3 -2
- package/src/modules/ChartFactory.js +6 -1
- package/src/modules/Core.js +57 -30
- package/src/modules/CoreUtils.js +32 -33
- package/src/modules/Crosshairs.js +29 -11
- package/src/modules/Data.js +279 -153
- package/src/modules/DataLabels.js +18 -2
- package/src/modules/Events.js +1 -4
- package/src/modules/Exports.js +284 -305
- package/src/modules/Fill.js +23 -10
- package/src/modules/Formatters.js +14 -3
- package/src/modules/Graphics.js +8 -14
- package/src/modules/MorphPieces.js +4 -2
- package/src/modules/MorphTypeChange.js +332 -316
- package/src/modules/Range.js +56 -99
- package/src/modules/Responsive.js +186 -61
- package/src/modules/Scales.js +4 -47
- package/src/modules/Series.js +14 -45
- package/src/modules/Theme.js +108 -57
- package/src/modules/Toolbar.js +7 -13
- package/src/modules/accessibility/KeyboardNavigation.js +29 -28
- package/src/modules/animations/AxisTransition.js +54 -16
- package/src/modules/animations/CircleTransition.js +1 -4
- package/src/modules/animations/DataLabelTransition.js +15 -10
- package/src/modules/animations/StreamScroll.js +6 -4
- package/src/modules/annotations/Annotations.js +18 -17
- package/src/modules/annotations/Helpers.js +41 -17
- package/src/modules/axes/XAxis.js +4 -4
- package/src/modules/axes/YAxis.js +1 -6
- package/src/modules/dimensions/Dimensions.js +12 -7
- package/src/modules/dimensions/Grid.js +15 -3
- package/src/modules/dimensions/YAxis.js +7 -6
- package/src/modules/drilldown/Drilldown.js +22 -1
- package/src/modules/dumbbell/DumbbellData.js +3 -5
- package/src/modules/helpers/Destroy.js +10 -1
- package/src/modules/helpers/InitCtxVariables.js +19 -16
- package/src/modules/helpers/RawStash.js +51 -0
- package/src/modules/helpers/UpdateHelpers.js +95 -30
- package/src/modules/highlightFilter/HighlightFilter.js +107 -52
- package/src/modules/highlightFilter/PiePart.js +1 -1
- package/src/modules/highlightFilter/RadialPart.js +1 -1
- package/src/modules/history/History.js +7 -2
- package/src/modules/legend/Legend.js +100 -62
- package/src/modules/license/LicenseEnforcer.js +6 -1
- package/src/modules/settings/Config.js +60 -153
- package/src/modules/settings/Defaults.js +352 -58
- package/src/modules/settings/Globals.js +23 -5
- package/src/modules/settings/Options.js +19 -5
- package/src/modules/settings/TypeAliases.js +3 -6
- package/src/modules/streamgraph/StreamData.js +3 -5
- package/src/modules/tooltip/AxesTooltip.js +33 -41
- package/src/modules/tooltip/Intersect.js +50 -43
- package/src/modules/tooltip/Labels.js +62 -23
- package/src/modules/tooltip/Marker.js +6 -7
- package/src/modules/tooltip/Position.js +31 -35
- package/src/modules/tooltip/Tooltip.js +107 -119
- package/src/modules/tooltip/Utils.js +94 -159
- package/src/modules/trellis/TrellisExports.js +21 -9
- package/src/modules/trellis/TrellisTooltip.js +18 -8
- package/src/modules/waterfall/WaterfallData.js +3 -5
- package/src/modules/weave/Claims.js +14 -3
- package/src/modules/weave/Highlights.js +209 -0
- package/src/modules/weave/PluginAPI.js +64 -3
- package/src/modules/weave/WeaveHost.js +215 -51
- package/src/ssr/BrowserAPIs.js +5 -3
- package/src/ssr/DOMShim.js +6 -30
- package/src/ssr/Hydration.js +5 -36
- package/src/ssr/RenderShim.js +333 -0
- package/src/ssr/SSRRenderer.js +81 -36
- package/src/svg/SVGAnimation.js +10 -7
- package/src/types/internal.d.ts +37 -7
- package/src/utils/Constants.js +7 -8
- package/src/utils/DateTime.js +21 -195
- package/src/utils/MissingFeature.js +7 -9
- package/src/utils/Resize.js +4 -0
- package/src/utils/Utils.js +102 -171
- package/types/apexcharts.d.ts +57 -7
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* ApexCharts v8.0
|
|
2
|
+
* ApexCharts v8.2.0
|
|
3
3
|
* (c) 2018-2026 ApexCharts
|
|
4
4
|
*/
|
|
5
5
|
import * as _core from "apexcharts/core";
|
|
6
6
|
import _core__default from "apexcharts/core";
|
|
7
7
|
import { default as default2 } from "apexcharts/core";
|
|
8
8
|
const AxesUtils = _core.__apex_axes_AxesUtils;
|
|
9
|
-
const Data = _core.__apex_Data;
|
|
10
9
|
const Series = _core.__apex_Series;
|
|
11
10
|
const Utils = _core.__apex_Utils;
|
|
12
11
|
const Environment = _core.__apex_Environment_Environment;
|
|
@@ -304,48 +303,58 @@ class Exports {
|
|
|
304
303
|
return families;
|
|
305
304
|
}
|
|
306
305
|
/**
|
|
307
|
-
* Every `@font-face` rule reachable from the document, as
|
|
306
|
+
* Every `@font-face` rule reachable from the document, as
|
|
307
|
+
* `{ family, css, base }`, where `base` is the URL the rule's relative
|
|
308
|
+
* `url()`s resolve against: its stylesheet, not the page.
|
|
308
309
|
*
|
|
309
|
-
* Same-origin sheets are read through `cssRules
|
|
310
|
-
*
|
|
311
|
-
*
|
|
312
|
-
*
|
|
313
|
-
*
|
|
310
|
+
* Same-origin sheets are read through `cssRules`, descending into `@import`
|
|
311
|
+
* and grouping rules (`@media`, `@supports`, `@layer`). A cross-origin sheet
|
|
312
|
+
* throws on that access, so it is re-fetched by href and its `@font-face`
|
|
313
|
+
* blocks are pulled out of the text: that is the path that matters in
|
|
314
|
+
* practice, since hosted webfonts (the subject of #3617) are exactly the
|
|
315
|
+
* cross-origin case.
|
|
316
|
+
* @returns {Promise<Array<{family: string, css: string, base: string}>>}
|
|
314
317
|
*/
|
|
315
318
|
collectFontFaceRules() {
|
|
316
319
|
if (!Environment.isBrowser()) return Promise.resolve([]);
|
|
317
320
|
const found = [];
|
|
318
321
|
const remote = [];
|
|
319
|
-
const pushFromText = (cssText) => {
|
|
322
|
+
const pushFromText = (cssText, base) => {
|
|
320
323
|
const blocks = cssText.match(/@font-face\s*\{[^}]*\}/gi) || [];
|
|
321
324
|
blocks.forEach((css) => {
|
|
322
325
|
const m = css.match(/font-family\s*:\s*([^;}]+)/i);
|
|
323
326
|
if (!m) return;
|
|
324
327
|
const family = m[1].trim().replace(/^['"]|['"]$/g, "");
|
|
325
|
-
found.push({ family: family.toLowerCase(), css });
|
|
328
|
+
found.push({ family: family.toLowerCase(), css, base });
|
|
326
329
|
});
|
|
327
330
|
};
|
|
328
|
-
const
|
|
329
|
-
|
|
331
|
+
const walkRules = (rules, base) => {
|
|
332
|
+
Array.from(rules).forEach((rule) => {
|
|
333
|
+
if (rule.type === 5) {
|
|
334
|
+
if (rule.cssText) pushFromText(rule.cssText, base);
|
|
335
|
+
} else if (rule.styleSheet) {
|
|
336
|
+
walkSheet(rule.styleSheet);
|
|
337
|
+
} else if (rule.cssRules) {
|
|
338
|
+
walkRules(rule.cssRules, base);
|
|
339
|
+
}
|
|
340
|
+
});
|
|
341
|
+
};
|
|
342
|
+
const walkSheet = (sheet) => {
|
|
330
343
|
let rules = null;
|
|
331
344
|
try {
|
|
332
345
|
rules = sheet.cssRules;
|
|
333
346
|
} catch (e) {
|
|
334
|
-
rules = null;
|
|
335
347
|
}
|
|
336
348
|
if (rules) {
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
});
|
|
340
|
-
return;
|
|
341
|
-
}
|
|
342
|
-
if (sheet.href) {
|
|
349
|
+
walkRules(rules, sheet.href || document.baseURI);
|
|
350
|
+
} else if (sheet.href) {
|
|
343
351
|
remote.push(
|
|
344
|
-
fetch(sheet.href).then((r) => r.ok ? r.text() : "").then(pushFromText).catch(() => {
|
|
352
|
+
fetch(sheet.href).then((r) => r.ok ? r.text() : "").then((text) => pushFromText(text, sheet.href)).catch(() => {
|
|
345
353
|
})
|
|
346
354
|
);
|
|
347
355
|
}
|
|
348
|
-
}
|
|
356
|
+
};
|
|
357
|
+
Array.from(document.styleSheets || []).forEach(walkSheet);
|
|
349
358
|
return Promise.all(remote).then(() => found);
|
|
350
359
|
}
|
|
351
360
|
/**
|
|
@@ -378,7 +387,7 @@ class Exports {
|
|
|
378
387
|
if (!wanted.length) return Promise.resolve([]);
|
|
379
388
|
return Promise.all(
|
|
380
389
|
wanted.map(
|
|
381
|
-
(face) => this.inlineFontFaceUrls(face.css).catch(() => null)
|
|
390
|
+
(face) => this.inlineFontFaceUrls(face.css, face.base).catch(() => null)
|
|
382
391
|
)
|
|
383
392
|
);
|
|
384
393
|
}).then((cssBlocks) => {
|
|
@@ -395,9 +404,10 @@ class Exports {
|
|
|
395
404
|
* data URI. Resolves to null if no url could be fetched, so the caller can
|
|
396
405
|
* drop a block that would only reference unreachable files.
|
|
397
406
|
* @param {string} css
|
|
407
|
+
* @param {string} [base] the URL relative `url()`s resolve against
|
|
398
408
|
* @returns {Promise<string | null>}
|
|
399
409
|
*/
|
|
400
|
-
inlineFontFaceUrls(css) {
|
|
410
|
+
inlineFontFaceUrls(css, base) {
|
|
401
411
|
const urls = [];
|
|
402
412
|
const re = /url\(\s*(['"]?)([^'")]+)\1\s*\)/gi;
|
|
403
413
|
let m;
|
|
@@ -407,7 +417,7 @@ class Exports {
|
|
|
407
417
|
if (!urls.length) return Promise.resolve(css.includes("data:") ? css : null);
|
|
408
418
|
return Promise.all(
|
|
409
419
|
urls.map(
|
|
410
|
-
(url) => this.fetchAsDataUri(url).then((dataUri) => ({ url, dataUri })).catch(() => ({ url, dataUri: null }))
|
|
420
|
+
(url) => this.fetchAsDataUri(base ? new URL(url, base).href : url).then((dataUri) => ({ url, dataUri })).catch(() => ({ url, dataUri: null }))
|
|
411
421
|
)
|
|
412
422
|
).then((results) => {
|
|
413
423
|
let out = css;
|
|
@@ -468,6 +478,7 @@ class Exports {
|
|
|
468
478
|
(_a = w.globals.layoutTween) == null ? void 0 : _a.finish();
|
|
469
479
|
(_b = w.globals.circleTween) == null ? void 0 : _b.finish();
|
|
470
480
|
(_c = w.globals.highlightTween) == null ? void 0 : _c.finish();
|
|
481
|
+
[...w.globals.chromeTweens || []].forEach((finish) => finish());
|
|
471
482
|
const clonedNode = (
|
|
472
483
|
/** @type {HTMLElement} */
|
|
473
484
|
w.dom.elWrap.cloneNode(true)
|
|
@@ -574,19 +585,26 @@ class Exports {
|
|
|
574
585
|
});
|
|
575
586
|
}
|
|
576
587
|
/**
|
|
588
|
+
* Resolves `{ imgURI: '' }` when the PNG cannot be made (no 2d context for
|
|
589
|
+
* a canvas that size, an SVG the browser will not decode, a tainted
|
|
590
|
+
* canvas), so a caller is never left waiting.
|
|
577
591
|
* @param {Record<string, any> | undefined} options
|
|
578
592
|
*/
|
|
579
593
|
dataURI(options) {
|
|
580
594
|
if (Environment.isSSR()) return Promise.resolve({ imgURI: "" });
|
|
581
595
|
return new Promise((resolve) => {
|
|
582
596
|
const w = this.w;
|
|
597
|
+
const fail = () => {
|
|
598
|
+
console.warn("ApexCharts: the PNG export could not be rendered");
|
|
599
|
+
resolve({ imgURI: "" });
|
|
600
|
+
};
|
|
583
601
|
const scale = options ? options.scale || options.width / w.globals.svgWidth : 1;
|
|
584
602
|
const canvas = document.createElement("canvas");
|
|
585
603
|
canvas.width = w.globals.svgWidth * scale;
|
|
586
604
|
canvas.height = parseInt(w.dom.elWrap.style.height, 10) * scale;
|
|
587
605
|
const canvasBg = this.resolveExportBackground();
|
|
588
606
|
const ctx = canvas.getContext("2d");
|
|
589
|
-
if (!ctx) return;
|
|
607
|
+
if (!ctx) return fail();
|
|
590
608
|
ctx.fillStyle = canvasBg;
|
|
591
609
|
ctx.fillRect(0, 0, canvas.width, canvas.height);
|
|
592
610
|
this.getSvgString(scale).then((svgData) => {
|
|
@@ -594,18 +612,23 @@ class Exports {
|
|
|
594
612
|
const img = new Image();
|
|
595
613
|
img.crossOrigin = "anonymous";
|
|
596
614
|
img.onload = () => {
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
615
|
+
try {
|
|
616
|
+
ctx.drawImage(img, 0, 0);
|
|
617
|
+
const edgeCanvas = canvas;
|
|
618
|
+
if (edgeCanvas.msToBlob) {
|
|
619
|
+
const blob = edgeCanvas.msToBlob();
|
|
620
|
+
resolve({ blob });
|
|
621
|
+
} else {
|
|
622
|
+
const imgURI = canvas.toDataURL("image/png");
|
|
623
|
+
resolve({ imgURI });
|
|
624
|
+
}
|
|
625
|
+
} catch (e) {
|
|
626
|
+
fail();
|
|
605
627
|
}
|
|
606
628
|
};
|
|
629
|
+
img.onerror = fail;
|
|
607
630
|
img.src = svgUrl;
|
|
608
|
-
});
|
|
631
|
+
}).catch(fail);
|
|
609
632
|
});
|
|
610
633
|
}
|
|
611
634
|
exportToSVG() {
|
|
@@ -624,7 +647,7 @@ class Exports {
|
|
|
624
647
|
this.dataURI(option).then(({ imgURI, blob }) => {
|
|
625
648
|
if (blob) {
|
|
626
649
|
navigator.msSaveOrOpenBlob(blob, this.w.globals.chartID + ".png");
|
|
627
|
-
} else {
|
|
650
|
+
} else if (imgURI) {
|
|
628
651
|
this.triggerDownload(
|
|
629
652
|
imgURI,
|
|
630
653
|
this.w.config.chart.toolbar.export.png.filename,
|
|
@@ -641,48 +664,54 @@ class Exports {
|
|
|
641
664
|
lineDelimiter = "\n"
|
|
642
665
|
}) {
|
|
643
666
|
const w = this.w;
|
|
644
|
-
|
|
645
|
-
|
|
667
|
+
const gl = w.globals;
|
|
668
|
+
const csvCfg = w.config.chart.toolbar.export.csv;
|
|
669
|
+
const raw = !series && (gl.streamgraphRawSeries || gl.waterfallRawSeries || gl.dumbbellRawSeries);
|
|
670
|
+
if (!series) series = raw || w.config.series;
|
|
671
|
+
const hidden = new Set(
|
|
672
|
+
raw && raw === gl.dumbbellRawSeries ? w.dumbbellData.hidden : gl.collapsedSeriesIndices
|
|
673
|
+
);
|
|
646
674
|
const rows = [];
|
|
647
|
-
|
|
648
|
-
const
|
|
649
|
-
const
|
|
650
|
-
return w.globals.collapsedSeriesIndices.indexOf(i) === -1 ? s : [];
|
|
651
|
-
});
|
|
675
|
+
const body = [];
|
|
676
|
+
const isDatetime = w.config.xaxis.type === "datetime";
|
|
677
|
+
const utc = w.config.xaxis.labels.datetimeUTC;
|
|
652
678
|
const csvSafe = (val) => {
|
|
653
679
|
if (val == null || Utils.isNumber(val)) return val;
|
|
654
680
|
const s = String(val);
|
|
655
|
-
return /^[=+\-@\t\r]/.test(s) ? `'${s}` : s;
|
|
681
|
+
return /^[=+\-@\t\r]/.test(s) && isNaN(+s) ? `'${s}` : s;
|
|
656
682
|
};
|
|
657
|
-
const
|
|
658
|
-
|
|
659
|
-
|
|
683
|
+
const isDateCat = (cat) => isDatetime && String(cat).length >= 10 && !isNaN(new Date(cat).getTime());
|
|
684
|
+
const datetimeText = (cat, withTime2) => {
|
|
685
|
+
const d = new Date(cat);
|
|
686
|
+
if (!utc) d.setTime(d.getTime() - d.getTimezoneOffset() * 6e4);
|
|
687
|
+
if (withTime2) {
|
|
688
|
+
return d.toISOString().slice(0, 23).replace("T", " ").replace(".000", "");
|
|
660
689
|
}
|
|
661
|
-
|
|
662
|
-
|
|
690
|
+
const [day, date, month, year] = d.toUTCString().split(" ");
|
|
691
|
+
return `${day.slice(0, 3)} ${month} ${date} ${year}`;
|
|
692
|
+
};
|
|
693
|
+
const getFormattedCategory = (cat, withTime2) => {
|
|
694
|
+
if (typeof csvCfg.categoryFormatter === "function") {
|
|
695
|
+
return csvCfg.categoryFormatter(cat);
|
|
663
696
|
}
|
|
664
|
-
|
|
697
|
+
if (cat == null) return "";
|
|
698
|
+
if (isDateCat(cat)) return datetimeText(cat, withTime2);
|
|
699
|
+
return Utils.isNumber(cat) ? cat : csvSafe(String(cat).split(columnDelimiter).join(""));
|
|
665
700
|
};
|
|
666
701
|
const getFormattedValue = (value) => {
|
|
667
|
-
return typeof
|
|
702
|
+
return typeof csvCfg.valueFormatter === "function" ? csvCfg.valueFormatter(value) : csvSafe(value);
|
|
668
703
|
};
|
|
669
|
-
const seriesMaxDataLength = Math.max(
|
|
670
|
-
...series.map((s) => {
|
|
671
|
-
return s.data ? s.data.length : 0;
|
|
672
|
-
})
|
|
673
|
-
);
|
|
674
|
-
const dataFormat = new Data(this.w);
|
|
675
704
|
const axesUtils = new AxesUtils(this.w, {
|
|
676
705
|
theme: this.ctx.theme,
|
|
677
706
|
timeScale: this.ctx.timeScale
|
|
678
707
|
});
|
|
679
708
|
const getCat = (i) => {
|
|
680
709
|
let cat = "";
|
|
681
|
-
if (!
|
|
710
|
+
if (!gl.axisCharts) {
|
|
682
711
|
cat = w.config.labels[i];
|
|
683
712
|
} else {
|
|
684
713
|
if (w.config.xaxis.type === "category" || w.config.xaxis.convertedCatToNumeric) {
|
|
685
|
-
if (
|
|
714
|
+
if (gl.isBarHorizontal) {
|
|
686
715
|
const lbFormatter = w.formatters.yLabelFormatters[0];
|
|
687
716
|
const sr = new Series(this.ctx.w);
|
|
688
717
|
const activeSeries = sr.getActiveConfigSeriesIndex();
|
|
@@ -700,7 +729,7 @@ class Exports {
|
|
|
700
729
|
).text;
|
|
701
730
|
}
|
|
702
731
|
}
|
|
703
|
-
if (
|
|
732
|
+
if (isDatetime) {
|
|
704
733
|
if (w.config.xaxis.categories.length) {
|
|
705
734
|
cat = w.config.xaxis.categories[i];
|
|
706
735
|
} else if (w.config.labels.length) {
|
|
@@ -708,159 +737,129 @@ class Exports {
|
|
|
708
737
|
}
|
|
709
738
|
}
|
|
710
739
|
}
|
|
711
|
-
|
|
712
|
-
if (Array.isArray(cat)) {
|
|
713
|
-
cat = cat.join(" ");
|
|
714
|
-
}
|
|
715
|
-
return Utils.isNumber(cat) ? cat : cat.split(columnDelimiter).join("");
|
|
716
|
-
};
|
|
717
|
-
const getEmptyDataForCsvColumn = () => {
|
|
718
|
-
return [...Array(seriesMaxDataLength)].map(() => "");
|
|
740
|
+
return Array.isArray(cat) ? cat.join(" ") : cat;
|
|
719
741
|
};
|
|
720
|
-
const
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
columns.push(w.candleData.seriesCandleL[sI][i]);
|
|
758
|
-
columns.push(w.candleData.seriesCandleC[sI][i]);
|
|
759
|
-
}
|
|
760
|
-
if (w.config.chart.type === "rangeBar") {
|
|
761
|
-
columns.pop();
|
|
762
|
-
columns.push(w.rangeData.seriesRangeStart[sI][i]);
|
|
763
|
-
columns.push(w.rangeData.seriesRangeEnd[sI][i]);
|
|
764
|
-
}
|
|
765
|
-
if (w.config.chart.type === "violin" || s.type && s.type === "violin") {
|
|
766
|
-
columns.pop();
|
|
767
|
-
columns.push((_b = w.violinData.seriesViolinMin[sI]) == null ? void 0 : _b[i]);
|
|
768
|
-
columns.push((_c = w.violinData.seriesViolinMax[sI]) == null ? void 0 : _c[i]);
|
|
769
|
-
columns.push((_f = (_e = (_d = w.violinData.seriesViolinPoints[sI]) == null ? void 0 : _d[i]) == null ? void 0 : _e.length) != null ? _f : 0);
|
|
770
|
-
}
|
|
771
|
-
if (columns.length) {
|
|
772
|
-
rows.push(columns.join(columnDelimiter));
|
|
742
|
+
const cd = w.candleData;
|
|
743
|
+
const rd = w.rangeData;
|
|
744
|
+
const vd = w.violinData;
|
|
745
|
+
const multi = series.length > 1;
|
|
746
|
+
const cols = series.map((s, sI) => {
|
|
747
|
+
const type = raw ? "" : s.type || w.config.chart.type;
|
|
748
|
+
const fields = type === "candlestick" ? {
|
|
749
|
+
open: cd.seriesCandleO,
|
|
750
|
+
high: cd.seriesCandleH,
|
|
751
|
+
low: cd.seriesCandleL,
|
|
752
|
+
close: cd.seriesCandleC
|
|
753
|
+
} : type === "boxPlot" ? {
|
|
754
|
+
minimum: cd.seriesCandleO,
|
|
755
|
+
q1: cd.seriesCandleH,
|
|
756
|
+
median: cd.seriesCandleM,
|
|
757
|
+
q3: cd.seriesCandleL,
|
|
758
|
+
maximum: cd.seriesCandleC
|
|
759
|
+
} : type === "rangeBar" || type === "rangeArea" ? { minimum: rd.seriesRangeStart, maximum: rd.seriesRangeEnd } : type === "violin" ? {
|
|
760
|
+
minimum: vd.seriesViolinMin,
|
|
761
|
+
maximum: vd.seriesViolinMax,
|
|
762
|
+
observations: vd.seriesViolinPoints
|
|
763
|
+
} : null;
|
|
764
|
+
const name = String(s.name || `series-${sI}`).split(columnDelimiter).join("") || `series-${sI}`;
|
|
765
|
+
const keys = fields ? Object.keys(fields) : [name];
|
|
766
|
+
return {
|
|
767
|
+
head: fields && multi ? keys.map((k) => `${name} ${k}`) : keys,
|
|
768
|
+
/** @param {number} i */
|
|
769
|
+
cells: (i) => {
|
|
770
|
+
var _a;
|
|
771
|
+
const off = hidden.has(sI);
|
|
772
|
+
if (!fields) {
|
|
773
|
+
const d = off ? void 0 : (_a = s.data) == null ? void 0 : _a[i];
|
|
774
|
+
return [
|
|
775
|
+
getFormattedValue(
|
|
776
|
+
d && typeof d === "object" ? Array.isArray(d) ? d[1] : d.y : d
|
|
777
|
+
)
|
|
778
|
+
];
|
|
773
779
|
}
|
|
780
|
+
return Object.values(fields).map((src) => {
|
|
781
|
+
var _a2;
|
|
782
|
+
const v = off ? void 0 : (_a2 = src == null ? void 0 : src[sI]) == null ? void 0 : _a2[i];
|
|
783
|
+
return getFormattedValue(Array.isArray(v) ? v.length : v);
|
|
784
|
+
});
|
|
774
785
|
}
|
|
775
|
-
}
|
|
776
|
-
};
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
} else {
|
|
789
|
-
return;
|
|
790
|
-
}
|
|
791
|
-
const key = String(cat);
|
|
792
|
-
let row = byCategory.get(key);
|
|
793
|
-
if (!row) {
|
|
794
|
-
row = { cat, values: Array(series.length).fill("") };
|
|
795
|
-
byCategory.set(key, row);
|
|
796
|
-
}
|
|
797
|
-
row.values[sI] = getFormattedValue(value);
|
|
798
|
-
});
|
|
799
|
-
});
|
|
800
|
-
if (columns.length) {
|
|
801
|
-
rows.push(columns.join(columnDelimiter));
|
|
802
|
-
}
|
|
803
|
-
Array.from(byCategory.values()).sort((a, b) => {
|
|
804
|
-
const aText = typeof a.cat === "string";
|
|
805
|
-
const bText = typeof b.cat === "string";
|
|
806
|
-
if (aText !== bText) return aText ? 1 : -1;
|
|
807
|
-
if (!aText) return a.cat - b.cat;
|
|
808
|
-
return a.cat < b.cat ? -1 : 1;
|
|
809
|
-
}).forEach(({ cat, values }) => {
|
|
810
|
-
rows.push([getFormattedCategory(cat), ...values].join(columnDelimiter));
|
|
811
|
-
});
|
|
812
|
-
};
|
|
813
|
-
columns.push(w.config.chart.toolbar.export.csv.headerCategory);
|
|
814
|
-
if (w.config.chart.type === "boxPlot") {
|
|
815
|
-
columns.push("minimum");
|
|
816
|
-
columns.push("q1");
|
|
817
|
-
columns.push("median");
|
|
818
|
-
columns.push("q3");
|
|
819
|
-
columns.push("maximum");
|
|
820
|
-
} else if (w.config.chart.type === "candlestick") {
|
|
821
|
-
columns.push("open");
|
|
822
|
-
columns.push("high");
|
|
823
|
-
columns.push("low");
|
|
824
|
-
columns.push("close");
|
|
825
|
-
} else if (w.config.chart.type === "rangeBar") {
|
|
826
|
-
columns.push("minimum");
|
|
827
|
-
columns.push("maximum");
|
|
828
|
-
} else if (w.config.chart.type === "violin") {
|
|
829
|
-
columns.push("minimum");
|
|
830
|
-
columns.push("maximum");
|
|
831
|
-
columns.push("observations");
|
|
832
|
-
} else {
|
|
833
|
-
series.map((s, sI) => {
|
|
834
|
-
const sname = (s.name ? s.name : `series-${sI}`) + "";
|
|
835
|
-
if (w.globals.axisCharts) {
|
|
836
|
-
columns.push(
|
|
837
|
-
sname.split(columnDelimiter).join("") ? sname.split(columnDelimiter).join("") : `series-${sI}`
|
|
838
|
-
);
|
|
839
|
-
}
|
|
786
|
+
};
|
|
787
|
+
});
|
|
788
|
+
if (!gl.axisCharts) {
|
|
789
|
+
rows.push(
|
|
790
|
+
[csvCfg.headerCategory, csvCfg.headerValue].join(columnDelimiter)
|
|
791
|
+
);
|
|
792
|
+
series.forEach((_, sI) => {
|
|
793
|
+
rows.push(
|
|
794
|
+
[
|
|
795
|
+
getFormattedCategory(w.labelData.labels[sI]),
|
|
796
|
+
getFormattedValue(hidden.has(sI) ? "" : w.seriesData.series[sI])
|
|
797
|
+
].join(columnDelimiter)
|
|
798
|
+
);
|
|
840
799
|
});
|
|
841
|
-
}
|
|
842
|
-
if (!w.globals.axisCharts) {
|
|
843
|
-
columns.push(w.config.chart.toolbar.export.csv.headerValue);
|
|
844
|
-
rows.push(columns.join(columnDelimiter));
|
|
845
|
-
}
|
|
846
|
-
if (!w.globals.allSeriesHasEqualX && w.globals.axisCharts && !w.config.xaxis.categories.length && !w.config.labels.length) {
|
|
847
|
-
handleUnequalXValues();
|
|
848
800
|
} else {
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
801
|
+
rows.push(
|
|
802
|
+
[csvCfg.headerCategory, ...cols.flatMap((c) => c.head)].join(
|
|
803
|
+
columnDelimiter
|
|
804
|
+
)
|
|
805
|
+
);
|
|
806
|
+
if (!gl.allSeriesHasEqualX && !w.config.xaxis.categories.length && !w.config.labels.length) {
|
|
807
|
+
const byCategory = /* @__PURE__ */ new Map();
|
|
808
|
+
series.forEach((s, sI) => {
|
|
809
|
+
var _a;
|
|
810
|
+
(_a = s == null ? void 0 : s.data) == null ? void 0 : _a.forEach((d, i) => {
|
|
811
|
+
if (!d || typeof d !== "object") return;
|
|
812
|
+
const cat = Array.isArray(d) ? d[0] : d.x;
|
|
813
|
+
const key = String(cat);
|
|
814
|
+
let row = byCategory.get(key);
|
|
815
|
+
if (!row) {
|
|
816
|
+
row = { cat, values: cols.map((c) => c.head.map(() => "")) };
|
|
817
|
+
byCategory.set(key, row);
|
|
818
|
+
}
|
|
819
|
+
row.values[sI] = cols[sI].cells(i);
|
|
820
|
+
});
|
|
821
|
+
});
|
|
822
|
+
Array.from(byCategory.values()).sort((a, b) => {
|
|
823
|
+
const aText = typeof a.cat === "string";
|
|
824
|
+
const bText = typeof b.cat === "string";
|
|
825
|
+
if (aText !== bText) return aText ? 1 : -1;
|
|
826
|
+
if (!aText) return a.cat - b.cat;
|
|
827
|
+
return w.axisFlags.isXNumeric ? a.cat < b.cat ? -1 : 1 : 0;
|
|
828
|
+
}).forEach(({ cat, values }) => body.push([cat, ...values.flat()]));
|
|
829
|
+
} else {
|
|
830
|
+
const len = Math.max(
|
|
831
|
+
0,
|
|
832
|
+
...series.map((s) => {
|
|
833
|
+
var _a;
|
|
834
|
+
return ((_a = s.data) == null ? void 0 : _a.length) || 0;
|
|
835
|
+
})
|
|
836
|
+
);
|
|
837
|
+
for (let i = 0; i < len; i++) {
|
|
838
|
+
let cat = getCat(i);
|
|
839
|
+
if (cat === null) continue;
|
|
840
|
+
if (!cat) {
|
|
841
|
+
const d = series.map((s) => {
|
|
842
|
+
var _a;
|
|
843
|
+
return (_a = s.data) == null ? void 0 : _a[i];
|
|
844
|
+
}).find((d2) => d2 != null);
|
|
845
|
+
cat = d == null ? "" : Array.isArray(d) ? d[0] : d.x;
|
|
846
|
+
}
|
|
847
|
+
body.push([cat, ...cols.flatMap((c) => c.cells(i))]);
|
|
857
848
|
}
|
|
858
|
-
}
|
|
849
|
+
}
|
|
859
850
|
}
|
|
860
|
-
|
|
851
|
+
const dates = body.map((r) => r[0]).filter(isDateCat);
|
|
852
|
+
const withTime = new Set(dates.map((c) => datetimeText(c))).size < dates.length;
|
|
853
|
+
body.forEach(
|
|
854
|
+
(r) => rows.push(
|
|
855
|
+
[getFormattedCategory(r[0], withTime), ...r.slice(1)].join(
|
|
856
|
+
columnDelimiter
|
|
857
|
+
)
|
|
858
|
+
)
|
|
859
|
+
);
|
|
861
860
|
this.triggerDownload(
|
|
862
|
-
"data:text/csv; charset=utf-8," + encodeURIComponent(
|
|
863
|
-
fileName ? fileName :
|
|
861
|
+
"data:text/csv; charset=utf-8," + encodeURIComponent("\uFEFF" + rows.join(lineDelimiter)),
|
|
862
|
+
fileName ? fileName : csvCfg.filename,
|
|
864
863
|
".csv"
|
|
865
864
|
);
|
|
866
865
|
}
|