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
|
@@ -67,6 +67,53 @@ export interface CanvasThemeStyle {
|
|
|
67
67
|
treemap: {stroke: string, lineWidth: number};
|
|
68
68
|
label: {font: string, color: string};
|
|
69
69
|
title: {font: string, color: string};
|
|
70
|
+
// the section of a type added by a module (see CanvasThemeExtension), by its name
|
|
71
|
+
[custom: string]: any;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/**
|
|
75
|
+
* Helpers to read the styles of a theme section from the stylesheet.
|
|
76
|
+
*/
|
|
77
|
+
export interface CanvasThemeProbe {
|
|
78
|
+
// style values of the element, with the given parents
|
|
79
|
+
probeIn(parentCls: string, tag: string, cls: string, props: string[]): Record<string, string>;
|
|
80
|
+
probeInNested(
|
|
81
|
+
parentCls: string,
|
|
82
|
+
groupCls: string,
|
|
83
|
+
tag: string,
|
|
84
|
+
cls: string,
|
|
85
|
+
props: string[]
|
|
86
|
+
): Record<string, string>;
|
|
87
|
+
// default font of the axis text
|
|
88
|
+
axisFont: string;
|
|
89
|
+
toColor(value: string | null | undefined, fallback: string): string;
|
|
90
|
+
toNumber(value: string | number | null | undefined, fallback: number): number;
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
/**
|
|
94
|
+
* Reads the value of a theme selector declaration.
|
|
95
|
+
*/
|
|
96
|
+
export interface CanvasThemeSelectorReader {
|
|
97
|
+
readColorValue(style: CanvasThemeSelectorStyle, prop: string): string | undefined;
|
|
98
|
+
readNumberValue(style: CanvasThemeSelectorStyle, prop: string): number | undefined;
|
|
99
|
+
readFontValue(style: CanvasThemeSelectorStyle): string | undefined;
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/**
|
|
103
|
+
* Theme section of a type that is added by its own module, so that the theme carries nothing of it.
|
|
104
|
+
*/
|
|
105
|
+
export interface CanvasThemeExtension {
|
|
106
|
+
// name of the section in the style
|
|
107
|
+
section: string;
|
|
108
|
+
// default values of the section, from the stylesheet
|
|
109
|
+
probe(helpers: CanvasThemeProbe): Record<string, any>;
|
|
110
|
+
// values of the section for the theme selectors it handles
|
|
111
|
+
selectors?: Record<
|
|
112
|
+
string,
|
|
113
|
+
(style: CanvasThemeSelectorStyle, reader: CanvasThemeSelectorReader) => Record<string, any>
|
|
114
|
+
>;
|
|
115
|
+
// last touch on the section, after the overrides were applied
|
|
116
|
+
normalize?(section: Record<string, any>, helpers: Pick<CanvasThemeProbe, "toNumber">): void;
|
|
70
117
|
}
|
|
71
118
|
|
|
72
119
|
type CanvasThemeDeepPartial<T> = {
|
|
@@ -362,6 +409,13 @@ function mergeThemeSection(
|
|
|
362
409
|
}
|
|
363
410
|
}
|
|
364
411
|
|
|
412
|
+
// handed to the selector handlers of a theme extension
|
|
413
|
+
const themeSelectorReader: CanvasThemeSelectorReader = {
|
|
414
|
+
readColorValue,
|
|
415
|
+
readNumberValue,
|
|
416
|
+
readFontValue
|
|
417
|
+
};
|
|
418
|
+
|
|
365
419
|
/**
|
|
366
420
|
* Normalize a supported SVG selector for canvas theme matching.
|
|
367
421
|
* @param {string} selector SVG selector
|
|
@@ -810,17 +864,27 @@ function applySelectorStyle(
|
|
|
810
864
|
/**
|
|
811
865
|
* Convert selector based canvas theme overrides to renderer theme slots.
|
|
812
866
|
* @param {object} selectors Selector style declarations
|
|
867
|
+
* @param {object} extension Theme section of a type added by a module
|
|
813
868
|
* @returns {object} Canvas theme override
|
|
814
869
|
* @private
|
|
815
870
|
*/
|
|
816
871
|
function getSelectorThemeOverride(
|
|
817
|
-
selectors?: CanvasThemeSelectorMap
|
|
872
|
+
selectors?: CanvasThemeSelectorMap,
|
|
873
|
+
extension?: CanvasThemeExtension
|
|
818
874
|
): CanvasThemeDeepPartial<CanvasThemeStyle> {
|
|
819
875
|
const override: CanvasThemeDeepPartial<CanvasThemeStyle> = {};
|
|
820
876
|
|
|
821
877
|
Object.keys(selectors ?? {}).forEach(selector => {
|
|
822
878
|
normalizeThemeSelectors(selector).forEach(normalizedSelector => {
|
|
823
879
|
applySelectorStyle(override, normalizedSelector, selectors![selector]);
|
|
880
|
+
|
|
881
|
+
const handler = extension?.selectors?.[normalizedSelector];
|
|
882
|
+
|
|
883
|
+
handler && mergeThemeSection(
|
|
884
|
+
override,
|
|
885
|
+
extension!.section,
|
|
886
|
+
handler(selectors![selector], themeSelectorReader)
|
|
887
|
+
);
|
|
824
888
|
});
|
|
825
889
|
});
|
|
826
890
|
|
|
@@ -830,11 +894,13 @@ function getSelectorThemeOverride(
|
|
|
830
894
|
/**
|
|
831
895
|
* Resolve user canvas theme override.
|
|
832
896
|
* @param {object} userOverride Canvas theme override
|
|
897
|
+
* @param {object} extension Theme section of a type added by a module
|
|
833
898
|
* @returns {object} Canvas theme override
|
|
834
899
|
* @private
|
|
835
900
|
*/
|
|
836
901
|
function getThemeOverride(
|
|
837
|
-
userOverride?: CanvasThemeOverride
|
|
902
|
+
userOverride?: CanvasThemeOverride,
|
|
903
|
+
extension?: CanvasThemeExtension
|
|
838
904
|
): CanvasThemeDeepPartial<CanvasThemeStyle> {
|
|
839
905
|
if (!userOverride) {
|
|
840
906
|
return {};
|
|
@@ -842,7 +908,7 @@ function getThemeOverride(
|
|
|
842
908
|
|
|
843
909
|
const {selectors, ...styleOverride} = userOverride;
|
|
844
910
|
|
|
845
|
-
return mergeObj({}, getSelectorThemeOverride(selectors), styleOverride);
|
|
911
|
+
return mergeObj({}, getSelectorThemeOverride(selectors, extension), styleOverride);
|
|
846
912
|
}
|
|
847
913
|
|
|
848
914
|
/**
|
|
@@ -877,16 +943,24 @@ export default class CanvasTheme {
|
|
|
877
943
|
private cacheKey: string | null = null;
|
|
878
944
|
private gridLineSelectorOverrides: CanvasGridLineSelectorOverride[] = [];
|
|
879
945
|
private directGridOverrideKeys = new Set<keyof CanvasThemeStyle["grid"]>();
|
|
946
|
+
private extension?: CanvasThemeExtension;
|
|
880
947
|
|
|
881
948
|
/**
|
|
882
949
|
* Read theme values from temporary SVG probes.
|
|
883
950
|
* @param {HTMLElement} container Chart container
|
|
884
951
|
* @param {object} userOverride Canvas theme override
|
|
952
|
+
* @param {object} extension Theme section of a type added by a module
|
|
885
953
|
* @private
|
|
886
954
|
*/
|
|
887
|
-
load(
|
|
955
|
+
load(
|
|
956
|
+
container: HTMLElement,
|
|
957
|
+
userOverride?: CanvasThemeOverride,
|
|
958
|
+
extension?: CanvasThemeExtension
|
|
959
|
+
): void {
|
|
888
960
|
const svg = document.createElementNS(SVG_NS, "svg");
|
|
889
961
|
|
|
962
|
+
extension && (this.extension = extension);
|
|
963
|
+
|
|
890
964
|
this.gridLineSelectorOverrides = getGridLineSelectorOverrides(userOverride?.selectors);
|
|
891
965
|
this.directGridOverrideKeys = new Set(
|
|
892
966
|
Object.keys(userOverride?.grid ?? {})
|
|
@@ -1110,7 +1184,7 @@ export default class CanvasTheme {
|
|
|
1110
1184
|
toOptionalNumber(subchartBrushExtent.opacity, 1) ??
|
|
1111
1185
|
zoomBrushOpacity;
|
|
1112
1186
|
const subchartBrushHandleStroke = toColor(subchartBrushHandle.stroke, "transparent");
|
|
1113
|
-
const defaultStyle = {
|
|
1187
|
+
const defaultStyle: Record<string, any> = {
|
|
1114
1188
|
axis: {
|
|
1115
1189
|
lineColor: toColor(axisLine.stroke, "#000"),
|
|
1116
1190
|
lineWidth: toNumber(axisLine["stroke-width"], 1),
|
|
@@ -1218,7 +1292,18 @@ export default class CanvasTheme {
|
|
|
1218
1292
|
color: toColor(title.fill, "#000")
|
|
1219
1293
|
}
|
|
1220
1294
|
};
|
|
1221
|
-
const
|
|
1295
|
+
const ext = this.extension;
|
|
1296
|
+
|
|
1297
|
+
// the section of a type that is added by a module
|
|
1298
|
+
ext && (defaultStyle[ext.section] = ext.probe({
|
|
1299
|
+
probeIn,
|
|
1300
|
+
probeInNested,
|
|
1301
|
+
axisFont: axisText.font || "10px sans-serif",
|
|
1302
|
+
toColor,
|
|
1303
|
+
toNumber
|
|
1304
|
+
}));
|
|
1305
|
+
|
|
1306
|
+
const themeOverride = getThemeOverride(userOverride, ext);
|
|
1222
1307
|
const style = mergeObj(defaultStyle, themeOverride);
|
|
1223
1308
|
const userAxisOverride = userOverride?.axis as
|
|
1224
1309
|
| CanvasThemeDeepPartial<CanvasThemeStyle["axis"]>
|
|
@@ -1320,6 +1405,7 @@ export default class CanvasTheme {
|
|
|
1320
1405
|
defaultStyle.subchartBrush.handleLineWidth
|
|
1321
1406
|
);
|
|
1322
1407
|
style.treemap.lineWidth = toNumber(style.treemap.lineWidth, defaultStyle.treemap.lineWidth);
|
|
1408
|
+
ext?.normalize?.(style[ext.section], {toNumber});
|
|
1323
1409
|
|
|
1324
1410
|
this.style = style;
|
|
1325
1411
|
this.cacheContainer = container;
|
|
@@ -2,7 +2,6 @@
|
|
|
2
2
|
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
3
|
* billboard.js project is licensed under the MIT license
|
|
4
4
|
*/
|
|
5
|
-
import {getTreemapNodeRect} from "../ChartInternal/shape/core/geometry";
|
|
6
5
|
import {TYPE} from "../config/const";
|
|
7
6
|
import {getCanvasBarGeometry, getCanvasCandlestickGeometry} from "./geometry";
|
|
8
7
|
import {
|
|
@@ -17,12 +16,20 @@ import {
|
|
|
17
16
|
isCanvasPointType,
|
|
18
17
|
isCanvasScatterType,
|
|
19
18
|
isCanvasTargetSupported,
|
|
20
|
-
isCanvasTreemapType,
|
|
21
19
|
isFiniteCanvasCoordinate,
|
|
22
20
|
markCanvasPointOccupancy
|
|
23
21
|
} from "./util";
|
|
24
22
|
|
|
25
|
-
|
|
23
|
+
// hit: whether a point inside the box is on the shape, for a shape that does not fill its box
|
|
24
|
+
type HitItem = {
|
|
25
|
+
x: number,
|
|
26
|
+
y: number,
|
|
27
|
+
w?: number,
|
|
28
|
+
h?: number,
|
|
29
|
+
sensitivity?: number,
|
|
30
|
+
data: any,
|
|
31
|
+
hit?: (x: number, y: number) => boolean
|
|
32
|
+
};
|
|
26
33
|
type HitGrid = Map<string, HitItem[]>;
|
|
27
34
|
type PlotArea = {x: number, y: number, w: number, h: number};
|
|
28
35
|
type HitRect = {x: number, y: number, w: number, h: number};
|
|
@@ -179,10 +186,11 @@ export default class HitDetector {
|
|
|
179
186
|
this.pointGrid = new Map();
|
|
180
187
|
this.maxPointSensitivity = HIT_DISTANCE;
|
|
181
188
|
this.indexAxis = $$.config.axis_rotated ? "y" : "x";
|
|
182
|
-
|
|
189
|
+
// a custom type and treemap are laid out over the whole chart area
|
|
190
|
+
this.plot = $$.state.customType || $$.state.hasTreemap ?
|
|
183
191
|
{x: 0, y: 0, w: current.width, h: current.height} :
|
|
184
192
|
{x: margin.left, y: margin.top, w: width, h: height};
|
|
185
|
-
this.grouped = !!$$.config.tooltip_grouped && !$$.state.hasTreemap;
|
|
193
|
+
this.grouped = !!$$.config.tooltip_grouped && !$$.state.customType && !$$.state.hasTreemap;
|
|
186
194
|
this.pointBased = !($$.config.axis_x_forceAsSingle && this.grouped) && (
|
|
187
195
|
!!$$.isMultipleX?.() ||
|
|
188
196
|
targets.some(target =>
|
|
@@ -209,29 +217,17 @@ export default class HitDetector {
|
|
|
209
217
|
}
|
|
210
218
|
};
|
|
211
219
|
|
|
212
|
-
if ($$.state.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
const {data} = node;
|
|
218
|
-
|
|
219
|
-
if (!isCanvasTreemapType($$, data)) {
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
|
|
223
|
-
const {x, y, w, h} = getTreemapNodeRect($$, node, root, true);
|
|
224
|
-
|
|
225
|
-
if (
|
|
226
|
-
!isFiniteCanvasCoordinate(x, y) ||
|
|
227
|
-
!isFiniteCanvasCoordinate(x + w, y + h)
|
|
228
|
-
) {
|
|
229
|
-
continue;
|
|
230
|
-
}
|
|
220
|
+
if ($$.state.customType) {
|
|
221
|
+
$$.getCustomTypeParts()?.canvas?.hits?.call($$, this);
|
|
222
|
+
this.indices = [];
|
|
223
|
+
return;
|
|
224
|
+
}
|
|
231
225
|
|
|
232
|
-
|
|
233
|
-
|
|
226
|
+
// the type that is the whole chart is hit by its module, alone
|
|
227
|
+
const exclusive = $$.getCanvasTypeParts?.().find(part => part.exclusive);
|
|
234
228
|
|
|
229
|
+
if (exclusive) {
|
|
230
|
+
exclusive.hits?.call($$, this);
|
|
235
231
|
this.indices = [];
|
|
236
232
|
return;
|
|
237
233
|
}
|
|
@@ -318,6 +314,11 @@ export default class HitDetector {
|
|
|
318
314
|
}
|
|
319
315
|
}
|
|
320
316
|
|
|
317
|
+
// the types of their own modules drawn on the axes
|
|
318
|
+
$$.getAxisTypeParts?.().forEach(part =>
|
|
319
|
+
part.canvas?.hits?.call($$, this, {shape, targets, margin, addIndex})
|
|
320
|
+
);
|
|
321
|
+
|
|
321
322
|
const {cx, cy} = shape.pos;
|
|
322
323
|
|
|
323
324
|
if (cx && cy) {
|
|
@@ -389,7 +390,8 @@ export default class HitDetector {
|
|
|
389
390
|
mx >= item.x &&
|
|
390
391
|
mx <= item.x + w &&
|
|
391
392
|
my >= item.y &&
|
|
392
|
-
my <= item.y + h
|
|
393
|
+
my <= item.y + h &&
|
|
394
|
+
(!item.hit || item.hit(mx, my))
|
|
393
395
|
) {
|
|
394
396
|
return item.data;
|
|
395
397
|
}
|
|
@@ -529,7 +531,7 @@ export default class HitDetector {
|
|
|
529
531
|
* @param {object} item Hit item
|
|
530
532
|
* @private
|
|
531
533
|
*/
|
|
532
|
-
|
|
534
|
+
addBar(item: HitItem): void {
|
|
533
535
|
this.bars.push(item);
|
|
534
536
|
addGridItem(this.barGrid, item, BAR_CELL_SIZE);
|
|
535
537
|
}
|
|
@@ -0,0 +1,230 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Copyright (c) 2017 ~ present NAVER Corp.
|
|
3
|
+
* billboard.js project is licensed under the MIT license
|
|
4
|
+
*/
|
|
5
|
+
import {getRenderPoint, getRenderRect} from "../ChartInternal/shape/core/geometry";
|
|
6
|
+
import {getCanvasTargetFocusOpacity, isCanvasRenderableTarget} from "./CanvasRenderer";
|
|
7
|
+
import type CanvasRenderer from "./CanvasRenderer";
|
|
8
|
+
import type {CanvasThemeExtension} from "./CanvasTheme";
|
|
9
|
+
import type HitDetector from "./HitDetector";
|
|
10
|
+
import {getCanvasShapeIndices, getCanvasTargetVisibleRange} from "./util";
|
|
11
|
+
|
|
12
|
+
// the section of the canvas theme for boxplot: read from the same stylesheet as SVG
|
|
13
|
+
const boxplotTheme: CanvasThemeExtension = {
|
|
14
|
+
section: "boxplot",
|
|
15
|
+
|
|
16
|
+
probe({probeIn, toColor, toNumber}) {
|
|
17
|
+
const box = probeIn("bb-chart-boxplot", "path", "bb-boxplot-box", [
|
|
18
|
+
"stroke",
|
|
19
|
+
"stroke-width",
|
|
20
|
+
"fill-opacity"
|
|
21
|
+
]);
|
|
22
|
+
const whisker = probeIn("bb-chart-boxplot", "path", "bb-boxplot-whisker", ["stroke-width"]);
|
|
23
|
+
const median = probeIn("bb-chart-boxplot", "path", "bb-boxplot-median", ["stroke-width"]);
|
|
24
|
+
const outlier = probeIn("bb-chart-boxplot", "path", "bb-boxplot-outlier", [
|
|
25
|
+
"stroke-width"
|
|
26
|
+
]);
|
|
27
|
+
const mean = probeIn("bb-chart-boxplot", "path", "bb-boxplot-mean", ["fill"]);
|
|
28
|
+
|
|
29
|
+
return {
|
|
30
|
+
stroke: toColor(box.stroke, "#000"),
|
|
31
|
+
boxLineWidth: toNumber(box["stroke-width"], 1),
|
|
32
|
+
boxOpacity: toNumber(box["fill-opacity"], 0.7),
|
|
33
|
+
whiskerLineWidth: toNumber(whisker["stroke-width"], 1),
|
|
34
|
+
medianLineWidth: toNumber(median["stroke-width"], 2),
|
|
35
|
+
outlierLineWidth: toNumber(outlier["stroke-width"], 1),
|
|
36
|
+
meanFill: toColor(mean.fill, "#fff")
|
|
37
|
+
};
|
|
38
|
+
},
|
|
39
|
+
|
|
40
|
+
selectors: {
|
|
41
|
+
".bb-boxplot-box": (style, {readColorValue, readNumberValue}) => ({
|
|
42
|
+
stroke: readColorValue(style, "stroke"),
|
|
43
|
+
boxLineWidth: readNumberValue(style, "stroke-width"),
|
|
44
|
+
boxOpacity: readNumberValue(style, "fill-opacity")
|
|
45
|
+
}),
|
|
46
|
+
".bb-boxplot-whisker": (style, {readNumberValue}) => ({
|
|
47
|
+
whiskerLineWidth: readNumberValue(style, "stroke-width")
|
|
48
|
+
}),
|
|
49
|
+
".bb-boxplot-median": (style, {readNumberValue}) => ({
|
|
50
|
+
medianLineWidth: readNumberValue(style, "stroke-width")
|
|
51
|
+
}),
|
|
52
|
+
".bb-boxplot-outlier": (style, {readNumberValue}) => ({
|
|
53
|
+
outlierLineWidth: readNumberValue(style, "stroke-width")
|
|
54
|
+
}),
|
|
55
|
+
".bb-boxplot-mean": (style, {readColorValue}) => ({
|
|
56
|
+
meanFill: readColorValue(style, "fill")
|
|
57
|
+
})
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
* Get the box geometry of a data row, in the coordinates of the canvas.
|
|
63
|
+
* @param {object} $$ ChartInternal instance
|
|
64
|
+
* @param {function} getPoints Function from generateGetBoxplotPoints()
|
|
65
|
+
* @param {object} d Data row
|
|
66
|
+
* @param {number} i Data index
|
|
67
|
+
* @returns {object|null} Box, median and whisker
|
|
68
|
+
* @private
|
|
69
|
+
*/
|
|
70
|
+
function getGeometry($$, getPoints, d, i: number) {
|
|
71
|
+
const points = getPoints(d, i);
|
|
72
|
+
|
|
73
|
+
if (!points) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const [[x0, q1], [x1, q3], [xc, min, max], [median], outliers, mean] = points;
|
|
78
|
+
const R = (x: number, y: number) => getRenderPoint($$, [x, y]);
|
|
79
|
+
const cap = (x1 - x0) * $$.config.boxplot_whisker_width / 2;
|
|
80
|
+
const m = $$.config.boxplot_mean_r;
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
box: getRenderRect($$, [[x0, q1], [x1, q3]]),
|
|
84
|
+
median: [R(x0, median), R(x1, median)],
|
|
85
|
+
whisker: [
|
|
86
|
+
[R(xc, max), R(xc, q3)],
|
|
87
|
+
[R(xc, q1), R(xc, min)],
|
|
88
|
+
...(cap > 0 ?
|
|
89
|
+
[
|
|
90
|
+
[R(xc - cap, max), R(xc + cap, max)],
|
|
91
|
+
[R(xc - cap, min), R(xc + cap, min)]
|
|
92
|
+
] :
|
|
93
|
+
[])
|
|
94
|
+
],
|
|
95
|
+
outliers: outliers.map(v => R(xc, v)),
|
|
96
|
+
mean: mean.map(v => [R(xc - m, v), R(xc, v - m), R(xc + m, v), R(xc, v + m)])
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
/**
|
|
101
|
+
* Canvas drawing, hit detection and theme of the boxplot type.
|
|
102
|
+
* Added to the chart by boxplot(): bundles without boxplot do not carry it.
|
|
103
|
+
*/
|
|
104
|
+
export default {
|
|
105
|
+
theme: boxplotTheme,
|
|
106
|
+
|
|
107
|
+
/**
|
|
108
|
+
* Draw the boxes on canvas.
|
|
109
|
+
* @param {CanvasRenderer} renderer Canvas renderer
|
|
110
|
+
* @param {object} shape Cached draw shape object
|
|
111
|
+
* @private
|
|
112
|
+
*/
|
|
113
|
+
draw(renderer: CanvasRenderer, shape): void {
|
|
114
|
+
const $$ = this;
|
|
115
|
+
const {ctx, painter, theme: {style: {boxplot}}} = renderer;
|
|
116
|
+
const {margin} = $$.state;
|
|
117
|
+
const r = $$.config.boxplot_outlier_r;
|
|
118
|
+
const isBoxplot = $$.isBoxplotType.bind($$);
|
|
119
|
+
const getPoints = $$.generateGetBoxplotPoints(
|
|
120
|
+
getCanvasShapeIndices($$, shape, "boxplot", isBoxplot),
|
|
121
|
+
false
|
|
122
|
+
);
|
|
123
|
+
|
|
124
|
+
painter.withTranslation(margin.left, margin.top, () => {
|
|
125
|
+
$$.filterTargetsToShow()
|
|
126
|
+
.filter(isBoxplot)
|
|
127
|
+
.filter(target => isCanvasRenderableTarget($$, target))
|
|
128
|
+
.forEach(target => {
|
|
129
|
+
const range = getCanvasTargetVisibleRange($$, target);
|
|
130
|
+
const alpha = getCanvasTargetFocusOpacity($$, target);
|
|
131
|
+
|
|
132
|
+
for (let i = range.start; i < range.end; i++) {
|
|
133
|
+
const d = target.values[i];
|
|
134
|
+
const geometry = getGeometry($$, getPoints, d, i);
|
|
135
|
+
|
|
136
|
+
if (!geometry) {
|
|
137
|
+
continue;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
const stroke = boxplot.stroke;
|
|
141
|
+
|
|
142
|
+
ctx.strokeStyle = stroke;
|
|
143
|
+
ctx.globalAlpha = alpha;
|
|
144
|
+
|
|
145
|
+
boxplot.whiskerLineWidth > 0 && painter.strokePath(() => {
|
|
146
|
+
geometry.whisker.forEach(([a, b]) =>
|
|
147
|
+
painter.traceLine(a[0], a[1], b[0], b[1])
|
|
148
|
+
);
|
|
149
|
+
}, {lineWidth: boxplot.whiskerLineWidth, stroke, alpha});
|
|
150
|
+
|
|
151
|
+
painter.fillRect(geometry.box, {
|
|
152
|
+
fill: $$.color(d),
|
|
153
|
+
alpha: boxplot.boxOpacity * alpha
|
|
154
|
+
});
|
|
155
|
+
boxplot.boxLineWidth > 0 && painter.strokeRect(geometry.box, {
|
|
156
|
+
stroke,
|
|
157
|
+
lineWidth: boxplot.boxLineWidth,
|
|
158
|
+
alpha
|
|
159
|
+
});
|
|
160
|
+
|
|
161
|
+
const [a, b] = geometry.median;
|
|
162
|
+
|
|
163
|
+
painter.strokePath(() => painter.traceLine(a[0], a[1], b[0], b[1]), {
|
|
164
|
+
lineWidth: boxplot.medianLineWidth,
|
|
165
|
+
stroke,
|
|
166
|
+
alpha
|
|
167
|
+
});
|
|
168
|
+
|
|
169
|
+
geometry.outliers.length && painter.strokePath(() => {
|
|
170
|
+
geometry.outliers.forEach(([x, y]) => {
|
|
171
|
+
ctx.moveTo(x + r, y);
|
|
172
|
+
ctx.arc(x, y, r, 0, Math.PI * 2);
|
|
173
|
+
});
|
|
174
|
+
}, {lineWidth: boxplot.outlierLineWidth, stroke, alpha});
|
|
175
|
+
|
|
176
|
+
geometry.mean.forEach(([p0, p1, p2, p3]) => {
|
|
177
|
+
ctx.beginPath();
|
|
178
|
+
ctx.moveTo(p0[0], p0[1]);
|
|
179
|
+
[p1, p2, p3].forEach(p => ctx.lineTo(p[0], p[1]));
|
|
180
|
+
ctx.closePath();
|
|
181
|
+
ctx.globalAlpha = alpha;
|
|
182
|
+
ctx.fillStyle = boxplot.meanFill;
|
|
183
|
+
ctx.fill();
|
|
184
|
+
ctx.strokeStyle = stroke;
|
|
185
|
+
ctx.lineWidth = boxplot.boxLineWidth;
|
|
186
|
+
ctx.stroke();
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
ctx.globalAlpha = 1;
|
|
190
|
+
});
|
|
191
|
+
});
|
|
192
|
+
},
|
|
193
|
+
|
|
194
|
+
/**
|
|
195
|
+
* Add the hit items of the boxes.
|
|
196
|
+
* @param {HitDetector} detector Hit detector
|
|
197
|
+
* @param {object} context Shape, targets, margin and the index registration of the detector
|
|
198
|
+
* @param {object} context.shape Shape helpers of the chart
|
|
199
|
+
* @param {Array} context.targets Data targets
|
|
200
|
+
* @param {object} context.margin Margin of the chart
|
|
201
|
+
* @param {function} context.addIndex Register the index of a hit item
|
|
202
|
+
* @private
|
|
203
|
+
*/
|
|
204
|
+
hits(detector: HitDetector, {shape, targets, margin, addIndex}): void {
|
|
205
|
+
const $$ = this;
|
|
206
|
+
const isBoxplot = $$.isBoxplotType.bind($$);
|
|
207
|
+
const getPoints = $$.generateGetBoxplotPoints(
|
|
208
|
+
getCanvasShapeIndices($$, shape, "boxplot", isBoxplot),
|
|
209
|
+
false
|
|
210
|
+
);
|
|
211
|
+
|
|
212
|
+
targets.filter(isBoxplot).forEach(target => {
|
|
213
|
+
const range = getCanvasTargetVisibleRange($$, target);
|
|
214
|
+
|
|
215
|
+
for (let i = range.start; i < range.end; i++) {
|
|
216
|
+
const d = target.values[i];
|
|
217
|
+
const geometry = getGeometry($$, getPoints, d, i);
|
|
218
|
+
|
|
219
|
+
if (!geometry) {
|
|
220
|
+
continue;
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
const {x, y, w, h} = geometry.box;
|
|
224
|
+
|
|
225
|
+
detector.addBar({x: margin.left + x, y: margin.top + y, w, h, data: d});
|
|
226
|
+
addIndex(margin.left + x + w / 2, margin.top + y + h / 2, d);
|
|
227
|
+
}
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
};
|