billboard.js 4.1.5 → 4.2.0-next.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/billboard.css +87 -1
- package/dist/billboard.js +11000 -6970
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +19 -19
- package/dist/billboard.pkgd.js +22584 -14102
- package/dist/billboard.pkgd.min.js +37 -37
- package/dist/billboard.react.js +5 -5
- package/dist/billboard.react.min.js +2 -2
- package/dist/billboard.worker.js +1 -1
- 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 +21 -4
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +22 -13
- package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-tableview.js +20 -3
- 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 +1689 -1252
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -8
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2288 -1012
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +6350 -2390
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -18
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1310 -1006
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +10 -10
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +1293 -1006
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +8 -8
- package/dist/theme/dark.css +90 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +87 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +87 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +87 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +87 -1
- package/dist/theme/modern.min.css +2 -2
- package/dist-esm/Chart/Chart.js +5 -5
- package/dist-esm/Chart/api/axis.js +2 -3
- package/dist-esm/Chart/api/category.js +2 -3
- package/dist-esm/Chart/api/chart.js +2 -3
- package/dist-esm/Chart/api/color.js +2 -3
- package/dist-esm/Chart/api/data.js +3 -4
- package/dist-esm/Chart/api/export.js +3 -4
- package/dist-esm/Chart/api/flow.js +3 -4
- package/dist-esm/Chart/api/focus.js +5 -3
- package/dist-esm/Chart/api/grid.js +2 -3
- package/dist-esm/Chart/api/group.js +2 -3
- package/dist-esm/Chart/api/legend.js +1 -2
- package/dist-esm/Chart/api/load.js +3 -4
- package/dist-esm/Chart/api/regions.js +3 -4
- package/dist-esm/Chart/api/selection.js +3 -4
- package/dist-esm/Chart/api/show.js +2 -3
- package/dist-esm/Chart/api/stubs.js +3 -4
- package/dist-esm/Chart/api/subchart.js +4 -5
- package/dist-esm/Chart/api/tooltip.js +28 -9
- package/dist-esm/Chart/api/x.js +2 -3
- package/dist-esm/Chart/api/zoom.js +6 -7
- package/dist-esm/ChartInternal/Axis/Axis.js +5 -6
- package/dist-esm/ChartInternal/Axis/AxisRenderer.js +9 -7
- package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +39 -11
- package/dist-esm/ChartInternal/ChartInternal.js +39 -24
- package/dist-esm/ChartInternal/data/convert.helper.js +2 -3
- package/dist-esm/ChartInternal/data/convert.js +3 -4
- package/dist-esm/ChartInternal/data/data.js +18 -11
- package/dist-esm/ChartInternal/data/load.js +4 -5
- package/dist-esm/ChartInternal/interactions/drag.js +3 -4
- package/dist-esm/ChartInternal/interactions/eventrect.js +4 -5
- package/dist-esm/ChartInternal/interactions/flow.js +3 -4
- package/dist-esm/ChartInternal/interactions/interaction.js +14 -13
- package/dist-esm/ChartInternal/interactions/subchart.js +5 -6
- package/dist-esm/ChartInternal/interactions/zoom.js +4 -5
- package/dist-esm/ChartInternal/internals/category.js +2 -3
- package/dist-esm/ChartInternal/internals/class.js +5 -5
- package/dist-esm/ChartInternal/internals/clip.js +2 -3
- package/dist-esm/ChartInternal/internals/color.js +4 -5
- package/dist-esm/ChartInternal/internals/domain.js +7 -7
- package/dist-esm/ChartInternal/internals/format.js +3 -4
- package/dist-esm/ChartInternal/internals/grid.js +4 -5
- package/dist-esm/ChartInternal/internals/legend.js +7 -7
- package/dist-esm/ChartInternal/internals/redraw.js +8 -8
- package/dist-esm/ChartInternal/internals/region.js +4 -5
- package/dist-esm/ChartInternal/internals/scale.js +2 -3
- package/dist-esm/ChartInternal/internals/selection.js +3 -4
- package/dist-esm/ChartInternal/internals/size.axis.js +2 -3
- package/dist-esm/ChartInternal/internals/size.js +8 -9
- package/dist-esm/ChartInternal/internals/style.js +4 -5
- package/dist-esm/ChartInternal/internals/subchart.util.js +2 -3
- package/dist-esm/ChartInternal/internals/text.arc.js +3 -4
- package/dist-esm/ChartInternal/internals/text.js +22 -23
- package/dist-esm/ChartInternal/internals/text.util.js +4 -5
- package/dist-esm/ChartInternal/internals/title.js +4 -5
- package/dist-esm/ChartInternal/internals/tooltip.js +20 -20
- package/dist-esm/ChartInternal/internals/transform.js +5 -6
- package/dist-esm/ChartInternal/internals/type.js +78 -11
- package/dist-esm/ChartInternal/shape/arc.js +5 -6
- package/dist-esm/ChartInternal/shape/area.js +4 -5
- package/dist-esm/ChartInternal/shape/bar.js +5 -6
- package/dist-esm/ChartInternal/shape/boxplot.js +111 -0
- package/dist-esm/ChartInternal/shape/bubble.js +2 -3
- package/dist-esm/ChartInternal/shape/bullet.js +213 -0
- package/dist-esm/ChartInternal/shape/candlestick.js +5 -6
- package/dist-esm/ChartInternal/shape/core/barRadius.js +2 -3
- package/dist-esm/ChartInternal/shape/core/boxplot.js +192 -0
- package/dist-esm/ChartInternal/shape/core/bubble.js +4 -5
- package/dist-esm/ChartInternal/shape/core/bullet.js +528 -0
- package/dist-esm/ChartInternal/shape/core/candlestick.js +2 -3
- package/dist-esm/ChartInternal/shape/core/dataRegion.js +2 -3
- package/dist-esm/ChartInternal/shape/core/geometry.js +2 -3
- package/dist-esm/ChartInternal/shape/core/heatmap.js +453 -0
- package/dist-esm/ChartInternal/shape/core/path.js +2 -3
- package/dist-esm/ChartInternal/shape/core/point.js +2 -3
- package/dist-esm/ChartInternal/shape/core/sankey.js +576 -0
- package/dist-esm/ChartInternal/shape/core/treemap.js +2 -3
- package/dist-esm/ChartInternal/shape/funnel.js +45 -6
- package/dist-esm/ChartInternal/shape/gauge.js +3 -4
- package/dist-esm/ChartInternal/shape/heatmap.js +144 -0
- package/dist-esm/ChartInternal/shape/line.js +7 -8
- package/dist-esm/ChartInternal/shape/point.js +5 -6
- package/dist-esm/ChartInternal/shape/polar.js +3 -4
- package/dist-esm/ChartInternal/shape/radar.js +19 -7
- package/dist-esm/ChartInternal/shape/sankey.js +154 -0
- package/dist-esm/ChartInternal/shape/shape.js +7 -7
- package/dist-esm/ChartInternal/shape/treemap.js +8 -5
- package/dist-esm/canvas/CanvasAxisRenderer.js +12 -315
- package/dist-esm/canvas/CanvasEngine.js +2 -3
- package/dist-esm/canvas/CanvasPainter.js +2 -3
- package/dist-esm/canvas/CanvasRenderer.js +38 -408
- package/dist-esm/canvas/CanvasTheme.js +28 -8
- package/dist-esm/canvas/HitDetector.js +20 -24
- package/dist-esm/canvas/axisTicks.js +5 -6
- package/dist-esm/canvas/boxplot.js +201 -0
- package/dist-esm/canvas/bullet.js +212 -0
- package/dist-esm/canvas/classes.js +2 -3
- package/dist-esm/canvas/color.js +2 -3
- package/dist-esm/canvas/flow.js +190 -0
- package/dist-esm/canvas/geometry.js +2 -3
- package/dist-esm/canvas/grid.js +206 -0
- package/dist-esm/canvas/heatmap.js +141 -0
- package/dist-esm/canvas/labels.js +3 -4
- package/dist-esm/canvas/pointPattern.js +2 -3
- package/dist-esm/canvas/sankey.js +137 -0
- package/dist-esm/canvas/selection.js +473 -0
- package/dist-esm/canvas/subchart.js +814 -0
- package/dist-esm/canvas/treemap.js +100 -0
- package/dist-esm/canvas/util.js +2 -3
- package/dist-esm/config/Options/Options.js +3 -4
- package/dist-esm/config/Options/axis/axis.js +2 -3
- package/dist-esm/config/Options/axis/x.js +2 -3
- package/dist-esm/config/Options/axis/y.js +2 -3
- package/dist-esm/config/Options/axis/y2.js +14 -3
- package/dist-esm/config/Options/common/boost.js +2 -3
- package/dist-esm/config/Options/common/color.js +2 -3
- package/dist-esm/config/Options/common/grid.js +2 -3
- package/dist-esm/config/Options/common/legend.js +2 -3
- package/dist-esm/config/Options/common/main.js +2 -3
- package/dist-esm/config/Options/common/point.js +2 -3
- package/dist-esm/config/Options/common/title.js +2 -3
- package/dist-esm/config/Options/common/tooltip.js +2 -3
- package/dist-esm/config/Options/data/axis.js +2 -3
- package/dist-esm/config/Options/data/data.js +49 -4
- package/dist-esm/config/Options/data/selection.js +2 -3
- package/dist-esm/config/Options/interaction/interaction.js +2 -3
- package/dist-esm/config/Options/interaction/subchart.js +2 -3
- package/dist-esm/config/Options/interaction/zoom.js +2 -3
- package/dist-esm/config/Options/shape/arc.js +2 -3
- package/dist-esm/config/Options/shape/area.js +2 -3
- package/dist-esm/config/Options/shape/bar.js +2 -3
- package/dist-esm/config/Options/shape/boxplot.js +106 -0
- package/dist-esm/config/Options/shape/bubble.js +2 -3
- package/dist-esm/config/Options/shape/bullet.js +177 -0
- package/dist-esm/config/Options/shape/candlestick.js +2 -3
- package/dist-esm/config/Options/shape/donut.js +2 -3
- package/dist-esm/config/Options/shape/funnel.js +2 -3
- package/dist-esm/config/Options/shape/gauge.js +2 -3
- package/dist-esm/config/Options/shape/heatmap.js +137 -0
- package/dist-esm/config/Options/shape/line.js +2 -3
- package/dist-esm/config/Options/shape/pie.js +2 -3
- package/dist-esm/config/Options/shape/polar.js +2 -3
- package/dist-esm/config/Options/shape/radar.js +2 -3
- package/dist-esm/config/Options/shape/sankey.js +116 -0
- package/dist-esm/config/Options/shape/scatter.js +2 -3
- package/dist-esm/config/Options/shape/spline.js +2 -3
- package/dist-esm/config/Options/shape/treemap.js +2 -3
- package/dist-esm/config/Store/Element.js +2 -3
- package/dist-esm/config/Store/State.js +3 -4
- package/dist-esm/config/Store/Store.js +2 -3
- package/dist-esm/config/classes.js +2 -4
- package/dist-esm/config/config.js +2 -3
- package/dist-esm/config/const.js +31 -23
- package/dist-esm/config/resolver/axis.core.js +4 -5
- package/dist-esm/config/resolver/axis.js +2 -3
- package/dist-esm/config/resolver/canvas.js +112 -911
- package/dist-esm/config/resolver/canvasBoxplot.js +49 -0
- package/dist-esm/config/resolver/canvasBullet.js +29 -0
- package/dist-esm/config/resolver/canvasFlow.js +28 -0
- package/dist-esm/config/resolver/canvasGrid.js +27 -0
- package/dist-esm/config/resolver/canvasHeatmap.js +31 -0
- package/dist-esm/config/resolver/canvasSankey.js +31 -0
- package/dist-esm/config/resolver/canvasSelection.js +30 -0
- package/dist-esm/config/resolver/canvasShape.js +13 -12
- package/dist-esm/config/resolver/canvasSubchart.js +30 -0
- package/dist-esm/config/resolver/canvasType.js +48 -0
- package/dist-esm/config/resolver/category.js +3 -4
- package/dist-esm/config/resolver/customType.js +58 -0
- package/dist-esm/config/resolver/export.js +3 -4
- package/dist-esm/config/resolver/flow.js +5 -6
- package/dist-esm/config/resolver/grid.js +6 -7
- package/dist-esm/config/resolver/interaction/selection.js +6 -7
- package/dist-esm/config/resolver/interaction/subchart.js +6 -7
- package/dist-esm/config/resolver/interaction/zoom.js +6 -7
- package/dist-esm/config/resolver/regions.js +5 -6
- package/dist-esm/config/resolver/shape/arc.helpers.js +5 -6
- package/dist-esm/config/resolver/shape/area.js +3 -4
- package/dist-esm/config/resolver/shape/axis.helpers.js +2 -3
- package/dist-esm/config/resolver/shape/bar.js +5 -6
- package/dist-esm/config/resolver/shape/boxplot.js +30 -0
- package/dist-esm/config/resolver/shape/bubble.js +5 -6
- package/dist-esm/config/resolver/shape/bullet.js +23 -0
- package/dist-esm/config/resolver/shape/candlestick.js +5 -6
- package/dist-esm/config/resolver/shape/donut.js +2 -3
- package/dist-esm/config/resolver/shape/funnel.js +7 -6
- package/dist-esm/config/resolver/shape/gauge.js +4 -5
- package/dist-esm/config/resolver/shape/heatmap.js +23 -0
- package/dist-esm/config/resolver/shape/line.js +2 -3
- package/dist-esm/config/resolver/shape/pie.js +3 -4
- package/dist-esm/config/resolver/shape/polar.js +4 -5
- package/dist-esm/config/resolver/shape/radar.js +5 -6
- package/dist-esm/config/resolver/shape/sankey.js +23 -0
- package/dist-esm/config/resolver/shape/scatter.js +4 -5
- package/dist-esm/config/resolver/shape/treemap.js +4 -5
- package/dist-esm/core.js +5 -6
- package/dist-esm/index.canvas.js +13 -9
- package/dist-esm/index.esm.js +6 -2
- package/dist-esm/module/Cache.js +2 -3
- package/dist-esm/module/browser.js +2 -3
- package/dist-esm/module/dsv.js +2 -3
- package/dist-esm/module/error.js +23 -16
- package/dist-esm/module/generator.js +3 -4
- package/dist-esm/module/sanitize.js +2 -3
- package/dist-esm/module/util/brush.js +2 -3
- package/dist-esm/module/util/dom.js +3 -4
- package/dist-esm/module/util/object.js +13 -6
- package/dist-esm/module/util/type-checks.js +2 -3
- package/dist-esm/module/worker.js +2 -3
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +6 -10
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +10 -18
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +17 -45
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +10 -18
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +9 -16
- package/dist-esm/react/index.js +2 -3
- package/package.json +44 -44
- package/src/Chart/Chart.ts +1 -0
- package/src/Chart/api/focus.ts +3 -0
- package/src/Chart/api/subchart.ts +1 -1
- package/src/Chart/api/tooltip.ts +54 -15
- package/src/ChartInternal/Axis/AxisRenderer.ts +9 -2
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +42 -8
- package/src/ChartInternal/ChartInternal.ts +46 -19
- package/src/ChartInternal/data/IData.ts +13 -0
- package/src/ChartInternal/data/data.ts +26 -5
- package/src/ChartInternal/data/load.ts +2 -2
- package/src/ChartInternal/interactions/interaction.ts +15 -11
- package/src/ChartInternal/internals/class.ts +3 -2
- package/src/ChartInternal/internals/domain.ts +4 -2
- package/src/ChartInternal/internals/format.ts +3 -1
- package/src/ChartInternal/internals/legend.ts +2 -1
- package/src/ChartInternal/internals/redraw.ts +3 -3
- package/src/ChartInternal/internals/size.ts +5 -3
- package/src/ChartInternal/internals/text.ts +24 -28
- package/src/ChartInternal/internals/tooltip.ts +35 -14
- package/src/ChartInternal/internals/transform.ts +2 -2
- package/src/ChartInternal/internals/type.ts +101 -9
- package/src/ChartInternal/shape/boxplot.ts +172 -0
- package/src/ChartInternal/shape/bullet.ts +323 -0
- package/src/ChartInternal/shape/core/boxplot.ts +241 -0
- package/src/ChartInternal/shape/core/bullet.ts +734 -0
- package/src/ChartInternal/shape/core/heatmap.ts +665 -0
- package/src/ChartInternal/shape/core/sankey.ts +782 -0
- package/src/ChartInternal/shape/funnel.ts +73 -2
- package/src/ChartInternal/shape/heatmap.ts +236 -0
- package/src/ChartInternal/shape/radar.ts +30 -1
- package/src/ChartInternal/shape/sankey.ts +242 -0
- package/src/ChartInternal/shape/shape.ts +1 -1
- package/src/ChartInternal/shape/treemap.ts +10 -0
- package/src/Plugin/stanford/index.ts +1 -28
- package/src/canvas/CanvasAxisRenderer.ts +35 -574
- package/src/canvas/CanvasRenderer.ts +68 -640
- package/src/canvas/CanvasTheme.ts +92 -6
- package/src/canvas/HitDetector.ts +30 -28
- package/src/canvas/boxplot.ts +230 -0
- package/src/canvas/bullet.ts +269 -0
- package/src/canvas/flow.ts +237 -0
- package/src/canvas/grid.ts +359 -0
- package/src/canvas/heatmap.ts +147 -0
- package/src/canvas/labels.ts +3 -1
- package/src/canvas/sankey.ts +151 -0
- package/src/canvas/selection.ts +626 -0
- package/src/canvas/subchart.ts +1292 -0
- package/src/canvas/treemap.ts +142 -0
- package/src/config/Options/axis/y2.ts +13 -0
- package/src/config/Options/data/data.ts +47 -1
- package/src/config/Options/shape/boxplot.ts +95 -0
- package/src/config/Options/shape/bullet.ts +170 -0
- package/src/config/Options/shape/heatmap.ts +125 -0
- package/src/config/Options/shape/sankey.ts +108 -0
- package/src/config/Store/State.ts +1 -1
- package/src/config/classes.ts +0 -1
- package/src/config/const.ts +30 -21
- package/src/config/resolver/canvas.ts +126 -1290
- package/src/config/resolver/canvasBoxplot.ts +42 -0
- package/src/config/resolver/canvasBullet.ts +20 -0
- package/src/config/resolver/canvasFlow.ts +18 -0
- package/src/config/resolver/canvasGrid.ts +17 -0
- package/src/config/resolver/canvasHeatmap.ts +23 -0
- package/src/config/resolver/canvasSankey.ts +23 -0
- package/src/config/resolver/canvasSelection.ts +20 -0
- package/src/config/resolver/canvasShape.ts +6 -1
- package/src/config/resolver/canvasSubchart.ts +20 -0
- package/src/config/resolver/canvasType.ts +51 -0
- package/src/config/resolver/customType.ts +69 -0
- package/src/config/resolver/shape/boxplot.ts +31 -0
- package/src/config/resolver/shape/bullet.ts +18 -0
- package/src/config/resolver/shape/funnel.ts +8 -2
- package/src/config/resolver/shape/heatmap.ts +18 -0
- package/src/config/resolver/shape/index.ts +4 -0
- package/src/config/resolver/shape/sankey.ts +18 -0
- package/src/index.canvas.ts +9 -3
- package/src/index.esm.ts +4 -0
- package/src/index.ts +34 -0
- package/src/module/error.ts +32 -18
- package/src/module/util/object.ts +26 -1
- package/src/scss/billboard.scss +106 -0
- package/src/scss/theme/dark.scss +110 -0
- package/src/scss/theme/datalab.scss +106 -0
- package/src/scss/theme/graph.scss +106 -0
- package/src/scss/theme/insight.scss +106 -0
- package/src/scss/theme/modern.scss +106 -0
- package/types/bb.d.ts +4 -0
- package/types/canvas.d.ts +3 -0
- package/types/chart.d.ts +5 -0
- package/types/index.d.ts +4 -0
- package/types/options.d.ts +10 -1
- package/types/options.shape.d.ts +431 -0
- package/types/types.d.ts +4 -0
|
@@ -5,23 +5,23 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.1
|
|
8
|
+
* @version 4.2.0-next.1
|
|
9
9
|
*/
|
|
10
|
-
import {
|
|
10
|
+
import { isContinuousGridFocusEnabled } from "../ChartInternal/internals/subchart.util.js";
|
|
11
|
+
import { getBarRadiusInfo, getBarRadiusResolver, getStackingBarRadiusSet } from "../ChartInternal/shape/core/barRadius.js";
|
|
12
|
+
import { getLineRegionSegments } from "../ChartInternal/shape/core/dataRegion.js";
|
|
13
|
+
import { getRenderDataPoint, getRenderPoint, getRenderRect, getShapePoint } from "../ChartInternal/shape/core/geometry.js";
|
|
14
|
+
import { generateDrawAreaPath, generateDrawLinePath } from "../ChartInternal/shape/core/path.js";
|
|
15
|
+
import { TYPE } from "../config/const.js";
|
|
11
16
|
import { window as win } from "../module/browser.js";
|
|
12
17
|
import { asHalfPixel, isFunction, isNumber, isObject, isString } from "../module/util/type-checks.js";
|
|
13
|
-
import { generateDrawAreaPath, generateDrawLinePath } from "../ChartInternal/shape/core/path.js";
|
|
14
|
-
import { getLineRegionSegments } from "../ChartInternal/shape/core/dataRegion.js";
|
|
15
|
-
import { getBarRadiusInfo, getBarRadiusResolver, getStackingBarRadiusSet } from "../ChartInternal/shape/core/barRadius.js";
|
|
16
|
-
import { getRenderDataPoint, getRenderPoint, getShapePoint, getTreemapLabelText, getTreemapNodeRect } from "../ChartInternal/shape/core/geometry.js";
|
|
17
|
-
import { isContinuousGridFocusEnabled } from "../ChartInternal/internals/subchart.util.js";
|
|
18
|
-
import { createCanvasPointOccupancyGrid, getCanvasShapeIndices, getCanvasTargetVisibleRange, getFontSize, hasCanvasDrawableValue, isCanvasAreaType, isCanvasBarType, isCanvasBubbleType, isCanvasCandlestickType, isCanvasLineType, isCanvasPointType, isCanvasScatterType, isCanvasTargetSupported, isCanvasTreemapType, isFiniteCanvasCoordinate, markCanvasPointOccupancy } from "./util.js";
|
|
19
18
|
import CanvasPainter from "./CanvasPainter.js";
|
|
20
19
|
import { withOpacity } from "./color.js";
|
|
21
20
|
import { getCanvasBarGeometry, getCanvasCandlestickGeometry } from "./geometry.js";
|
|
22
21
|
import { drawLabelDecorations, getExpandedFocusMatcher, getLabelColor, getLabelDecorationBox, getLabelImageOption, getLabelImagePosition, getLabelImageUrl, getLabelPosition, getLabelText, getPointLabelAnchor, getRotatedLabelPosition } from "./labels.js";
|
|
23
22
|
import { drawPointPattern } from "./pointPattern.js";
|
|
24
|
-
|
|
23
|
+
import { createCanvasPointOccupancyGrid, getCanvasShapeIndices, getCanvasTargetVisibleRange, hasCanvasDrawableValue, isCanvasAreaType, isCanvasBarType, isCanvasBubbleType, isCanvasCandlestickType, isCanvasLineType, isCanvasPointType, isCanvasScatterType, isCanvasTargetSupported, isFiniteCanvasCoordinate, markCanvasPointOccupancy } from "./util.js";
|
|
24
|
+
// src/canvas/CanvasRenderer.ts
|
|
25
25
|
/**
|
|
26
26
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
27
27
|
* billboard.js project is licensed under the MIT license
|
|
@@ -34,7 +34,6 @@ const RENDERER_GROUPED_TYPE_FILTERS = [
|
|
|
34
34
|
];
|
|
35
35
|
const MAX_BATCHED_CIRCLE_POINTS = 1e3;
|
|
36
36
|
const canvasFocusLookupCache = /* @__PURE__ */ new WeakMap();
|
|
37
|
-
const subchartBrushHandlePathCache = /* @__PURE__ */ new Map();
|
|
38
37
|
/**
|
|
39
38
|
* Apply a CSS matrix transform to a canvas context.
|
|
40
39
|
* @param {CanvasRenderingContext2D} ctx Canvas context
|
|
@@ -88,7 +87,7 @@ function getPreservedAspectRatioRect(image, width, height) {
|
|
|
88
87
|
*/
|
|
89
88
|
function getBackgroundImageOffset($$) {
|
|
90
89
|
const { state } = $$;
|
|
91
|
-
return state.
|
|
90
|
+
return state.customType || state.hasTreemap ? {
|
|
92
91
|
x: 0,
|
|
93
92
|
y: 0
|
|
94
93
|
} : {
|
|
@@ -161,23 +160,6 @@ function getFocusedCanvasDatum(focusData, d) {
|
|
|
161
160
|
return "index" in d ? lookup.get(`${d.id}:${d.index}`) || null : lookup.get(`${d.id}:*`) || null;
|
|
162
161
|
}
|
|
163
162
|
/**
|
|
164
|
-
* Get cached Path2D for a subchart brush handle.
|
|
165
|
-
* @param {string} axis Brush axis
|
|
166
|
-
* @param {string} type Brush handle side
|
|
167
|
-
* @returns {Path2D|null}
|
|
168
|
-
* @private
|
|
169
|
-
*/
|
|
170
|
-
function getSubchartBrushHandlePath(axis, type) {
|
|
171
|
-
const Path2DCtor = win.Path2D;
|
|
172
|
-
if (!Path2DCtor) return null;
|
|
173
|
-
const key = `${axis}:${type}`;
|
|
174
|
-
const cached = subchartBrushHandlePathCache.get(key);
|
|
175
|
-
if (cached) return cached;
|
|
176
|
-
const path = new Path2DCtor(SUBCHART_BRUSH_HANDLE_PATH[axis][type]);
|
|
177
|
-
subchartBrushHandlePathCache.set(key, path);
|
|
178
|
-
return path;
|
|
179
|
-
}
|
|
180
|
-
/**
|
|
181
163
|
* Resolve color.onover for a focused data row.
|
|
182
164
|
* @param {object} $$ ChartInternal instance
|
|
183
165
|
* @param {object} d Focused data row
|
|
@@ -247,10 +229,10 @@ function getCanvasAreaBounds($$, target, indices, isSub = false) {
|
|
|
247
229
|
const getPoints = $$.generateGetAreaPoints?.(indices, isSub);
|
|
248
230
|
if (!getPoints) return null;
|
|
249
231
|
const range = getCanvasTargetVisibleRange($$, target);
|
|
250
|
-
let minX =
|
|
251
|
-
let minY =
|
|
252
|
-
let maxX = -
|
|
253
|
-
let maxY = -
|
|
232
|
+
let minX = 1e400;
|
|
233
|
+
let minY = 1e400;
|
|
234
|
+
let maxX = -1e400;
|
|
235
|
+
let maxY = -1e400;
|
|
254
236
|
for (let i = range.start; i < range.end; i++) {
|
|
255
237
|
const d = target.values[i];
|
|
256
238
|
if (!hasCanvasDrawableValue($$, d)) continue;
|
|
@@ -828,8 +810,13 @@ var CanvasRenderer = class {
|
|
|
828
810
|
* @private
|
|
829
811
|
*/
|
|
830
812
|
draw($$, shape, focusData) {
|
|
831
|
-
|
|
832
|
-
|
|
813
|
+
const exclusive = $$.getCanvasTypeParts?.().find((part) => part.exclusive);
|
|
814
|
+
if (exclusive) {
|
|
815
|
+
exclusive.draw?.call($$, this, shape, focusData);
|
|
816
|
+
return;
|
|
817
|
+
}
|
|
818
|
+
if ($$.state.customType) {
|
|
819
|
+
$$.getCustomTypeParts()?.canvas?.draw?.call($$, this);
|
|
833
820
|
return;
|
|
834
821
|
}
|
|
835
822
|
const { margin, width, height } = $$.state;
|
|
@@ -842,9 +829,10 @@ var CanvasRenderer = class {
|
|
|
842
829
|
const drawContent = () => {
|
|
843
830
|
if (!$$.config.bar_front) this.drawBars($$, shape, focusData);
|
|
844
831
|
this.drawCandlesticks($$, shape, focusData);
|
|
832
|
+
$$.getAxisTypeParts?.().forEach((part) => part.canvas?.draw?.call($$, this, shape));
|
|
845
833
|
drawLineLayers();
|
|
846
834
|
if ($$.config.bar_front) this.drawBars($$, shape, focusData);
|
|
847
|
-
|
|
835
|
+
$$.getCanvasFeature?.("selection")?.draw.call($$, this, shape);
|
|
848
836
|
this.drawLabels($$, shape);
|
|
849
837
|
};
|
|
850
838
|
$$.config.clipPath === false ? drawContent() : this.painter.clipRect({
|
|
@@ -855,190 +843,6 @@ var CanvasRenderer = class {
|
|
|
855
843
|
}, drawContent);
|
|
856
844
|
}
|
|
857
845
|
/**
|
|
858
|
-
* Draw the canvas subchart overview and brush selection.
|
|
859
|
-
* @param {object} $$ ChartInternal instance
|
|
860
|
-
* @param {object} _shape Cached main shape object
|
|
861
|
-
* @private
|
|
862
|
-
*/
|
|
863
|
-
drawSubchart($$, _shape) {
|
|
864
|
-
const { config, state } = $$;
|
|
865
|
-
if (!config.subchart_show || !state.hasAxis || state.width2 <= 0 || state.height2 <= 0) return;
|
|
866
|
-
const { ctx, painter, theme: { style } } = this;
|
|
867
|
-
const { margin2, width2, height2 } = state;
|
|
868
|
-
const rect = {
|
|
869
|
-
x: margin2.left,
|
|
870
|
-
y: margin2.top,
|
|
871
|
-
w: width2,
|
|
872
|
-
h: height2
|
|
873
|
-
};
|
|
874
|
-
$$.withSubchartTypeContext(() => {
|
|
875
|
-
const targets = $$.filterTargetsToShow().filter(isCanvasRenderableTarget.bind(null, $$));
|
|
876
|
-
const shape = $$.getDrawShape();
|
|
877
|
-
$$.updateSubchartYDomain?.(targets);
|
|
878
|
-
painter.withState(() => {
|
|
879
|
-
painter.clipRect(rect, () => {
|
|
880
|
-
painter.withTranslation(rect.x, rect.y, () => {
|
|
881
|
-
const areaTargets = targets.filter(isCanvasAreaType.bind(null, $$));
|
|
882
|
-
const areaIndices = getCanvasShapeIndices($$, shape, TYPE.AREA, isCanvasAreaType.bind(null, $$));
|
|
883
|
-
for (const target of areaTargets) {
|
|
884
|
-
if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) continue;
|
|
885
|
-
ctx.globalAlpha = style.shape.areaOpacity * getCanvasTargetFocusOpacity($$, target);
|
|
886
|
-
ctx.fillStyle = $$.color(target.id);
|
|
887
|
-
drawCanvasArea($$, target, areaIndices, painter, true);
|
|
888
|
-
}
|
|
889
|
-
ctx.globalAlpha = 1;
|
|
890
|
-
const barTargets = targets.filter(isCanvasBarType.bind(null, $$));
|
|
891
|
-
const barIndices = getCanvasShapeIndices($$, shape, TYPE.BAR, isCanvasBarType.bind(null, $$));
|
|
892
|
-
const getBarPoints = $$.generateGetBarPoints?.(barIndices, true);
|
|
893
|
-
if (getBarPoints) {
|
|
894
|
-
for (const target of barTargets) {
|
|
895
|
-
ctx.globalAlpha = style.shape.barOpacity * getCanvasTargetFocusOpacity($$, target);
|
|
896
|
-
ctx.fillStyle = $$.color(target.id);
|
|
897
|
-
target.values.forEach((d, i) => {
|
|
898
|
-
if (!hasCanvasDrawableValue($$, d)) return;
|
|
899
|
-
const geometry = getCanvasBarGeometry($$, getBarPoints, d, i);
|
|
900
|
-
const fill = $$.getSubchartCandlestickBarColor?.(d, true) || ctx.fillStyle;
|
|
901
|
-
geometry && painter.fillRect(geometry.rect, { fill });
|
|
902
|
-
});
|
|
903
|
-
}
|
|
904
|
-
ctx.globalAlpha = 1;
|
|
905
|
-
}
|
|
906
|
-
const candlestickTargets = targets.filter(isCanvasCandlestickType.bind(null, $$));
|
|
907
|
-
const candlestickIndices = getCanvasShapeIndices($$, shape, TYPE.CANDLESTICK, isCanvasCandlestickType.bind(null, $$));
|
|
908
|
-
const getCandlestickPoints = $$.generateGetCandlestickPoints?.(candlestickIndices, true);
|
|
909
|
-
if (getCandlestickPoints) {
|
|
910
|
-
ctx.lineWidth = style.shape.candlestickLineWidth;
|
|
911
|
-
for (const target of candlestickTargets) {
|
|
912
|
-
const targetOpacity = getCanvasTargetFocusOpacity($$, target);
|
|
913
|
-
ctx.globalAlpha = targetOpacity;
|
|
914
|
-
target.values.forEach((d, i) => {
|
|
915
|
-
const value = $$.getCandlestickData?.(d);
|
|
916
|
-
const geometry = value && getCanvasCandlestickGeometry($$, getCandlestickPoints, d, i);
|
|
917
|
-
if (!geometry) return;
|
|
918
|
-
const color = getCandlestickColor($$, { id: target.id }, value);
|
|
919
|
-
ctx.strokeStyle = color;
|
|
920
|
-
ctx.fillStyle = color;
|
|
921
|
-
painter.strokePath(() => {
|
|
922
|
-
painter.traceLine(geometry.wickStart[0], geometry.wickStart[1], geometry.wickEnd[0], geometry.wickEnd[1]);
|
|
923
|
-
});
|
|
924
|
-
painter.fillRect(geometry.body, { fill: ctx.fillStyle });
|
|
925
|
-
});
|
|
926
|
-
}
|
|
927
|
-
}
|
|
928
|
-
const lineTargets = targets.filter(isCanvasLineType.bind(null, $$));
|
|
929
|
-
const lineIndices = getCanvasShapeIndices($$, shape, TYPE.LINE, isCanvasLineType.bind(null, $$));
|
|
930
|
-
ctx.globalAlpha = 1;
|
|
931
|
-
for (const target of lineTargets) {
|
|
932
|
-
if (!target.values.some(hasCanvasDrawableValue.bind(null, $$))) continue;
|
|
933
|
-
ctx.globalAlpha = getCanvasTargetFocusOpacity($$, target);
|
|
934
|
-
ctx.lineWidth = isCanvasTargetFocused($$, target) ? style.shape.lineFocusedWidth : style.shape.lineWidth;
|
|
935
|
-
ctx.strokeStyle = $$.color(target.id);
|
|
936
|
-
drawCanvasLine($$, target, lineIndices, painter, true);
|
|
937
|
-
}
|
|
938
|
-
ctx.globalAlpha = 1;
|
|
939
|
-
if (config.point_show && !$$.isPointFocusOnly?.()) {
|
|
940
|
-
const cy = $$.updateCircleY?.(true);
|
|
941
|
-
const cx = $$.subxx?.bind($$);
|
|
942
|
-
if (cx && cy) {
|
|
943
|
-
for (const target of targets) {
|
|
944
|
-
if (!isCanvasScatterType($$, target) && !isCanvasBubbleType($$, target)) continue;
|
|
945
|
-
const color = $$.color(target.id);
|
|
946
|
-
const pointFill = style.shape.pointFillColor || color;
|
|
947
|
-
const pointStroke = style.shape.pointStrokeColor || color;
|
|
948
|
-
const pointLineWidth = pointStroke ? style.shape.pointLineWidth ?? 1 : 0;
|
|
949
|
-
const pointStyle = pointStroke && pointLineWidth > 0 ? {
|
|
950
|
-
fill: pointFill,
|
|
951
|
-
stroke: pointStroke,
|
|
952
|
-
lineWidth: pointLineWidth
|
|
953
|
-
} : { fill: pointFill };
|
|
954
|
-
ctx.globalAlpha = getPointOpacity($$, target) * getCanvasTargetFocusOpacity($$, target);
|
|
955
|
-
target.values.forEach((d, i) => {
|
|
956
|
-
if (!hasCanvasDrawableValue($$, d)) return;
|
|
957
|
-
const x = config.axis_rotated ? cy(d, i) : cx(d);
|
|
958
|
-
const y = config.axis_rotated ? cx(d) : cy(d, i);
|
|
959
|
-
const r = Math.min(getTargetPointRadius($$, target, d), 3);
|
|
960
|
-
if (isFiniteCanvasCoordinate(x, y)) drawPointPattern(painter, "circle", x, y, r, pointStyle);
|
|
961
|
-
});
|
|
962
|
-
}
|
|
963
|
-
ctx.globalAlpha = 1;
|
|
964
|
-
}
|
|
965
|
-
}
|
|
966
|
-
});
|
|
967
|
-
});
|
|
968
|
-
this.drawSubchartBrush($$);
|
|
969
|
-
});
|
|
970
|
-
});
|
|
971
|
-
}
|
|
972
|
-
/**
|
|
973
|
-
* Draw current subchart brush selection.
|
|
974
|
-
* @param {object} $$ ChartInternal instance
|
|
975
|
-
* @private
|
|
976
|
-
*/
|
|
977
|
-
drawSubchartBrush($$) {
|
|
978
|
-
const { config, scale, state } = $$;
|
|
979
|
-
const domain = state.domain;
|
|
980
|
-
if (!config.subchart_show || config.subchart_brush_enabled === false || !domain?.length || !scale.subX) return;
|
|
981
|
-
const { margin2, width2, height2 } = state;
|
|
982
|
-
const p0 = scale.subX(domain[0]);
|
|
983
|
-
const p1 = scale.subX(domain[1]);
|
|
984
|
-
const axisLength = config.axis_rotated ? height2 : width2;
|
|
985
|
-
const extent = $$.axis?.getExtent?.();
|
|
986
|
-
const extentValues = Array.isArray(extent) && extent.length >= 2 && extent.every(Number.isFinite) ? extent.slice(0, 2) : [0, axisLength];
|
|
987
|
-
const extentStart = Math.max(0, Math.min(axisLength, Math.min(...extentValues)));
|
|
988
|
-
const extentEnd = Math.max(0, Math.min(axisLength, Math.max(...extentValues)));
|
|
989
|
-
const start = Math.max(extentStart, Math.min(extentEnd, Math.min(p0, p1)));
|
|
990
|
-
const end = Math.max(extentStart, Math.min(extentEnd, Math.max(p0, p1)));
|
|
991
|
-
const size = end - start;
|
|
992
|
-
if (size <= 0) return;
|
|
993
|
-
const rect = config.axis_rotated ? {
|
|
994
|
-
x: margin2.left,
|
|
995
|
-
y: margin2.top + start,
|
|
996
|
-
w: width2,
|
|
997
|
-
h: size
|
|
998
|
-
} : {
|
|
999
|
-
x: margin2.left + start,
|
|
1000
|
-
y: margin2.top,
|
|
1001
|
-
w: size,
|
|
1002
|
-
h: height2
|
|
1003
|
-
};
|
|
1004
|
-
this.painter.fillRect(rect, {
|
|
1005
|
-
fill: this.theme.style.subchartBrush.fill,
|
|
1006
|
-
alpha: this.theme.style.subchartBrush.opacity
|
|
1007
|
-
});
|
|
1008
|
-
if (config.subchart_showHandle) {
|
|
1009
|
-
this.drawSubchartBrushHandle($$, start, "start");
|
|
1010
|
-
this.drawSubchartBrushHandle($$, end, "end");
|
|
1011
|
-
}
|
|
1012
|
-
}
|
|
1013
|
-
/**
|
|
1014
|
-
* Draw a visible subchart brush resize handle.
|
|
1015
|
-
* @param {object} $$ ChartInternal instance
|
|
1016
|
-
* @param {number} coord Brush handle coordinate
|
|
1017
|
-
* @param {string} type Brush handle side
|
|
1018
|
-
* @private
|
|
1019
|
-
*/
|
|
1020
|
-
drawSubchartBrushHandle($$, coord, type) {
|
|
1021
|
-
const { config, state: { margin2, width2, height2 } } = $$;
|
|
1022
|
-
const { ctx, painter, theme: { style } } = this;
|
|
1023
|
-
const isRotated = config.axis_rotated;
|
|
1024
|
-
const fill = style.subchartBrush.handleFill;
|
|
1025
|
-
const stroke = style.subchartBrush.handleStroke;
|
|
1026
|
-
const x = isRotated ? margin2.left + width2 / 2 : margin2.left + coord;
|
|
1027
|
-
const y = isRotated ? margin2.top + coord : margin2.top + height2 / 2;
|
|
1028
|
-
const path = getSubchartBrushHandlePath(isRotated ? "y" : "x", type);
|
|
1029
|
-
if (!path) return;
|
|
1030
|
-
painter.withState(() => {
|
|
1031
|
-
ctx.translate(x, y);
|
|
1032
|
-
ctx.fillStyle = fill;
|
|
1033
|
-
ctx.strokeStyle = stroke;
|
|
1034
|
-
ctx.lineWidth = style.subchartBrush.handleLineWidth;
|
|
1035
|
-
ctx.globalAlpha = style.subchartBrush.handleOpacity;
|
|
1036
|
-
ctx.fill(path);
|
|
1037
|
-
ctx.globalAlpha = 1;
|
|
1038
|
-
ctx.stroke(path);
|
|
1039
|
-
});
|
|
1040
|
-
}
|
|
1041
|
-
/**
|
|
1042
846
|
* Draw bar shapes on canvas.
|
|
1043
847
|
* @param {object} $$ ChartInternal instance
|
|
1044
848
|
* @param {object} shape Cached draw shape object
|
|
@@ -1147,7 +951,18 @@ var CanvasRenderer = class {
|
|
|
1147
951
|
* @private
|
|
1148
952
|
*/
|
|
1149
953
|
hasExpandedShapeFocus($$, selectedData) {
|
|
1150
|
-
|
|
954
|
+
const isBar = isCanvasBarType.bind(null, $$);
|
|
955
|
+
let getPoints;
|
|
956
|
+
return !!selectedData?.some((d) => {
|
|
957
|
+
if (!d) return false;
|
|
958
|
+
if (isCanvasCandlestickType($$, d)) return true;
|
|
959
|
+
if (!isBar(d)) return false;
|
|
960
|
+
getPoints = getPoints || $$.generateGetBarPoints(getCanvasShapeIndices($$, $$.state.canvasShape || { indices: {} }, TYPE.BAR, isBar), false);
|
|
961
|
+
const points = getPoints?.(d, d.index);
|
|
962
|
+
if (!points) return true;
|
|
963
|
+
const rect = getRenderRect($$, points, 0);
|
|
964
|
+
return ($$.config.axis_rotated ? rect.h : rect.w) >= 1;
|
|
965
|
+
});
|
|
1151
966
|
}
|
|
1152
967
|
/**
|
|
1153
968
|
* Draw line strokes on canvas.
|
|
@@ -1301,85 +1116,6 @@ var CanvasRenderer = class {
|
|
|
1301
1116
|
});
|
|
1302
1117
|
}
|
|
1303
1118
|
/**
|
|
1304
|
-
* Draw selected canvas shapes.
|
|
1305
|
-
* @param {object} $$ ChartInternal instance
|
|
1306
|
-
* @param {object} shape Cached draw shape object
|
|
1307
|
-
* @private
|
|
1308
|
-
*/
|
|
1309
|
-
drawSelections($$, shape) {
|
|
1310
|
-
const selectedData = $$.getCanvasSelectedData?.();
|
|
1311
|
-
if (!$$.config.data_selection_enabled || !selectedData?.length || $$.state.hasTreemap) return;
|
|
1312
|
-
const { ctx, painter, theme: { style } } = this;
|
|
1313
|
-
const { margin } = $$.state;
|
|
1314
|
-
const isBar = isCanvasBarType.bind(null, $$);
|
|
1315
|
-
const isCandlestick = isCanvasCandlestickType.bind(null, $$);
|
|
1316
|
-
const barPoints = selectedData.some(isBar) ? $$.generateGetBarPoints(getCanvasShapeIndices($$, shape, TYPE.BAR, isBar), false) : null;
|
|
1317
|
-
const candlestickPoints = selectedData.some(isCandlestick) ? $$.generateGetCandlestickPoints?.(getCanvasShapeIndices($$, shape, TYPE.CANDLESTICK, isCandlestick), false) : null;
|
|
1318
|
-
const getRadius = barPoints ? getBarRadiusResolver($$) : null;
|
|
1319
|
-
const stackingRadiusSet = getRadius ? getStackingBarRadiusSet($$) : /* @__PURE__ */ new Set();
|
|
1320
|
-
painter.withTranslation(margin.left, margin.top, () => {
|
|
1321
|
-
selectedData.forEach((d) => {
|
|
1322
|
-
const color = $$.color(d.id);
|
|
1323
|
-
if (isBar(d) && barPoints) {
|
|
1324
|
-
const geometry = getCanvasBarGeometry($$, barPoints, d, d.index);
|
|
1325
|
-
if (!geometry) return;
|
|
1326
|
-
const { points, rect } = geometry;
|
|
1327
|
-
const corners = getRadius ? getBarRadiusInfo($$, d, points, getRadius, stackingRadiusSet).corners : 0;
|
|
1328
|
-
getRadius ? painter.fillRoundRect(rect, corners, {
|
|
1329
|
-
fill: "#fff",
|
|
1330
|
-
alpha: .3
|
|
1331
|
-
}) : painter.fillRect(rect, {
|
|
1332
|
-
fill: "#fff",
|
|
1333
|
-
alpha: .3
|
|
1334
|
-
});
|
|
1335
|
-
getRadius ? painter.strokeRoundRect(rect, corners, {
|
|
1336
|
-
stroke: color,
|
|
1337
|
-
lineWidth: 2
|
|
1338
|
-
}) : painter.strokeRect(rect, {
|
|
1339
|
-
stroke: color,
|
|
1340
|
-
lineWidth: 2
|
|
1341
|
-
});
|
|
1342
|
-
} else if (isCandlestick(d) && candlestickPoints) {
|
|
1343
|
-
if (!$$.getCandlestickData?.(d)) return;
|
|
1344
|
-
const geometry = getCanvasCandlestickGeometry($$, candlestickPoints, d, d.index);
|
|
1345
|
-
if (!geometry) return;
|
|
1346
|
-
const { body, wickStart, wickEnd } = geometry;
|
|
1347
|
-
painter.strokePath(() => {
|
|
1348
|
-
painter.traceLine(wickStart[0], wickStart[1], wickEnd[0], wickEnd[1]);
|
|
1349
|
-
}, {
|
|
1350
|
-
stroke: color,
|
|
1351
|
-
lineWidth: 3
|
|
1352
|
-
});
|
|
1353
|
-
painter.fillRect(body, {
|
|
1354
|
-
fill: "#fff",
|
|
1355
|
-
alpha: .3
|
|
1356
|
-
});
|
|
1357
|
-
painter.strokeRect(body, {
|
|
1358
|
-
stroke: color,
|
|
1359
|
-
lineWidth: 2
|
|
1360
|
-
});
|
|
1361
|
-
} else if (isCanvasPointType($$, d)) {
|
|
1362
|
-
const pointType = getPointType($$, { id: d.id });
|
|
1363
|
-
const { x, y } = getRenderDataPoint($$, d);
|
|
1364
|
-
const r = $$.pointR?.(d) ?? 2.5;
|
|
1365
|
-
const selectR = $$.pointSelectR?.(d) ?? r * 2;
|
|
1366
|
-
if (!isFiniteCanvasCoordinate(x, y)) return;
|
|
1367
|
-
drawPointPattern(painter, "circle", x, y, selectR, {
|
|
1368
|
-
fill: style.selectedPoint.fill,
|
|
1369
|
-
lineWidth: style.selectedPoint.lineWidth,
|
|
1370
|
-
stroke: style.selectedPoint.stroke || color
|
|
1371
|
-
});
|
|
1372
|
-
if (!$$.isPointFocusOnly?.()) drawPointPattern(painter, pointType, x, y, r, {
|
|
1373
|
-
fill: style.shape.pointFillColor || color,
|
|
1374
|
-
stroke: style.shape.pointStrokeColor || color,
|
|
1375
|
-
lineWidth: style.shape.pointLineWidth ?? 1
|
|
1376
|
-
});
|
|
1377
|
-
}
|
|
1378
|
-
});
|
|
1379
|
-
ctx.globalAlpha = 1;
|
|
1380
|
-
});
|
|
1381
|
-
}
|
|
1382
|
-
/**
|
|
1383
1119
|
* Draw data labels on canvas.
|
|
1384
1120
|
* @param {object} $$ ChartInternal instance
|
|
1385
1121
|
* @param {object} shape Cached draw shape object
|
|
@@ -1502,123 +1238,18 @@ var CanvasRenderer = class {
|
|
|
1502
1238
|
});
|
|
1503
1239
|
}
|
|
1504
1240
|
/**
|
|
1505
|
-
* Draw data selection drag area.
|
|
1506
|
-
* @param {object} $$ ChartInternal instance
|
|
1507
|
-
* @param {object} rect Selection rectangle
|
|
1508
|
-
* @private
|
|
1509
|
-
*/
|
|
1510
|
-
drawSelectionDragArea($$, rect) {
|
|
1511
|
-
const { margin, width, height } = $$.state;
|
|
1512
|
-
const plot = {
|
|
1513
|
-
x: margin.left,
|
|
1514
|
-
y: margin.top,
|
|
1515
|
-
w: width,
|
|
1516
|
-
h: height
|
|
1517
|
-
};
|
|
1518
|
-
const x = Math.max(plot.x, rect.x);
|
|
1519
|
-
const y = Math.max(plot.y, rect.y);
|
|
1520
|
-
const right = Math.min(plot.x + plot.w, rect.x + rect.w);
|
|
1521
|
-
const bottom = Math.min(plot.y + plot.h, rect.y + rect.h);
|
|
1522
|
-
if (right <= x || bottom <= y) return;
|
|
1523
|
-
this.painter.fillRect({
|
|
1524
|
-
x,
|
|
1525
|
-
y,
|
|
1526
|
-
w: right - x,
|
|
1527
|
-
h: bottom - y
|
|
1528
|
-
}, {
|
|
1529
|
-
fill: this.theme.style.zoomBrush.fill,
|
|
1530
|
-
alpha: this.theme.style.zoomBrush.opacity
|
|
1531
|
-
});
|
|
1532
|
-
}
|
|
1533
|
-
/**
|
|
1534
|
-
* Draw treemap tiles and labels on canvas.
|
|
1535
|
-
* @param {object} $$ ChartInternal instance
|
|
1536
|
-
* @private
|
|
1537
|
-
*/
|
|
1538
|
-
drawTreemaps($$) {
|
|
1539
|
-
const { ctx, painter, theme: { style } } = this;
|
|
1540
|
-
const { config } = $$;
|
|
1541
|
-
const root = $$.getTreemapRoot?.($$.data.targets);
|
|
1542
|
-
const nodes = root?.children || [];
|
|
1543
|
-
painter.withState(() => {
|
|
1544
|
-
ctx.lineWidth = style.treemap.lineWidth;
|
|
1545
|
-
ctx.strokeStyle = style.treemap.stroke;
|
|
1546
|
-
for (const node of nodes) {
|
|
1547
|
-
const { data } = node;
|
|
1548
|
-
if (!isCanvasTreemapType($$, data)) continue;
|
|
1549
|
-
const { x, y, w, h } = getTreemapNodeRect($$, node, root, true);
|
|
1550
|
-
if (!isFiniteCanvasCoordinate(x, y) || !isFiniteCanvasCoordinate(x + w, y + h) || w <= 0 || h <= 0) continue;
|
|
1551
|
-
const rect = {
|
|
1552
|
-
x,
|
|
1553
|
-
y,
|
|
1554
|
-
w,
|
|
1555
|
-
h
|
|
1556
|
-
};
|
|
1557
|
-
ctx.fillStyle = $$.color(data.name);
|
|
1558
|
-
painter.fillRect(rect);
|
|
1559
|
-
painter.strokeRect(rect);
|
|
1560
|
-
if (!config.treemap_label_show || (data.ratio || 0) < (config.treemap_label_threshold || 0)) continue;
|
|
1561
|
-
const label = getTreemapLabelText($$, data, w, h);
|
|
1562
|
-
if (!label) continue;
|
|
1563
|
-
const lines = label.split("\n");
|
|
1564
|
-
const isCentered = !!config.data_labels.centered;
|
|
1565
|
-
ctx.font = style.label.font;
|
|
1566
|
-
const lineHeight = getFontSize(ctx.font);
|
|
1567
|
-
const metrics = ctx.measureText(lines[0] ?? "");
|
|
1568
|
-
const fontBoundingHeight = (metrics.fontBoundingBoxAscent || 0) + (metrics.fontBoundingBoxDescent || 0) || (metrics.actualBoundingBoxAscent || 0) + (metrics.actualBoundingBoxDescent || 0);
|
|
1569
|
-
const textHeight = Math.max(lineHeight, fontBoundingHeight) + (lines.length - 1) * lineHeight;
|
|
1570
|
-
const blockY = isCentered ? y + h / 2 : y + textHeight + 5;
|
|
1571
|
-
let textX = isCentered ? x + w / 2 : x + 5;
|
|
1572
|
-
let textY = blockY - (lines.length - 1) * lineHeight / (isCentered ? 2 : 1);
|
|
1573
|
-
ctx.textAlign = isCentered ? "center" : "left";
|
|
1574
|
-
ctx.textBaseline = isCentered ? "middle" : "alphabetic";
|
|
1575
|
-
({x: textX, y: textY} = this.drawLabelImage($$, data, label, textX, textY));
|
|
1576
|
-
ctx.fillStyle = getLabelColor($$, data, style.label.color);
|
|
1577
|
-
drawLabelDecorations($$, painter, data, label, textX, isCentered ? textY + (lines.length - 1) * lineHeight / 2 : blockY);
|
|
1578
|
-
lines.forEach((line, i) => {
|
|
1579
|
-
painter.text(line, textX, textY + i * lineHeight, { maxWidth: Math.max(0, w - 8) });
|
|
1580
|
-
});
|
|
1581
|
-
}
|
|
1582
|
-
});
|
|
1583
|
-
}
|
|
1584
|
-
/**
|
|
1585
|
-
* Draw synchronized focus grid on the canvas subchart.
|
|
1586
|
-
* @param {object} $$ ChartInternal instance
|
|
1587
|
-
* @param {Array} selectedData Focused data rows
|
|
1588
|
-
* @private
|
|
1589
|
-
*/
|
|
1590
|
-
drawSubchartFocus($$, selectedData) {
|
|
1591
|
-
const { config, scale, state } = $$;
|
|
1592
|
-
const focus = selectedData?.find((d) => d && hasCanvasDrawableValue($$, d));
|
|
1593
|
-
if (!focus || !config.subchart_show || config.subchart_grid_focus_continuous || config.subchart_brush_enabled !== false || config.grid_focus_show === false || config.subchart_grid_focus === false || !config.tooltip_show || config.axis_tooltip || !scale.subX || state.width2 <= 0 || state.height2 <= 0) return;
|
|
1594
|
-
const { margin2, width2, height2 } = state;
|
|
1595
|
-
const pos = scale.subX(focus.x);
|
|
1596
|
-
if (!Number.isFinite(pos)) return;
|
|
1597
|
-
const { painter, theme: { style } } = this;
|
|
1598
|
-
const lineWidth = style.axis.lineWidth;
|
|
1599
|
-
const x = painter.crisp(margin2.left + pos, lineWidth);
|
|
1600
|
-
const y = painter.crisp(margin2.top + pos, lineWidth);
|
|
1601
|
-
painter.strokePath(() => {
|
|
1602
|
-
config.axis_rotated ? painter.traceLine(margin2.left, y, margin2.left + width2, y) : painter.traceLine(x, margin2.top, x, margin2.top + height2);
|
|
1603
|
-
}, {
|
|
1604
|
-
lineDash: style.focusGrid.dashArray,
|
|
1605
|
-
lineWidth: style.focusGrid.lineWidth,
|
|
1606
|
-
stroke: style.focusGrid.lineColor
|
|
1607
|
-
});
|
|
1608
|
-
}
|
|
1609
|
-
/**
|
|
1610
1241
|
* Draw focus grid and focused points on canvas.
|
|
1611
1242
|
* @param {object} $$ ChartInternal instance
|
|
1612
1243
|
* @param {Array} selectedData Focused data rows
|
|
1613
1244
|
* @private
|
|
1614
1245
|
*/
|
|
1615
1246
|
drawFocus($$, selectedData) {
|
|
1616
|
-
if (!selectedData?.length) return;
|
|
1247
|
+
if (!selectedData?.length || $$.state.customType) return;
|
|
1617
1248
|
const { painter } = this;
|
|
1618
1249
|
const { style } = this.theme;
|
|
1619
1250
|
const { margin } = $$.state;
|
|
1620
1251
|
const focus = selectedData.find((d) => d && hasCanvasDrawableValue($$, d));
|
|
1621
|
-
$$.config.subchart_grid_focus !== false && !isContinuousGridFocusEnabled($$) &&
|
|
1252
|
+
$$.config.subchart_grid_focus !== false && !isContinuousGridFocusEnabled($$) && $$.getCanvasFeature?.("subchart")?.drawFocus.call($$, this, selectedData);
|
|
1622
1253
|
painter.withTranslation(margin.left, margin.top, () => {
|
|
1623
1254
|
if ($$.config.tooltip_show && $$.config.grid_focus_show !== false && !$$.config.axis_tooltip && focus) {
|
|
1624
1255
|
const { x, y } = getRenderDataPoint($$, focus);
|
|
@@ -1680,5 +1311,4 @@ var CanvasRenderer = class {
|
|
|
1680
1311
|
});
|
|
1681
1312
|
}
|
|
1682
1313
|
};
|
|
1683
|
-
|
|
1684
|
-
export { CanvasRenderer as default };
|
|
1314
|
+
export { CanvasRenderer as default, drawCanvasArea, drawCanvasLine, getCandlestickColor, getCanvasTargetFocusOpacity, getPointOpacity, getPointType, getTargetPointRadius, isCanvasRenderableTarget, isCanvasTargetFocused };
|
|
@@ -5,11 +5,11 @@
|
|
|
5
5
|
* billboard.js, JavaScript chart library
|
|
6
6
|
* https://naver.github.io/billboard.js/
|
|
7
7
|
*
|
|
8
|
-
* @version 4.1
|
|
8
|
+
* @version 4.2.0-next.1
|
|
9
9
|
*/
|
|
10
10
|
import { document as doc, window as win } from "../module/browser.js";
|
|
11
11
|
import { mergeObj } from "../module/util/object.js";
|
|
12
|
-
|
|
12
|
+
// src/canvas/CanvasTheme.ts
|
|
13
13
|
/**
|
|
14
14
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
15
15
|
* billboard.js project is licensed under the MIT license
|
|
@@ -205,6 +205,11 @@ function mergeThemeSection(target, section, values) {
|
|
|
205
205
|
}, {});
|
|
206
206
|
if (Object.keys(override).length) target[section] = mergeObj(target[section] ?? {}, override);
|
|
207
207
|
}
|
|
208
|
+
const themeSelectorReader = {
|
|
209
|
+
readColorValue,
|
|
210
|
+
readNumberValue,
|
|
211
|
+
readFontValue
|
|
212
|
+
};
|
|
208
213
|
/**
|
|
209
214
|
* Normalize a supported SVG selector for canvas theme matching.
|
|
210
215
|
* @param {string} selector SVG selector
|
|
@@ -571,14 +576,17 @@ function applySelectorStyle(target, selector, style) {
|
|
|
571
576
|
/**
|
|
572
577
|
* Convert selector based canvas theme overrides to renderer theme slots.
|
|
573
578
|
* @param {object} selectors Selector style declarations
|
|
579
|
+
* @param {object} extension Theme section of a type added by a module
|
|
574
580
|
* @returns {object} Canvas theme override
|
|
575
581
|
* @private
|
|
576
582
|
*/
|
|
577
|
-
function getSelectorThemeOverride(selectors) {
|
|
583
|
+
function getSelectorThemeOverride(selectors, extension) {
|
|
578
584
|
const override = {};
|
|
579
585
|
Object.keys(selectors ?? {}).forEach((selector) => {
|
|
580
586
|
normalizeThemeSelectors(selector).forEach((normalizedSelector) => {
|
|
581
587
|
applySelectorStyle(override, normalizedSelector, selectors[selector]);
|
|
588
|
+
const handler = extension?.selectors?.[normalizedSelector];
|
|
589
|
+
handler && mergeThemeSection(override, extension.section, handler(selectors[selector], themeSelectorReader));
|
|
582
590
|
});
|
|
583
591
|
});
|
|
584
592
|
return override;
|
|
@@ -586,13 +594,14 @@ function getSelectorThemeOverride(selectors) {
|
|
|
586
594
|
/**
|
|
587
595
|
* Resolve user canvas theme override.
|
|
588
596
|
* @param {object} userOverride Canvas theme override
|
|
597
|
+
* @param {object} extension Theme section of a type added by a module
|
|
589
598
|
* @returns {object} Canvas theme override
|
|
590
599
|
* @private
|
|
591
600
|
*/
|
|
592
|
-
function getThemeOverride(userOverride) {
|
|
601
|
+
function getThemeOverride(userOverride, extension) {
|
|
593
602
|
if (!userOverride) return {};
|
|
594
603
|
const { selectors, ...styleOverride } = userOverride;
|
|
595
|
-
return mergeObj({}, getSelectorThemeOverride(selectors), styleOverride);
|
|
604
|
+
return mergeObj({}, getSelectorThemeOverride(selectors, extension), styleOverride);
|
|
596
605
|
}
|
|
597
606
|
/**
|
|
598
607
|
* Build a stable enough cache key for theme reloads.
|
|
@@ -622,14 +631,17 @@ var CanvasTheme = class {
|
|
|
622
631
|
cacheKey = null;
|
|
623
632
|
gridLineSelectorOverrides = [];
|
|
624
633
|
directGridOverrideKeys = /* @__PURE__ */ new Set();
|
|
634
|
+
extension;
|
|
625
635
|
/**
|
|
626
636
|
* Read theme values from temporary SVG probes.
|
|
627
637
|
* @param {HTMLElement} container Chart container
|
|
628
638
|
* @param {object} userOverride Canvas theme override
|
|
639
|
+
* @param {object} extension Theme section of a type added by a module
|
|
629
640
|
* @private
|
|
630
641
|
*/
|
|
631
|
-
load(container, userOverride) {
|
|
642
|
+
load(container, userOverride, extension) {
|
|
632
643
|
const svg = doc.createElementNS(SVG_NS, "svg");
|
|
644
|
+
extension && (this.extension = extension);
|
|
633
645
|
this.gridLineSelectorOverrides = getGridLineSelectorOverrides(userOverride?.selectors);
|
|
634
646
|
this.directGridOverrideKeys = new Set(Object.keys(userOverride?.grid ?? {}));
|
|
635
647
|
svg.setAttribute("class", "bb");
|
|
@@ -881,7 +893,15 @@ var CanvasTheme = class {
|
|
|
881
893
|
color: toColor(title.fill, "#000")
|
|
882
894
|
}
|
|
883
895
|
};
|
|
884
|
-
const
|
|
896
|
+
const ext = this.extension;
|
|
897
|
+
ext && (defaultStyle[ext.section] = ext.probe({
|
|
898
|
+
probeIn,
|
|
899
|
+
probeInNested,
|
|
900
|
+
axisFont: axisText.font || "10px sans-serif",
|
|
901
|
+
toColor,
|
|
902
|
+
toNumber
|
|
903
|
+
}));
|
|
904
|
+
const themeOverride = getThemeOverride(userOverride, ext);
|
|
885
905
|
const style = mergeObj(defaultStyle, themeOverride);
|
|
886
906
|
const userAxisOverride = userOverride?.axis;
|
|
887
907
|
const hasUserAxisLabelColor = !!userAxisOverride && Object.prototype.hasOwnProperty.call(userAxisOverride, "labelColor");
|
|
@@ -934,6 +954,7 @@ var CanvasTheme = class {
|
|
|
934
954
|
style.subchartBrush.handleOpacity = toNumber(style.subchartBrush.handleOpacity, defaultStyle.subchartBrush.handleOpacity);
|
|
935
955
|
style.subchartBrush.handleLineWidth = toNumber(style.subchartBrush.handleLineWidth, defaultStyle.subchartBrush.handleLineWidth);
|
|
936
956
|
style.treemap.lineWidth = toNumber(style.treemap.lineWidth, defaultStyle.treemap.lineWidth);
|
|
957
|
+
ext?.normalize?.(style[ext.section], { toNumber });
|
|
937
958
|
this.style = style;
|
|
938
959
|
this.cacheContainer = container;
|
|
939
960
|
this.cacheKey = getThemeCacheKey(container, userOverride);
|
|
@@ -968,5 +989,4 @@ var CanvasTheme = class {
|
|
|
968
989
|
return getDefinedKeys(style).length ? style : void 0;
|
|
969
990
|
}
|
|
970
991
|
};
|
|
971
|
-
//#endregion
|
|
972
992
|
export { CanvasTheme as default };
|