billboard.js 4.1.5 → 4.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billboard.css +87 -1
- package/dist/billboard.js +11000 -6970
- package/dist/billboard.min.css +2 -2
- package/dist/billboard.min.js +19 -19
- package/dist/billboard.pkgd.js +22584 -14102
- package/dist/billboard.pkgd.min.js +37 -37
- package/dist/billboard.react.js +5 -5
- package/dist/billboard.react.min.js +2 -2
- package/dist/billboard.worker.js +1 -1
- package/dist/plugin/billboardjs-plugin-bubblecompare.js +2 -2
- package/dist/plugin/billboardjs-plugin-bubblecompare.min.js +2 -2
- package/dist/plugin/billboardjs-plugin-sparkline.js +21 -4
- package/dist/plugin/billboardjs-plugin-sparkline.min.js +3 -3
- package/dist/plugin/billboardjs-plugin-stanford.js +22 -13
- package/dist/plugin/billboardjs-plugin-stanford.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-tableview.js +20 -3
- package/dist/plugin/billboardjs-plugin-tableview.min.js +4 -4
- package/dist/plugin/billboardjs-plugin-textoverlap.js +2 -2
- package/dist/plugin/billboardjs-plugin-textoverlap.min.js +2 -2
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.js +1689 -1252
- package/dist/plugin/pkgd/billboardjs-plugin-bubblecompare.pkgd.min.js +8 -8
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.js +2288 -1012
- package/dist/plugin/pkgd/billboardjs-plugin-sparkline.pkgd.min.js +10 -10
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.js +6350 -2390
- package/dist/plugin/pkgd/billboardjs-plugin-stanford.pkgd.min.js +18 -18
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.js +1310 -1006
- package/dist/plugin/pkgd/billboardjs-plugin-tableview.pkgd.min.js +10 -10
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.js +1293 -1006
- package/dist/plugin/pkgd/billboardjs-plugin-textoverlap.pkgd.min.js +8 -8
- package/dist/theme/dark.css +90 -1
- package/dist/theme/dark.min.css +2 -2
- package/dist/theme/datalab.css +87 -1
- package/dist/theme/datalab.min.css +2 -2
- package/dist/theme/graph.css +87 -1
- package/dist/theme/graph.min.css +2 -2
- package/dist/theme/insight.css +87 -1
- package/dist/theme/insight.min.css +2 -2
- package/dist/theme/modern.css +87 -1
- package/dist/theme/modern.min.css +2 -2
- package/dist-esm/Chart/Chart.js +5 -5
- package/dist-esm/Chart/api/axis.js +2 -3
- package/dist-esm/Chart/api/category.js +2 -3
- package/dist-esm/Chart/api/chart.js +2 -3
- package/dist-esm/Chart/api/color.js +2 -3
- package/dist-esm/Chart/api/data.js +3 -4
- package/dist-esm/Chart/api/export.js +3 -4
- package/dist-esm/Chart/api/flow.js +3 -4
- package/dist-esm/Chart/api/focus.js +5 -3
- package/dist-esm/Chart/api/grid.js +2 -3
- package/dist-esm/Chart/api/group.js +2 -3
- package/dist-esm/Chart/api/legend.js +1 -2
- package/dist-esm/Chart/api/load.js +3 -4
- package/dist-esm/Chart/api/regions.js +3 -4
- package/dist-esm/Chart/api/selection.js +3 -4
- package/dist-esm/Chart/api/show.js +2 -3
- package/dist-esm/Chart/api/stubs.js +3 -4
- package/dist-esm/Chart/api/subchart.js +4 -5
- package/dist-esm/Chart/api/tooltip.js +28 -9
- package/dist-esm/Chart/api/x.js +2 -3
- package/dist-esm/Chart/api/zoom.js +6 -7
- package/dist-esm/ChartInternal/Axis/Axis.js +5 -6
- package/dist-esm/ChartInternal/Axis/AxisRenderer.js +9 -7
- package/dist-esm/ChartInternal/Axis/AxisRendererHelper.js +39 -11
- package/dist-esm/ChartInternal/ChartInternal.js +39 -24
- package/dist-esm/ChartInternal/data/convert.helper.js +2 -3
- package/dist-esm/ChartInternal/data/convert.js +3 -4
- package/dist-esm/ChartInternal/data/data.js +18 -11
- package/dist-esm/ChartInternal/data/load.js +4 -5
- package/dist-esm/ChartInternal/interactions/drag.js +3 -4
- package/dist-esm/ChartInternal/interactions/eventrect.js +4 -5
- package/dist-esm/ChartInternal/interactions/flow.js +3 -4
- package/dist-esm/ChartInternal/interactions/interaction.js +14 -13
- package/dist-esm/ChartInternal/interactions/subchart.js +5 -6
- package/dist-esm/ChartInternal/interactions/zoom.js +4 -5
- package/dist-esm/ChartInternal/internals/category.js +2 -3
- package/dist-esm/ChartInternal/internals/class.js +5 -5
- package/dist-esm/ChartInternal/internals/clip.js +2 -3
- package/dist-esm/ChartInternal/internals/color.js +4 -5
- package/dist-esm/ChartInternal/internals/domain.js +7 -7
- package/dist-esm/ChartInternal/internals/format.js +3 -4
- package/dist-esm/ChartInternal/internals/grid.js +4 -5
- package/dist-esm/ChartInternal/internals/legend.js +7 -7
- package/dist-esm/ChartInternal/internals/redraw.js +8 -8
- package/dist-esm/ChartInternal/internals/region.js +4 -5
- package/dist-esm/ChartInternal/internals/scale.js +2 -3
- package/dist-esm/ChartInternal/internals/selection.js +3 -4
- package/dist-esm/ChartInternal/internals/size.axis.js +2 -3
- package/dist-esm/ChartInternal/internals/size.js +8 -9
- package/dist-esm/ChartInternal/internals/style.js +4 -5
- package/dist-esm/ChartInternal/internals/subchart.util.js +2 -3
- package/dist-esm/ChartInternal/internals/text.arc.js +3 -4
- package/dist-esm/ChartInternal/internals/text.js +22 -23
- package/dist-esm/ChartInternal/internals/text.util.js +4 -5
- package/dist-esm/ChartInternal/internals/title.js +4 -5
- package/dist-esm/ChartInternal/internals/tooltip.js +20 -20
- package/dist-esm/ChartInternal/internals/transform.js +5 -6
- package/dist-esm/ChartInternal/internals/type.js +78 -11
- package/dist-esm/ChartInternal/shape/arc.js +5 -6
- package/dist-esm/ChartInternal/shape/area.js +4 -5
- package/dist-esm/ChartInternal/shape/bar.js +5 -6
- package/dist-esm/ChartInternal/shape/boxplot.js +111 -0
- package/dist-esm/ChartInternal/shape/bubble.js +2 -3
- package/dist-esm/ChartInternal/shape/bullet.js +213 -0
- package/dist-esm/ChartInternal/shape/candlestick.js +5 -6
- package/dist-esm/ChartInternal/shape/core/barRadius.js +2 -3
- package/dist-esm/ChartInternal/shape/core/boxplot.js +192 -0
- package/dist-esm/ChartInternal/shape/core/bubble.js +4 -5
- package/dist-esm/ChartInternal/shape/core/bullet.js +528 -0
- package/dist-esm/ChartInternal/shape/core/candlestick.js +2 -3
- package/dist-esm/ChartInternal/shape/core/dataRegion.js +2 -3
- package/dist-esm/ChartInternal/shape/core/geometry.js +2 -3
- package/dist-esm/ChartInternal/shape/core/heatmap.js +453 -0
- package/dist-esm/ChartInternal/shape/core/path.js +2 -3
- package/dist-esm/ChartInternal/shape/core/point.js +2 -3
- package/dist-esm/ChartInternal/shape/core/sankey.js +576 -0
- package/dist-esm/ChartInternal/shape/core/treemap.js +2 -3
- package/dist-esm/ChartInternal/shape/funnel.js +45 -6
- package/dist-esm/ChartInternal/shape/gauge.js +3 -4
- package/dist-esm/ChartInternal/shape/heatmap.js +144 -0
- package/dist-esm/ChartInternal/shape/line.js +7 -8
- package/dist-esm/ChartInternal/shape/point.js +5 -6
- package/dist-esm/ChartInternal/shape/polar.js +3 -4
- package/dist-esm/ChartInternal/shape/radar.js +19 -7
- package/dist-esm/ChartInternal/shape/sankey.js +154 -0
- package/dist-esm/ChartInternal/shape/shape.js +7 -7
- package/dist-esm/ChartInternal/shape/treemap.js +8 -5
- package/dist-esm/canvas/CanvasAxisRenderer.js +12 -315
- package/dist-esm/canvas/CanvasEngine.js +2 -3
- package/dist-esm/canvas/CanvasPainter.js +2 -3
- package/dist-esm/canvas/CanvasRenderer.js +38 -408
- package/dist-esm/canvas/CanvasTheme.js +28 -8
- package/dist-esm/canvas/HitDetector.js +20 -24
- package/dist-esm/canvas/axisTicks.js +5 -6
- package/dist-esm/canvas/boxplot.js +201 -0
- package/dist-esm/canvas/bullet.js +212 -0
- package/dist-esm/canvas/classes.js +2 -3
- package/dist-esm/canvas/color.js +2 -3
- package/dist-esm/canvas/flow.js +190 -0
- package/dist-esm/canvas/geometry.js +2 -3
- package/dist-esm/canvas/grid.js +206 -0
- package/dist-esm/canvas/heatmap.js +141 -0
- package/dist-esm/canvas/labels.js +3 -4
- package/dist-esm/canvas/pointPattern.js +2 -3
- package/dist-esm/canvas/sankey.js +137 -0
- package/dist-esm/canvas/selection.js +473 -0
- package/dist-esm/canvas/subchart.js +814 -0
- package/dist-esm/canvas/treemap.js +100 -0
- package/dist-esm/canvas/util.js +2 -3
- package/dist-esm/config/Options/Options.js +3 -4
- package/dist-esm/config/Options/axis/axis.js +2 -3
- package/dist-esm/config/Options/axis/x.js +2 -3
- package/dist-esm/config/Options/axis/y.js +2 -3
- package/dist-esm/config/Options/axis/y2.js +14 -3
- package/dist-esm/config/Options/common/boost.js +2 -3
- package/dist-esm/config/Options/common/color.js +2 -3
- package/dist-esm/config/Options/common/grid.js +2 -3
- package/dist-esm/config/Options/common/legend.js +2 -3
- package/dist-esm/config/Options/common/main.js +2 -3
- package/dist-esm/config/Options/common/point.js +2 -3
- package/dist-esm/config/Options/common/title.js +2 -3
- package/dist-esm/config/Options/common/tooltip.js +2 -3
- package/dist-esm/config/Options/data/axis.js +2 -3
- package/dist-esm/config/Options/data/data.js +49 -4
- package/dist-esm/config/Options/data/selection.js +2 -3
- package/dist-esm/config/Options/interaction/interaction.js +2 -3
- package/dist-esm/config/Options/interaction/subchart.js +2 -3
- package/dist-esm/config/Options/interaction/zoom.js +2 -3
- package/dist-esm/config/Options/shape/arc.js +2 -3
- package/dist-esm/config/Options/shape/area.js +2 -3
- package/dist-esm/config/Options/shape/bar.js +2 -3
- package/dist-esm/config/Options/shape/boxplot.js +106 -0
- package/dist-esm/config/Options/shape/bubble.js +2 -3
- package/dist-esm/config/Options/shape/bullet.js +177 -0
- package/dist-esm/config/Options/shape/candlestick.js +2 -3
- package/dist-esm/config/Options/shape/donut.js +2 -3
- package/dist-esm/config/Options/shape/funnel.js +2 -3
- package/dist-esm/config/Options/shape/gauge.js +2 -3
- package/dist-esm/config/Options/shape/heatmap.js +137 -0
- package/dist-esm/config/Options/shape/line.js +2 -3
- package/dist-esm/config/Options/shape/pie.js +2 -3
- package/dist-esm/config/Options/shape/polar.js +2 -3
- package/dist-esm/config/Options/shape/radar.js +2 -3
- package/dist-esm/config/Options/shape/sankey.js +116 -0
- package/dist-esm/config/Options/shape/scatter.js +2 -3
- package/dist-esm/config/Options/shape/spline.js +2 -3
- package/dist-esm/config/Options/shape/treemap.js +2 -3
- package/dist-esm/config/Store/Element.js +2 -3
- package/dist-esm/config/Store/State.js +3 -4
- package/dist-esm/config/Store/Store.js +2 -3
- package/dist-esm/config/classes.js +2 -4
- package/dist-esm/config/config.js +2 -3
- package/dist-esm/config/const.js +31 -23
- package/dist-esm/config/resolver/axis.core.js +4 -5
- package/dist-esm/config/resolver/axis.js +2 -3
- package/dist-esm/config/resolver/canvas.js +112 -911
- package/dist-esm/config/resolver/canvasBoxplot.js +49 -0
- package/dist-esm/config/resolver/canvasBullet.js +29 -0
- package/dist-esm/config/resolver/canvasFlow.js +28 -0
- package/dist-esm/config/resolver/canvasGrid.js +27 -0
- package/dist-esm/config/resolver/canvasHeatmap.js +31 -0
- package/dist-esm/config/resolver/canvasSankey.js +31 -0
- package/dist-esm/config/resolver/canvasSelection.js +30 -0
- package/dist-esm/config/resolver/canvasShape.js +13 -12
- package/dist-esm/config/resolver/canvasSubchart.js +30 -0
- package/dist-esm/config/resolver/canvasType.js +48 -0
- package/dist-esm/config/resolver/category.js +3 -4
- package/dist-esm/config/resolver/customType.js +58 -0
- package/dist-esm/config/resolver/export.js +3 -4
- package/dist-esm/config/resolver/flow.js +5 -6
- package/dist-esm/config/resolver/grid.js +6 -7
- package/dist-esm/config/resolver/interaction/selection.js +6 -7
- package/dist-esm/config/resolver/interaction/subchart.js +6 -7
- package/dist-esm/config/resolver/interaction/zoom.js +6 -7
- package/dist-esm/config/resolver/regions.js +5 -6
- package/dist-esm/config/resolver/shape/arc.helpers.js +5 -6
- package/dist-esm/config/resolver/shape/area.js +3 -4
- package/dist-esm/config/resolver/shape/axis.helpers.js +2 -3
- package/dist-esm/config/resolver/shape/bar.js +5 -6
- package/dist-esm/config/resolver/shape/boxplot.js +30 -0
- package/dist-esm/config/resolver/shape/bubble.js +5 -6
- package/dist-esm/config/resolver/shape/bullet.js +23 -0
- package/dist-esm/config/resolver/shape/candlestick.js +5 -6
- package/dist-esm/config/resolver/shape/donut.js +2 -3
- package/dist-esm/config/resolver/shape/funnel.js +7 -6
- package/dist-esm/config/resolver/shape/gauge.js +4 -5
- package/dist-esm/config/resolver/shape/heatmap.js +23 -0
- package/dist-esm/config/resolver/shape/line.js +2 -3
- package/dist-esm/config/resolver/shape/pie.js +3 -4
- package/dist-esm/config/resolver/shape/polar.js +4 -5
- package/dist-esm/config/resolver/shape/radar.js +5 -6
- package/dist-esm/config/resolver/shape/sankey.js +23 -0
- package/dist-esm/config/resolver/shape/scatter.js +4 -5
- package/dist-esm/config/resolver/shape/treemap.js +4 -5
- package/dist-esm/core.js +5 -6
- package/dist-esm/index.canvas.js +13 -9
- package/dist-esm/index.esm.js +6 -2
- package/dist-esm/module/Cache.js +2 -3
- package/dist-esm/module/browser.js +2 -3
- package/dist-esm/module/dsv.js +2 -3
- package/dist-esm/module/error.js +23 -16
- package/dist-esm/module/generator.js +3 -4
- package/dist-esm/module/sanitize.js +2 -3
- package/dist-esm/module/util/brush.js +2 -3
- package/dist-esm/module/util/dom.js +3 -4
- package/dist-esm/module/util/object.js +13 -6
- package/dist-esm/module/util/type-checks.js +2 -3
- package/dist-esm/module/worker.js +2 -3
- package/dist-esm/plugin/billboardjs-plugin-bubblecompare.js +6 -10
- package/dist-esm/plugin/billboardjs-plugin-sparkline.js +10 -18
- package/dist-esm/plugin/billboardjs-plugin-stanford.js +17 -45
- package/dist-esm/plugin/billboardjs-plugin-tableview.js +10 -18
- package/dist-esm/plugin/billboardjs-plugin-textoverlap.js +9 -16
- package/dist-esm/react/index.js +2 -3
- package/package.json +44 -44
- package/src/Chart/Chart.ts +1 -0
- package/src/Chart/api/focus.ts +3 -0
- package/src/Chart/api/subchart.ts +1 -1
- package/src/Chart/api/tooltip.ts +54 -15
- package/src/ChartInternal/Axis/AxisRenderer.ts +9 -2
- package/src/ChartInternal/Axis/AxisRendererHelper.ts +42 -8
- package/src/ChartInternal/ChartInternal.ts +46 -19
- package/src/ChartInternal/data/IData.ts +13 -0
- package/src/ChartInternal/data/data.ts +26 -5
- package/src/ChartInternal/data/load.ts +2 -2
- package/src/ChartInternal/interactions/interaction.ts +15 -11
- package/src/ChartInternal/internals/class.ts +3 -2
- package/src/ChartInternal/internals/domain.ts +4 -2
- package/src/ChartInternal/internals/format.ts +3 -1
- package/src/ChartInternal/internals/legend.ts +2 -1
- package/src/ChartInternal/internals/redraw.ts +3 -3
- package/src/ChartInternal/internals/size.ts +5 -3
- package/src/ChartInternal/internals/text.ts +24 -28
- package/src/ChartInternal/internals/tooltip.ts +35 -14
- package/src/ChartInternal/internals/transform.ts +2 -2
- package/src/ChartInternal/internals/type.ts +101 -9
- package/src/ChartInternal/shape/boxplot.ts +172 -0
- package/src/ChartInternal/shape/bullet.ts +323 -0
- package/src/ChartInternal/shape/core/boxplot.ts +241 -0
- package/src/ChartInternal/shape/core/bullet.ts +734 -0
- package/src/ChartInternal/shape/core/heatmap.ts +665 -0
- package/src/ChartInternal/shape/core/sankey.ts +782 -0
- package/src/ChartInternal/shape/funnel.ts +73 -2
- package/src/ChartInternal/shape/heatmap.ts +236 -0
- package/src/ChartInternal/shape/radar.ts +30 -1
- package/src/ChartInternal/shape/sankey.ts +242 -0
- package/src/ChartInternal/shape/shape.ts +1 -1
- package/src/ChartInternal/shape/treemap.ts +10 -0
- package/src/Plugin/stanford/index.ts +1 -28
- package/src/canvas/CanvasAxisRenderer.ts +35 -574
- package/src/canvas/CanvasRenderer.ts +68 -640
- package/src/canvas/CanvasTheme.ts +92 -6
- package/src/canvas/HitDetector.ts +30 -28
- package/src/canvas/boxplot.ts +230 -0
- package/src/canvas/bullet.ts +269 -0
- package/src/canvas/flow.ts +237 -0
- package/src/canvas/grid.ts +359 -0
- package/src/canvas/heatmap.ts +147 -0
- package/src/canvas/labels.ts +3 -1
- package/src/canvas/sankey.ts +151 -0
- package/src/canvas/selection.ts +626 -0
- package/src/canvas/subchart.ts +1292 -0
- package/src/canvas/treemap.ts +142 -0
- package/src/config/Options/axis/y2.ts +13 -0
- package/src/config/Options/data/data.ts +47 -1
- package/src/config/Options/shape/boxplot.ts +95 -0
- package/src/config/Options/shape/bullet.ts +170 -0
- package/src/config/Options/shape/heatmap.ts +125 -0
- package/src/config/Options/shape/sankey.ts +108 -0
- package/src/config/Store/State.ts +1 -1
- package/src/config/classes.ts +0 -1
- package/src/config/const.ts +30 -21
- package/src/config/resolver/canvas.ts +126 -1290
- package/src/config/resolver/canvasBoxplot.ts +42 -0
- package/src/config/resolver/canvasBullet.ts +20 -0
- package/src/config/resolver/canvasFlow.ts +18 -0
- package/src/config/resolver/canvasGrid.ts +17 -0
- package/src/config/resolver/canvasHeatmap.ts +23 -0
- package/src/config/resolver/canvasSankey.ts +23 -0
- package/src/config/resolver/canvasSelection.ts +20 -0
- package/src/config/resolver/canvasShape.ts +6 -1
- package/src/config/resolver/canvasSubchart.ts +20 -0
- package/src/config/resolver/canvasType.ts +51 -0
- package/src/config/resolver/customType.ts +69 -0
- package/src/config/resolver/shape/boxplot.ts +31 -0
- package/src/config/resolver/shape/bullet.ts +18 -0
- package/src/config/resolver/shape/funnel.ts +8 -2
- package/src/config/resolver/shape/heatmap.ts +18 -0
- package/src/config/resolver/shape/index.ts +4 -0
- package/src/config/resolver/shape/sankey.ts +18 -0
- package/src/index.canvas.ts +9 -3
- package/src/index.esm.ts +4 -0
- package/src/index.ts +34 -0
- package/src/module/error.ts +32 -18
- package/src/module/util/object.ts +26 -1
- package/src/scss/billboard.scss +106 -0
- package/src/scss/theme/dark.scss +110 -0
- package/src/scss/theme/datalab.scss +106 -0
- package/src/scss/theme/graph.scss +106 -0
- package/src/scss/theme/insight.scss +106 -0
- package/src/scss/theme/modern.scss +106 -0
- package/types/bb.d.ts +4 -0
- package/types/canvas.d.ts +3 -0
- package/types/chart.d.ts +5 -0
- package/types/index.d.ts +4 -0
- package/types/options.d.ts +10 -1
- package/types/options.shape.d.ts +431 -0
- package/types/types.d.ts +4 -0
|
@@ -5,8 +5,9 @@
|
|
|
5
5
|
import {select as d3Select} from "d3-selection";
|
|
6
6
|
import {curveLinear as d3CurveLinear, line as d3Line} from "d3-shape";
|
|
7
7
|
import {$COMMON, $FUNNEL} from "../../config/classes";
|
|
8
|
-
import {isObject} from "../../module/util";
|
|
8
|
+
import {getElementPos, isNumber, isObject} from "../../module/util";
|
|
9
9
|
import type {IData, IDataRow, IFunnelData} from "../data/IData";
|
|
10
|
+
import {getTextPos} from "../internals/text.util";
|
|
10
11
|
|
|
11
12
|
type TSize = { [key in "width" | "height" | "top" | "left"]: number };
|
|
12
13
|
type TSizeCurrent = Pick<TSize, "width" | "height">;
|
|
@@ -285,7 +286,67 @@ function _getSplineClipPath(): string {
|
|
|
285
286
|
return isRotated ? `${path1}${path2}z` : `M0,0${path1.replace(/^M/, "L")}${path2}z`;
|
|
286
287
|
}
|
|
287
288
|
|
|
289
|
+
/**
|
|
290
|
+
* How the funnel differs from the other types for the shared code.
|
|
291
|
+
* It asks these through `getCustomTypeHooks()` (they are registered with the type name).
|
|
292
|
+
* @private
|
|
293
|
+
*/
|
|
294
|
+
export const customTypeHooks = {
|
|
295
|
+
// the label is not drawn with the color of the series
|
|
296
|
+
themeTextColor: true,
|
|
297
|
+
|
|
298
|
+
// funnel is drawn by svg only: canvas mode falls back to it, and warns with this
|
|
299
|
+
canvasUnsupported: "funnel chart",
|
|
300
|
+
|
|
301
|
+
// the data of the types that are left is transformed again after the unload
|
|
302
|
+
afterUnload($$): void {
|
|
303
|
+
$$.updateFunnel($$.data.targets);
|
|
304
|
+
},
|
|
305
|
+
|
|
306
|
+
// the data labels are of the values, as for the type of the axis
|
|
307
|
+
labelData($$, d): IDataRow[] {
|
|
308
|
+
return d.values.filter(v => isNumber(v.value) || Boolean(v.value));
|
|
309
|
+
},
|
|
310
|
+
|
|
311
|
+
// the pre-calculated center x is in points[2]
|
|
312
|
+
// the current position is kept when there are no points (during the hide transition)
|
|
313
|
+
textX($$, points, d, textElement, labelDimension?): number {
|
|
314
|
+
if (!points) {
|
|
315
|
+
return getElementPos(textElement, "x");
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
return (points[2]?.[0] ?? points[0][0]) +
|
|
319
|
+
$$.getCenteredTextPos(d, points, textElement, "x", labelDimension) +
|
|
320
|
+
getTextPos.call($$, d, "x");
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
// the pre-calculated center y is in points[2], and it is kept as well without points
|
|
324
|
+
textY($$, points, d, textElement, rect, labelDimension?): number {
|
|
325
|
+
if (!points) {
|
|
326
|
+
return getElementPos(textElement, "y");
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
let yPos = (points[2]?.[1] ?? points[0][1]) + rect.height / 2 - 3;
|
|
330
|
+
|
|
331
|
+
if (!$$.config.axis_rotated) {
|
|
332
|
+
yPos += $$.getCenteredTextPos(d, points, textElement, "y", labelDimension);
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
return yPos + getTextPos.call($$, d, "y");
|
|
336
|
+
}
|
|
337
|
+
};
|
|
338
|
+
|
|
288
339
|
export default {
|
|
340
|
+
/**
|
|
341
|
+
* Whether the data belongs to the funnel type.
|
|
342
|
+
* @param {object} d Data object
|
|
343
|
+
* @returns {boolean}
|
|
344
|
+
* @private
|
|
345
|
+
*/
|
|
346
|
+
isFunnelType(d): boolean {
|
|
347
|
+
return this.isTypeOf(d, "funnel");
|
|
348
|
+
},
|
|
349
|
+
|
|
289
350
|
/**
|
|
290
351
|
* Initialize funnel
|
|
291
352
|
* @private
|
|
@@ -343,6 +404,16 @@ export default {
|
|
|
343
404
|
$$.hideTooltip();
|
|
344
405
|
$$.setOverOut(false, data);
|
|
345
406
|
}
|
|
407
|
+
})
|
|
408
|
+
// use the clicked path itself: getTarget() takes the tooltip API's receiver for an
|
|
409
|
+
// untrusted event, and the background path has no data
|
|
410
|
+
.on("click", event => {
|
|
411
|
+
const {target} = event;
|
|
412
|
+
const data = /^path$/i.test(target.tagName) ?
|
|
413
|
+
d3Select(target).datum() as IDataRow :
|
|
414
|
+
null;
|
|
415
|
+
|
|
416
|
+
data?.id && config.data_onclick.bind($$.api)(data, target);
|
|
346
417
|
});
|
|
347
418
|
},
|
|
348
419
|
|
|
@@ -360,7 +431,7 @@ export default {
|
|
|
360
431
|
}
|
|
361
432
|
|
|
362
433
|
const classChartFunnel = $$.getChartClass("Funnel");
|
|
363
|
-
const classFunnel = $$.getClass("funnel", true);
|
|
434
|
+
const classFunnel = $$.getClass("funnel", true, true);
|
|
364
435
|
const targets = _getFunnelData.call($$, t.filter($$.isFunnelType.bind($$)));
|
|
365
436
|
|
|
366
437
|
const mainFunnelUpdate = $$.filterNullish(targets);
|
|
@@ -0,0 +1,236 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import {select as d3Select} from "d3-selection";
|
|
6
|
+
import {$COMMON, $FOCUS, $SHAPE} from "../../config/classes";
|
|
7
|
+
import shapeHeatmapCommon, {$HEATMAP, type IHeatmapCell, type IHeatmapText} from "./core/heatmap";
|
|
8
|
+
|
|
9
|
+
const ANCHOR = {left: "start", right: "end", center: "middle"};
|
|
10
|
+
const DY = {middle: ".35em", top: ".71em", bottom: "0"};
|
|
11
|
+
|
|
12
|
+
export default {
|
|
13
|
+
...shapeHeatmapCommon,
|
|
14
|
+
|
|
15
|
+
/**
|
|
16
|
+
* Initialize heatmap
|
|
17
|
+
* @private
|
|
18
|
+
*/
|
|
19
|
+
initHeatmap(): void {
|
|
20
|
+
const $$ = this;
|
|
21
|
+
const {$el} = $$;
|
|
22
|
+
|
|
23
|
+
$el.heatmap = $el.main.select(`.${$COMMON.chart}`)
|
|
24
|
+
.append("g")
|
|
25
|
+
.classed($HEATMAP.chartHeatmap, true);
|
|
26
|
+
|
|
27
|
+
// the gradient of the color bar
|
|
28
|
+
$el.heatmap.append("defs");
|
|
29
|
+
$el.heatmap.append("g").classed($HEATMAP.heatmapRows, true);
|
|
30
|
+
$el.heatmap.append("g").classed($HEATMAP.heatmapNames, true);
|
|
31
|
+
$el.heatmap.append("g").classed($HEATMAP.heatmapColorbar, true);
|
|
32
|
+
|
|
33
|
+
$$.bindHeatmapEvent();
|
|
34
|
+
},
|
|
35
|
+
|
|
36
|
+
/**
|
|
37
|
+
* Bind events
|
|
38
|
+
* @private
|
|
39
|
+
*/
|
|
40
|
+
bindHeatmapEvent(): void {
|
|
41
|
+
const $$ = this;
|
|
42
|
+
const {$el: {heatmap}, config, state} = $$;
|
|
43
|
+
|
|
44
|
+
if (!config.interaction_enabled) {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
const getTarget = event => {
|
|
49
|
+
// events emulated by the tooltip API are dispatched on the group itself
|
|
50
|
+
const target = event.target === heatmap.node() ?
|
|
51
|
+
state.eventReceiver.rect?.node?.() :
|
|
52
|
+
event.target;
|
|
53
|
+
|
|
54
|
+
if (target && /^rect$/i.test(target.tagName)) {
|
|
55
|
+
const datum: IHeatmapCell | undefined = d3Select(target).datum() as any;
|
|
56
|
+
|
|
57
|
+
// a cell without a value is not hit
|
|
58
|
+
if (datum?.id !== undefined && datum.value !== undefined && datum.value !== null) {
|
|
59
|
+
state.event = event;
|
|
60
|
+
return $$.getHeatmapCellData(datum);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const isTouch = state.inputType === "touch";
|
|
66
|
+
|
|
67
|
+
heatmap
|
|
68
|
+
.on(isTouch ? "touchstart" : "mouseover mousemove", event => {
|
|
69
|
+
const data = getTarget(event);
|
|
70
|
+
|
|
71
|
+
if (data) {
|
|
72
|
+
$$.showTooltip([data], $$.$el.svg.node());
|
|
73
|
+
/^(touchstart|mouseover)$/.test(event.type) &&
|
|
74
|
+
$$.setOverOut(true, data, event.target);
|
|
75
|
+
}
|
|
76
|
+
}, isTouch ? {passive: true} : undefined)
|
|
77
|
+
.on(isTouch ? "touchend" : "mouseout", event => {
|
|
78
|
+
const data = getTarget(event);
|
|
79
|
+
|
|
80
|
+
if (config.interaction_onout) {
|
|
81
|
+
$$.hideTooltip();
|
|
82
|
+
$$.setOverOut(false, data, event.target);
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
.on("click", event => {
|
|
86
|
+
const data = getTarget(event);
|
|
87
|
+
|
|
88
|
+
data && config.data_onclick.bind($$.api)(data, event.target);
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Update targets for heatmap.
|
|
94
|
+
* The cells are made from all the series together, on redraw.
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
updateTargetsForHeatmap(): void {
|
|
98
|
+
const $$ = this;
|
|
99
|
+
|
|
100
|
+
!$$.$el.heatmap && $$.initHeatmap();
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Draw a text of the axis or of the color bar
|
|
105
|
+
* @param {d3Selection} sel Text selection
|
|
106
|
+
* @param {boolean} withTransition Whether to transit
|
|
107
|
+
* @private
|
|
108
|
+
*/
|
|
109
|
+
setHeatmapText(sel, withTransition?: boolean): void {
|
|
110
|
+
const $$ = this;
|
|
111
|
+
|
|
112
|
+
sel.each(function(d: IHeatmapText) {
|
|
113
|
+
d3Select(this)
|
|
114
|
+
.attr("class", $HEATMAP.heatmapAxis)
|
|
115
|
+
.text(d.text)
|
|
116
|
+
.attr("dy", DY[d.baseline])
|
|
117
|
+
.style("text-anchor", ANCHOR[d.align]);
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
$$.$T(sel, withTransition)
|
|
121
|
+
.attr("x", d => d.x)
|
|
122
|
+
.attr("y", d => d.y);
|
|
123
|
+
},
|
|
124
|
+
|
|
125
|
+
/**
|
|
126
|
+
* Render heatmap
|
|
127
|
+
* @param {boolean} withTransition Whether to transit
|
|
128
|
+
* @private
|
|
129
|
+
*/
|
|
130
|
+
redrawHeatmap(withTransition?: boolean): void {
|
|
131
|
+
const $$ = this;
|
|
132
|
+
const {$el: {heatmap}, config, state} = $$;
|
|
133
|
+
const {cells, rows, axisX, axisY, colorbar} = $$.getHeatmapLayout();
|
|
134
|
+
const radius = config.heatmap_cell_radius;
|
|
135
|
+
const borderWidth = config.heatmap_cell_border_width;
|
|
136
|
+
const byRow = new Map<string, IHeatmapCell[]>(rows.map(id => [id, []]));
|
|
137
|
+
|
|
138
|
+
cells.forEach(d => byRow.get(d.id)?.push(d));
|
|
139
|
+
|
|
140
|
+
// rows: the target class of the id makes show(), hide(), focus() and tooltip.show() find it
|
|
141
|
+
const row = heatmap.select(`.${$HEATMAP.heatmapRows}`)
|
|
142
|
+
.selectAll(`.${$HEATMAP.heatmapRow}`)
|
|
143
|
+
.data(rows, d => d);
|
|
144
|
+
|
|
145
|
+
row.exit().remove();
|
|
146
|
+
|
|
147
|
+
const rowMerge = row.enter().append("g").merge(row)
|
|
148
|
+
.attr("class", id => $HEATMAP.heatmapRow + $$.classTarget(id));
|
|
149
|
+
|
|
150
|
+
rowMerge.each(function(id) {
|
|
151
|
+
const g = d3Select(this);
|
|
152
|
+
const rowCells = byRow.get(id) as IHeatmapCell[];
|
|
153
|
+
const cell = g.selectAll<SVGRectElement, IHeatmapCell>(`.${$HEATMAP.heatmapCell}`)
|
|
154
|
+
.data(rowCells, d => d.index);
|
|
155
|
+
|
|
156
|
+
cell.exit().remove();
|
|
157
|
+
|
|
158
|
+
const cellMerge = cell.enter()
|
|
159
|
+
.append("rect")
|
|
160
|
+
.style("opacity", "0")
|
|
161
|
+
.merge(cell)
|
|
162
|
+
.attr("class",
|
|
163
|
+
d => `${$SHAPE.shape} ${$SHAPE.shape}-${d.index} ${$HEATMAP.heatmapCell}`)
|
|
164
|
+
.style("fill", d => d.color)
|
|
165
|
+
.style("stroke", <any>(borderWidth ? config.heatmap_cell_border_color : null))
|
|
166
|
+
.style("stroke-width", <any>(borderWidth ? `${borderWidth}px` : null))
|
|
167
|
+
.attr("rx", radius || null);
|
|
168
|
+
|
|
169
|
+
$$.$T(cellMerge, withTransition)
|
|
170
|
+
.attr("x", d => d.x0)
|
|
171
|
+
.attr("y", d => d.y0)
|
|
172
|
+
.attr("width", d => Math.max(0, d.x1 - d.x0))
|
|
173
|
+
.attr("height", d => Math.max(0, d.y1 - d.y0))
|
|
174
|
+
.style("opacity", null);
|
|
175
|
+
|
|
176
|
+
// the values in the cells
|
|
177
|
+
const label = g.selectAll<SVGTextElement, IHeatmapCell>(`.${$HEATMAP.heatmapLabel}`)
|
|
178
|
+
.data(config.heatmap_label_show ? rowCells.filter(d => d.value !== null) : [],
|
|
179
|
+
d => d.index);
|
|
180
|
+
|
|
181
|
+
label.exit().remove();
|
|
182
|
+
label.enter().append("text").merge(label)
|
|
183
|
+
.attr("class", $HEATMAP.heatmapLabel)
|
|
184
|
+
.attr("x", d => (d.x0 + d.x1) / 2)
|
|
185
|
+
.attr("y", d => (d.y0 + d.y1) / 2)
|
|
186
|
+
.attr("dy", ".35em")
|
|
187
|
+
.style("text-anchor", "middle")
|
|
188
|
+
.style("fill", d => $$.getHeatmapLabelColor(d))
|
|
189
|
+
.text(d => $$.getHeatmapLabel(d));
|
|
190
|
+
});
|
|
191
|
+
|
|
192
|
+
// the names of the columns and of the rows
|
|
193
|
+
const axis = heatmap.select(`.${$HEATMAP.heatmapNames}`)
|
|
194
|
+
.selectAll("text")
|
|
195
|
+
.data(axisX.concat(axisY), (d: IHeatmapText) => `${d.align}${d.text}`);
|
|
196
|
+
|
|
197
|
+
axis.exit().remove();
|
|
198
|
+
$$.setHeatmapText(axis.enter().append("text").merge(axis), withTransition);
|
|
199
|
+
|
|
200
|
+
// the color bar
|
|
201
|
+
const bar = heatmap.select(`.${$HEATMAP.heatmapColorbar}`);
|
|
202
|
+
const gradientId = `${state.datetimeId}-heatmap-colorbar`;
|
|
203
|
+
|
|
204
|
+
bar.selectAll("*").remove();
|
|
205
|
+
heatmap.select("defs").selectAll("*").remove();
|
|
206
|
+
|
|
207
|
+
if (colorbar) {
|
|
208
|
+
heatmap.select("defs")
|
|
209
|
+
.append("linearGradient")
|
|
210
|
+
.attr("id", gradientId)
|
|
211
|
+
.attr("x1", 0).attr("x2", colorbar.horizontal ? 1 : 0).attr("y1", 0).attr("y2",
|
|
212
|
+
colorbar.horizontal ? 0 : 1)
|
|
213
|
+
.selectAll("stop")
|
|
214
|
+
.data(colorbar.stops)
|
|
215
|
+
.enter()
|
|
216
|
+
.append("stop")
|
|
217
|
+
.attr("offset", d => d[0])
|
|
218
|
+
.attr("stop-color", d => d[1]);
|
|
219
|
+
|
|
220
|
+
bar.append("rect")
|
|
221
|
+
.attr("x", colorbar.x)
|
|
222
|
+
.attr("y", colorbar.y)
|
|
223
|
+
.attr("width", colorbar.width)
|
|
224
|
+
.attr("height", colorbar.height)
|
|
225
|
+
.style("fill", `url(#${gradientId})`);
|
|
226
|
+
|
|
227
|
+
$$.setHeatmapText(bar.selectAll("text").data(colorbar.labels).enter().append("text"));
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
$$.fitHeatmapHeight();
|
|
231
|
+
|
|
232
|
+
// the classes are set again above: keep the focus state over a redraw
|
|
233
|
+
heatmap.selectAll(`.${$HEATMAP.heatmapRow}`)
|
|
234
|
+
.classed($FOCUS.defocused, id => $$.isHeatmapDefocused(id as string));
|
|
235
|
+
}
|
|
236
|
+
};
|
|
@@ -17,6 +17,7 @@ import {
|
|
|
17
17
|
setTextValue,
|
|
18
18
|
toArray
|
|
19
19
|
} from "../../module/util";
|
|
20
|
+
import type {IDataRow} from "../data/IData";
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Get the position value
|
|
@@ -65,6 +66,16 @@ export default {
|
|
|
65
66
|
|
|
66
67
|
current.dataMax = config.radar_axis_max || $$.getMinMaxData().max[0].value;
|
|
67
68
|
|
|
69
|
+
// points take clicks even when the axis text is hidden
|
|
70
|
+
config.interaction_enabled && $el.radar.shapes.on("click", event => {
|
|
71
|
+
const {target} = event;
|
|
72
|
+
const data = /^circle$/i.test(target.tagName) ?
|
|
73
|
+
d3Select(target).datum() as IDataRow :
|
|
74
|
+
null;
|
|
75
|
+
|
|
76
|
+
data?.id && config.data_onclick.bind($$.api)(data, target);
|
|
77
|
+
});
|
|
78
|
+
|
|
68
79
|
if (config.radar_axis_text_show) {
|
|
69
80
|
config.interaction_enabled && $$.bindRadarEvent();
|
|
70
81
|
|
|
@@ -374,7 +385,25 @@ export default {
|
|
|
374
385
|
$$.selectRectForSingle(svg.node(), index);
|
|
375
386
|
isMouse ? $$.setOverOut(true, index) : $$.callOverOutForTouch(index);
|
|
376
387
|
}, isMouse ? undefined : {passive: true})
|
|
377
|
-
.on("mouseout", isMouse ? hide : null)
|
|
388
|
+
.on("mouseout", isMouse ? hide : null)
|
|
389
|
+
// an axis text stands for its index, like the tooltip it shows: every row at it
|
|
390
|
+
.on("click", event => {
|
|
391
|
+
const index = $$.getDataIndexFromEvent(event);
|
|
392
|
+
|
|
393
|
+
if (isUndefined(index)) {
|
|
394
|
+
return;
|
|
395
|
+
}
|
|
396
|
+
|
|
397
|
+
const target = /tspan/i.test(event.target.tagName) ?
|
|
398
|
+
event.target.parentNode :
|
|
399
|
+
event.target;
|
|
400
|
+
|
|
401
|
+
$$.filterTargetsToShow($$.data.targets).forEach(t => {
|
|
402
|
+
const data = $$.getValueOnIndex(t.values, index);
|
|
403
|
+
|
|
404
|
+
data && config.data_onclick.bind($$.api)(data, target);
|
|
405
|
+
});
|
|
406
|
+
});
|
|
378
407
|
|
|
379
408
|
if (!isMouse) {
|
|
380
409
|
svg.on("touchstart", hide, {passive: true});
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import {select as d3Select} from "d3-selection";
|
|
6
|
+
import {$COMMON, $FOCUS, $SHAPE} from "../../config/classes";
|
|
7
|
+
import shapeSankeyCommon, {$SANKEY, type ISankeyLink, type ISankeyNode} from "./core/sankey";
|
|
8
|
+
|
|
9
|
+
export default {
|
|
10
|
+
...shapeSankeyCommon,
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* Initialize sankey
|
|
14
|
+
* @private
|
|
15
|
+
*/
|
|
16
|
+
initSankey(): void {
|
|
17
|
+
const $$ = this;
|
|
18
|
+
const {$el} = $$;
|
|
19
|
+
|
|
20
|
+
$el.sankey = $el.main.select(`.${$COMMON.chart}`)
|
|
21
|
+
.append("g")
|
|
22
|
+
.classed($SANKEY.chartSankey, true);
|
|
23
|
+
|
|
24
|
+
// the gradients of the links, for sankey.link.color="gradient"
|
|
25
|
+
$el.sankey.append("defs");
|
|
26
|
+
|
|
27
|
+
// the links are under the nodes
|
|
28
|
+
$el.sankey.append("g").classed($SANKEY.sankeyLinks, true);
|
|
29
|
+
$el.sankey.append("g").classed($SANKEY.sankeyNodes, true);
|
|
30
|
+
|
|
31
|
+
$$.bindSankeyEvent();
|
|
32
|
+
},
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Bind events
|
|
36
|
+
* @private
|
|
37
|
+
*/
|
|
38
|
+
bindSankeyEvent(): void {
|
|
39
|
+
const $$ = this;
|
|
40
|
+
const {$el: {sankey}, config, state} = $$;
|
|
41
|
+
|
|
42
|
+
if (!config.interaction_enabled) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
const getTarget = event => {
|
|
47
|
+
// events emulated by the tooltip API are dispatched on the group itself
|
|
48
|
+
const target = event.target === sankey.node() ?
|
|
49
|
+
state.eventReceiver.rect?.node?.() :
|
|
50
|
+
event.target;
|
|
51
|
+
|
|
52
|
+
if (target && /^(rect|path)$/i.test(target.tagName)) {
|
|
53
|
+
const datum: any = d3Select(target).datum();
|
|
54
|
+
|
|
55
|
+
if (datum?.sourceLinks) {
|
|
56
|
+
state.event = event;
|
|
57
|
+
return $$.getSankeyNodeData(datum);
|
|
58
|
+
} else if (datum?.source) {
|
|
59
|
+
state.event = event;
|
|
60
|
+
return $$.getSankeyLinkData(datum);
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
const isTouch = state.inputType === "touch";
|
|
66
|
+
|
|
67
|
+
sankey
|
|
68
|
+
.on(isTouch ? "touchstart" : "mouseover mousemove", event => {
|
|
69
|
+
const data = getTarget(event);
|
|
70
|
+
|
|
71
|
+
if (data) {
|
|
72
|
+
$$.showTooltip([data], $$.$el.svg.node());
|
|
73
|
+
/^(touchstart|mouseover)$/.test(event.type) &&
|
|
74
|
+
$$.setOverOut(true, data, event.target);
|
|
75
|
+
}
|
|
76
|
+
}, isTouch ? {passive: true} : undefined)
|
|
77
|
+
.on(isTouch ? "touchend" : "mouseout", event => {
|
|
78
|
+
const data = getTarget(event);
|
|
79
|
+
|
|
80
|
+
if (config.interaction_onout) {
|
|
81
|
+
$$.hideTooltip();
|
|
82
|
+
$$.setOverOut(false, data, event.target);
|
|
83
|
+
}
|
|
84
|
+
})
|
|
85
|
+
.on("click", event => {
|
|
86
|
+
const data = getTarget(event);
|
|
87
|
+
|
|
88
|
+
data && config.data_onclick.bind($$.api)(data, event.target);
|
|
89
|
+
});
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
/**
|
|
93
|
+
* Update targets for sankey.
|
|
94
|
+
* The nodes and the links are made from all the series together, on redraw.
|
|
95
|
+
* @private
|
|
96
|
+
*/
|
|
97
|
+
updateTargetsForSankey(): void {
|
|
98
|
+
const $$ = this;
|
|
99
|
+
|
|
100
|
+
!$$.$el.sankey && $$.initSankey();
|
|
101
|
+
},
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Set the defocused class of the links and the nodes, from the focus state.
|
|
105
|
+
* @private
|
|
106
|
+
*/
|
|
107
|
+
updateSankeyFocus(): void {
|
|
108
|
+
const $$ = this;
|
|
109
|
+
const isDefocused = d => $$.isSankeyDefocused(d);
|
|
110
|
+
|
|
111
|
+
$$.$el.sankey?.selectAll(`.${$SANKEY.sankeyLink}, .${$SANKEY.sankeyNode}`)
|
|
112
|
+
.classed($FOCUS.defocused, isDefocused);
|
|
113
|
+
},
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Render sankey
|
|
117
|
+
* @param {boolean} withTransition Whether to transit
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
redrawSankey(withTransition?: boolean): void {
|
|
121
|
+
const $$ = this;
|
|
122
|
+
const {$el: {sankey}, config, state} = $$;
|
|
123
|
+
const {nodes, links} = $$.getSankeyLayout();
|
|
124
|
+
const rotated = config.sankey_rotated;
|
|
125
|
+
const borderWidth = config.sankey_node_border_width;
|
|
126
|
+
const linkKey = (d: ISankeyLink) => `${d.source.id}\u0000${d.target.id}\u0000${d.index}`;
|
|
127
|
+
const nodeKey = (d: ISankeyNode) => d.id;
|
|
128
|
+
const gradientId = (d: ISankeyLink) => `${state.datetimeId}-sankey-link-${d.index}`;
|
|
129
|
+
|
|
130
|
+
// sankey.link.opacity: the stylesheet reads it, and keeps the hover highlight over it
|
|
131
|
+
sankey.style("--bb-sankey-link-opacity", config.sankey_link_opacity ?? null);
|
|
132
|
+
|
|
133
|
+
// links
|
|
134
|
+
const link = sankey.select(`.${$SANKEY.sankeyLinks}`)
|
|
135
|
+
.selectAll(`.${$SANKEY.sankeyLink}`)
|
|
136
|
+
.data(links, linkKey);
|
|
137
|
+
|
|
138
|
+
link.exit().remove();
|
|
139
|
+
|
|
140
|
+
const linkMerge = link.enter()
|
|
141
|
+
.append("path")
|
|
142
|
+
.style("opacity", "0")
|
|
143
|
+
.merge(link)
|
|
144
|
+
.attr("class", d => $$.generateClass($SANKEY.sankeyLink, d.source.id))
|
|
145
|
+
.style("stroke", d => {
|
|
146
|
+
const [start, end] = $$.getSankeyLinkColors(d);
|
|
147
|
+
|
|
148
|
+
return start === end ? start : `url(#${gradientId(d)})`;
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
// a gradient along the flow for each link painted with two colors
|
|
152
|
+
const gradient = sankey.select("defs")
|
|
153
|
+
.selectAll("linearGradient")
|
|
154
|
+
.data(links.filter(d => {
|
|
155
|
+
const [start, end] = $$.getSankeyLinkColors(d);
|
|
156
|
+
|
|
157
|
+
return start !== end;
|
|
158
|
+
}));
|
|
159
|
+
|
|
160
|
+
gradient.exit().remove();
|
|
161
|
+
|
|
162
|
+
gradient.enter()
|
|
163
|
+
.append("linearGradient")
|
|
164
|
+
.attr("gradientUnits", "userSpaceOnUse")
|
|
165
|
+
.call(g => {
|
|
166
|
+
g.append("stop").attr("offset", "0");
|
|
167
|
+
g.append("stop").attr("offset", "1");
|
|
168
|
+
})
|
|
169
|
+
.merge(gradient)
|
|
170
|
+
.attr("id", d => gradientId(d))
|
|
171
|
+
.each(function(d) {
|
|
172
|
+
const [[start], , , [end]] = $$.getSankeyLinkPoints(d, true);
|
|
173
|
+
const [along, across] = rotated ? ["y", "x"] : ["x", "y"];
|
|
174
|
+
const colors = $$.getSankeyLinkColors(d);
|
|
175
|
+
|
|
176
|
+
d3Select(this)
|
|
177
|
+
.attr(`${along}1`, start)
|
|
178
|
+
.attr(`${along}2`, end)
|
|
179
|
+
.attr(`${across}1`, 0)
|
|
180
|
+
.attr(`${across}2`, 0)
|
|
181
|
+
.selectAll("stop")
|
|
182
|
+
.attr("stop-color", (_, j) => colors[j]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
$$.$T(linkMerge, withTransition)
|
|
186
|
+
.attr("d", d => $$.getSankeyLinkPath(d))
|
|
187
|
+
.style("stroke-width", d => `${Math.max(1, d.width)}px`)
|
|
188
|
+
.style("opacity", null);
|
|
189
|
+
|
|
190
|
+
// nodes, and their names
|
|
191
|
+
const node = sankey.select(`.${$SANKEY.sankeyNodes}`)
|
|
192
|
+
.selectAll(`.${$SANKEY.sankeyNode}`)
|
|
193
|
+
.data(nodes, nodeKey);
|
|
194
|
+
|
|
195
|
+
node.exit().remove();
|
|
196
|
+
|
|
197
|
+
const nodeEnter = node.enter().append("g");
|
|
198
|
+
|
|
199
|
+
nodeEnter.append("rect").attr("class", $SHAPE.shape);
|
|
200
|
+
nodeEnter.append("text").attr("class", $SANKEY.sankeyLabel);
|
|
201
|
+
|
|
202
|
+
// the target class of the node id: show(), hide(), focus() and tooltip.show() find it so
|
|
203
|
+
const nodeMerge = nodeEnter.merge(node)
|
|
204
|
+
.attr("class", d => $SANKEY.sankeyNode + $$.classTarget(d.id));
|
|
205
|
+
|
|
206
|
+
nodeMerge.select("rect")
|
|
207
|
+
.datum(d => d)
|
|
208
|
+
.style("fill", d => d.color)
|
|
209
|
+
.style("stroke", borderWidth ? config.sankey_node_border_color : null)
|
|
210
|
+
.style("stroke-width", borderWidth ? `${borderWidth}px` : null)
|
|
211
|
+
.call(sel => {
|
|
212
|
+
$$.$T(sel, withTransition)
|
|
213
|
+
.attr("x", d => d.x0)
|
|
214
|
+
.attr("y", d => d.y0)
|
|
215
|
+
.attr("width", d => Math.max(1, d.x1 - d.x0))
|
|
216
|
+
.attr("height", d => Math.max(1, d.y1 - d.y0));
|
|
217
|
+
});
|
|
218
|
+
|
|
219
|
+
nodeMerge.select("text")
|
|
220
|
+
.datum(d => d)
|
|
221
|
+
.each(function(d: ISankeyNode) {
|
|
222
|
+
const label = $$.getSankeyLabel(d);
|
|
223
|
+
const text = d3Select(this);
|
|
224
|
+
|
|
225
|
+
if (label) {
|
|
226
|
+
text.text(label.text)
|
|
227
|
+
.attr("dy", {middle: ".35em", top: ".71em", bottom: "0"}[label.baseline])
|
|
228
|
+
.style("text-anchor",
|
|
229
|
+
{left: "start", right: "end", center: "middle"}[label.align]);
|
|
230
|
+
|
|
231
|
+
$$.$T(text, withTransition)
|
|
232
|
+
.attr("x", label.x)
|
|
233
|
+
.attr("y", label.y);
|
|
234
|
+
} else {
|
|
235
|
+
text.text(null);
|
|
236
|
+
}
|
|
237
|
+
});
|
|
238
|
+
|
|
239
|
+
// the classes are set again above: keep the focus state over a redraw
|
|
240
|
+
$$.updateSankeyFocus();
|
|
241
|
+
}
|
|
242
|
+
};
|
|
@@ -311,7 +311,7 @@ export default {
|
|
|
311
311
|
const {hasRadar, hasTreemap} = $$.state;
|
|
312
312
|
const shape = {type: <TShape>{}, indices: <TShape>{}, pos: {}};
|
|
313
313
|
|
|
314
|
-
!hasTreemap && ["bar", "candlestick", "line", "area"].forEach(v => {
|
|
314
|
+
!hasTreemap && ["bar", "candlestick", "line", "area", ...$$.getAxisTypes()].forEach(v => {
|
|
315
315
|
const name = capitalize(v);
|
|
316
316
|
|
|
317
317
|
if (
|
|
@@ -102,6 +102,16 @@ export default {
|
|
|
102
102
|
$$.hideTooltip();
|
|
103
103
|
$$.setOverOut(false, data);
|
|
104
104
|
}
|
|
105
|
+
})
|
|
106
|
+
// use the clicked tile itself: getTarget() takes the tooltip API's receiver
|
|
107
|
+
// for an untrusted event
|
|
108
|
+
.on("click", event => {
|
|
109
|
+
const {target} = event;
|
|
110
|
+
const data = /^rect$/i.test(target.tagName) ?
|
|
111
|
+
(d3Select(target).datum() as {data?: IDataRow})?.data :
|
|
112
|
+
null;
|
|
113
|
+
|
|
114
|
+
data && config.data_onclick.bind($$.api)(data, target);
|
|
105
115
|
});
|
|
106
116
|
}
|
|
107
117
|
},
|
|
@@ -12,33 +12,6 @@ import Elements from "./Elements";
|
|
|
12
12
|
import Options from "./Options";
|
|
13
13
|
import {compareEpochs, isEmpty, isFunction, pointInRegion} from "./util";
|
|
14
14
|
|
|
15
|
-
/**
|
|
16
|
-
* HSL color object compatible with d3-interpolate
|
|
17
|
-
*/
|
|
18
|
-
interface HSLColor {
|
|
19
|
-
h: number;
|
|
20
|
-
s: number;
|
|
21
|
-
l: number;
|
|
22
|
-
opacity: number;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Creates an HSL color object.
|
|
27
|
-
* @param {number} h Hue (0-360)
|
|
28
|
-
* @param {number} s Saturation (0-1)
|
|
29
|
-
* @param {number} l Lightness (0-1)
|
|
30
|
-
* @param {number} opacity Opacity (0-1), defaults to 1
|
|
31
|
-
* @returns {HSLColor} HSL color object
|
|
32
|
-
*/
|
|
33
|
-
function hsl(h: number, s: number, l: number, opacity: number = 1): HSLColor {
|
|
34
|
-
return {
|
|
35
|
-
h: +h,
|
|
36
|
-
s: +s,
|
|
37
|
-
l: +l,
|
|
38
|
-
opacity: +opacity
|
|
39
|
-
};
|
|
40
|
-
}
|
|
41
|
-
|
|
42
15
|
/**
|
|
43
16
|
* Stanford diagram plugin
|
|
44
17
|
* - **NOTE:**
|
|
@@ -216,7 +189,7 @@ export default class Stanford extends Plugin {
|
|
|
216
189
|
|
|
217
190
|
target.colors = isFunction(config.colors) ?
|
|
218
191
|
config.colors :
|
|
219
|
-
d3InterpolateHslLong(hsl(250,
|
|
192
|
+
d3InterpolateHslLong("hsl(250, 100%, 50%)", "hsl(0, 100%, 50%)");
|
|
220
193
|
|
|
221
194
|
target.colorscale = d3ScaleSequentialLog(target.colors)
|
|
222
195
|
.domain([target.minEpochs, target.maxEpochs]);
|