billboard.js 4.1.4 → 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 +11129 -7032
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +20 -20
- package/dist/billboard.pkgd.js +22703 -14154
- 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 +3 -4
- 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 +15 -9
- 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 +26 -17
- package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +40 -12
- 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 +25 -19
- 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 +13 -13
- 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 +42 -23
- 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 +9 -9
- 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 +15 -11
- package/dist-esm/ChartInternal/shape/treemap.js +8 -5
- package/dist-esm/canvas/CanvasAxisRenderer.js +28 -328
- 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 +6 -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 +4 -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 +113 -900
- 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/chart.ts +2 -1
- package/src/Chart/api/flow.ts +20 -7
- 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 +29 -20
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +45 -9
- 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/flow.ts +50 -19
- 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 +18 -12
- package/src/ChartInternal/internals/size.ts +5 -3
- package/src/ChartInternal/internals/text.ts +24 -28
- package/src/ChartInternal/internals/tooltip.ts +59 -20
- 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/point.ts +6 -3
- package/src/ChartInternal/shape/radar.ts +30 -1
- package/src/ChartInternal/shape/sankey.ts +242 -0
- package/src/ChartInternal/shape/shape.ts +16 -4
- package/src/ChartInternal/shape/treemap.ts +10 -0
- package/src/Plugin/stanford/index.ts +1 -28
- package/src/canvas/CanvasAxisRenderer.ts +54 -596
- 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/interaction/subchart.ts +4 -0
- 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 +2 -1
- package/src/config/classes.ts +0 -1
- package/src/config/const.ts +30 -21
- package/src/config/resolver/canvas.ts +147 -1293
- 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 +13 -1
- package/types/options.shape.d.ts +431 -0
- package/types/types.d.ts +4 -0
|
@@ -0,0 +1,528 @@
|
|
|
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 { getElementPos } from "../../../module/util/dom.js";
|
|
11
|
+
import { isArray, isFunction, isNumber, isObject } from "../../../module/util/type-checks.js";
|
|
12
|
+
import { getTextPos } from "../../internals/text.util.js";
|
|
13
|
+
import { scaleLinear } from "d3-scale";
|
|
14
|
+
// src/ChartInternal/shape/core/bullet.ts
|
|
15
|
+
/**
|
|
16
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
17
|
+
* billboard.js project is licensed under the MIT license
|
|
18
|
+
*/
|
|
19
|
+
const $BULLET = {
|
|
20
|
+
bullet: "bb-bullet",
|
|
21
|
+
chartBullet: "bb-chart-bullet",
|
|
22
|
+
chartBullets: "bb-chart-bullets",
|
|
23
|
+
bulletRange: "bb-bullet-range",
|
|
24
|
+
bulletMeasure: "bb-bullet-measure",
|
|
25
|
+
bulletTarget: "bb-bullet-target",
|
|
26
|
+
bulletAxis: "bb-bullet-axis",
|
|
27
|
+
bulletTitle: "bb-bullet-title"
|
|
28
|
+
};
|
|
29
|
+
const AXIS_EDGE = 16;
|
|
30
|
+
const isValid = (v) => Number.isFinite(v);
|
|
31
|
+
const own = (obj, key) => obj && Object.prototype.hasOwnProperty.call(obj, key) ? obj[key] : void 0;
|
|
32
|
+
/**
|
|
33
|
+
* Get the min and max of the values, and 0.
|
|
34
|
+
* (not Math.min(...values): too many values are too many arguments)
|
|
35
|
+
* @param {Array} values Values
|
|
36
|
+
* @returns {Array} Min and max
|
|
37
|
+
* @private
|
|
38
|
+
*/
|
|
39
|
+
function _getExtent(values) {
|
|
40
|
+
let min = 0;
|
|
41
|
+
let max = 0;
|
|
42
|
+
values.forEach((v) => {
|
|
43
|
+
min = Math.min(min, v);
|
|
44
|
+
max = Math.max(max, v);
|
|
45
|
+
});
|
|
46
|
+
return [min, max];
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Get the title text of the given bullet row
|
|
50
|
+
* @param {string} id Data id
|
|
51
|
+
* @param {number} value Measure value
|
|
52
|
+
* @returns {string} Title text
|
|
53
|
+
* @private
|
|
54
|
+
*/
|
|
55
|
+
function _getTitleText(id, value) {
|
|
56
|
+
const { config, api } = this;
|
|
57
|
+
const text = config.bullet_title_text;
|
|
58
|
+
let resolved;
|
|
59
|
+
if (isFunction(text)) resolved = text.call(api, id, value);
|
|
60
|
+
else if (isObject(text)) resolved = own(text, id);
|
|
61
|
+
return String(resolved ?? own(config.data_names, id) ?? id);
|
|
62
|
+
}
|
|
63
|
+
/**
|
|
64
|
+
* Get the space the titles of the rows take: the width of the widest one (horizontal),
|
|
65
|
+
* or the height of the line under the columns (rotated)
|
|
66
|
+
* @param {Array} rows Bullet rows
|
|
67
|
+
* @returns {number} Size in px
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
function _getTitleSize(rows) {
|
|
71
|
+
const $$ = this;
|
|
72
|
+
const { config, cache, state: { isCanvasMode }, $el } = $$;
|
|
73
|
+
if (config.bullet_rotated) return 18;
|
|
74
|
+
const titles = rows.map((d) => d.title);
|
|
75
|
+
const key = `bullet-title-${isCanvasMode}-${titles.join("\0")}`;
|
|
76
|
+
let width = cache.get(key) || 0;
|
|
77
|
+
if (!width && isCanvasMode && $$.canvasRenderer) {
|
|
78
|
+
const { ctx } = $$.canvasRenderer;
|
|
79
|
+
ctx.save();
|
|
80
|
+
ctx.font = $$.canvasTheme.style.bullet.titleFont;
|
|
81
|
+
width = titles.reduce((w, v) => Math.max(w, ctx.measureText(v).width), 0);
|
|
82
|
+
ctx.restore();
|
|
83
|
+
} else if (!width && !isCanvasMode && $el.bullet) {
|
|
84
|
+
const text = $el.bullet.append("text").attr("class", $BULLET.bulletTitle).style("visibility", "hidden");
|
|
85
|
+
titles.forEach((v) => {
|
|
86
|
+
width = Math.max(width, text.text(v).node().getComputedTextLength?.() || 0);
|
|
87
|
+
});
|
|
88
|
+
text.remove();
|
|
89
|
+
}
|
|
90
|
+
if (width) cache.add(key, width);
|
|
91
|
+
else width = titles.reduce((n, v) => Math.max(n, v.length), 0) * 6.5;
|
|
92
|
+
return Math.ceil(width) + 8;
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Get the plot area of the bullets
|
|
96
|
+
* @param {Array} rows Bullet rows, when the caller has them already
|
|
97
|
+
* @returns {object} size object
|
|
98
|
+
* @private
|
|
99
|
+
*/
|
|
100
|
+
function _getArea(rows) {
|
|
101
|
+
const $$ = this;
|
|
102
|
+
const { config, state: { current: { width, height }, isCanvasMode, isLegendRight } } = $$;
|
|
103
|
+
const padding = $$.getCurrentPadding();
|
|
104
|
+
const legendHeight = config.legend_show && config.legend_position === "bottom" ? (isCanvasMode ? 0 : $$.getLegendHeight()) + 10 : 0;
|
|
105
|
+
const surfaceHeight = isCanvasMode ? $$.getCanvasSurfaceHeight() : height;
|
|
106
|
+
const edge = config.bullet_axis_show && !config.bullet_rotated ? AXIS_EDGE : 0;
|
|
107
|
+
const legendRight = config.legend_show && isLegendRight ? $$.getLegendWidth() + (config.padding?.mode === "fit" ? 0 : 20) : 0;
|
|
108
|
+
const hasLabel = !config.bullet_rotated && config.bullet_label_show && $$.hasDataLabel();
|
|
109
|
+
const list = hasLabel || config.bullet_title_show ? rows ?? $$.getBulletData() : [];
|
|
110
|
+
const labelRoom = hasLabel && list.some((d) => d.domainMax <= 0 || d.value >= d.domainMax) ? 14 : 0;
|
|
111
|
+
const titleSize = config.bullet_title_show ? _getTitleSize.call($$, list) : 0;
|
|
112
|
+
const titleWidth = config.bullet_rotated ? 0 : titleSize;
|
|
113
|
+
const titleHeight = config.bullet_rotated ? titleSize : 0;
|
|
114
|
+
const top = padding.top + (isCanvasMode ? $$.getCanvasTitleDescent?.() || 0 : 0);
|
|
115
|
+
return {
|
|
116
|
+
width: Math.max(0, width - padding.left - padding.right - edge * 2 - labelRoom - titleWidth - legendRight),
|
|
117
|
+
height: Math.max(0, surfaceHeight - legendHeight - top - padding.bottom - titleHeight),
|
|
118
|
+
left: padding.left + edge + titleWidth,
|
|
119
|
+
top
|
|
120
|
+
};
|
|
121
|
+
}
|
|
122
|
+
/**
|
|
123
|
+
* Get the space (in px) reserved for the axis of each bullet
|
|
124
|
+
* @returns {number} axis size
|
|
125
|
+
* @private
|
|
126
|
+
*/
|
|
127
|
+
function _getAxisSize() {
|
|
128
|
+
const { config } = this;
|
|
129
|
+
return config.bullet_axis_show ? config.bullet_rotated ? 34 : 20 : 0;
|
|
130
|
+
}
|
|
131
|
+
/**
|
|
132
|
+
* Resolve the qualitative range thresholds for the given bullet row
|
|
133
|
+
* @param {string} id Data id
|
|
134
|
+
* @param {number} value Measure value
|
|
135
|
+
* @returns {Array} Ascending range thresholds
|
|
136
|
+
* @private
|
|
137
|
+
*/
|
|
138
|
+
function _getRanges(id, value) {
|
|
139
|
+
const ranges = this.config.bullet_ranges;
|
|
140
|
+
let resolved = [];
|
|
141
|
+
if (isFunction(ranges)) resolved = ranges.call(this.api, id, value) || [];
|
|
142
|
+
else if (isArray(ranges)) resolved = ranges;
|
|
143
|
+
else if (isObject(ranges) && isArray(ranges[id])) resolved = ranges[id];
|
|
144
|
+
return resolved.filter(isValid).sort((a, b) => a - b);
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* Resolve the comparative target values for the given bullet row
|
|
148
|
+
* @param {string} id Data id
|
|
149
|
+
* @param {number} value Measure value
|
|
150
|
+
* @returns {Array} Target values: empty when there is none
|
|
151
|
+
* @private
|
|
152
|
+
*/
|
|
153
|
+
function _getTargets(id, value) {
|
|
154
|
+
const target = this.config.bullet_target;
|
|
155
|
+
let resolved;
|
|
156
|
+
if (isFunction(target)) resolved = target.call(this.api, id, value);
|
|
157
|
+
else if (isArray(target) || isValid(target)) resolved = target;
|
|
158
|
+
else if (isObject(target)) resolved = own(target, id);
|
|
159
|
+
return (isArray(resolved) ? resolved : [resolved]).filter(isValid);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Get the fill color given by bullet.range.colors for the qualitative range band
|
|
163
|
+
* @param {number} index Band index (0 = smallest range)
|
|
164
|
+
* @param {number} length Total number of bands
|
|
165
|
+
* @returns {string|null} Color string, or null to use the default grayscale of the theme
|
|
166
|
+
* @private
|
|
167
|
+
*/
|
|
168
|
+
function _getRangeColor(index, length) {
|
|
169
|
+
const colors = this.config.bullet_range_colors;
|
|
170
|
+
if (isFunction(colors)) return colors.call(this.api, index, length);
|
|
171
|
+
else if (isArray(colors) && colors[index]) return colors[index];
|
|
172
|
+
return null;
|
|
173
|
+
}
|
|
174
|
+
/**
|
|
175
|
+
* Get the axis (scale, ticks, format) for the given domain, shared between rows of same domain.
|
|
176
|
+
* @param {IBulletLayout} layout Bullet layout
|
|
177
|
+
* @param {number} domainMin Domain min value
|
|
178
|
+
* @param {number} domainMax Domain max value
|
|
179
|
+
* @returns {object} Axis
|
|
180
|
+
* @private
|
|
181
|
+
*/
|
|
182
|
+
function _getAxis(layout, domainMin, domainMax) {
|
|
183
|
+
const { config, api } = this;
|
|
184
|
+
const { axes, axisLen, isRotated } = layout;
|
|
185
|
+
const key = `${domainMin}|${domainMax}`;
|
|
186
|
+
let axis = axes.get(key);
|
|
187
|
+
if (!axis) {
|
|
188
|
+
const scale = scaleLinear().domain([domainMin, domainMax]).range(isRotated ? [axisLen, 0] : [0, axisLen]);
|
|
189
|
+
const { bullet_axis_tick_count: tickCount, bullet_axis_tick_values: tickValues, bullet_axis_tick_format: tickFormat } = config;
|
|
190
|
+
const count = isValid(tickCount) && tickCount > 0 ? Math.min(tickCount, Math.max(2, axisLen)) : Math.max(2, Math.floor(axisLen / (isRotated ? 40 : 60)));
|
|
191
|
+
const [min, max] = [domainMin, domainMax];
|
|
192
|
+
const ticks = isArray(tickValues) ? tickValues.filter((v) => isValid(v) && v >= min && v <= max) : scale.ticks(count);
|
|
193
|
+
const format = isFunction(tickFormat) ? (value) => String(tickFormat.call(api, value)) : scale.tickFormat(count);
|
|
194
|
+
axis = {
|
|
195
|
+
scale,
|
|
196
|
+
count,
|
|
197
|
+
ticks,
|
|
198
|
+
format,
|
|
199
|
+
key: `${scale.domain()}|${scale.range()}|${ticks}|${ticks.map(format)}`
|
|
200
|
+
};
|
|
201
|
+
axes.set(key, axis);
|
|
202
|
+
}
|
|
203
|
+
return axis;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* Get the layout shared by all bullet rows. Computed once per draw.
|
|
207
|
+
* @returns {object} Bullet layout
|
|
208
|
+
* @private
|
|
209
|
+
*/
|
|
210
|
+
function _getLayout() {
|
|
211
|
+
const $$ = this;
|
|
212
|
+
const { config } = $$;
|
|
213
|
+
const rows = $$.getBulletData();
|
|
214
|
+
const area = _getArea.call($$, rows);
|
|
215
|
+
const isRotated = config.bullet_rotated;
|
|
216
|
+
const axisSize = _getAxisSize.call($$);
|
|
217
|
+
const band = (isRotated ? area.width : area.height) / (rows.length || 1);
|
|
218
|
+
return {
|
|
219
|
+
rows,
|
|
220
|
+
area,
|
|
221
|
+
isRotated,
|
|
222
|
+
axisSize,
|
|
223
|
+
band,
|
|
224
|
+
bandInner: Math.max(0, band - config.bullet_padding - axisSize),
|
|
225
|
+
axisLen: isRotated ? area.height : area.width,
|
|
226
|
+
axes: /* @__PURE__ */ new Map()
|
|
227
|
+
};
|
|
228
|
+
}
|
|
229
|
+
/**
|
|
230
|
+
* Get the geometry of a single bullet row, relative to the row origin.
|
|
231
|
+
* Shared by the SVG and the canvas renderer.
|
|
232
|
+
* @param {object} d Bullet row data
|
|
233
|
+
* @param {object} layout Bullet layout
|
|
234
|
+
* @returns {object} Row geometry
|
|
235
|
+
* @private
|
|
236
|
+
*/
|
|
237
|
+
function _getRowGeometry(d, layout) {
|
|
238
|
+
const $$ = this;
|
|
239
|
+
const { config } = $$;
|
|
240
|
+
const { area, isRotated, axisSize, band, bandInner, axisLen } = layout;
|
|
241
|
+
const { height, left, top } = area;
|
|
242
|
+
const { domainMin, domainMax } = d;
|
|
243
|
+
const measureThickness = bandInner * config.bullet_width_ratio;
|
|
244
|
+
const targetLen = bandInner * config.bullet_width_target_ratio;
|
|
245
|
+
const scale = (v) => (v - domainMin) / (domainMax - domainMin) * axisLen;
|
|
246
|
+
const pos = (v) => Math.min(Math.max(scale(v), 0), axisLen);
|
|
247
|
+
const zero = pos(0);
|
|
248
|
+
const ranges = d.ranges.map((value, index) => ({
|
|
249
|
+
value,
|
|
250
|
+
index
|
|
251
|
+
})).sort((a, b) => b.value - a.value).map(({ value, index }) => {
|
|
252
|
+
const len = pos(value);
|
|
253
|
+
return {
|
|
254
|
+
...isRotated ? {
|
|
255
|
+
x: 0,
|
|
256
|
+
y: height - len,
|
|
257
|
+
width: bandInner,
|
|
258
|
+
height: len
|
|
259
|
+
} : {
|
|
260
|
+
x: 0,
|
|
261
|
+
y: 0,
|
|
262
|
+
width: len,
|
|
263
|
+
height: bandInner
|
|
264
|
+
},
|
|
265
|
+
fill: _getRangeColor.call($$, index, d.ranges.length),
|
|
266
|
+
t: index / Math.max(d.ranges.length - 1, 1)
|
|
267
|
+
};
|
|
268
|
+
});
|
|
269
|
+
const isDot = config.bullet_type === "dot";
|
|
270
|
+
const markerSize = config.bullet_marker_size || measureThickness / 2;
|
|
271
|
+
const len = pos(d.value);
|
|
272
|
+
const isNegative = d.value < 0;
|
|
273
|
+
let measure;
|
|
274
|
+
if (isDot) measure = {
|
|
275
|
+
cx: isRotated ? bandInner / 2 : len,
|
|
276
|
+
cy: isRotated ? height - len : bandInner / 2,
|
|
277
|
+
r: markerSize
|
|
278
|
+
};
|
|
279
|
+
else {
|
|
280
|
+
const size = Math.abs(len - zero);
|
|
281
|
+
measure = isRotated ? {
|
|
282
|
+
x: (bandInner - measureThickness) / 2,
|
|
283
|
+
y: height - Math.max(zero, len),
|
|
284
|
+
width: measureThickness,
|
|
285
|
+
height: size
|
|
286
|
+
} : {
|
|
287
|
+
x: Math.min(zero, len),
|
|
288
|
+
y: (bandInner - measureThickness) / 2,
|
|
289
|
+
width: size,
|
|
290
|
+
height: measureThickness
|
|
291
|
+
};
|
|
292
|
+
}
|
|
293
|
+
const targets = d.targets.filter((value) => value >= domainMin && value <= domainMax).map((value) => {
|
|
294
|
+
const at = scale(value);
|
|
295
|
+
return isRotated ? {
|
|
296
|
+
x1: (bandInner - targetLen) / 2,
|
|
297
|
+
x2: (bandInner + targetLen) / 2,
|
|
298
|
+
y1: height - at,
|
|
299
|
+
y2: height - at
|
|
300
|
+
} : {
|
|
301
|
+
x1: at,
|
|
302
|
+
x2: at,
|
|
303
|
+
y1: (bandInner - targetLen) / 2,
|
|
304
|
+
y2: (bandInner + targetLen) / 2
|
|
305
|
+
};
|
|
306
|
+
});
|
|
307
|
+
const gap = isDot ? markerSize : 0;
|
|
308
|
+
const labelPos = isNegative ? zero : len;
|
|
309
|
+
const label = {
|
|
310
|
+
...isRotated ? {
|
|
311
|
+
x: bandInner / 2,
|
|
312
|
+
y: height - labelPos - gap - 6
|
|
313
|
+
} : {
|
|
314
|
+
x: labelPos + gap + 5,
|
|
315
|
+
y: bandInner / 2
|
|
316
|
+
},
|
|
317
|
+
center: isDot ? {
|
|
318
|
+
x: measure.cx,
|
|
319
|
+
y: measure.cy
|
|
320
|
+
} : {
|
|
321
|
+
x: measure.x + measure.width / 2,
|
|
322
|
+
y: measure.y + measure.height / 2
|
|
323
|
+
}
|
|
324
|
+
};
|
|
325
|
+
const title = config.bullet_title_show ? isRotated ? {
|
|
326
|
+
text: d.title,
|
|
327
|
+
x: bandInner / 2,
|
|
328
|
+
y: height + 13,
|
|
329
|
+
anchor: "middle"
|
|
330
|
+
} : {
|
|
331
|
+
text: d.title,
|
|
332
|
+
x: -(axisSize ? AXIS_EDGE : 0) - 6,
|
|
333
|
+
y: bandInner / 2,
|
|
334
|
+
anchor: "end"
|
|
335
|
+
} : null;
|
|
336
|
+
return {
|
|
337
|
+
area: {
|
|
338
|
+
left,
|
|
339
|
+
top
|
|
340
|
+
},
|
|
341
|
+
offset: isRotated ? {
|
|
342
|
+
x: d.index * band + axisSize,
|
|
343
|
+
y: 0
|
|
344
|
+
} : {
|
|
345
|
+
x: 0,
|
|
346
|
+
y: d.index * band
|
|
347
|
+
},
|
|
348
|
+
ranges,
|
|
349
|
+
isDot,
|
|
350
|
+
measure,
|
|
351
|
+
color: $$.color(d),
|
|
352
|
+
targets,
|
|
353
|
+
title,
|
|
354
|
+
axis: axisSize ? {
|
|
355
|
+
..._getAxis.call($$, layout, domainMin, domainMax),
|
|
356
|
+
rotated: isRotated,
|
|
357
|
+
x: 0,
|
|
358
|
+
y: isRotated ? 0 : bandInner
|
|
359
|
+
} : null,
|
|
360
|
+
label
|
|
361
|
+
};
|
|
362
|
+
}
|
|
363
|
+
/**
|
|
364
|
+
* How the data labels of a bullet differ from the other types.
|
|
365
|
+
* The shared data label code asks these through `getCustomTypeHooks()`.
|
|
366
|
+
* They are registered with the type name (registerCustomType()).
|
|
367
|
+
* @private
|
|
368
|
+
*/
|
|
369
|
+
const customTypeHooks = {
|
|
370
|
+
ownLegendLayout: true,
|
|
371
|
+
themeTextColor: true,
|
|
372
|
+
textAnchor($$) {
|
|
373
|
+
return $$.config.bullet_rotated || $$.config.data_labels.centered ? "middle" : "start";
|
|
374
|
+
},
|
|
375
|
+
labelData($$, d) {
|
|
376
|
+
const last = d.values[d.values.length - 1];
|
|
377
|
+
return $$.config.bullet_label_show && last && (isNumber(last.value) || Boolean(last.value)) ? [last] : [];
|
|
378
|
+
},
|
|
379
|
+
labelFormat($$) {
|
|
380
|
+
const format = $$.config.bullet_label_format;
|
|
381
|
+
return isFunction(format) ? (value, id) => format.call($$.api, value, id) : void 0;
|
|
382
|
+
},
|
|
383
|
+
tooltipTarget($$, args) {
|
|
384
|
+
const rows = $$.getBulletData().filter((d) => $$.isTargetToShow(d.id));
|
|
385
|
+
const data = args.data?.id ? rows.filter((d) => d.id === args.data.id) : [rows[args.index]].filter(Boolean);
|
|
386
|
+
return {
|
|
387
|
+
data,
|
|
388
|
+
point: data[0] && $$.getBulletMeasureCenter(data[0])
|
|
389
|
+
};
|
|
390
|
+
},
|
|
391
|
+
textX($$, points, d, textElement) {
|
|
392
|
+
return points ? points[$$.config.data_labels.centered ? 1 : 0][0] + getTextPos.call($$, d, "x") : getElementPos(textElement, "x");
|
|
393
|
+
},
|
|
394
|
+
textY($$, points, d, textElement, rect) {
|
|
395
|
+
if (!points) return getElementPos(textElement, "y");
|
|
396
|
+
const centered = $$.config.data_labels.centered;
|
|
397
|
+
const y = points[centered ? 1 : 0][1];
|
|
398
|
+
return (centered || !$$.config.bullet_rotated ? y + rect.height / 2 - 3 : y) + getTextPos.call($$, d, "y");
|
|
399
|
+
}
|
|
400
|
+
};
|
|
401
|
+
var bullet_default = {
|
|
402
|
+
/**
|
|
403
|
+
* Whether the data belongs to the bullet type.
|
|
404
|
+
* @param {object} d Data object
|
|
405
|
+
* @returns {boolean}
|
|
406
|
+
* @private
|
|
407
|
+
*/
|
|
408
|
+
isBulletType(d) {
|
|
409
|
+
return this.isTypeOf(d, "bullet");
|
|
410
|
+
},
|
|
411
|
+
/**
|
|
412
|
+
* Get the plot area of the bullets
|
|
413
|
+
* @returns {object} Plot size and offset
|
|
414
|
+
* @private
|
|
415
|
+
*/
|
|
416
|
+
getBulletSize() {
|
|
417
|
+
return _getArea.call(this);
|
|
418
|
+
},
|
|
419
|
+
/**
|
|
420
|
+
* Get the space the canvas title text takes below its baseline.
|
|
421
|
+
* SVG title padding includes it, but canvas title padding stops at the baseline.
|
|
422
|
+
* @returns {number} Title descent
|
|
423
|
+
* @private
|
|
424
|
+
*/
|
|
425
|
+
getCanvasTitleDescent() {
|
|
426
|
+
const { config, canvasRenderer, canvasTheme } = this;
|
|
427
|
+
if (!config.title_text || !canvasRenderer) return 0;
|
|
428
|
+
const { ctx } = canvasRenderer;
|
|
429
|
+
ctx.save();
|
|
430
|
+
ctx.font = canvasTheme.style.title.font;
|
|
431
|
+
const descent = ctx.measureText(String(config.title_text)).fontBoundingBoxDescent || 0;
|
|
432
|
+
ctx.restore();
|
|
433
|
+
return descent;
|
|
434
|
+
},
|
|
435
|
+
/**
|
|
436
|
+
* Get bullet rows data
|
|
437
|
+
* @returns {Array} Bullet rows
|
|
438
|
+
* @private
|
|
439
|
+
*/
|
|
440
|
+
getBulletData() {
|
|
441
|
+
const $$ = this;
|
|
442
|
+
return $$.data.targets.filter($$.isBulletType.bind($$)).map((t, index) => {
|
|
443
|
+
const latest = Number(t.values[t.values.length - 1]?.value);
|
|
444
|
+
const value = isValid(latest) ? latest : 0;
|
|
445
|
+
const ranges = _getRanges.call($$, t.id, value);
|
|
446
|
+
const targets = _getTargets.call($$, t.id, value);
|
|
447
|
+
const [autoMin, autoMax] = _getExtent([value].concat(targets, ranges));
|
|
448
|
+
const { bullet_axis_min: min, bullet_axis_max: max } = $$.config;
|
|
449
|
+
let domainMin = isValid(min) ? min : autoMin;
|
|
450
|
+
let domainMax = isValid(max) ? max : autoMax;
|
|
451
|
+
if (domainMin >= domainMax) {
|
|
452
|
+
domainMin = autoMin;
|
|
453
|
+
domainMax = autoMax;
|
|
454
|
+
}
|
|
455
|
+
if (domainMax === domainMin) domainMax = domainMin + 1;
|
|
456
|
+
const span = domainMax - domainMin;
|
|
457
|
+
const resolvedRanges = ranges.length ? ranges : [
|
|
458
|
+
.5,
|
|
459
|
+
.75,
|
|
460
|
+
1
|
|
461
|
+
].map((v) => domainMin + span * v);
|
|
462
|
+
return {
|
|
463
|
+
id: t.id,
|
|
464
|
+
index,
|
|
465
|
+
x: index,
|
|
466
|
+
name: t.id,
|
|
467
|
+
value,
|
|
468
|
+
title: $$.config.bullet_title_show ? _getTitleText.call($$, t.id, value) : "",
|
|
469
|
+
ranges: resolvedRanges,
|
|
470
|
+
targets,
|
|
471
|
+
domainMin,
|
|
472
|
+
domainMax
|
|
473
|
+
};
|
|
474
|
+
});
|
|
475
|
+
},
|
|
476
|
+
/**
|
|
477
|
+
* Get the layout shared by all rows. Compute it once per draw and pass it to each row.
|
|
478
|
+
* @returns {object} Bullet layout
|
|
479
|
+
* @private
|
|
480
|
+
*/
|
|
481
|
+
getBulletLayout() {
|
|
482
|
+
return _getLayout.call(this);
|
|
483
|
+
},
|
|
484
|
+
/**
|
|
485
|
+
* Get the center of the measure of a bullet row, in chart coordinates.
|
|
486
|
+
* @param {object} d Bullet row data
|
|
487
|
+
* @returns {Array} x, y coordinate
|
|
488
|
+
* @private
|
|
489
|
+
*/
|
|
490
|
+
getBulletMeasureCenter(d) {
|
|
491
|
+
const { area, offset, measure } = _getRowGeometry.call(this, d, _getLayout.call(this));
|
|
492
|
+
const [x, y] = "cx" in measure ? [measure.cx, measure.cy] : [measure.x + measure.width / 2, measure.y + measure.height / 2];
|
|
493
|
+
return [area.left + offset.x + x, area.top + offset.y + y];
|
|
494
|
+
},
|
|
495
|
+
/**
|
|
496
|
+
* Get the positions of the data label of each row, for the data label pipeline.
|
|
497
|
+
* @returns {function(IDataRow): Array.<Array.<number>>} Point getter: [anchor, measure center]
|
|
498
|
+
* @private
|
|
499
|
+
*/
|
|
500
|
+
generateGetBulletPoints() {
|
|
501
|
+
const $$ = this;
|
|
502
|
+
let points;
|
|
503
|
+
return (d) => {
|
|
504
|
+
if (!points) {
|
|
505
|
+
const layout = _getLayout.call($$);
|
|
506
|
+
points = {};
|
|
507
|
+
layout.rows.forEach((row) => {
|
|
508
|
+
const { area, offset, label } = _getRowGeometry.call($$, row, layout);
|
|
509
|
+
const x = area.left + offset.x;
|
|
510
|
+
const y = area.top + offset.y;
|
|
511
|
+
points[row.id] = [[x + label.x, y + label.y], [x + label.center.x, y + label.center.y]];
|
|
512
|
+
});
|
|
513
|
+
}
|
|
514
|
+
return points[d.id];
|
|
515
|
+
};
|
|
516
|
+
},
|
|
517
|
+
/**
|
|
518
|
+
* Get the geometry of a bullet row. Shared by the SVG and the canvas renderer.
|
|
519
|
+
* @param {object} d Bullet row data
|
|
520
|
+
* @param {object} layout Bullet layout from getBulletLayout()
|
|
521
|
+
* @returns {object} Row geometry, relative to the row origin
|
|
522
|
+
* @private
|
|
523
|
+
*/
|
|
524
|
+
getBulletRowGeometry(d, layout) {
|
|
525
|
+
return _getRowGeometry.call(this, d, layout);
|
|
526
|
+
}
|
|
527
|
+
};
|
|
528
|
+
export { $BULLET, customTypeHooks, bullet_default as default };
|
|
@@ -5,10 +5,10 @@
|
|
|
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 { isArray, isNumber, isObject } from "../../../module/util/type-checks.js";
|
|
11
|
-
|
|
11
|
+
// src/ChartInternal/shape/core/candlestick.ts
|
|
12
12
|
/**
|
|
13
13
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
14
14
|
* billboard.js project is licensed under the MIT license
|
|
@@ -99,5 +99,4 @@ var candlestick_default = {
|
|
|
99
99
|
return d || null;
|
|
100
100
|
}
|
|
101
101
|
};
|
|
102
|
-
//#endregion
|
|
103
102
|
export { candlestick_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 { isUndefined, isValue } from "../../../module/util/type-checks.js";
|
|
11
11
|
import { parseDate } from "../../../module/util/object.js";
|
|
12
|
-
|
|
12
|
+
// src/ChartInternal/shape/core/dataRegion.ts
|
|
13
13
|
/**
|
|
14
14
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
15
15
|
* billboard.js project is licensed under the MIT license
|
|
@@ -87,5 +87,4 @@ function getLineRegionSegments($$, values, x, y, regions) {
|
|
|
87
87
|
}
|
|
88
88
|
return segments;
|
|
89
89
|
}
|
|
90
|
-
//#endregion
|
|
91
90
|
export { getDataRegionDash, getDataRegionStyle, getLineRegionSegments, normalizeDataRegions };
|
|
@@ -5,9 +5,9 @@
|
|
|
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
|
+
// src/ChartInternal/shape/core/geometry.ts
|
|
11
11
|
/**
|
|
12
12
|
* Convert shared shape point coordinates into renderer coordinates.
|
|
13
13
|
* Shared geometry keeps the x-index coordinate first and value coordinate second.
|
|
@@ -138,5 +138,4 @@ function getTreemapLabelText($$, data, width, height) {
|
|
|
138
138
|
}) : `${id}\n${(ratio * 100).toFixed(2)}%`;
|
|
139
139
|
return text === null || text === void 0 ? null : String(text);
|
|
140
140
|
}
|
|
141
|
-
//#endregion
|
|
142
141
|
export { getCandlestickGeometry, getRenderDataPoint, getRenderPoint, getRenderRect, getShapePoint, getTreemapLabelText, getTreemapNodeRect };
|