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
|
@@ -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
|
* @requires billboard.js
|
|
10
10
|
* @summary billboard.js plugin
|
|
11
11
|
*/
|
|
12
|
-
|
|
12
|
+
// src/module/polygon.ts
|
|
13
13
|
/**
|
|
14
14
|
* Compute the signed area of a polygon using the Shoelace formula.
|
|
15
15
|
* @param {Array} polygon Array of [x, y] coordinates
|
|
@@ -49,8 +49,7 @@ function polygonCentroid(polygon) {
|
|
|
49
49
|
k *= 3;
|
|
50
50
|
return [x / k, y / k];
|
|
51
51
|
}
|
|
52
|
-
|
|
53
|
-
//#region src/module/voronoi.ts
|
|
52
|
+
// src/module/voronoi.ts
|
|
54
53
|
const EPSILON = 1e-9;
|
|
55
54
|
/**
|
|
56
55
|
* Clip a convex polygon by the half-plane of points at least as close to `a` as
|
|
@@ -121,12 +120,10 @@ function voronoiCells(points, bounds) {
|
|
|
121
120
|
return cell.length > 2 ? [...cell, cell[0]] : null;
|
|
122
121
|
});
|
|
123
122
|
}
|
|
124
|
-
|
|
125
|
-
//#region src/module/util/type-checks.ts
|
|
123
|
+
// src/module/util/type-checks.ts
|
|
126
124
|
const isDefined = (v) => typeof v !== "undefined";
|
|
127
125
|
const isObjectType = (v) => typeof v === "object";
|
|
128
|
-
|
|
129
|
-
//#region src/config/config.ts
|
|
126
|
+
// src/config/config.ts
|
|
130
127
|
/**
|
|
131
128
|
* Load configuration option
|
|
132
129
|
* @param {object} config User's generation config value
|
|
@@ -152,8 +149,7 @@ function loadConfig(config) {
|
|
|
152
149
|
});
|
|
153
150
|
if (this.api) this.state.orgConfig = config;
|
|
154
151
|
}
|
|
155
|
-
|
|
156
|
-
//#region src/Plugin/Plugin.ts
|
|
152
|
+
// src/Plugin/Plugin.ts
|
|
157
153
|
/**
|
|
158
154
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
159
155
|
* billboard.js project is licensed under the MIT license
|
|
@@ -175,7 +171,7 @@ var Plugin = class {
|
|
|
175
171
|
$$;
|
|
176
172
|
options;
|
|
177
173
|
config;
|
|
178
|
-
static version = "4.1
|
|
174
|
+
static version = "4.2.0-next.1";
|
|
179
175
|
/**
|
|
180
176
|
* Constructor
|
|
181
177
|
* @param {Any} options config option object
|
|
@@ -222,8 +218,7 @@ var Plugin = class {
|
|
|
222
218
|
});
|
|
223
219
|
}
|
|
224
220
|
};
|
|
225
|
-
|
|
226
|
-
//#region src/Plugin/textoverlap/Options.ts
|
|
221
|
+
// src/Plugin/textoverlap/Options.ts
|
|
227
222
|
/**
|
|
228
223
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
229
224
|
* billboard.js project is licensed under the MIT license
|
|
@@ -274,8 +269,7 @@ var Options = class {
|
|
|
274
269
|
};
|
|
275
270
|
}
|
|
276
271
|
};
|
|
277
|
-
|
|
278
|
-
//#region src/Plugin/textoverlap/index.ts
|
|
272
|
+
// src/Plugin/textoverlap/index.ts
|
|
279
273
|
/**
|
|
280
274
|
* TextOverlap plugin<br>
|
|
281
275
|
* Prevents label overlap using [Voronoi layout](https://en.wikipedia.org/wiki/Voronoi_diagram).
|
|
@@ -369,5 +363,4 @@ var TextOverlap = class extends Plugin {
|
|
|
369
363
|
});
|
|
370
364
|
}
|
|
371
365
|
};
|
|
372
|
-
//#endregion
|
|
373
366
|
export { TextOverlap as default };
|
package/dist-esm/react/index.js
CHANGED
|
@@ -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 { createElement, forwardRef, useEffect, useImperativeHandle, useRef } from "react";
|
|
11
|
-
|
|
11
|
+
// src/react/index.ts
|
|
12
12
|
/**
|
|
13
13
|
* Resolve chart type from a direct string or resolver function.
|
|
14
14
|
* @param {string|function} [type] Chart type value or resolver
|
|
@@ -153,5 +153,4 @@ const Chart = forwardRef((props, ref) => {
|
|
|
153
153
|
ref: container
|
|
154
154
|
});
|
|
155
155
|
});
|
|
156
|
-
//#endregion
|
|
157
156
|
export { Chart, Chart as default };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "billboard.js",
|
|
3
|
-
"version": "4.1
|
|
3
|
+
"version": "4.2.0-next.1",
|
|
4
4
|
"description": "Re-usable easy interface JavaScript chart library, based on D3 v4+",
|
|
5
5
|
"homepage": "https://naver.github.io/billboard.js/",
|
|
6
6
|
"main": "dist/billboard.js",
|
|
@@ -110,17 +110,17 @@
|
|
|
110
110
|
"dependencies": {
|
|
111
111
|
"@types/d3-selection": "^3.0.12",
|
|
112
112
|
"@types/d3-transition": "^3.0.9",
|
|
113
|
-
"d3-axis": "^3.0.
|
|
114
|
-
"d3-brush": "^3.0.
|
|
115
|
-
"d3-drag": "^3.0.
|
|
116
|
-
"d3-hierarchy": "^3.1.
|
|
117
|
-
"d3-interpolate": "^3.0.
|
|
118
|
-
"d3-scale": "^4.0.
|
|
119
|
-
"d3-selection": "^3.0.
|
|
120
|
-
"d3-shape": "^3.2.
|
|
121
|
-
"d3-time-format": "^4.1.
|
|
122
|
-
"d3-transition": "^3.0.
|
|
123
|
-
"d3-zoom": "^3.0.
|
|
113
|
+
"d3-axis": "^3.0.1",
|
|
114
|
+
"d3-brush": "^3.0.1",
|
|
115
|
+
"d3-drag": "^3.0.1",
|
|
116
|
+
"d3-hierarchy": "^3.1.3",
|
|
117
|
+
"d3-interpolate": "^3.0.2",
|
|
118
|
+
"d3-scale": "^4.0.3",
|
|
119
|
+
"d3-selection": "^3.0.1",
|
|
120
|
+
"d3-shape": "^3.2.1",
|
|
121
|
+
"d3-time-format": "^4.1.1",
|
|
122
|
+
"d3-transition": "^3.0.2",
|
|
123
|
+
"d3-zoom": "^3.0.1"
|
|
124
124
|
},
|
|
125
125
|
"peerDependencies": {
|
|
126
126
|
"react": ">=16.8.0"
|
|
@@ -131,71 +131,71 @@
|
|
|
131
131
|
}
|
|
132
132
|
},
|
|
133
133
|
"devDependencies": {
|
|
134
|
-
"@commitlint/cli": "^21.2.
|
|
135
|
-
"@commitlint/config-conventional": "^21.2.
|
|
134
|
+
"@commitlint/cli": "^21.2.4",
|
|
135
|
+
"@commitlint/config-conventional": "^21.2.4",
|
|
136
136
|
"@eslint/js": "^10.0.1",
|
|
137
|
-
"@playwright/test": "^1.
|
|
137
|
+
"@playwright/test": "^1.65.1",
|
|
138
138
|
"@semantic-release/changelog": "^7.0.0",
|
|
139
139
|
"@semantic-release/commit-analyzer": "^13.0.1",
|
|
140
140
|
"@semantic-release/exec": "^7.1.0",
|
|
141
141
|
"@semantic-release/git": "^11.0.1",
|
|
142
142
|
"@semantic-release/npm": "^13.2.0",
|
|
143
143
|
"@semantic-release/release-notes-generator": "^14.1.1",
|
|
144
|
-
"@storybook/react-vite": "^10.6.
|
|
144
|
+
"@storybook/react-vite": "^10.6.7",
|
|
145
145
|
"@testing-library/dom": "^10.4.2",
|
|
146
146
|
"@testing-library/react": "^16.3.3",
|
|
147
147
|
"@types/d3": "^7.4.3",
|
|
148
148
|
"@types/react": "^19.3.0",
|
|
149
149
|
"@types/react-dom": "^19.3.0",
|
|
150
|
-
"@types/sinon": "^22.0.
|
|
151
|
-
"@vitest/browser": "^5.0
|
|
152
|
-
"@vitest/browser-playwright": "^5.0
|
|
153
|
-
"@vitest/coverage-istanbul": "^5.0
|
|
154
|
-
"@vitest/ui": "^5.0
|
|
150
|
+
"@types/sinon": "^22.0.2",
|
|
151
|
+
"@vitest/browser": "^5.1.0",
|
|
152
|
+
"@vitest/browser-playwright": "^5.1.0",
|
|
153
|
+
"@vitest/coverage-istanbul": "^5.1.0",
|
|
154
|
+
"@vitest/ui": "^5.1.0",
|
|
155
155
|
"better-docs": "^2.7.3",
|
|
156
156
|
"clean-webpack-plugin": "^4.0.0",
|
|
157
|
-
"cloc": "2.
|
|
158
|
-
"core-js": "^3.
|
|
157
|
+
"cloc": "2.12.0-cloc",
|
|
158
|
+
"core-js": "^3.51.0",
|
|
159
159
|
"cross-env": "^10.1.0",
|
|
160
160
|
"css-loader": "^7.1.5",
|
|
161
|
-
"d3-delaunay": "^6.0.
|
|
162
|
-
"d3-format": "^3.1.
|
|
163
|
-
"d3-time": "^3.1.
|
|
161
|
+
"d3-delaunay": "^6.0.6",
|
|
162
|
+
"d3-format": "^3.1.3",
|
|
163
|
+
"d3-time": "^3.1.1",
|
|
164
164
|
"docdash": "^2.0.2",
|
|
165
|
-
"dprint": "^0.
|
|
165
|
+
"dprint": "^0.64.3",
|
|
166
166
|
"esbuild-loader": "^4.5.0",
|
|
167
|
-
"eslint": "^10.
|
|
167
|
+
"eslint": "^10.15.0",
|
|
168
168
|
"eslint-plugin-import": "^2.32.0",
|
|
169
|
-
"eslint-plugin-jsdoc": "^
|
|
169
|
+
"eslint-plugin-jsdoc": "^65.4.7",
|
|
170
170
|
"husky": "^9.1.7",
|
|
171
171
|
"jsdoc": "^4.0.5",
|
|
172
172
|
"lint-staged": "^17.6.0",
|
|
173
173
|
"mini-css-extract-plugin": "^2.10.2",
|
|
174
|
-
"playwright": "^1.
|
|
175
|
-
"react": "^19.3.
|
|
176
|
-
"react-dom": "^19.3.
|
|
174
|
+
"playwright": "^1.65.1",
|
|
175
|
+
"react": "^19.3.1",
|
|
176
|
+
"react-dom": "^19.3.1",
|
|
177
177
|
"regenerator-runtime": "^0.14.1",
|
|
178
|
-
"rolldown": "^1.2
|
|
179
|
-
"sass": "^1.
|
|
180
|
-
"sass-loader": "^17.0
|
|
178
|
+
"rolldown": "^1.3.2",
|
|
179
|
+
"sass": "^1.108.2",
|
|
180
|
+
"sass-loader": "^17.1.0",
|
|
181
181
|
"semantic-release": "^25.0.9",
|
|
182
182
|
"simulant": "^0.2.2",
|
|
183
183
|
"sinon": "^22.1.0",
|
|
184
|
-
"storybook": "^10.6.
|
|
184
|
+
"storybook": "^10.6.7",
|
|
185
185
|
"string-replace-loader": "^3.3.0",
|
|
186
186
|
"style-loader": "^4.0.0",
|
|
187
|
-
"tslib": "^2.
|
|
187
|
+
"tslib": "^2.9.1",
|
|
188
188
|
"typescript": "^6.0.3",
|
|
189
|
-
"typescript-eslint": "^8.
|
|
190
|
-
"vitest": "^5.0
|
|
191
|
-
"webpack": "^5.
|
|
192
|
-
"webpack-bundle-analyzer": "^5.4.
|
|
189
|
+
"typescript-eslint": "^8.72.2",
|
|
190
|
+
"vitest": "^5.1.0",
|
|
191
|
+
"webpack": "^5.112.2",
|
|
192
|
+
"webpack-bundle-analyzer": "^5.4.2",
|
|
193
193
|
"webpack-clean": "^1.2.5",
|
|
194
|
-
"webpack-cli": "^7.
|
|
195
|
-
"webpack-dev-server": "^6.
|
|
194
|
+
"webpack-cli": "^7.3.1",
|
|
195
|
+
"webpack-dev-server": "^6.1.0",
|
|
196
196
|
"webpack-merge": "^6.0.1",
|
|
197
197
|
"webpackbar": "^7.0.0",
|
|
198
198
|
"write-file-webpack-plugin": "^4.5.1"
|
|
199
199
|
},
|
|
200
|
-
"packageManager": "pnpm@10.
|
|
200
|
+
"packageManager": "pnpm@10.34.9"
|
|
201
201
|
}
|
package/src/Chart/Chart.ts
CHANGED
|
@@ -51,6 +51,7 @@ import apiTooltip from "./api/tooltip";
|
|
|
51
51
|
* @property {object} $.bar Bar element object
|
|
52
52
|
* @property {d3.selection} $.bar.bars Bar elements
|
|
53
53
|
* @property {d3.selection} $.candlestick Candlestick elements
|
|
54
|
+
* @property {d3.selection} $.boxplot Boxplot elements
|
|
54
55
|
* @property {object} $.line Line element object
|
|
55
56
|
* @property {d3.selection} $.line.lines Line elements
|
|
56
57
|
* @property {d3.selection} $.line.areas Areas elements
|
package/src/Chart/api/chart.ts
CHANGED
|
@@ -70,7 +70,8 @@ export default {
|
|
|
70
70
|
|
|
71
71
|
// keep current zoom domain
|
|
72
72
|
if ($$.scale.zoom) {
|
|
73
|
-
|
|
73
|
+
// in the range of .zoom(): a category scale reads its end one category further
|
|
74
|
+
state.current.zoomDomain = $$.zoom?.getDomain() ?? $$.scale.zoom.domain();
|
|
74
75
|
}
|
|
75
76
|
|
|
76
77
|
$$.scale.zoom = null;
|
package/src/Chart/api/flow.ts
CHANGED
|
@@ -86,6 +86,18 @@ export default {
|
|
|
86
86
|
const orgDataCount = $$.getMaxDataCount();
|
|
87
87
|
const targets = $$.convertDataToTargets(data, true);
|
|
88
88
|
const isTimeSeries = $$.axis.isTimeSeries();
|
|
89
|
+
// timeseries and custom x take x from the data; otherwise x follows the index
|
|
90
|
+
const isCustomX = !isTimeSeries && $$.axis.isCustomX() && !$$.axis.isCategorized();
|
|
91
|
+
const hasDataX = isTimeSeries || isCustomX;
|
|
92
|
+
const firstValue = $$.data.targets.find(t => t.values.length)?.values[0];
|
|
93
|
+
// updateDataIndexByX() renumbers the index from 0 after each flow while x keeps
|
|
94
|
+
// moving on, so the gap between them carries x forward
|
|
95
|
+
const xOffset = firstValue ? firstValue.x - firstValue.index : 0;
|
|
96
|
+
const getX = (
|
|
97
|
+
index: number
|
|
98
|
+
) => (isTimeSeries ? $$.getOtherTargetX(index) : index + xOffset);
|
|
99
|
+
// x of the values added by this flow, for series missing from the flow data
|
|
100
|
+
const flowedXs: number[] = [];
|
|
89
101
|
|
|
90
102
|
// Update/Add data
|
|
91
103
|
$$.data.targets.forEach(t => {
|
|
@@ -106,10 +118,11 @@ export default {
|
|
|
106
118
|
for (let j = 0; j < length; j++) {
|
|
107
119
|
values[j].index = tail + j;
|
|
108
120
|
|
|
109
|
-
if (!
|
|
110
|
-
values[j].x = tail + j;
|
|
121
|
+
if (!hasDataX) {
|
|
122
|
+
values[j].x = getX(tail + j);
|
|
111
123
|
}
|
|
112
124
|
|
|
125
|
+
flowedXs[j] = values[j].x;
|
|
113
126
|
t.values.push(values[j]);
|
|
114
127
|
}
|
|
115
128
|
|
|
@@ -136,7 +149,7 @@ export default {
|
|
|
136
149
|
t.values.push({
|
|
137
150
|
id: t.id,
|
|
138
151
|
index: tail + j,
|
|
139
|
-
x:
|
|
152
|
+
x: isCustomX ? flowedXs[j] : getX(tail + j),
|
|
140
153
|
value: null
|
|
141
154
|
});
|
|
142
155
|
}
|
|
@@ -165,7 +178,7 @@ export default {
|
|
|
165
178
|
values[i] = {
|
|
166
179
|
id: t.id,
|
|
167
180
|
index,
|
|
168
|
-
x:
|
|
181
|
+
x: isCustomX ? $$.data.targets[0].values[i]?.x : getX(index),
|
|
169
182
|
value: null
|
|
170
183
|
};
|
|
171
184
|
}
|
|
@@ -176,8 +189,8 @@ export default {
|
|
|
176
189
|
|
|
177
190
|
v.index += tail;
|
|
178
191
|
|
|
179
|
-
if (!
|
|
180
|
-
v.x
|
|
192
|
+
if (!hasDataX) {
|
|
193
|
+
v.x = getX(v.index);
|
|
181
194
|
}
|
|
182
195
|
}
|
|
183
196
|
});
|
|
@@ -257,6 +270,7 @@ export default {
|
|
|
257
270
|
withUpdateXDomain: true
|
|
258
271
|
});
|
|
259
272
|
$$.updateTypesElements();
|
|
273
|
+
$$.updateCanvasFlowFocus?.();
|
|
260
274
|
args.done?.call($$.api);
|
|
261
275
|
return;
|
|
262
276
|
}
|
|
@@ -269,7 +283,6 @@ export default {
|
|
|
269
283
|
// Redraw with new targets
|
|
270
284
|
$$.redraw({
|
|
271
285
|
flow: {
|
|
272
|
-
index: baseValue.index,
|
|
273
286
|
length: length,
|
|
274
287
|
duration: isValue(args.duration) ?
|
|
275
288
|
args.duration :
|
package/src/Chart/api/focus.ts
CHANGED
|
@@ -66,6 +66,7 @@ export default {
|
|
|
66
66
|
|
|
67
67
|
state.focusedTargetIds = new Set(targetIds);
|
|
68
68
|
targetIds.forEach(id => state.defocusedTargetIds.delete(id));
|
|
69
|
+
$$.customTypeHooks?.afterFocus?.($$);
|
|
69
70
|
},
|
|
70
71
|
|
|
71
72
|
/**
|
|
@@ -118,6 +119,7 @@ export default {
|
|
|
118
119
|
|
|
119
120
|
targetIds.forEach(id => state.focusedTargetIds.delete(id));
|
|
120
121
|
state.defocusedTargetIds = new Set(targetIds);
|
|
122
|
+
$$.customTypeHooks?.afterFocus?.($$);
|
|
121
123
|
},
|
|
122
124
|
|
|
123
125
|
/**
|
|
@@ -173,5 +175,6 @@ export default {
|
|
|
173
175
|
|
|
174
176
|
state.focusedTargetIds = new Set();
|
|
175
177
|
state.defocusedTargetIds = new Set();
|
|
178
|
+
$$.customTypeHooks?.afterFocus?.($$);
|
|
176
179
|
}
|
|
177
180
|
};
|
|
@@ -35,7 +35,7 @@ const subchart = function<T = TDomain[]>(domainValue?: T): T | undefined {
|
|
|
35
35
|
|
|
36
36
|
if (Array.isArray(domain)) {
|
|
37
37
|
domain = axis.isTimeSeries() ? domain.map(x => parseDate.bind($$)(x)) : domain;
|
|
38
|
-
domain = $$.setCanvasSubchartDomain(domain) || state.domain;
|
|
38
|
+
domain = $$.setCanvasSubchartDomain?.(domain) || state.domain;
|
|
39
39
|
} else {
|
|
40
40
|
domain = state.domain ?? x.orgDomain();
|
|
41
41
|
}
|
package/src/Chart/api/tooltip.ts
CHANGED
|
@@ -73,10 +73,22 @@ const tooltip = {
|
|
|
73
73
|
*/
|
|
74
74
|
show: function(args): void {
|
|
75
75
|
const $$ = this.internal;
|
|
76
|
-
const {
|
|
76
|
+
const {
|
|
77
|
+
$el,
|
|
78
|
+
config,
|
|
79
|
+
state: {customType, eventReceiver, hasTreemap, inputType, isCanvasMode}
|
|
80
|
+
} = $$;
|
|
77
81
|
let index;
|
|
78
82
|
let mouse;
|
|
79
83
|
|
|
84
|
+
// a custom type addresses its data by id: resolve the given index to it.
|
|
85
|
+
// canvas resolves it by itself below
|
|
86
|
+
if (customType && !isCanvasMode && !args.data) {
|
|
87
|
+
const found = $$.customTypeHooks?.tooltipTarget?.($$, args).data[0];
|
|
88
|
+
|
|
89
|
+
found && (args = {...args, data: {id: found.id}, index: args.index ?? found.index});
|
|
90
|
+
}
|
|
91
|
+
|
|
80
92
|
// determine mouse position on the chart
|
|
81
93
|
if (args.mouse) {
|
|
82
94
|
mouse = args.mouse;
|
|
@@ -87,10 +99,26 @@ const tooltip = {
|
|
|
87
99
|
const {data} = args;
|
|
88
100
|
const y = $$.getYScaleById(data.id)?.(data.value);
|
|
89
101
|
|
|
90
|
-
if ((
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
102
|
+
if ((customType || hasTreemap) && data.id) {
|
|
103
|
+
// canvas has no shape elements: the tooltip is resolved from the data below
|
|
104
|
+
if (!isCanvasMode) {
|
|
105
|
+
const shape = `.${$SHAPE.shape}`;
|
|
106
|
+
// a shape of the type can be of the given index too: `bb-shape-{index}`
|
|
107
|
+
// the index of the data, or of the given x for a type that names its columns
|
|
108
|
+
const at = args.index ?? data.index ??
|
|
109
|
+
(isDefined(args.x) ?
|
|
110
|
+
$$.customTypeHooks?.tooltipTarget?.($$, args).data[0]?.index :
|
|
111
|
+
undefined);
|
|
112
|
+
const byIndex = isDefined(at) ?
|
|
113
|
+
$el.main.select(
|
|
114
|
+
$$.selectorTarget(data.id, undefined, `${shape}${shape}-${at}`)
|
|
115
|
+
) :
|
|
116
|
+
null;
|
|
117
|
+
|
|
118
|
+
eventReceiver.rect = byIndex?.node() ?
|
|
119
|
+
byIndex :
|
|
120
|
+
$el.main.select($$.selectorTarget(data.id, undefined, shape));
|
|
121
|
+
}
|
|
94
122
|
} else if ($$.isMultipleX()) {
|
|
95
123
|
// if multiple xs, target point will be determined by mouse
|
|
96
124
|
mouse = [$$.xx(data), y];
|
|
@@ -113,30 +141,41 @@ const tooltip = {
|
|
|
113
141
|
|
|
114
142
|
if ($$.state.isCanvasMode) {
|
|
115
143
|
const targets = $$.filterTargetsToShow?.() || $$.data.targets;
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
144
|
+
// a custom type can address its data other than by index
|
|
145
|
+
const custom = customType ? $$.customTypeHooks?.tooltipTarget?.($$, args) : null;
|
|
146
|
+
const selectedData = custom ?
|
|
147
|
+
custom.data :
|
|
148
|
+
(args.data?.id && !config.tooltip_grouped ?
|
|
149
|
+
targets
|
|
150
|
+
.filter(target => target.id === args.data.id)
|
|
151
|
+
.map(target => target.values[index ?? args.data.index])
|
|
152
|
+
.filter(Boolean) :
|
|
153
|
+
targets
|
|
154
|
+
.map(target => target.values[index])
|
|
155
|
+
.filter(Boolean));
|
|
124
156
|
const canvas = $el.canvas?.node?.();
|
|
125
157
|
const shape = $$.state.canvasShape || $$.getDrawShape?.();
|
|
126
158
|
const first = selectedData[0];
|
|
127
159
|
const point = mouse || (
|
|
128
|
-
first && shape?.pos?.cx && shape?.pos?.cy ?
|
|
160
|
+
custom ? custom.point : (first && shape?.pos?.cx && shape?.pos?.cy ?
|
|
129
161
|
[
|
|
130
162
|
$$.state.margin.left + shape.pos.cx(first),
|
|
131
163
|
$$.state.margin.top + shape.pos.cy(first)
|
|
132
164
|
] :
|
|
133
|
-
undefined
|
|
165
|
+
undefined)
|
|
134
166
|
);
|
|
135
167
|
|
|
136
168
|
if (!selectedData.length || !canvas) {
|
|
137
169
|
return;
|
|
138
170
|
}
|
|
139
171
|
|
|
172
|
+
// a programmatic show has no pointer: place the tooltip at the point of the custom type
|
|
173
|
+
if (custom && point) {
|
|
174
|
+
const rect = canvas.getBoundingClientRect();
|
|
175
|
+
|
|
176
|
+
$$.state.event = {clientX: rect.left + point[0], clientY: rect.top + point[1]};
|
|
177
|
+
}
|
|
178
|
+
|
|
140
179
|
$$.state.canvasFocusKey = selectedData
|
|
141
180
|
.map(v => `${v.id}:${v.index}`)
|
|
142
181
|
.join("|");
|
|
@@ -197,6 +197,10 @@ export default class AxisRenderer {
|
|
|
197
197
|
});
|
|
198
198
|
|
|
199
199
|
if (tickShow.tick || tickShow.text) {
|
|
200
|
+
// resolve the .domain node once: a selector string handed to insert() runs
|
|
201
|
+
// querySelector for every entering tick, which is O(ticks^2) on dense axes
|
|
202
|
+
const domainNode = g.select(".domain").node();
|
|
203
|
+
|
|
200
204
|
// count of tick data in array
|
|
201
205
|
const ticks = config.tickValues ||
|
|
202
206
|
helper.generateTicks(scale1, isLeftRight || params.config.axis_rotated);
|
|
@@ -221,7 +225,7 @@ export default class AxisRenderer {
|
|
|
221
225
|
// enter selection
|
|
222
226
|
const tickEnter = tick
|
|
223
227
|
.enter()
|
|
224
|
-
.insert("g",
|
|
228
|
+
.insert("g", () => domainNode)
|
|
225
229
|
.attr("class", "tick");
|
|
226
230
|
|
|
227
231
|
// MEMO: No exit transition. The reason is this transition affects max tick width calculation because old tick will be included in the ticks.
|
|
@@ -285,7 +289,10 @@ export default class AxisRenderer {
|
|
|
285
289
|
.enter()
|
|
286
290
|
.append("tspan")
|
|
287
291
|
.merge(tspan)
|
|
288
|
-
.
|
|
292
|
+
.each(function(d) {
|
|
293
|
+
// assigning textContent replaces the text node even for the same string
|
|
294
|
+
this.textContent !== d.splitted && (this.textContent = d.splitted);
|
|
295
|
+
});
|
|
289
296
|
|
|
290
297
|
// set <tspan>'s position
|
|
291
298
|
tspan
|
|
@@ -545,34 +552,36 @@ export default class AxisRenderer {
|
|
|
545
552
|
);
|
|
546
553
|
}
|
|
547
554
|
|
|
548
|
-
// split given text by tick width size
|
|
549
|
-
//
|
|
550
|
-
|
|
551
|
-
|
|
555
|
+
// split given text by tick width size.
|
|
556
|
+
// iterate rather than recurse per line, so a very long label cannot overflow the stack
|
|
557
|
+
const text = String(tickText);
|
|
558
|
+
const result: string[] = [];
|
|
559
|
+
let start = 0;
|
|
560
|
+
|
|
561
|
+
while (true) {
|
|
552
562
|
let spaceIndex;
|
|
553
|
-
let
|
|
563
|
+
let splitAt = -1;
|
|
554
564
|
|
|
555
|
-
for (let i = 1; i < text.length; i++) {
|
|
556
|
-
if (text.charAt(i) === " ") {
|
|
565
|
+
for (let i = 1; start + i < text.length; i++) {
|
|
566
|
+
if (text.charAt(start + i) === " ") {
|
|
557
567
|
spaceIndex = i;
|
|
558
568
|
}
|
|
559
569
|
|
|
560
|
-
subtext = text.substr(0, i + 1);
|
|
561
|
-
textWidth = charWidth * subtext.length;
|
|
562
|
-
|
|
563
570
|
// if text width gets over tick width, split by space index or current index
|
|
564
|
-
if (tickWidth <
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
text.slice(spaceIndex ? spaceIndex + 1 : i)
|
|
568
|
-
);
|
|
571
|
+
if (tickWidth < charWidth * (i + 1)) {
|
|
572
|
+
splitAt = i;
|
|
573
|
+
break;
|
|
569
574
|
}
|
|
570
575
|
}
|
|
571
576
|
|
|
572
|
-
|
|
573
|
-
|
|
577
|
+
if (splitAt === -1) {
|
|
578
|
+
result.push(text.slice(start));
|
|
579
|
+
return result;
|
|
580
|
+
}
|
|
574
581
|
|
|
575
|
-
|
|
582
|
+
result.push(text.substr(start, spaceIndex || splitAt));
|
|
583
|
+
start += spaceIndex ? spaceIndex + 1 : splitAt;
|
|
584
|
+
}
|
|
576
585
|
}
|
|
577
586
|
|
|
578
587
|
scale(x?): AxisRenderer {
|
|
@@ -7,6 +7,12 @@ import type {d3Selection} from "../../../types/types";
|
|
|
7
7
|
import {getBBox, isDefined, isValue} from "../../module/util";
|
|
8
8
|
import {getScale} from "../internals/scale";
|
|
9
9
|
|
|
10
|
+
/**
|
|
11
|
+
* Size of one character per chart and font
|
|
12
|
+
* @private
|
|
13
|
+
*/
|
|
14
|
+
const charSizeCache = new WeakMap<object, Record<string, {w: number, h: number}>>();
|
|
15
|
+
|
|
10
16
|
export default class AxisRendererHelper {
|
|
11
17
|
private owner;
|
|
12
18
|
private config;
|
|
@@ -49,20 +55,48 @@ export default class AxisRendererHelper {
|
|
|
49
55
|
return this.charSize[orient];
|
|
50
56
|
}
|
|
51
57
|
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
58
|
+
const node = text.node();
|
|
59
|
+
|
|
60
|
+
if (node) {
|
|
61
|
+
// A new renderer is made per redraw, so the size is kept per chart. It depends on
|
|
62
|
+
// the font only, which the key tells apart when the style changes.
|
|
63
|
+
const chart = this.owner.params.owner;
|
|
64
|
+
const style = window.getComputedStyle(node);
|
|
65
|
+
const key = [
|
|
66
|
+
orient,
|
|
67
|
+
style.fontStyle,
|
|
68
|
+
style.fontWeight,
|
|
69
|
+
style.fontSize,
|
|
70
|
+
style.fontFamily,
|
|
71
|
+
style.letterSpacing
|
|
72
|
+
].join(" ");
|
|
73
|
+
const cache = charSizeCache.get(chart) ?? {};
|
|
74
|
+
const cached = cache[key];
|
|
75
|
+
|
|
76
|
+
charSizeCache.set(chart, cache);
|
|
77
|
+
|
|
78
|
+
try {
|
|
79
|
+
if (cached) {
|
|
80
|
+
size.w = cached.w;
|
|
81
|
+
size.h = cached.h;
|
|
82
|
+
} else {
|
|
83
|
+
// only the first node is measured, so write "0" to it alone
|
|
84
|
+
node.textContent = "0";
|
|
85
|
+
|
|
86
|
+
const {width, height} = getBBox(node, true);
|
|
57
87
|
|
|
58
88
|
if (width && height) {
|
|
59
89
|
size.w = width;
|
|
60
90
|
size.h = height;
|
|
91
|
+
cache[key] = {w: width, h: height};
|
|
61
92
|
}
|
|
62
|
-
} finally {
|
|
63
|
-
el.text("");
|
|
64
93
|
}
|
|
65
|
-
}
|
|
94
|
+
} finally {
|
|
95
|
+
// every node is emptied, as the callers rebuild their content
|
|
96
|
+
// (and a leftover <title> would stay)
|
|
97
|
+
text.text("");
|
|
98
|
+
}
|
|
99
|
+
}
|
|
66
100
|
|
|
67
101
|
this.charSize[orient] = size;
|
|
68
102
|
|
|
@@ -166,7 +200,9 @@ export default class AxisRendererHelper {
|
|
|
166
200
|
const {config} = this;
|
|
167
201
|
let transitionSelection = selection;
|
|
168
202
|
|
|
169
|
-
|
|
203
|
+
// a flow passes its own transition (setTransition), which applies even when the
|
|
204
|
+
// chart transition is off, so the ticks slide with the shapes
|
|
205
|
+
if (config.withoutTransition && !config.transition) {
|
|
170
206
|
transitionSelection = selection.interrupt();
|
|
171
207
|
} else if (config.transition || !this.owner.params.noTransition) {
|
|
172
208
|
// prevent for 'transition not found' case
|