billboard.js 4.0.0-next.3 → 4.0.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/billboard.css +1 -1
- package/dist/billboard.js +240 -149
- package/dist/billboard.min.css +1 -1
- package/dist/billboard.min.js +20 -20
- package/dist/billboard.pkgd.js +240 -149
- package/dist/billboard.pkgd.min.js +27 -27
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +11 -13
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +11 -13
- package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-tableview.js +28 -15
- package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +11 -13
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +9 -9
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +11 -13
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +3 -3
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +28 -15
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +6 -6
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +2 -2
- package/dist/theme/dark.css +1 -1
- package/dist/theme/dark.min.css +1 -1
- package/dist/theme/datalab.css +1 -1
- package/dist/theme/datalab.min.css +1 -1
- package/dist/theme/graph.css +1 -1
- package/dist/theme/graph.min.css +1 -1
- package/dist/theme/insight.css +1 -1
- package/dist/theme/insight.min.css +1 -1
- package/dist/theme/modern.css +1 -1
- package/dist/theme/modern.min.css +1 -1
- package/dist-esm/Chart/Chart.js +1 -1
- package/dist-esm/Chart/api/axis.js +1 -1
- package/dist-esm/Chart/api/category.js +1 -1
- package/dist-esm/Chart/api/chart.js +1 -1
- package/dist-esm/Chart/api/color.js +1 -1
- package/dist-esm/Chart/api/data.js +1 -1
- package/dist-esm/Chart/api/export.js +1 -1
- package/dist-esm/Chart/api/flow.js +1 -1
- package/dist-esm/Chart/api/focus.js +1 -1
- package/dist-esm/Chart/api/grid.js +1 -1
- package/dist-esm/Chart/api/group.js +1 -1
- package/dist-esm/Chart/api/legend.js +1 -1
- package/dist-esm/Chart/api/load.js +1 -1
- package/dist-esm/Chart/api/regions.js +1 -1
- package/dist-esm/Chart/api/selection.js +1 -1
- package/dist-esm/Chart/api/show.js +1 -1
- package/dist-esm/Chart/api/stubs.js +53 -0
- package/dist-esm/Chart/api/subchart.js +2 -2
- package/dist-esm/Chart/api/tooltip.js +1 -1
- package/dist-esm/Chart/api/x.js +1 -1
- package/dist-esm/Chart/api/zoom.js +2 -2
- package/dist-esm/ChartInternal/Axis/Axis.js +1 -1
- package/dist-esm/ChartInternal/Axis/AxisRenderer.js +149 -96
- package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +1 -1
- package/dist-esm/ChartInternal/ChartInternal.js +8 -4
- package/dist-esm/ChartInternal/data/convert.helper.js +1 -1
- package/dist-esm/ChartInternal/data/convert.js +1 -1
- package/dist-esm/ChartInternal/data/data.js +1 -1
- package/dist-esm/ChartInternal/data/load.js +1 -1
- package/dist-esm/ChartInternal/interactions/drag.js +1 -1
- package/dist-esm/ChartInternal/interactions/eventrect.js +2 -2
- package/dist-esm/ChartInternal/interactions/flow.js +1 -1
- package/dist-esm/ChartInternal/interactions/interaction.js +1 -1
- package/dist-esm/ChartInternal/interactions/subchart.js +1 -1
- package/dist-esm/ChartInternal/interactions/zoom.js +1 -1
- package/dist-esm/ChartInternal/internals/category.js +1 -1
- package/dist-esm/ChartInternal/internals/class.js +1 -1
- package/dist-esm/ChartInternal/internals/clip.js +1 -1
- package/dist-esm/ChartInternal/internals/color.js +1 -1
- package/dist-esm/ChartInternal/internals/domain.js +1 -1
- package/dist-esm/ChartInternal/internals/format.js +1 -1
- package/dist-esm/ChartInternal/internals/grid.js +1 -1
- package/dist-esm/ChartInternal/internals/legend.js +1 -1
- package/dist-esm/ChartInternal/internals/redraw.js +1 -1
- package/dist-esm/ChartInternal/internals/region.js +1 -1
- package/dist-esm/ChartInternal/internals/scale.js +1 -1
- package/dist-esm/ChartInternal/internals/selection.js +1 -1
- package/dist-esm/ChartInternal/internals/size.axis.js +1 -1
- package/dist-esm/ChartInternal/internals/size.js +1 -1
- package/dist-esm/ChartInternal/internals/style.js +1 -1
- package/dist-esm/ChartInternal/internals/text.arc.js +1 -1
- package/dist-esm/ChartInternal/internals/text.js +1 -1
- package/dist-esm/ChartInternal/internals/text.util.js +1 -1
- package/dist-esm/ChartInternal/internals/title.js +1 -1
- package/dist-esm/ChartInternal/internals/tooltip.js +1 -1
- package/dist-esm/ChartInternal/internals/transform.js +1 -1
- package/dist-esm/ChartInternal/internals/type.js +1 -1
- package/dist-esm/ChartInternal/shape/arc.js +1 -1
- package/dist-esm/ChartInternal/shape/area.js +1 -1
- package/dist-esm/ChartInternal/shape/bar.js +1 -1
- package/dist-esm/ChartInternal/shape/bubble.js +1 -1
- package/dist-esm/ChartInternal/shape/candlestick.js +1 -1
- package/dist-esm/ChartInternal/shape/core/barRadius.js +1 -1
- package/dist-esm/ChartInternal/shape/core/bubble.js +1 -1
- package/dist-esm/ChartInternal/shape/core/candlestick.js +1 -1
- package/dist-esm/ChartInternal/shape/core/dataRegion.js +1 -1
- package/dist-esm/ChartInternal/shape/core/geometry.js +1 -1
- package/dist-esm/ChartInternal/shape/core/path.js +1 -1
- package/dist-esm/ChartInternal/shape/core/point.js +1 -1
- package/dist-esm/ChartInternal/shape/core/treemap.js +1 -1
- package/dist-esm/ChartInternal/shape/funnel.js +1 -1
- package/dist-esm/ChartInternal/shape/gauge.js +1 -1
- package/dist-esm/ChartInternal/shape/line.js +1 -1
- package/dist-esm/ChartInternal/shape/point.js +1 -1
- package/dist-esm/ChartInternal/shape/polar.js +1 -1
- package/dist-esm/ChartInternal/shape/radar.js +1 -1
- package/dist-esm/ChartInternal/shape/shape.js +6 -4
- package/dist-esm/ChartInternal/shape/treemap.js +1 -1
- package/dist-esm/canvas/CanvasAxisRenderer.js +1 -1
- package/dist-esm/canvas/CanvasEngine.js +18 -5
- package/dist-esm/canvas/CanvasPainter.js +1 -1
- package/dist-esm/canvas/CanvasRenderer.js +58 -35
- package/dist-esm/canvas/CanvasTheme.js +1 -1
- package/dist-esm/canvas/HitDetector.js +1 -1
- package/dist-esm/canvas/axisTicks.js +1 -1
- package/dist-esm/canvas/classes.js +1 -1
- package/dist-esm/canvas/color.js +1 -1
- package/dist-esm/canvas/geometry.js +1 -1
- package/dist-esm/canvas/labels.js +1 -1
- package/dist-esm/canvas/pointPattern.js +1 -1
- package/dist-esm/canvas/util.js +1 -1
- package/dist-esm/config/Options/Options.js +1 -1
- package/dist-esm/config/Options/axis/axis.js +1 -1
- package/dist-esm/config/Options/axis/x.js +1 -1
- package/dist-esm/config/Options/axis/y.js +1 -1
- package/dist-esm/config/Options/axis/y2.js +1 -13
- package/dist-esm/config/Options/common/boost.js +1 -1
- package/dist-esm/config/Options/common/color.js +1 -1
- package/dist-esm/config/Options/common/grid.js +1 -1
- package/dist-esm/config/Options/common/legend.js +1 -1
- package/dist-esm/config/Options/common/main.js +1 -1
- package/dist-esm/config/Options/common/point.js +1 -1
- package/dist-esm/config/Options/common/title.js +1 -1
- package/dist-esm/config/Options/common/tooltip.js +1 -1
- package/dist-esm/config/Options/data/axis.js +1 -1
- package/dist-esm/config/Options/data/data.js +1 -1
- package/dist-esm/config/Options/data/selection.js +1 -1
- package/dist-esm/config/Options/interaction/interaction.js +1 -1
- package/dist-esm/config/Options/interaction/subchart.js +1 -1
- package/dist-esm/config/Options/interaction/zoom.js +1 -1
- package/dist-esm/config/Options/shape/arc.js +1 -1
- package/dist-esm/config/Options/shape/area.js +1 -1
- package/dist-esm/config/Options/shape/bar.js +1 -1
- package/dist-esm/config/Options/shape/bubble.js +1 -1
- package/dist-esm/config/Options/shape/candlestick.js +1 -1
- package/dist-esm/config/Options/shape/donut.js +1 -1
- package/dist-esm/config/Options/shape/funnel.js +1 -1
- package/dist-esm/config/Options/shape/gauge.js +1 -1
- package/dist-esm/config/Options/shape/line.js +1 -1
- package/dist-esm/config/Options/shape/pie.js +1 -1
- package/dist-esm/config/Options/shape/polar.js +1 -1
- package/dist-esm/config/Options/shape/radar.js +1 -1
- package/dist-esm/config/Options/shape/scatter.js +1 -1
- package/dist-esm/config/Options/shape/spline.js +1 -1
- package/dist-esm/config/Options/shape/treemap.js +1 -1
- package/dist-esm/config/Store/Element.js +1 -1
- package/dist-esm/config/Store/State.js +1 -1
- package/dist-esm/config/Store/Store.js +1 -1
- package/dist-esm/config/classes.js +1 -1
- package/dist-esm/config/config.js +1 -1
- package/dist-esm/config/const.js +17 -2
- package/dist-esm/config/resolver/axis.core.js +1 -1
- package/dist-esm/config/resolver/axis.js +1 -1
- package/dist-esm/config/resolver/canvas.js +1 -1
- package/dist-esm/config/resolver/canvasShape.js +1 -1
- package/dist-esm/config/resolver/category.js +1 -1
- package/dist-esm/config/resolver/export.js +1 -1
- package/dist-esm/config/resolver/flow.js +1 -1
- package/dist-esm/config/resolver/grid.js +1 -1
- package/dist-esm/config/resolver/interaction/selection.js +1 -1
- package/dist-esm/config/resolver/interaction/subchart.js +1 -1
- package/dist-esm/config/resolver/interaction/zoom.js +1 -1
- package/dist-esm/config/resolver/regions.js +1 -1
- package/dist-esm/config/resolver/shape/arc.helpers.js +1 -1
- package/dist-esm/config/resolver/shape/area.js +1 -1
- package/dist-esm/config/resolver/shape/axis.helpers.js +1 -1
- package/dist-esm/config/resolver/shape/bar.js +1 -1
- package/dist-esm/config/resolver/shape/bubble.js +1 -1
- package/dist-esm/config/resolver/shape/candlestick.js +1 -1
- package/dist-esm/config/resolver/shape/donut.js +1 -1
- package/dist-esm/config/resolver/shape/funnel.js +1 -1
- package/dist-esm/config/resolver/shape/gauge.js +1 -1
- package/dist-esm/config/resolver/shape/line.js +1 -1
- package/dist-esm/config/resolver/shape/pie.js +1 -1
- package/dist-esm/config/resolver/shape/polar.js +1 -1
- package/dist-esm/config/resolver/shape/radar.js +1 -1
- package/dist-esm/config/resolver/shape/scatter.js +1 -1
- package/dist-esm/config/resolver/shape/treemap.js +1 -1
- package/dist-esm/core.js +3 -3
- package/dist-esm/index.canvas.js +2 -1
- package/dist-esm/index.esm.js +2 -1
- package/dist-esm/module/Cache.js +1 -1
- package/dist-esm/module/browser.js +1 -1
- package/dist-esm/module/dsv.js +1 -1
- package/dist-esm/module/error.js +16 -3
- package/dist-esm/module/generator.js +1 -1
- package/dist-esm/module/sanitize.js +14 -18
- package/dist-esm/module/util/brush.js +1 -1
- package/dist-esm/module/util/dom.js +1 -1
- package/dist-esm/module/util/object.js +7 -4
- package/dist-esm/module/util/type-checks.js +1 -1
- package/dist-esm/module/worker.js +32 -22
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +2 -2
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +32 -21
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/package.json +37 -11
- package/src/ChartInternal/Axis/AxisRenderer.ts +179 -105
- package/src/ChartInternal/ChartInternal.ts +11 -3
- package/src/ChartInternal/interactions/eventrect.ts +3 -1
- package/src/ChartInternal/shape/shape.ts +5 -3
- package/src/Plugin/tableview/Options.ts +17 -1
- package/src/Plugin/tableview/index.ts +1 -1
- package/src/canvas/CanvasEngine.ts +18 -5
- package/src/canvas/CanvasRenderer.ts +71 -36
- package/src/config/Options/axis/y2.ts +0 -13
- package/src/module/sanitize.ts +13 -20
- package/src/module/util/object.ts +4 -2
- package/src/module/worker.ts +34 -24
- package/types/index.d.ts +0 -3
- package/types/plugin/tableview/options.d.ts +5 -0
|
@@ -188,6 +188,22 @@ function drawCanvasArea($$, target, indices, painter: CanvasPainter, isSub = fal
|
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
190
|
|
|
191
|
+
/**
|
|
192
|
+
* Get a target copy clipped to the current visible x range.
|
|
193
|
+
* @param {object} $$ ChartInternal instance
|
|
194
|
+
* @param {object} target Data target
|
|
195
|
+
* @returns {object} Original target or a visible values copy
|
|
196
|
+
* @private
|
|
197
|
+
*/
|
|
198
|
+
function getVisibleCanvasTarget($$, target) {
|
|
199
|
+
const range = getCanvasTargetVisibleRange($$, target);
|
|
200
|
+
|
|
201
|
+
return range.start === 0 && range.end === target.values.length ? target : {
|
|
202
|
+
...target,
|
|
203
|
+
values: target.values.slice(range.start, range.end)
|
|
204
|
+
};
|
|
205
|
+
}
|
|
206
|
+
|
|
191
207
|
/**
|
|
192
208
|
* Get focused row for a datum or target.
|
|
193
209
|
* @param {Array} focusData Focused data rows
|
|
@@ -1657,8 +1673,7 @@ export default class CanvasRenderer {
|
|
|
1657
1673
|
d &&
|
|
1658
1674
|
(
|
|
1659
1675
|
isCanvasBarType($$, d) ||
|
|
1660
|
-
isCanvasCandlestickType($$, d)
|
|
1661
|
-
(isCanvasPointType($$, d) && getPointOpacity($$, d) < 1)
|
|
1676
|
+
isCanvasCandlestickType($$, d)
|
|
1662
1677
|
)
|
|
1663
1678
|
);
|
|
1664
1679
|
}
|
|
@@ -1684,7 +1699,9 @@ export default class CanvasRenderer {
|
|
|
1684
1699
|
|
|
1685
1700
|
painter.withTranslation(margin.left, margin.top, () => {
|
|
1686
1701
|
for (const target of targets) {
|
|
1687
|
-
|
|
1702
|
+
const visibleTarget = getVisibleCanvasTarget($$, target);
|
|
1703
|
+
|
|
1704
|
+
if (!visibleTarget.values.some(hasCanvasDrawableValue.bind(null, $$))) {
|
|
1688
1705
|
continue;
|
|
1689
1706
|
}
|
|
1690
1707
|
|
|
@@ -1693,9 +1710,9 @@ export default class CanvasRenderer {
|
|
|
1693
1710
|
style.shape.lineFocusedWidth :
|
|
1694
1711
|
style.shape.lineWidth;
|
|
1695
1712
|
ctx.strokeStyle = $$.color(target.id);
|
|
1696
|
-
$$.config.data_regions?.[
|
|
1697
|
-
drawCanvasLineWithDataRegions($$,
|
|
1698
|
-
drawCanvasLine($$,
|
|
1713
|
+
$$.config.data_regions?.[visibleTarget.id] ?
|
|
1714
|
+
drawCanvasLineWithDataRegions($$, visibleTarget, painter) :
|
|
1715
|
+
drawCanvasLine($$, visibleTarget, indices, painter);
|
|
1699
1716
|
}
|
|
1700
1717
|
ctx.globalAlpha = 1;
|
|
1701
1718
|
});
|
|
@@ -1723,23 +1740,26 @@ export default class CanvasRenderer {
|
|
|
1723
1740
|
|
|
1724
1741
|
painter.withTranslation(margin.left, margin.top, () => {
|
|
1725
1742
|
for (const target of targets) {
|
|
1726
|
-
|
|
1743
|
+
const visibleTarget = getVisibleCanvasTarget($$, target);
|
|
1744
|
+
|
|
1745
|
+
if (!visibleTarget.values.some(hasCanvasDrawableValue.bind(null, $$))) {
|
|
1727
1746
|
continue;
|
|
1728
1747
|
}
|
|
1729
1748
|
|
|
1730
|
-
const color = getCanvasRenderColor($$,
|
|
1749
|
+
const color = getCanvasRenderColor($$, visibleTarget, focusData);
|
|
1731
1750
|
|
|
1732
1751
|
ctx.globalAlpha = style.shape.areaOpacity * getCanvasTargetFocusOpacity($$, target);
|
|
1733
1752
|
ctx.fillStyle = getCanvasLinearGradientFill(
|
|
1734
1753
|
$$,
|
|
1735
1754
|
ctx,
|
|
1736
|
-
|
|
1755
|
+
visibleTarget,
|
|
1737
1756
|
"area",
|
|
1738
|
-
//
|
|
1757
|
+
// Bounds computation walks visible rows, so skip it when no gradient is set.
|
|
1758
|
+
// Use the original target so the range cache stays aligned with unsliced values.
|
|
1739
1759
|
$$.config.area_linearGradient ? getCanvasAreaBounds($$, target, indices) : null,
|
|
1740
1760
|
color
|
|
1741
1761
|
);
|
|
1742
|
-
drawCanvasArea($$,
|
|
1762
|
+
drawCanvasArea($$, visibleTarget, indices, painter);
|
|
1743
1763
|
}
|
|
1744
1764
|
ctx.globalAlpha = 1;
|
|
1745
1765
|
});
|
|
@@ -2073,14 +2093,13 @@ export default class CanvasRenderer {
|
|
|
2073
2093
|
) &&
|
|
2074
2094
|
isCanvasRenderableTarget($$, target)
|
|
2075
2095
|
);
|
|
2076
|
-
|
|
2077
|
-
const targetRows: Array<{d, i: number, text: string}[]> = [];
|
|
2096
|
+
const targetRows: Array<{d, text: string}[]> = [];
|
|
2078
2097
|
let labelCount = 0;
|
|
2079
2098
|
|
|
2080
2099
|
targets.forEach(target => {
|
|
2081
2100
|
const range = getCanvasTargetVisibleRange($$, target);
|
|
2082
2101
|
const data = $$.labelishData(target);
|
|
2083
|
-
const rows: {d,
|
|
2102
|
+
const rows: {d, text: string}[] = [];
|
|
2084
2103
|
|
|
2085
2104
|
for (let i = 0; i < data.length; i++) {
|
|
2086
2105
|
const d = data[i];
|
|
@@ -2092,7 +2111,7 @@ export default class CanvasRenderer {
|
|
|
2092
2111
|
d.index < range.end &&
|
|
2093
2112
|
hasCanvasDrawableValue($$, d)
|
|
2094
2113
|
) {
|
|
2095
|
-
rows.push({d,
|
|
2114
|
+
rows.push({d, text});
|
|
2096
2115
|
}
|
|
2097
2116
|
}
|
|
2098
2117
|
|
|
@@ -2110,12 +2129,12 @@ export default class CanvasRenderer {
|
|
|
2110
2129
|
|
|
2111
2130
|
targetRows
|
|
2112
2131
|
.forEach(rows => {
|
|
2113
|
-
for (const {d,
|
|
2132
|
+
for (const {d, text} of rows) {
|
|
2114
2133
|
let x;
|
|
2115
2134
|
let y;
|
|
2116
2135
|
|
|
2117
2136
|
if (isCanvasBarType($$, d) && barPoints) {
|
|
2118
|
-
const geometry = getCanvasBarGeometry($$, barPoints, d,
|
|
2137
|
+
const geometry = getCanvasBarGeometry($$, barPoints, d, d.index);
|
|
2119
2138
|
|
|
2120
2139
|
if (!geometry) {
|
|
2121
2140
|
continue;
|
|
@@ -2148,7 +2167,7 @@ export default class CanvasRenderer {
|
|
|
2148
2167
|
$$,
|
|
2149
2168
|
candlestickPoints,
|
|
2150
2169
|
d,
|
|
2151
|
-
|
|
2170
|
+
d.index
|
|
2152
2171
|
);
|
|
2153
2172
|
const isUp = value?._isUp;
|
|
2154
2173
|
|
|
@@ -2156,22 +2175,23 @@ export default class CanvasRenderer {
|
|
|
2156
2175
|
continue;
|
|
2157
2176
|
}
|
|
2158
2177
|
|
|
2159
|
-
const {
|
|
2178
|
+
const {wickEnd, wickStart} = geometry;
|
|
2179
|
+
const isInverted = $$.config[`axis_${$$.axis?.getId(d.id)}_inverted`];
|
|
2160
2180
|
|
|
2161
2181
|
x = $$.config.axis_rotated ?
|
|
2162
|
-
(isUp ?
|
|
2163
|
-
|
|
2182
|
+
(isUp ? wickEnd[0] + 4 : wickStart[0] - 4) :
|
|
2183
|
+
wickStart[0];
|
|
2164
2184
|
y = $$.config.axis_rotated ?
|
|
2165
|
-
|
|
2166
|
-
(isUp ?
|
|
2185
|
+
wickStart[1] + 3 :
|
|
2186
|
+
(isUp ? wickEnd[1] - 3 : wickStart[1] + 12);
|
|
2187
|
+
!$$.config.axis_rotated && isInverted &&
|
|
2188
|
+
(y += 15 * (isUp ? 1 : -1));
|
|
2167
2189
|
ctx.textAlign = $$.config.axis_rotated ?
|
|
2168
2190
|
(isUp ? "left" : "right") :
|
|
2169
2191
|
"center";
|
|
2170
|
-
ctx.textBaseline =
|
|
2171
|
-
"middle" :
|
|
2172
|
-
(isUp ? "bottom" : "top");
|
|
2192
|
+
ctx.textBaseline = "alphabetic";
|
|
2173
2193
|
} else if (cx && cy) {
|
|
2174
|
-
({x, y} = getShapePoint(shape.pos, d,
|
|
2194
|
+
({x, y} = getShapePoint(shape.pos, d, d.index));
|
|
2175
2195
|
({x, y} = getPointLabelAnchor($$, ctx, d, x, y));
|
|
2176
2196
|
}
|
|
2177
2197
|
|
|
@@ -2472,20 +2492,35 @@ export default class CanvasRenderer {
|
|
|
2472
2492
|
const r = $$.pointExpandedR?.(d) ?? (baseR * 1.75);
|
|
2473
2493
|
const overColor = getCanvasOverColor($$, d);
|
|
2474
2494
|
const color = overColor || $$.color(d.id);
|
|
2495
|
+
const fill = overColor ||
|
|
2496
|
+
style.focusPoint.fill ||
|
|
2497
|
+
style.shape.pointFillColor ||
|
|
2498
|
+
color;
|
|
2499
|
+
const stroke = overColor || style.focusPoint.stroke || color;
|
|
2500
|
+
const lineWidth = style.focusPoint.lineWidth;
|
|
2501
|
+
const alpha = getPointOpacity($$, d);
|
|
2502
|
+
const hasStroke = !!stroke && (lineWidth ?? 0) > 0;
|
|
2503
|
+
const mergeSameColorStroke = pointType === "circle" &&
|
|
2504
|
+
hasStroke &&
|
|
2505
|
+
isNumber(alpha) &&
|
|
2506
|
+
alpha < 1 &&
|
|
2507
|
+
fill === stroke;
|
|
2475
2508
|
|
|
2476
2509
|
if (!isFiniteCanvasCoordinate(x, y)) {
|
|
2477
2510
|
return;
|
|
2478
2511
|
}
|
|
2479
2512
|
|
|
2480
|
-
drawPointPattern(
|
|
2481
|
-
|
|
2482
|
-
|
|
2483
|
-
|
|
2484
|
-
|
|
2485
|
-
lineWidth:
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
|
|
2513
|
+
drawPointPattern(
|
|
2514
|
+
painter,
|
|
2515
|
+
pointType,
|
|
2516
|
+
x,
|
|
2517
|
+
y,
|
|
2518
|
+
mergeSameColorStroke ? r + (lineWidth || 0) / 2 : r,
|
|
2519
|
+
hasStroke && !mergeSameColorStroke ?
|
|
2520
|
+
{fill, lineWidth, stroke, alpha} :
|
|
2521
|
+
{fill, alpha},
|
|
2522
|
+
baseR
|
|
2523
|
+
);
|
|
2489
2524
|
});
|
|
2490
2525
|
}
|
|
2491
2526
|
|
|
@@ -6,19 +6,6 @@
|
|
|
6
6
|
* y2 Axis config options
|
|
7
7
|
*/
|
|
8
8
|
export default {
|
|
9
|
-
/**
|
|
10
|
-
* Set clip-path attribute for y2 axis element
|
|
11
|
-
* - **NOTE**: `clip-path` attribute for y2 Axis is set only when `axis.y2.inner` option is true.
|
|
12
|
-
* @name axis․y2․clipPath
|
|
13
|
-
* @memberof Options
|
|
14
|
-
* @type {boolean}
|
|
15
|
-
* @default true
|
|
16
|
-
* @example
|
|
17
|
-
* // don't set 'clip-path' attribute
|
|
18
|
-
* clipPath: false
|
|
19
|
-
*/
|
|
20
|
-
axis_y2_clipPath: true,
|
|
21
|
-
|
|
22
9
|
/**
|
|
23
10
|
* Show or hide y2 axis.
|
|
24
11
|
* - **NOTE**:
|
package/src/module/sanitize.ts
CHANGED
|
@@ -214,10 +214,10 @@ function decodeHTMLEntities(str: string): string {
|
|
|
214
214
|
.replace(/&/gi, "&")
|
|
215
215
|
.replace(/"/gi, "\"")
|
|
216
216
|
.replace(/'/gi, "'")
|
|
217
|
-
// Numeric entities (decimal)
|
|
218
|
-
.replace(/&#(\d+)
|
|
219
|
-
// Numeric entities (hex)
|
|
220
|
-
.replace(/&#x([0-9a-f]+)
|
|
217
|
+
// Numeric entities (decimal) - trailing semicolon is optional per HTML5 tokenizer
|
|
218
|
+
.replace(/&#(\d+);?/gi, (_, code) => String.fromCharCode(parseInt(code, 10)))
|
|
219
|
+
// Numeric entities (hex) - trailing semicolon is optional per HTML5 tokenizer
|
|
220
|
+
.replace(/&#x([0-9a-f]+);?/gi, (_, code) => String.fromCharCode(parseInt(code, 16)));
|
|
221
221
|
}
|
|
222
222
|
|
|
223
223
|
/**
|
|
@@ -239,24 +239,17 @@ function isSafeURI(uri: string): boolean {
|
|
|
239
239
|
return true;
|
|
240
240
|
}
|
|
241
241
|
|
|
242
|
-
//
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
return true;
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
// Check if protocol is in whitelist
|
|
253
|
-
const colonIndex = normalized.indexOf(":");
|
|
254
|
-
if (colonIndex > 0) {
|
|
255
|
-
const protocol = normalized.substring(0, colonIndex + 1);
|
|
256
|
-
return ALLOWED_URI_PROTOCOLS.has(protocol);
|
|
242
|
+
// A ':' appearing before the first '/', '?' or '#' denotes a URI scheme.
|
|
243
|
+
// Reject the value unless that scheme is whitelisted - do NOT infer safety
|
|
244
|
+
// merely from the absence of a literal colon (which could be reconstructed
|
|
245
|
+
// from an alternate encoding once assigned to innerHTML).
|
|
246
|
+
const schemeMatch = normalized.match(/^[^/?#]*:/);
|
|
247
|
+
if (schemeMatch) {
|
|
248
|
+
return ALLOWED_URI_PROTOCOLS.has(schemeMatch[0]);
|
|
257
249
|
}
|
|
258
250
|
|
|
259
|
-
|
|
251
|
+
// No scheme → relative path / query / fragment only → safe
|
|
252
|
+
return true;
|
|
260
253
|
}
|
|
261
254
|
|
|
262
255
|
/**
|
|
@@ -25,7 +25,7 @@ function _forEachValidItem<T>(items: T[], callback: (item: T, index: number) =>
|
|
|
25
25
|
for (let i = 0; i < items.length; i++) {
|
|
26
26
|
const item = items[i];
|
|
27
27
|
|
|
28
|
-
if (item) {
|
|
28
|
+
if (item !== null && isDefined(item)) {
|
|
29
29
|
callback(item, i);
|
|
30
30
|
}
|
|
31
31
|
}
|
|
@@ -224,7 +224,9 @@ function mergeObj(target: object, ...objectN): any {
|
|
|
224
224
|
if (!/^(__proto__|constructor|prototype)$/i.test(key)) {
|
|
225
225
|
const value = source[key];
|
|
226
226
|
|
|
227
|
-
if (
|
|
227
|
+
if (value instanceof Date) {
|
|
228
|
+
target[key] = new Date(value.getTime());
|
|
229
|
+
} else if (isObject(value)) {
|
|
228
230
|
!target[key] && (target[key] = {});
|
|
229
231
|
target[key] = mergeObj(target[key], value);
|
|
230
232
|
} else {
|
package/src/module/worker.ts
CHANGED
|
@@ -17,29 +17,35 @@ let messageId = 0;
|
|
|
17
17
|
* @returns {{key: string, src: string}} Cache key and Object URL
|
|
18
18
|
* @private
|
|
19
19
|
*/
|
|
20
|
-
function getOrCreateWorkerResources(fn: Function, depsFn?: Function[]):
|
|
20
|
+
function getOrCreateWorkerResources(fn: Function, depsFn?: Function[]):
|
|
21
|
+
| {key: string, src: string}
|
|
22
|
+
| null {
|
|
21
23
|
const fnString = fn.toString();
|
|
22
24
|
// Include depsFn in cache key to handle different dependencies
|
|
23
25
|
const depsString = depsFn?.map(String).join(";") ?? "";
|
|
24
26
|
const key = (fnString + depsString).replace(/(function|[\s\W\n])/g, "").substring(0, 30);
|
|
25
27
|
|
|
26
28
|
if (!(key in cache)) {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
29
|
+
try {
|
|
30
|
+
// Create Blob and Object URL for Web Worker
|
|
31
|
+
const blob = new window.Blob([
|
|
32
|
+
`${depsString}
|
|
33
|
+
|
|
34
|
+
self.onmessage=function({data}) {
|
|
35
|
+
const result = (${fnString}).apply(null, data.args);
|
|
36
|
+
self.postMessage({id: data.id, result});
|
|
37
|
+
};`
|
|
38
|
+
], {
|
|
39
|
+
type: "text/javascript"
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
cache[key] = {
|
|
43
|
+
src: window.URL.createObjectURL(blob),
|
|
44
|
+
worker: null
|
|
45
|
+
};
|
|
46
|
+
} catch {
|
|
47
|
+
return null;
|
|
48
|
+
}
|
|
43
49
|
}
|
|
44
50
|
|
|
45
51
|
return {key, src: cache[key].src};
|
|
@@ -61,7 +67,11 @@ export function getWorker(key: string, src: string): Worker | null {
|
|
|
61
67
|
}
|
|
62
68
|
|
|
63
69
|
if (!cached.worker) {
|
|
64
|
-
|
|
70
|
+
try {
|
|
71
|
+
cached.worker = new window.Worker(src);
|
|
72
|
+
} catch {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
65
75
|
|
|
66
76
|
// handle error
|
|
67
77
|
if (cached.worker) {
|
|
@@ -111,11 +121,11 @@ export function runWorker(
|
|
|
111
121
|
};
|
|
112
122
|
|
|
113
123
|
if (window.Worker && useWorker) {
|
|
114
|
-
const
|
|
115
|
-
const worker = getWorker(key, src);
|
|
124
|
+
const workerResources = getOrCreateWorkerResources(fn, depsFn);
|
|
125
|
+
const worker = workerResources && getWorker(workerResources.key, workerResources.src);
|
|
116
126
|
|
|
117
|
-
|
|
118
|
-
|
|
127
|
+
if (worker) {
|
|
128
|
+
runFn = function(...args: unknown[]) {
|
|
119
129
|
// workers are cached and shared: match the response by id so concurrent
|
|
120
130
|
// callers don't steal each other's result
|
|
121
131
|
const id = ++messageId;
|
|
@@ -129,8 +139,8 @@ export function runWorker(
|
|
|
129
139
|
|
|
130
140
|
worker.addEventListener("message", handler);
|
|
131
141
|
worker.postMessage({id, args});
|
|
132
|
-
}
|
|
133
|
-
}
|
|
142
|
+
};
|
|
143
|
+
}
|
|
134
144
|
}
|
|
135
145
|
|
|
136
146
|
return runFn;
|
package/types/index.d.ts
CHANGED