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
|
@@ -0,0 +1,190 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*
|
|
5
|
+
* billboard.js, JavaScript chart library
|
|
6
|
+
* https://naver.github.io/billboard.js/
|
|
7
|
+
*
|
|
8
|
+
* @version 4.2.0-next.1
|
|
9
|
+
*/
|
|
10
|
+
import { window as win } from "../module/browser.js";
|
|
11
|
+
// src/canvas/flow.ts
|
|
12
|
+
/**
|
|
13
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
14
|
+
* billboard.js project is licensed under the MIT license
|
|
15
|
+
*/
|
|
16
|
+
const CANVAS_FLOW_ANIMATION_MAX_VALUES = 1e5;
|
|
17
|
+
/**
|
|
18
|
+
* Get current animation timestamp.
|
|
19
|
+
* @returns {number} Timestamp
|
|
20
|
+
* @private
|
|
21
|
+
*/
|
|
22
|
+
function getCanvasAnimationTime() {
|
|
23
|
+
return win.performance?.now?.() ?? Date.now();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* Check whether a domain can be interpolated for canvas flow.
|
|
27
|
+
* @param {Array} domain Domain values
|
|
28
|
+
* @param {boolean} isLog Whether the domain is in log scale
|
|
29
|
+
* @returns {boolean} Whether domain is numeric/date-like
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
function isCanvasFlowDomain(domain, isLog = false) {
|
|
33
|
+
return Array.isArray(domain) && domain.length >= 2 && domain.every((v) => Number.isFinite(+v) && (!isLog || +v > 0));
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Interpolate numeric/date domain values.
|
|
37
|
+
* @param {Array} start Start domain
|
|
38
|
+
* @param {Array} end End domain
|
|
39
|
+
* @param {number} ratio Interpolation ratio
|
|
40
|
+
* @param {boolean} isLog Whether to interpolate in log space
|
|
41
|
+
* @returns {Array} Interpolated domain
|
|
42
|
+
* @private
|
|
43
|
+
*/
|
|
44
|
+
function interpolateCanvasFlowDomain(start, end, ratio, isLog = false) {
|
|
45
|
+
return start.slice(0, 2).map((value, index) => {
|
|
46
|
+
const next = isLog ? Math.exp(Math.log(+value) + (Math.log(+end[index]) - Math.log(+value)) * ratio) : +value + (+end[index] - +value) * ratio;
|
|
47
|
+
return value instanceof Date || end[index] instanceof Date ? new Date(next) : next;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Count current canvas flow values.
|
|
52
|
+
* @param {object} $$ ChartInternal instance
|
|
53
|
+
* @returns {number} Total values
|
|
54
|
+
* @private
|
|
55
|
+
*/
|
|
56
|
+
function getCanvasFlowValueCount($$) {
|
|
57
|
+
return $$.data.targets.reduce((sum, target) => sum + target.values.length, 0);
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sync y/y2 domains for canvas flow frames after data has been appended.
|
|
61
|
+
* @param {object} $$ ChartInternal instance
|
|
62
|
+
* @private
|
|
63
|
+
*/
|
|
64
|
+
function syncCanvasFlowYDomains($$) {
|
|
65
|
+
const { scale } = $$;
|
|
66
|
+
const targetsToShow = $$.filterTargetsToShow($$.data.targets);
|
|
67
|
+
["y", "y2"].forEach((key) => {
|
|
68
|
+
scale[key]?.domain($$.getYDomain(targetsToShow, key));
|
|
69
|
+
});
|
|
70
|
+
$$.withSubchartTypeContext(() => {
|
|
71
|
+
scale.subY?.domain($$.getYDomain(targetsToShow, "y"));
|
|
72
|
+
scale.subY2?.domain($$.getYDomain(targetsToShow, "y2"));
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Canvas drawing of chart.flow(): animates the x domain, then commits the final data window.
|
|
77
|
+
* Added to the chart by flow(): bundles without the module do not carry it.
|
|
78
|
+
* @private
|
|
79
|
+
*/
|
|
80
|
+
var flow_default = {
|
|
81
|
+
/**
|
|
82
|
+
* Show the focus and tooltip of the data the flow moved under the pointer.
|
|
83
|
+
* @private
|
|
84
|
+
*/
|
|
85
|
+
updateCanvasFlowFocus() {
|
|
86
|
+
const $$ = this;
|
|
87
|
+
const { state } = $$;
|
|
88
|
+
state.canvasFocusKey = null;
|
|
89
|
+
$$.$el.tooltip?.style("display") === "block" && state.event && $$.onCanvasMouseMove(state.event);
|
|
90
|
+
},
|
|
91
|
+
/**
|
|
92
|
+
* Finish a pending canvas flow animation before accepting another flow mutation.
|
|
93
|
+
* @private
|
|
94
|
+
*/
|
|
95
|
+
flushCanvasFlow() {
|
|
96
|
+
const { state } = this;
|
|
97
|
+
if (!state.canvasFlowFinish) return;
|
|
98
|
+
state.canvasFlowFrame !== null && win.cancelAnimationFrame?.(state.canvasFlowFrame);
|
|
99
|
+
state.canvasFlowFrame = null;
|
|
100
|
+
state.canvasFlowFinish();
|
|
101
|
+
},
|
|
102
|
+
/**
|
|
103
|
+
* Animate canvas flow by interpolating the x domain, then commit the final data window.
|
|
104
|
+
* @param {object} flow Flow metadata
|
|
105
|
+
* @returns {boolean} Whether animation was started
|
|
106
|
+
* @private
|
|
107
|
+
*/
|
|
108
|
+
animateCanvasFlow(flow) {
|
|
109
|
+
const $$ = this;
|
|
110
|
+
const { axis, data, org, scale, state } = $$;
|
|
111
|
+
const { done = () => {}, duration, length, orgDataCount } = flow;
|
|
112
|
+
const requestFrame = win.requestAnimationFrame?.bind(win);
|
|
113
|
+
const isLog = !!axis.isLog?.("x");
|
|
114
|
+
if (!requestFrame || !duration || !length || !orgDataCount || getCanvasFlowValueCount($$) > CANVAS_FLOW_ANIMATION_MAX_VALUES) return false;
|
|
115
|
+
const startDomain = scale.x.domain().slice(0, 2);
|
|
116
|
+
const startOrgDomain = org.xDomain?.slice?.();
|
|
117
|
+
const startSubXDomain = scale.subX?.domain?.().slice?.();
|
|
118
|
+
const focusData = state.canvasFocusKey ? state.canvasFocusData : null;
|
|
119
|
+
if (!isCanvasFlowDomain(startDomain, isLog)) return false;
|
|
120
|
+
const removed = data.targets.map((target) => target.values.splice(0, length));
|
|
121
|
+
$$.updateXDomain($$.filterTargetsToShow(data.targets), true, true);
|
|
122
|
+
const endDomain = scale.x.domain().slice(0, 2);
|
|
123
|
+
const endOrgDomain = org.xDomain?.slice?.();
|
|
124
|
+
data.targets.forEach((target, index) => {
|
|
125
|
+
target.values.unshift(...removed[index]);
|
|
126
|
+
});
|
|
127
|
+
if (!isCanvasFlowDomain(endDomain, isLog)) {
|
|
128
|
+
startOrgDomain && (org.xDomain = startOrgDomain);
|
|
129
|
+
scale.x.domain(startDomain);
|
|
130
|
+
startSubXDomain && scale.subX.domain(startSubXDomain);
|
|
131
|
+
axis.x.scale(scale.x);
|
|
132
|
+
return false;
|
|
133
|
+
}
|
|
134
|
+
syncCanvasFlowYDomains($$);
|
|
135
|
+
let finished = false;
|
|
136
|
+
const started = getCanvasAnimationTime();
|
|
137
|
+
const finish = () => {
|
|
138
|
+
if (finished) return;
|
|
139
|
+
finished = true;
|
|
140
|
+
data.targets.forEach((target) => {
|
|
141
|
+
target.values.splice(0, length);
|
|
142
|
+
});
|
|
143
|
+
endOrgDomain && (org.xDomain = endOrgDomain);
|
|
144
|
+
scale.x.domain(endDomain);
|
|
145
|
+
scale.subX?.domain?.(endOrgDomain ?? endDomain);
|
|
146
|
+
axis.x.scale(scale.x);
|
|
147
|
+
state.dirty.data = true;
|
|
148
|
+
state._eventRectFingerprint = null;
|
|
149
|
+
state.canvasShape = null;
|
|
150
|
+
state._cachedDrawShape = null;
|
|
151
|
+
$$.redraw({
|
|
152
|
+
withLegend: true,
|
|
153
|
+
withTransition: false,
|
|
154
|
+
withTrimXDomain: false,
|
|
155
|
+
withUpdateOrgXDomain: true,
|
|
156
|
+
withUpdateXAxis: true,
|
|
157
|
+
withUpdateXDomain: true
|
|
158
|
+
});
|
|
159
|
+
$$.updateTypesElements();
|
|
160
|
+
state.canvasFlowFrame = null;
|
|
161
|
+
state.canvasFlowFinish = null;
|
|
162
|
+
state.flowing = false;
|
|
163
|
+
$$.updateCanvasFlowFocus();
|
|
164
|
+
done.call($$.api);
|
|
165
|
+
};
|
|
166
|
+
const render = (timestamp) => {
|
|
167
|
+
const ratio = Math.min(1, Math.max(0, (timestamp - started) / duration));
|
|
168
|
+
const domain = interpolateCanvasFlowDomain(startDomain, endDomain, ratio, isLog);
|
|
169
|
+
scale.x.domain(domain);
|
|
170
|
+
axis.x.scale(scale.x);
|
|
171
|
+
state.canvasShape = null;
|
|
172
|
+
state._cachedDrawShape = null;
|
|
173
|
+
state._canvasVisibleRangeCache = null;
|
|
174
|
+
state._canvasXTickValuesCache = null;
|
|
175
|
+
$$.renderCanvasFrame(void 0, focusData, false);
|
|
176
|
+
if (ratio < 1) state.canvasFlowFrame = requestFrame(render);
|
|
177
|
+
else finish();
|
|
178
|
+
};
|
|
179
|
+
startOrgDomain && (org.xDomain = startOrgDomain);
|
|
180
|
+
scale.x.domain(startDomain);
|
|
181
|
+
startSubXDomain && scale.subX.domain(startSubXDomain);
|
|
182
|
+
axis.x.scale(scale.x);
|
|
183
|
+
state.flowing = true;
|
|
184
|
+
state.cancelClick = true;
|
|
185
|
+
state.canvasFlowFinish = finish;
|
|
186
|
+
state.canvasFlowFrame = requestFrame(render);
|
|
187
|
+
return true;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
export { flow_default as default };
|
|
@@ -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 { getCandlestickGeometry, getRenderRect } from "../ChartInternal/shape/core/geometry.js";
|
|
11
11
|
import { isFiniteCanvasCoordinate } from "./util.js";
|
|
12
|
-
|
|
12
|
+
// src/canvas/geometry.ts
|
|
13
13
|
/**
|
|
14
14
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
15
15
|
* billboard.js project is licensed under the MIT license
|
|
@@ -50,5 +50,4 @@ function getCanvasCandlestickGeometry($$, getPoints, d, index) {
|
|
|
50
50
|
wickEnd
|
|
51
51
|
} : null;
|
|
52
52
|
}
|
|
53
|
-
//#endregion
|
|
54
53
|
export { getCanvasBarGeometry, getCanvasCandlestickGeometry };
|
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*
|
|
5
|
+
* billboard.js, JavaScript chart library
|
|
6
|
+
* https://naver.github.io/billboard.js/
|
|
7
|
+
*
|
|
8
|
+
* @version 4.2.0-next.1
|
|
9
|
+
*/
|
|
10
|
+
import { getXTickValues, getYGridTickValues, normalizeYValue } from "./axisTicks.js";
|
|
11
|
+
import { getXPosition, isDrawable } from "./CanvasAxisRenderer.js";
|
|
12
|
+
// src/canvas/grid.ts
|
|
13
|
+
/**
|
|
14
|
+
* Convert resolved grid line style to painter line style.
|
|
15
|
+
* @param {object} style Grid line style
|
|
16
|
+
* @returns {object|undefined} Canvas line style
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
function getGridLineCanvasStyle(style) {
|
|
20
|
+
return style ? {
|
|
21
|
+
stroke: style.lineColor,
|
|
22
|
+
lineWidth: style.lineWidth,
|
|
23
|
+
lineDash: style.dashArray
|
|
24
|
+
} : void 0;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Convert resolved grid text style to painter text style.
|
|
28
|
+
* @param {object} style Grid text style
|
|
29
|
+
* @returns {object|undefined} Canvas text style
|
|
30
|
+
* @private
|
|
31
|
+
*/
|
|
32
|
+
function getGridTextCanvasStyle(style) {
|
|
33
|
+
return style ? {
|
|
34
|
+
fill: style.labelColor,
|
|
35
|
+
font: style.labelFont
|
|
36
|
+
} : void 0;
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Get a text position along a grid line.
|
|
40
|
+
* @param {string} position Grid label position
|
|
41
|
+
* @param {number} start Start coordinate
|
|
42
|
+
* @param {number} end End coordinate
|
|
43
|
+
* @returns {number} Label coordinate
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
function getLineTextPosition(position, start, end) {
|
|
47
|
+
if (position === "start") return start + 4;
|
|
48
|
+
if (position === "middle") return (start + end) / 2;
|
|
49
|
+
return end - 4;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Get a text position for labels drawn with SVG-compatible rotate(-90).
|
|
53
|
+
* @param {string} position Grid label position
|
|
54
|
+
* @param {number} start Start coordinate
|
|
55
|
+
* @param {number} end End coordinate
|
|
56
|
+
* @returns {number} Label coordinate
|
|
57
|
+
* @private
|
|
58
|
+
*/
|
|
59
|
+
function getRotatedLineTextPosition(position, start, end) {
|
|
60
|
+
if (position === "start") return end - 4;
|
|
61
|
+
if (position === "middle") return (start + end) / 2;
|
|
62
|
+
return start + 4;
|
|
63
|
+
}
|
|
64
|
+
/**
|
|
65
|
+
* Draw configured x/y grid lines and labels.
|
|
66
|
+
* @param {CanvasAxisRenderer} renderer Canvas axis renderer
|
|
67
|
+
* @param {object} $$ ChartInternal instance
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
function drawGridLines(renderer, $$) {
|
|
71
|
+
const { ctx, painter, theme: { style: { axis, grid } } } = renderer;
|
|
72
|
+
const { config, scale, state: { height, margin, width } } = $$;
|
|
73
|
+
const isRotated = config.axis_rotated;
|
|
74
|
+
const x1 = margin.left;
|
|
75
|
+
const x2 = margin.left + width;
|
|
76
|
+
const y1 = margin.top;
|
|
77
|
+
const y2 = margin.top + height;
|
|
78
|
+
if (!grid.lineColor) return;
|
|
79
|
+
painter.withState(() => {
|
|
80
|
+
ctx.strokeStyle = grid.lineColor;
|
|
81
|
+
ctx.lineWidth = grid.lineWidth;
|
|
82
|
+
ctx.font = grid.labelFont || axis.labelFont;
|
|
83
|
+
ctx.fillStyle = grid.labelColor;
|
|
84
|
+
ctx.textBaseline = "middle";
|
|
85
|
+
ctx.setLineDash([]);
|
|
86
|
+
const drawLabel = (text, x, y, rotated = false, style) => {
|
|
87
|
+
if (!text) return;
|
|
88
|
+
painter.text(text, x, y, {
|
|
89
|
+
...style,
|
|
90
|
+
angle: rotated ? -90 : 0
|
|
91
|
+
});
|
|
92
|
+
};
|
|
93
|
+
const drawLine = (line, axisId, draw) => {
|
|
94
|
+
const style = getGridLineCanvasStyle(renderer.theme.getGridLineStyle(axisId, line, "line"));
|
|
95
|
+
painter.strokePath(draw, style);
|
|
96
|
+
};
|
|
97
|
+
const getTextStyle = (axisId, line) => getGridTextCanvasStyle(renderer.theme.getGridLineStyle(axisId, line, "text"));
|
|
98
|
+
const drawXLine = (line) => {
|
|
99
|
+
if (line.value === void 0 || !scale.x) return;
|
|
100
|
+
const pos = getXPosition($$, line.value);
|
|
101
|
+
if (!isDrawable(pos)) return;
|
|
102
|
+
if (isRotated) {
|
|
103
|
+
const y = margin.top + pos;
|
|
104
|
+
drawLine(line, "x", () => {
|
|
105
|
+
painter.traceLine(x1, y, x2, y);
|
|
106
|
+
});
|
|
107
|
+
ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
|
|
108
|
+
drawLabel(line.text, getLineTextPosition(line.position, x1, x2), y - 5, false, getTextStyle("x", line));
|
|
109
|
+
} else {
|
|
110
|
+
const x = margin.left + pos;
|
|
111
|
+
drawLine(line, "x", () => {
|
|
112
|
+
painter.traceLine(x, y1, x, y2);
|
|
113
|
+
});
|
|
114
|
+
ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
|
|
115
|
+
drawLabel(line.text, x - 5, getRotatedLineTextPosition(line.position, y1, y2), true, getTextStyle("x", line));
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const drawYLine = (line) => {
|
|
119
|
+
const targetScale = line.axis === "y2" ? scale.y2 : scale.y;
|
|
120
|
+
const axisId = line.axis === "y2" ? "y2" : "y";
|
|
121
|
+
if (line.value === void 0 || !targetScale) return;
|
|
122
|
+
const pos = targetScale(normalizeYValue($$, line.value, axisId));
|
|
123
|
+
if (!isDrawable(pos)) return;
|
|
124
|
+
if (isRotated) {
|
|
125
|
+
const x = margin.left + pos;
|
|
126
|
+
drawLine(line, "y", () => {
|
|
127
|
+
painter.traceLine(x, y1, x, y2);
|
|
128
|
+
});
|
|
129
|
+
ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
|
|
130
|
+
drawLabel(line.text, x - 5, getRotatedLineTextPosition(line.position, y1, y2), true, getTextStyle("y", line));
|
|
131
|
+
} else {
|
|
132
|
+
const y = margin.top + pos;
|
|
133
|
+
drawLine(line, "y", () => {
|
|
134
|
+
painter.traceLine(x1, y, x2, y);
|
|
135
|
+
});
|
|
136
|
+
ctx.textAlign = line.position === "start" ? "left" : line.position === "middle" ? "center" : "right";
|
|
137
|
+
drawLabel(line.text, getLineTextPosition(line.position, x1, x2), y - 5, false, getTextStyle("y", line));
|
|
138
|
+
}
|
|
139
|
+
};
|
|
140
|
+
(config.grid_x_lines || []).forEach(drawXLine);
|
|
141
|
+
(config.grid_y_lines || []).forEach(drawYLine);
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
/**
|
|
145
|
+
* Draw visible grid lines.
|
|
146
|
+
* @param {CanvasAxisRenderer} renderer Canvas axis renderer
|
|
147
|
+
* @param {object} $$ ChartInternal instance
|
|
148
|
+
* @private
|
|
149
|
+
*/
|
|
150
|
+
function drawGrid(renderer, $$) {
|
|
151
|
+
const { ctx, painter, theme: { style: { grid } } } = renderer;
|
|
152
|
+
const { config, scale, state: { height, margin, width } } = $$;
|
|
153
|
+
if (!grid.lineColor) return;
|
|
154
|
+
const isRotated = config.axis_rotated;
|
|
155
|
+
const x1 = margin.left;
|
|
156
|
+
const x2 = margin.left + width;
|
|
157
|
+
const y1 = margin.top;
|
|
158
|
+
const y2 = margin.top + height;
|
|
159
|
+
painter.withState(() => {
|
|
160
|
+
ctx.strokeStyle = grid.lineColor;
|
|
161
|
+
ctx.lineWidth = grid.lineWidth;
|
|
162
|
+
grid.dashArray.length && ctx.setLineDash(grid.dashArray);
|
|
163
|
+
if (config.grid_x_show && scale.x) painter.strokePath(() => {
|
|
164
|
+
for (const tick of getXTickValues($$)) {
|
|
165
|
+
const pos = getXPosition($$, tick);
|
|
166
|
+
if (!isDrawable(pos)) continue;
|
|
167
|
+
if (isRotated) painter.traceCrispLine(x1, margin.top + pos, x2, margin.top + pos, grid.lineWidth);
|
|
168
|
+
else painter.traceCrispLine(margin.left + pos, y1, margin.left + pos, y2, grid.lineWidth);
|
|
169
|
+
}
|
|
170
|
+
});
|
|
171
|
+
if (config.grid_y_show && scale.y) painter.strokePath(() => {
|
|
172
|
+
for (const tick of getYGridTickValues($$)) {
|
|
173
|
+
const value = normalizeYValue($$, tick);
|
|
174
|
+
const pos = scale.y(value);
|
|
175
|
+
if (!isDrawable(pos)) continue;
|
|
176
|
+
if (isRotated) painter.traceCrispLine(margin.left + pos, y1, margin.left + pos, y2, grid.lineWidth);
|
|
177
|
+
else painter.traceCrispLine(x1, margin.top + pos, x2, margin.top + pos, grid.lineWidth);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
!config.grid_lines_front && drawGridLines(renderer, $$);
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
/**
|
|
184
|
+
* Canvas drawing of the grid lines and the grid line labels.
|
|
185
|
+
* Added to the chart by grid(): bundles without the module do not carry it.
|
|
186
|
+
* The functions are called with the chart (ChartInternal) as `this`.
|
|
187
|
+
*/
|
|
188
|
+
var grid_default = {
|
|
189
|
+
/**
|
|
190
|
+
* Draw visible grid lines.
|
|
191
|
+
* @param {CanvasAxisRenderer} renderer Canvas axis renderer
|
|
192
|
+
* @private
|
|
193
|
+
*/
|
|
194
|
+
draw(renderer) {
|
|
195
|
+
drawGrid(renderer, this);
|
|
196
|
+
},
|
|
197
|
+
/**
|
|
198
|
+
* Draw configured x/y grid lines and labels.
|
|
199
|
+
* @param {CanvasAxisRenderer} renderer Canvas axis renderer
|
|
200
|
+
* @private
|
|
201
|
+
*/
|
|
202
|
+
drawLines(renderer) {
|
|
203
|
+
drawGridLines(renderer, this);
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
export { grid_default as default };
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
/*!
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*
|
|
5
|
+
* billboard.js, JavaScript chart library
|
|
6
|
+
* https://naver.github.io/billboard.js/
|
|
7
|
+
*
|
|
8
|
+
* @version 4.2.0-next.1
|
|
9
|
+
*/
|
|
10
|
+
// src/canvas/heatmap.ts
|
|
11
|
+
const heatmapTheme = {
|
|
12
|
+
section: "heatmap",
|
|
13
|
+
probe({ probeIn, axisFont, toColor }) {
|
|
14
|
+
const axis = probeIn("bb-chart-heatmap", "text", "bb-heatmap-axis", ["fill", "font"]);
|
|
15
|
+
const label = probeIn("bb-chart-heatmap", "text", "bb-heatmap-label", ["font"]);
|
|
16
|
+
return {
|
|
17
|
+
axisFont: axis.font || axisFont,
|
|
18
|
+
axisColor: toColor(axis.fill, "#000"),
|
|
19
|
+
labelFont: label.font || axisFont
|
|
20
|
+
};
|
|
21
|
+
},
|
|
22
|
+
selectors: {
|
|
23
|
+
".bb-heatmap-axis": (style, { readColorValue, readFontValue }) => ({
|
|
24
|
+
axisColor: readColorValue(style, "fill"),
|
|
25
|
+
axisFont: readFontValue(style)
|
|
26
|
+
}),
|
|
27
|
+
".bb-heatmap-label": (style, { readFontValue }) => ({ labelFont: readFontValue(style) })
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
const BASELINE_DY = {
|
|
31
|
+
middle: .35,
|
|
32
|
+
top: .71,
|
|
33
|
+
bottom: 0
|
|
34
|
+
};
|
|
35
|
+
/**
|
|
36
|
+
* Draw a text at the place the SVG text is: on the alphabetic baseline, moved by the same dy.
|
|
37
|
+
* The baselines of canvas (the box of the font) are not the ones of SVG, and differ by a pixel or two.
|
|
38
|
+
* @param {CanvasRenderer} renderer Canvas renderer
|
|
39
|
+
* @param {object} d Text with its position, alignment and baseline
|
|
40
|
+
* @param {object} style Font, color and alpha
|
|
41
|
+
* @param {string} style.font Font of the text
|
|
42
|
+
* @param {string} style.fill Color of the text
|
|
43
|
+
* @param {number} [style.alpha] Opacity of the text
|
|
44
|
+
* @private
|
|
45
|
+
*/
|
|
46
|
+
function drawText(renderer, d, style) {
|
|
47
|
+
const size = parseFloat(/(\d+(?:\.\d+)?)px/.exec(style.font)?.[1] ?? "10");
|
|
48
|
+
renderer.painter.text(d.text, d.x, d.y + BASELINE_DY[d.baseline] * size, {
|
|
49
|
+
...style,
|
|
50
|
+
textAlign: d.align,
|
|
51
|
+
textBaseline: "alphabetic"
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Canvas drawing, hit detection and theme of the heatmap type.
|
|
56
|
+
* Added to the chart by heatmap(): bundles without heatmap do not carry it.
|
|
57
|
+
*/
|
|
58
|
+
var heatmap_default = {
|
|
59
|
+
theme: heatmapTheme,
|
|
60
|
+
/**
|
|
61
|
+
* Draw the cells, the names and the color bar on canvas.
|
|
62
|
+
* Layout comes from the shared heatmap layout, same as SVG rendering.
|
|
63
|
+
* @param {CanvasRenderer} renderer Canvas renderer
|
|
64
|
+
* @private
|
|
65
|
+
*/
|
|
66
|
+
draw(renderer) {
|
|
67
|
+
const $$ = this;
|
|
68
|
+
const { painter, theme: { style: { heatmap, shape } } } = renderer;
|
|
69
|
+
const { config } = $$;
|
|
70
|
+
const { cells, axisX, axisY, colorbar } = $$.getHeatmapLayout();
|
|
71
|
+
const radius = config.heatmap_cell_radius;
|
|
72
|
+
const borderWidth = config.heatmap_cell_border_width;
|
|
73
|
+
cells.forEach((d) => {
|
|
74
|
+
const rect = {
|
|
75
|
+
x: d.x0,
|
|
76
|
+
y: d.y0,
|
|
77
|
+
w: Math.max(0, d.x1 - d.x0),
|
|
78
|
+
h: Math.max(0, d.y1 - d.y0)
|
|
79
|
+
};
|
|
80
|
+
const alpha = $$.isHeatmapDefocused(d.id) ? shape.targetDefocusedOpacity : 1;
|
|
81
|
+
painter.fillRoundRect(rect, radius, {
|
|
82
|
+
fill: d.color,
|
|
83
|
+
alpha
|
|
84
|
+
});
|
|
85
|
+
borderWidth && painter.strokeRoundRect(rect, radius, {
|
|
86
|
+
stroke: config.heatmap_cell_border_color,
|
|
87
|
+
lineWidth: borderWidth,
|
|
88
|
+
alpha
|
|
89
|
+
});
|
|
90
|
+
const text = $$.getHeatmapLabel(d);
|
|
91
|
+
text && drawText(renderer, {
|
|
92
|
+
text,
|
|
93
|
+
x: (d.x0 + d.x1) / 2,
|
|
94
|
+
y: (d.y0 + d.y1) / 2,
|
|
95
|
+
align: "center",
|
|
96
|
+
baseline: "middle"
|
|
97
|
+
}, {
|
|
98
|
+
fill: $$.getHeatmapLabelColor(d),
|
|
99
|
+
alpha,
|
|
100
|
+
font: heatmap.labelFont
|
|
101
|
+
});
|
|
102
|
+
});
|
|
103
|
+
const drawName = (d) => drawText(renderer, d, {
|
|
104
|
+
fill: heatmap.axisColor,
|
|
105
|
+
font: heatmap.axisFont
|
|
106
|
+
});
|
|
107
|
+
axisX.forEach(drawName);
|
|
108
|
+
axisY.forEach(drawName);
|
|
109
|
+
if (colorbar) {
|
|
110
|
+
const { x, y, width, height, stops, horizontal } = colorbar;
|
|
111
|
+
const gradient = horizontal ? painter.context.createLinearGradient(x, 0, x + width, 0) : painter.context.createLinearGradient(0, y, 0, y + height);
|
|
112
|
+
stops.forEach(([offset, color]) => gradient.addColorStop(offset, color));
|
|
113
|
+
painter.fillRect({
|
|
114
|
+
x,
|
|
115
|
+
y,
|
|
116
|
+
w: width,
|
|
117
|
+
h: height
|
|
118
|
+
}, { fill: gradient });
|
|
119
|
+
colorbar.labels.forEach(drawName);
|
|
120
|
+
}
|
|
121
|
+
$$.fitHeatmapHeight();
|
|
122
|
+
},
|
|
123
|
+
/**
|
|
124
|
+
* Add the hit items of the cells that have a value.
|
|
125
|
+
* @param {HitDetector} detector Hit detector
|
|
126
|
+
* @private
|
|
127
|
+
*/
|
|
128
|
+
hits(detector) {
|
|
129
|
+
const $$ = this;
|
|
130
|
+
$$.getHeatmapLayout().cells.forEach((d) => {
|
|
131
|
+
d.value !== null && detector.addBar({
|
|
132
|
+
x: d.x0,
|
|
133
|
+
y: d.y0,
|
|
134
|
+
w: Math.max(1, d.x1 - d.x0),
|
|
135
|
+
h: Math.max(1, d.y1 - d.y0),
|
|
136
|
+
data: $$.getHeatmapCellData(d)
|
|
137
|
+
});
|
|
138
|
+
});
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
export { heatmap_default as default };
|
|
@@ -5,12 +5,12 @@
|
|
|
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 { isFunction, isNumber, isObject, isString } from "../module/util/type-checks.js";
|
|
11
11
|
import { parseShorthand, tplProcess } from "../module/util/object.js";
|
|
12
12
|
import { getFontSize, isCanvasBubbleType, isCanvasCandlestickType, isCanvasLineType, isCanvasScatterType } from "./util.js";
|
|
13
|
-
|
|
13
|
+
// src/canvas/labels.ts
|
|
14
14
|
/**
|
|
15
15
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
16
16
|
* billboard.js project is licensed under the MIT license
|
|
@@ -156,7 +156,7 @@ function getLabelImagePosition($$, option, text, x, y, d) {
|
|
|
156
156
|
*/
|
|
157
157
|
function getLabelColor($$, d, fallback) {
|
|
158
158
|
const color = $$.updateTextColor?.(d);
|
|
159
|
-
return typeof color === "string" ? color : $$.isTreemapType?.(d) ? fallback : $$.color?.(d) || fallback;
|
|
159
|
+
return typeof color === "string" ? color : $$.getCustomTypeHooks?.(d)?.themeTextColor || $$.isTreemapType?.(d) ? fallback : $$.color?.(d) || fallback;
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
162
162
|
* Get canvas fill style for data label background.
|
|
@@ -375,5 +375,4 @@ function getPointLabelAnchor($$, ctx, d, x, y) {
|
|
|
375
375
|
y
|
|
376
376
|
};
|
|
377
377
|
}
|
|
378
|
-
//#endregion
|
|
379
378
|
export { drawLabelDecorations, getCanvasTextAlign, getExpandedFocusMatcher, getLabelBackgroundColor, getLabelBorderOption, getLabelColor, getLabelDecorationBox, getLabelImageOption, getLabelImagePosition, getLabelImageUrl, getLabelPosition, getLabelRotateAnchor, getLabelRowKey, getLabelText, getLabelValue, getPointLabelAnchor, getRotatedLabelPosition };
|
|
@@ -5,12 +5,12 @@
|
|
|
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 { window as win } from "../module/browser.js";
|
|
11
11
|
import { sanitize } from "../module/sanitize.js";
|
|
12
12
|
import { withOpacity } from "./color.js";
|
|
13
|
-
|
|
13
|
+
// src/canvas/pointPattern.ts
|
|
14
14
|
/**
|
|
15
15
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
16
16
|
* billboard.js project is licensed under the MIT license
|
|
@@ -652,5 +652,4 @@ function drawPointPattern(painter, pattern, x, y, r, style, baseR = r) {
|
|
|
652
652
|
shapes.forEach(drawShape);
|
|
653
653
|
});
|
|
654
654
|
}
|
|
655
|
-
//#endregion
|
|
656
655
|
export { drawPointPattern };
|