@d3plus/core 4.7.0 → 4.9.0
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/README.md +1 -26117
- package/es/index.js +1 -3
- package/es/internal.js +148 -7
- package/es/src/charts/AreaPlot/index.js +7 -10
- package/es/src/charts/BarChart/index.js +50 -17
- package/es/src/charts/Beeswarm/index.js +39 -0
- package/es/src/charts/BoxWhisker/index.js +6 -16
- package/es/src/charts/Bullet/applyLayout.js +157 -0
- package/es/src/charts/Bullet/bulletGeometry.js +215 -0
- package/es/src/charts/Bullet/bulletLayout.js +111 -0
- package/es/src/charts/Bullet/bulletStyle.js +44 -0
- package/es/src/charts/Bullet/emit.js +258 -0
- package/es/src/charts/Bullet/index.js +268 -0
- package/es/src/charts/BumpChart/index.js +21 -49
- package/es/src/charts/Calendar/applyLayout.js +120 -0
- package/es/src/charts/Calendar/calendarDates.js +151 -0
- package/es/src/charts/Calendar/calendarFormat.js +40 -0
- package/es/src/charts/Calendar/calendarGrid.js +138 -0
- package/es/src/charts/Calendar/calendarInset.js +22 -0
- package/es/src/charts/Calendar/calendarLayout.js +242 -0
- package/es/src/charts/Calendar/emit.js +179 -0
- package/es/src/charts/Calendar/index.js +206 -0
- package/es/src/charts/Candlestick/aggregate.js +154 -0
- package/es/src/charts/Candlestick/buffer.js +83 -0
- package/es/src/charts/Candlestick/emit.js +198 -0
- package/es/src/charts/Candlestick/index.js +257 -0
- package/es/src/charts/Candlestick/ohlc.js +114 -0
- package/es/src/charts/Candlestick/periods.js +191 -0
- package/es/src/charts/Candlestick/tooltip.js +116 -0
- package/es/src/charts/Candlestick/volume.js +278 -0
- package/es/src/charts/Chord/applyLayout.js +75 -111
- package/es/src/charts/Chord/emit.js +82 -173
- package/es/src/charts/Chord/index.js +92 -106
- package/es/src/charts/Donut/index.js +6 -12
- package/es/src/charts/Dumbbell/emit.js +106 -0
- package/es/src/charts/Dumbbell/gapSort.js +79 -0
- package/es/src/charts/Dumbbell/index.js +84 -0
- package/es/src/charts/FanChart/index.js +28 -0
- package/es/src/charts/Funnel/applyLayout.js +103 -0
- package/es/src/charts/Funnel/emit.js +99 -0
- package/es/src/charts/Funnel/funnelFacet.js +53 -0
- package/es/src/charts/Funnel/funnelGeometry.js +171 -0
- package/es/src/charts/Funnel/funnelLabels.js +118 -0
- package/es/src/charts/Funnel/index.js +180 -0
- package/es/src/charts/Funnel/labelNodes.js +202 -0
- package/es/src/charts/Gauge/applyLayout.js +70 -0
- package/es/src/charts/Gauge/dialLayout.js +106 -0
- package/es/src/charts/Gauge/emit.js +214 -0
- package/es/src/charts/Gauge/emitDial.js +167 -0
- package/es/src/charts/Gauge/gaugeGeometry.js +157 -0
- package/es/src/charts/Gauge/index.js +148 -0
- package/es/src/charts/Geomap/applyLayout.js +42 -73
- package/es/src/charts/Geomap/basemapTheme.js +16 -31
- package/es/src/charts/Geomap/emit.js +94 -162
- package/es/src/charts/Geomap/index.js +186 -193
- package/es/src/charts/Geomap/projections.js +37 -0
- package/es/src/charts/Histogram/binData.js +60 -209
- package/es/src/charts/Histogram/index.js +104 -137
- package/es/src/charts/Icicle/applyLayout.js +124 -0
- package/es/src/charts/Icicle/emit.js +162 -0
- package/es/src/charts/Icicle/enterStagger.js +55 -0
- package/es/src/charts/Icicle/geometry.js +101 -0
- package/es/src/charts/Icicle/index.js +130 -0
- package/es/src/charts/Icicle/interaction.js +20 -0
- package/es/src/charts/Icicle/labelFit.js +55 -0
- package/es/src/charts/Icicle/layout.js +20 -0
- package/es/src/charts/LinePlot/index.js +1 -9
- package/es/src/charts/Lollipop/emit.js +85 -0
- package/es/src/charts/Lollipop/index.js +97 -0
- package/es/src/charts/Lollipop/stemLayout.js +97 -0
- package/es/src/charts/Marimekko/axis.js +46 -0
- package/es/src/charts/Marimekko/index.js +77 -0
- package/es/src/charts/Matrix/applyLayout.js +22 -27
- package/es/src/charts/Matrix/emit.js +33 -34
- package/es/src/charts/Matrix/index.js +56 -80
- package/es/src/charts/Network/applyLayout.js +95 -172
- package/es/src/charts/Network/emit.js +132 -266
- package/es/src/charts/Network/index.js +148 -132
- package/es/src/charts/Pack/applyLayout.js +12 -17
- package/es/src/charts/Pack/emit.js +44 -106
- package/es/src/charts/Pack/index.js +63 -107
- package/es/src/charts/Pack/recursionCircles.js +2 -5
- package/es/src/charts/ParallelCoordinates/applyLayout.js +99 -0
- package/es/src/charts/ParallelCoordinates/axes.js +213 -0
- package/es/src/charts/ParallelCoordinates/brushDom.js +187 -0
- package/es/src/charts/ParallelCoordinates/brushFilter.js +79 -0
- package/es/src/charts/ParallelCoordinates/dimensions.js +102 -0
- package/es/src/charts/ParallelCoordinates/emit.js +72 -0
- package/es/src/charts/ParallelCoordinates/format.js +23 -0
- package/es/src/charts/ParallelCoordinates/index.js +190 -0
- package/es/src/charts/ParallelCoordinates/lineStates.js +62 -0
- package/es/src/charts/ParallelCoordinates/paths.js +31 -0
- package/es/src/charts/ParallelCoordinates/titles.js +56 -0
- package/es/src/charts/Pie/applyLayout.js +20 -28
- package/es/src/charts/Pie/emit.js +109 -219
- package/es/src/charts/Pie/index.js +49 -78
- package/es/src/charts/Plot/axisInk.js +31 -0
- package/es/src/charts/Plot/barConfidence.js +273 -0
- package/es/src/charts/Plot/barWidth.js +255 -0
- package/es/src/charts/Plot/baselineBreak.js +139 -0
- package/es/src/charts/Plot/baselineDomain.js +120 -0
- package/es/src/charts/Plot/columnHighlight.js +39 -0
- package/es/src/charts/Plot/confidenceBands.js +143 -0
- package/es/src/charts/Plot/confidenceConfig.js +50 -0
- package/es/src/charts/Plot/confidenceTooltip.js +102 -0
- package/es/src/charts/Plot/curveLength.js +97 -0
- package/es/src/charts/Plot/discreteDomain.js +19 -0
- package/es/src/charts/Plot/discreteSpan.js +6 -24
- package/es/src/charts/Plot/domainClip.js +190 -0
- package/es/src/charts/Plot/draw.js +164 -295
- package/es/src/charts/Plot/facetScales.js +27 -0
- package/es/src/charts/Plot/fillBetween.js +233 -0
- package/es/src/charts/Plot/forecast.js +211 -0
- package/es/src/charts/Plot/forecastScene.js +316 -0
- package/es/src/charts/Plot/index.js +355 -930
- package/es/src/charts/Plot/insetRegion.js +5 -10
- package/es/src/charts/Plot/labelPlacement.js +12 -14
- package/es/src/charts/Plot/lineBands.js +48 -0
- package/es/src/charts/Plot/lineCurve.js +25 -0
- package/es/src/charts/Plot/openDomainEnds.js +92 -0
- package/es/src/charts/Plot/pipeline.js +143 -480
- package/es/src/charts/Plot/pipelineAxisLayout.js +132 -0
- package/es/src/charts/Plot/pipelineDomains.js +121 -239
- package/es/src/charts/Plot/pipelineLineLabels.js +81 -147
- package/es/src/charts/Plot/pipelineScales.js +177 -0
- package/es/src/charts/Plot/plotBreaks.js +223 -0
- package/es/src/charts/Plot/plotFacet.js +172 -0
- package/es/src/charts/Plot/plotInit.js +252 -0
- package/es/src/charts/Plot/plotZoom.js +105 -206
- package/es/src/charts/Plot/shapeDefaults.js +66 -81
- package/es/src/charts/Plot/sharedHover.js +185 -308
- package/es/src/charts/Plot/sharedHoverScene.js +115 -157
- package/es/src/charts/Plot/sharedTooltip.js +96 -104
- package/es/src/charts/Plot/stackEnter.js +87 -0
- package/es/src/charts/Plot/stackHelpers.js +36 -69
- package/es/src/charts/Plot/stackShareLabels.js +34 -88
- package/es/src/charts/Plot/stackShareTooltip.js +10 -15
- package/es/src/charts/Plot/swarm.js +96 -0
- package/es/src/charts/Plot/swarmLayout.js +102 -0
- package/es/src/charts/Plot/trendLines.js +105 -321
- package/es/src/charts/Plot/trendProjection.js +27 -69
- package/es/src/charts/Plot/trendScene.js +27 -171
- package/es/src/charts/Plot/trendTooltip.js +50 -132
- package/es/src/charts/PolarArea/applyLayout.js +26 -0
- package/es/src/charts/PolarArea/emit.js +12 -0
- package/es/src/charts/PolarArea/index.js +183 -0
- package/es/src/charts/Priestley/applyLayout.js +33 -53
- package/es/src/charts/Priestley/emit.js +50 -111
- package/es/src/charts/Priestley/index.js +35 -35
- package/es/src/charts/Pyramid/gutter.js +208 -0
- package/es/src/charts/Pyramid/index.js +373 -0
- package/es/src/charts/Pyramid/pyramidData.js +65 -0
- package/es/src/charts/Pyramid/scene.js +224 -0
- package/es/src/charts/Pyramid/stackOrder.js +39 -0
- package/es/src/charts/Radar/applyLayout.js +52 -291
- package/es/src/charts/Radar/axisDecorations.js +200 -0
- package/es/src/charts/Radar/axisLabels.js +109 -0
- package/es/src/charts/Radar/emit.js +23 -19
- package/es/src/charts/Radar/index.js +64 -45
- package/es/src/charts/Radar/levels.js +136 -0
- package/es/src/charts/Radar/rings.js +72 -0
- package/es/src/charts/RadialBar/applyLayout.js +47 -0
- package/es/src/charts/RadialBar/emit.js +38 -0
- package/es/src/charts/RadialBar/index.js +221 -0
- package/es/src/charts/RadialBar/trackLayout.js +330 -0
- package/es/src/charts/RadialBar/tracks.js +53 -0
- package/es/src/charts/RadialMatrix/applyLayout.js +42 -80
- package/es/src/charts/RadialMatrix/emit.js +23 -23
- package/es/src/charts/RadialMatrix/index.js +65 -67
- package/es/src/charts/Ridgeline/emit.js +75 -0
- package/es/src/charts/Ridgeline/index.js +55 -0
- package/es/src/charts/Rings/applyLayout.js +124 -266
- package/es/src/charts/Rings/emit.js +127 -236
- package/es/src/charts/Rings/index.js +118 -98
- package/es/src/charts/Rings/ringsGraph.js +88 -0
- package/es/src/charts/Rings/ringsSizing.js +41 -89
- package/es/src/charts/Sankey/applyLayout.js +32 -60
- package/es/src/charts/Sankey/emit.js +94 -150
- package/es/src/charts/Sankey/index.js +130 -104
- package/es/src/charts/Sankey/sankeyLayout.js +283 -0
- package/es/src/charts/StackedArea/index.js +3 -10
- package/es/src/charts/Sunburst/applyLayout.js +116 -0
- package/es/src/charts/Sunburst/emit.js +181 -0
- package/es/src/charts/Sunburst/geometry.js +98 -0
- package/es/src/charts/Sunburst/index.js +168 -0
- package/es/src/charts/Sunburst/interaction.js +23 -0
- package/es/src/charts/Sunburst/labelFit.js +159 -0
- package/es/src/charts/Sunburst/partition.js +32 -0
- package/es/src/charts/Tree/applyLayout.js +78 -130
- package/es/src/charts/Tree/emit.js +76 -184
- package/es/src/charts/Tree/index.js +26 -37
- package/es/src/charts/Treemap/applyLayout.js +34 -57
- package/es/src/charts/Treemap/emit.js +57 -136
- package/es/src/charts/Treemap/index.js +57 -95
- package/es/src/charts/Treemap/thresholdFunction.js +14 -75
- package/es/src/charts/Violin/emit.js +80 -0
- package/es/src/charts/Violin/index.js +88 -0
- package/es/src/charts/Violin/inner.js +196 -0
- package/es/src/charts/Violin/violinLayout.js +80 -0
- package/es/src/charts/Waffle/applyLayout.js +90 -0
- package/es/src/charts/Waffle/emit.js +89 -0
- package/es/src/charts/Waffle/index.js +170 -0
- package/es/src/charts/Waffle/tooltip.js +37 -0
- package/es/src/charts/Waffle/waffleLayout.js +104 -0
- package/es/src/charts/Waterfall/buffer.js +65 -0
- package/es/src/charts/Waterfall/connectors.js +103 -0
- package/es/src/charts/Waterfall/index.js +211 -0
- package/es/src/charts/Waterfall/labels.js +82 -0
- package/es/src/charts/Waterfall/state.js +147 -0
- package/es/src/charts/Waterfall/steps.js +138 -0
- package/es/src/charts/definition/ChartDefinition.js +2 -4
- package/es/src/charts/definition/applyDefinition.js +4 -88
- package/es/src/charts/definition/makeChart.js +35 -141
- package/es/src/charts/drawSteps/backControl.js +15 -14
- package/es/src/charts/drawSteps/bottomRightControls.js +39 -115
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js +60 -174
- package/es/src/charts/drawSteps/controlButtonStyle.js +39 -63
- package/es/src/charts/drawSteps/minimap.js +82 -139
- package/es/src/charts/drawSteps/minimapMarkup.js +13 -93
- package/es/src/charts/drawSteps/searchControls.js +48 -105
- package/es/src/charts/drawSteps/searchControlsMarkup.js +62 -176
- package/es/src/charts/drawSteps/tableView.js +23 -40
- package/es/src/charts/drawSteps/tableViewControl.js +2 -8
- package/es/src/charts/drawSteps/tableViewMarkup.js +152 -233
- package/es/src/charts/drawSteps/topLeftControls.js +8 -28
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js +49 -119
- package/es/src/charts/drawSteps/zoomControls.js +72 -145
- package/es/src/charts/drawSteps/zoomControlsMarkup.js +59 -124
- package/es/src/charts/drawSteps/zoomGesture.js +17 -0
- package/es/src/charts/drawSteps/zoomShown.js +40 -0
- package/es/src/charts/events/click.legend.js +12 -23
- package/es/src/charts/events/click.shape.js +6 -11
- package/es/src/charts/events/mouseenter.js +14 -24
- package/es/src/charts/events/mouseleave.js +29 -14
- package/es/src/charts/events/mousemove.legend.js +20 -30
- package/es/src/charts/events/mousemove.shape.js +12 -21
- package/es/src/charts/events/touchstart.body.js +0 -2
- package/es/src/charts/facet/drawFacets.js +332 -0
- package/es/src/charts/facet/facetConfig.js +72 -0
- package/es/src/charts/facet/facetData.js +97 -0
- package/es/src/charts/facet/facetGrid.js +107 -0
- package/es/src/charts/facet/facetGutter.js +131 -0
- package/es/src/charts/facet/facetPanel.js +56 -0
- package/es/src/charts/facet/facetScene.js +111 -0
- package/es/src/charts/features/attributionFeature.js +38 -38
- package/es/src/charts/features/axes.js +105 -304
- package/es/src/charts/features/axesFinal.js +134 -0
- package/es/src/charts/features/axesMeasure.js +138 -0
- package/es/src/charts/features/backgroundImageEmit.js +61 -0
- package/es/src/charts/features/chartGeometry.js +3 -5
- package/es/src/charts/features/colorScaleBucket.js +17 -21
- package/es/src/charts/features/edgeArrows.js +36 -70
- package/es/src/charts/features/emitHelpers.js +42 -137
- package/es/src/charts/features/ensureZoomDom.js +27 -40
- package/es/src/charts/features/features.js +216 -256
- package/es/src/charts/features/featuresColorScale.js +40 -39
- package/es/src/charts/features/featuresLegend.js +152 -188
- package/es/src/charts/features/frozenAxis.js +14 -0
- package/es/src/charts/features/insetState.js +25 -90
- package/es/src/charts/features/legendCategory.js +61 -0
- package/es/src/charts/features/legendLabel.js +5 -9
- package/es/src/charts/features/lineLabels.js +20 -87
- package/es/src/charts/features/plotAnnotations.js +105 -0
- package/es/src/charts/features/plotEndLabels.js +209 -0
- package/es/src/charts/features/plotPaint.js +192 -404
- package/es/src/charts/features/sceneBounds.js +57 -164
- package/es/src/charts/features/shapeEmit.js +183 -184
- package/es/src/charts/features/shareKey.js +32 -0
- package/es/src/charts/features/sharedFields.js +38 -0
- package/es/src/charts/features/tooltipSwatch.js +99 -42
- package/es/src/charts/features/xAxisConfig.js +19 -0
- package/es/src/charts/features/zoomExtent.js +23 -108
- package/es/src/charts/helpers/densityChart.js +267 -0
- package/es/src/charts/helpers/densityData.js +116 -0
- package/es/src/charts/helpers/densityEnter.js +64 -0
- package/es/src/charts/helpers/matrixData.js +11 -82
- package/es/src/charts/helpers/tileAttributions.js +1 -3
- package/es/src/charts/helpers/valueTitle.js +29 -0
- package/es/src/charts/index.js +20 -2
- package/es/src/charts/partition/chartFields.js +43 -0
- package/es/src/charts/partition/hierarchy.js +174 -0
- package/es/src/charts/partition/interaction.js +158 -0
- package/es/src/charts/partition/labelWords.js +95 -0
- package/es/src/charts/partition/shade.js +56 -0
- package/es/src/charts/partition/zoom.js +80 -0
- package/es/src/charts/pipeline/drillMorph.js +16 -37
- package/es/src/charts/pipeline/insetPlacement.js +95 -188
- package/es/src/charts/pipeline/preDrawData.js +74 -0
- package/es/src/charts/pipeline/resolveSpec.js +1 -3
- package/es/src/charts/pipeline/runChartDraw.js +14 -69
- package/es/src/charts/pipeline/runVizPipeline.js +13 -35
- package/es/src/charts/pipeline/stages.js +24 -61
- package/es/src/charts/pipeline/vizDraw.js +165 -30
- package/es/src/charts/pipeline/vizPreDraw.js +145 -106
- package/es/src/charts/plotBuffers/Bar.js +7 -108
- package/es/src/charts/plotBuffers/Box.js +6 -102
- package/es/src/charts/plotBuffers/Circle.js +11 -14
- package/es/src/charts/plotBuffers/Line.js +7 -13
- package/es/src/charts/plotBuffers/Rect.js +11 -15
- package/es/src/charts/plotBuffers/defaultBuffers.js +12 -0
- package/es/src/charts/plotBuffers/discreteBuffer.js +5 -9
- package/es/src/charts/plotBuffers/numericBuffer.js +24 -33
- package/es/src/charts/plotBuffers/rectLikeBuffer.js +39 -0
- package/es/src/charts/polar/chrome.js +170 -0
- package/es/src/charts/polar/config.js +82 -0
- package/es/src/charts/polar/geometry.js +92 -0
- package/es/src/charts/polar/labels.js +124 -0
- package/es/src/charts/polar/polarFacet.js +43 -0
- package/es/src/charts/polar/wedgeLayout.js +140 -0
- package/es/src/charts/viz/Viz.js +503 -991
- package/es/src/charts/viz/VizBase.js +260 -613
- package/es/src/charts/viz/backgroundInk.js +17 -0
- package/es/src/charts/viz/interactionOpacity.js +92 -135
- package/es/src/charts/viz/labelDefaults.js +61 -0
- package/es/src/charts/viz/linkGroup.js +63 -237
- package/es/src/charts/viz/ordinalColor.js +12 -44
- package/es/src/charts/viz/reserveContainerSize.js +49 -0
- package/es/src/charts/viz/resetChromeBoxes.js +41 -0
- package/es/src/charts/viz/sceneRows.js +7 -9
- package/es/src/charts/viz/shapeClassTargets.js +33 -0
- package/es/src/charts/viz/shapeHover.js +9 -0
- package/es/src/charts/viz/simpleHover.js +14 -0
- package/es/src/charts/viz/trailCatchup.js +28 -87
- package/es/src/charts/viz/vizDefaults.js +113 -385
- package/es/src/charts/viz/vizFields.js +197 -0
- package/es/src/charts/viz/vizRender.js +84 -78
- package/es/src/charts/viz/vizTypes.js +1 -3
- package/es/src/charts/viz/vizVisibility.js +32 -51
- package/es/src/components/Axis/Axis.js +304 -469
- package/es/src/components/Axis/AxisBottom.js +9 -74
- package/es/src/components/Axis/AxisLeft.js +9 -74
- package/es/src/components/Axis/AxisRight.js +9 -74
- package/es/src/components/Axis/AxisTop.js +9 -74
- package/es/src/components/Axis/axisBreak.js +243 -0
- package/es/src/components/Axis/axisDefaults.js +65 -0
- package/es/src/components/Axis/axisEndLabels.js +60 -0
- package/es/src/components/Axis/axisLabelThinning.js +123 -0
- package/es/src/components/Axis/axisLayout.js +211 -160
- package/es/src/components/Axis/axisLayoutLabels.js +187 -108
- package/es/src/components/Axis/axisLayoutScale.js +130 -247
- package/es/src/components/Axis/axisRender.js +82 -411
- package/es/src/components/Axis/axisRounding.js +68 -0
- package/es/src/components/Axis/axisScene.js +184 -0
- package/es/src/components/Axis/brokenScale.js +183 -0
- package/es/src/components/Axis/gridStroke.js +10 -0
- package/es/src/components/Axis/timeValues.js +155 -0
- package/es/src/components/Axis/yearValues.js +32 -0
- package/es/src/components/ColorScale/ColorScale.js +187 -345
- package/es/src/components/ColorScale/colorScaleRender.js +72 -108
- package/es/src/components/ColorScale/colorScaleScale.js +101 -164
- package/es/src/components/Legend/Legend.js +164 -352
- package/es/src/components/Legend/legendConfig.js +43 -55
- package/es/src/components/Legend/legendRender.js +61 -109
- package/es/src/components/Message.js +50 -98
- package/es/src/components/SizeLegend/SizeLegend.js +188 -330
- package/es/src/components/SizeLegend/sizeLegendLayout.js +65 -161
- package/es/src/components/TextBox.js +156 -615
- package/es/src/components/Timeline/Timeline.js +345 -554
- package/es/src/components/Timeline/timelineConfig.js +23 -56
- package/es/src/components/Timeline/timelineRender.js +58 -112
- package/es/src/components/Tooltip.js +128 -607
- package/es/src/components/index.js +0 -2
- package/es/src/components/textBoxLayout.js +230 -0
- package/es/src/components/tooltipDom.js +218 -0
- package/es/src/fluent.js +177 -203
- package/es/src/shapes/Area.js +128 -329
- package/es/src/shapes/Bar.js +92 -245
- package/es/src/shapes/Box.js +231 -405
- package/es/src/shapes/Circle.js +46 -199
- package/es/src/shapes/Image.js +98 -210
- package/es/src/shapes/Line.js +73 -251
- package/es/src/shapes/Path.js +34 -149
- package/es/src/shapes/Rect.js +57 -210
- package/es/src/shapes/Shape.js +328 -655
- package/es/src/shapes/Whisker.js +166 -371
- package/es/src/shapes/buildLabelData.js +31 -80
- package/es/src/shapes/emitLabels.js +17 -49
- package/es/src/shapes/hitAreaNode.js +8 -10
- package/es/src/shapes/index.js +0 -2
- package/es/src/shapes/interactionPoints.js +5 -7
- package/es/src/shapes/sceneSort.js +61 -161
- package/es/src/shapes/shapeConfig.js +0 -2
- package/es/src/shapes/shapeOwners.js +37 -0
- package/es/src/shapes/shapeStandalone.js +71 -0
- package/es/src/shapes/textureKey.js +11 -61
- package/es/src/shapes/uniqueIds.js +19 -0
- package/es/src/shapes/validateShapeConfig.js +23 -119
- package/es/src/utils/AccessorFn.js +0 -2
- package/es/src/utils/BaseClass.js +114 -262
- package/es/src/utils/D3Scale.js +0 -2
- package/es/src/utils/D3plusConfig.js +0 -2
- package/es/src/utils/RESET.js +1 -3
- package/es/src/utils/accessor.js +2 -8
- package/es/src/utils/configDefault.js +1 -3
- package/es/src/utils/configPrep.js +15 -35
- package/es/src/utils/configWarnings.js +11 -13
- package/es/src/utils/constant.js +0 -2
- package/es/src/utils/getProp.js +0 -2
- package/es/src/utils/index.js +0 -2
- package/es/src/utils/paintComponentScene.js +12 -23
- package/es/src/utils/wholeWords.js +44 -0
- package/package.json +16 -25
- package/types/index.d.ts +12 -4
- package/types/internal.d.ts +210 -12
- package/types/src/charts/AreaPlot/index.d.ts +2 -1
- package/types/src/charts/BarChart/index.d.ts +4 -2
- package/types/src/charts/Beeswarm/index.d.ts +15 -0
- package/types/src/charts/Bullet/applyLayout.d.ts +65 -0
- package/types/src/charts/Bullet/bulletGeometry.d.ts +91 -0
- package/types/src/charts/Bullet/bulletLayout.d.ts +54 -0
- package/types/src/charts/Bullet/bulletStyle.d.ts +33 -0
- package/types/src/charts/Bullet/emit.d.ts +25 -0
- package/types/src/charts/Bullet/index.d.ts +40 -0
- package/types/src/charts/Calendar/applyLayout.d.ts +37 -0
- package/types/src/charts/Calendar/calendarDates.d.ts +68 -0
- package/types/src/charts/Calendar/calendarFormat.d.ts +24 -0
- package/types/src/charts/Calendar/calendarGrid.d.ts +84 -0
- package/types/src/charts/Calendar/calendarInset.d.ts +13 -0
- package/types/src/charts/Calendar/calendarLayout.d.ts +84 -0
- package/types/src/charts/Calendar/emit.d.ts +31 -0
- package/types/src/charts/Calendar/index.d.ts +26 -0
- package/types/src/charts/Candlestick/aggregate.d.ts +91 -0
- package/types/src/charts/Candlestick/buffer.d.ts +37 -0
- package/types/src/charts/Candlestick/emit.d.ts +54 -0
- package/types/src/charts/Candlestick/index.d.ts +16 -0
- package/types/src/charts/Candlestick/ohlc.d.ts +94 -0
- package/types/src/charts/Candlestick/periods.d.ts +84 -0
- package/types/src/charts/Candlestick/tooltip.d.ts +50 -0
- package/types/src/charts/Candlestick/volume.d.ts +129 -0
- package/types/src/charts/Chord/emit.d.ts +2 -2
- package/types/src/charts/Dumbbell/emit.d.ts +34 -0
- package/types/src/charts/Dumbbell/gapSort.d.ts +47 -0
- package/types/src/charts/Dumbbell/index.d.ts +21 -0
- package/types/src/charts/FanChart/index.d.ts +17 -0
- package/types/src/charts/Funnel/applyLayout.d.ts +89 -0
- package/types/src/charts/Funnel/emit.d.ts +29 -0
- package/types/src/charts/Funnel/funnelFacet.d.ts +33 -0
- package/types/src/charts/Funnel/funnelGeometry.d.ts +78 -0
- package/types/src/charts/Funnel/funnelLabels.d.ts +101 -0
- package/types/src/charts/Funnel/index.d.ts +30 -0
- package/types/src/charts/Funnel/labelNodes.d.ts +57 -0
- package/types/src/charts/Gauge/applyLayout.d.ts +41 -0
- package/types/src/charts/Gauge/dialLayout.d.ts +78 -0
- package/types/src/charts/Gauge/emit.d.ts +22 -0
- package/types/src/charts/Gauge/emitDial.d.ts +41 -0
- package/types/src/charts/Gauge/gaugeGeometry.d.ts +89 -0
- package/types/src/charts/Gauge/index.d.ts +21 -0
- package/types/src/charts/Geomap/projections.d.ts +8 -0
- package/types/src/charts/Histogram/binData.d.ts +9 -1
- package/types/src/charts/Icicle/applyLayout.d.ts +54 -0
- package/types/src/charts/Icicle/emit.d.ts +20 -0
- package/types/src/charts/Icicle/enterStagger.d.ts +30 -0
- package/types/src/charts/Icicle/geometry.d.ts +72 -0
- package/types/src/charts/Icicle/index.d.ts +25 -0
- package/types/src/charts/Icicle/interaction.d.ts +16 -0
- package/types/src/charts/Icicle/labelFit.d.ts +37 -0
- package/types/src/charts/Icicle/layout.d.ts +21 -0
- package/types/src/charts/Lollipop/emit.d.ts +19 -0
- package/types/src/charts/Lollipop/index.d.ts +17 -0
- package/types/src/charts/Lollipop/stemLayout.d.ts +82 -0
- package/types/src/charts/Marimekko/axis.d.ts +27 -0
- package/types/src/charts/Marimekko/index.d.ts +19 -0
- package/types/src/charts/ParallelCoordinates/applyLayout.d.ts +27 -0
- package/types/src/charts/ParallelCoordinates/axes.d.ts +40 -0
- package/types/src/charts/ParallelCoordinates/brushDom.d.ts +47 -0
- package/types/src/charts/ParallelCoordinates/brushFilter.d.ts +39 -0
- package/types/src/charts/ParallelCoordinates/dimensions.d.ts +63 -0
- package/types/src/charts/ParallelCoordinates/emit.d.ts +27 -0
- package/types/src/charts/ParallelCoordinates/format.d.ts +13 -0
- package/types/src/charts/ParallelCoordinates/index.d.ts +27 -0
- package/types/src/charts/ParallelCoordinates/lineStates.d.ts +21 -0
- package/types/src/charts/ParallelCoordinates/paths.d.ts +27 -0
- package/types/src/charts/ParallelCoordinates/titles.d.ts +21 -0
- package/types/src/charts/Plot/axisInk.d.ts +8 -0
- package/types/src/charts/Plot/barConfidence.d.ts +120 -0
- package/types/src/charts/Plot/barWidth.d.ts +119 -0
- package/types/src/charts/Plot/baselineBreak.d.ts +52 -0
- package/types/src/charts/Plot/baselineDomain.d.ts +67 -0
- package/types/src/charts/Plot/columnHighlight.d.ts +23 -0
- package/types/src/charts/Plot/confidenceBands.d.ts +72 -0
- package/types/src/charts/Plot/confidenceConfig.d.ts +16 -0
- package/types/src/charts/Plot/confidenceTooltip.d.ts +70 -0
- package/types/src/charts/Plot/curveLength.d.ts +27 -0
- package/types/src/charts/Plot/discreteDomain.d.ts +14 -0
- package/types/src/charts/Plot/domainClip.d.ts +21 -0
- package/types/src/charts/Plot/facetScales.d.ts +27 -0
- package/types/src/charts/Plot/fillBetween.d.ts +69 -0
- package/types/src/charts/Plot/forecast.d.ts +102 -0
- package/types/src/charts/Plot/forecastScene.d.ts +88 -0
- package/types/src/charts/Plot/index.d.ts +24 -5
- package/types/src/charts/Plot/lineBands.d.ts +7 -0
- package/types/src/charts/Plot/lineCurve.d.ts +15 -0
- package/types/src/charts/Plot/openDomainEnds.d.ts +25 -0
- package/types/src/charts/Plot/pipeline.d.ts +5 -30
- package/types/src/charts/Plot/pipelineAxisLayout.d.ts +2 -0
- package/types/src/charts/Plot/pipelineScales.d.ts +20 -0
- package/types/src/charts/Plot/plotBreaks.d.ts +61 -0
- package/types/src/charts/Plot/plotFacet.d.ts +36 -0
- package/types/src/charts/Plot/plotInit.d.ts +44 -0
- package/types/src/charts/Plot/plotZoom.d.ts +14 -8
- package/types/src/charts/Plot/sharedHover.d.ts +5 -0
- package/types/src/charts/Plot/sharedHoverScene.d.ts +3 -6
- package/types/src/charts/Plot/sharedTooltip.d.ts +13 -8
- package/types/src/charts/Plot/stackEnter.d.ts +42 -0
- package/types/src/charts/Plot/swarm.d.ts +66 -0
- package/types/src/charts/Plot/swarmLayout.d.ts +59 -0
- package/types/src/charts/PolarArea/applyLayout.d.ts +17 -0
- package/types/src/charts/PolarArea/emit.d.ts +3 -0
- package/types/src/charts/PolarArea/index.d.ts +19 -0
- package/types/src/charts/Pyramid/gutter.d.ts +76 -0
- package/types/src/charts/Pyramid/index.d.ts +19 -0
- package/types/src/charts/Pyramid/pyramidData.d.ts +48 -0
- package/types/src/charts/Pyramid/scene.d.ts +106 -0
- package/types/src/charts/Pyramid/stackOrder.d.ts +9 -0
- package/types/src/charts/Radar/applyLayout.d.ts +7 -5
- package/types/src/charts/Radar/axisDecorations.d.ts +67 -0
- package/types/src/charts/Radar/axisLabels.d.ts +79 -0
- package/types/src/charts/Radar/emit.d.ts +2 -2
- package/types/src/charts/Radar/index.d.ts +5 -1
- package/types/src/charts/Radar/levels.d.ts +68 -0
- package/types/src/charts/Radar/rings.d.ts +30 -0
- package/types/src/charts/RadialBar/applyLayout.d.ts +19 -0
- package/types/src/charts/RadialBar/emit.d.ts +6 -0
- package/types/src/charts/RadialBar/index.d.ts +21 -0
- package/types/src/charts/RadialBar/trackLayout.d.ts +46 -0
- package/types/src/charts/RadialBar/tracks.d.ts +32 -0
- package/types/src/charts/Ridgeline/emit.d.ts +11 -0
- package/types/src/charts/Ridgeline/index.d.ts +16 -0
- package/types/src/charts/Rings/index.d.ts +2 -0
- package/types/src/charts/Rings/ringsGraph.d.ts +72 -0
- package/types/src/charts/Sankey/applyLayout.d.ts +1 -1
- package/types/src/charts/Sankey/sankeyLayout.d.ts +57 -0
- package/types/src/charts/StackedArea/index.d.ts +2 -1
- package/types/src/charts/Sunburst/applyLayout.d.ts +67 -0
- package/types/src/charts/Sunburst/emit.d.ts +29 -0
- package/types/src/charts/Sunburst/geometry.d.ts +65 -0
- package/types/src/charts/Sunburst/index.d.ts +21 -0
- package/types/src/charts/Sunburst/interaction.d.ts +20 -0
- package/types/src/charts/Sunburst/labelFit.d.ts +73 -0
- package/types/src/charts/Sunburst/partition.d.ts +34 -0
- package/types/src/charts/Violin/emit.d.ts +4 -0
- package/types/src/charts/Violin/index.d.ts +16 -0
- package/types/src/charts/Violin/inner.d.ts +31 -0
- package/types/src/charts/Violin/violinLayout.d.ts +64 -0
- package/types/src/charts/Waffle/applyLayout.d.ts +36 -0
- package/types/src/charts/Waffle/emit.d.ts +29 -0
- package/types/src/charts/Waffle/index.d.ts +21 -0
- package/types/src/charts/Waffle/tooltip.d.ts +20 -0
- package/types/src/charts/Waffle/waffleLayout.d.ts +81 -0
- package/types/src/charts/Waterfall/buffer.d.ts +31 -0
- package/types/src/charts/Waterfall/connectors.d.ts +40 -0
- package/types/src/charts/Waterfall/index.d.ts +24 -0
- package/types/src/charts/Waterfall/labels.d.ts +59 -0
- package/types/src/charts/Waterfall/state.d.ts +62 -0
- package/types/src/charts/Waterfall/steps.d.ts +84 -0
- package/types/src/charts/definition/ChartDefinition.d.ts +28 -7
- package/types/src/charts/definition/makeChart.d.ts +3 -1
- package/types/src/charts/drawSteps/bottomRightControls.d.ts +19 -0
- package/types/src/charts/drawSteps/bottomRightControlsMarkup.d.ts +1 -1
- package/types/src/charts/drawSteps/controlButtonStyle.d.ts +21 -0
- package/types/src/charts/drawSteps/searchControlsMarkup.d.ts +2 -6
- package/types/src/charts/drawSteps/topLeftControlsMarkup.d.ts +10 -2
- package/types/src/charts/drawSteps/zoomControlsMarkup.d.ts +9 -0
- package/types/src/charts/drawSteps/zoomGesture.d.ts +17 -0
- package/types/src/charts/drawSteps/zoomShown.d.ts +32 -0
- package/types/src/charts/facet/drawFacets.d.ts +52 -0
- package/types/src/charts/facet/facetConfig.d.ts +178 -0
- package/types/src/charts/facet/facetData.d.ts +47 -0
- package/types/src/charts/facet/facetGrid.d.ts +62 -0
- package/types/src/charts/facet/facetGutter.d.ts +68 -0
- package/types/src/charts/facet/facetPanel.d.ts +24 -0
- package/types/src/charts/facet/facetScene.d.ts +39 -0
- package/types/src/charts/features/axes.d.ts +4 -89
- package/types/src/charts/features/axesFinal.d.ts +66 -0
- package/types/src/charts/features/axesMeasure.d.ts +88 -0
- package/types/src/charts/features/backgroundImageEmit.d.ts +32 -0
- package/types/src/charts/features/features.d.ts +40 -12
- package/types/src/charts/features/featuresLegend.d.ts +10 -2
- package/types/src/charts/features/frozenAxis.d.ts +8 -0
- package/types/src/charts/features/insetState.d.ts +3 -4
- package/types/src/charts/features/legendCategory.d.ts +36 -0
- package/types/src/charts/features/legendLabel.d.ts +3 -6
- package/types/src/charts/features/plotAnnotations.d.ts +38 -0
- package/types/src/charts/features/plotEndLabels.d.ts +108 -0
- package/types/src/charts/features/plotPaint.d.ts +10 -25
- package/types/src/charts/features/sceneBounds.d.ts +8 -2
- package/types/src/charts/features/shapeEmit.d.ts +14 -1
- package/types/src/charts/features/shareKey.d.ts +24 -0
- package/types/src/charts/features/sharedFields.d.ts +22 -0
- package/types/src/charts/features/tooltipSwatch.d.ts +36 -4
- package/types/src/charts/features/xAxisConfig.d.ts +6 -0
- package/types/src/charts/helpers/densityChart.d.ts +62 -0
- package/types/src/charts/helpers/densityData.d.ts +88 -0
- package/types/src/charts/helpers/densityEnter.d.ts +23 -0
- package/types/src/charts/helpers/valueTitle.d.ts +23 -0
- package/types/src/charts/index.d.ts +20 -0
- package/types/src/charts/partition/chartFields.d.ts +29 -0
- package/types/src/charts/partition/hierarchy.d.ts +109 -0
- package/types/src/charts/partition/interaction.d.ts +57 -0
- package/types/src/charts/partition/labelWords.d.ts +50 -0
- package/types/src/charts/partition/shade.d.ts +61 -0
- package/types/src/charts/partition/zoom.d.ts +51 -0
- package/types/src/charts/pipeline/preDrawData.d.ts +34 -0
- package/types/src/charts/pipeline/stages.d.ts +11 -3
- package/types/src/charts/pipeline/vizDraw.d.ts +25 -20
- package/types/src/charts/pipeline/vizPreDraw.d.ts +23 -17
- package/types/src/charts/plotBuffers/Bar.d.ts +9 -12
- package/types/src/charts/plotBuffers/Box.d.ts +8 -11
- package/types/src/charts/plotBuffers/defaultBuffers.d.ts +25 -0
- package/types/src/charts/plotBuffers/numericBuffer.d.ts +1 -1
- package/types/src/charts/plotBuffers/rectLikeBuffer.d.ts +25 -0
- package/types/src/charts/polar/chrome.d.ts +62 -0
- package/types/src/charts/polar/config.d.ts +21 -0
- package/types/src/charts/polar/geometry.d.ts +68 -0
- package/types/src/charts/polar/labels.d.ts +87 -0
- package/types/src/charts/polar/polarFacet.d.ts +33 -0
- package/types/src/charts/polar/wedgeLayout.d.ts +81 -0
- package/types/src/charts/viz/Viz.d.ts +24 -24
- package/types/src/charts/viz/VizBase.d.ts +59 -204
- package/types/src/charts/viz/backgroundInk.d.ts +15 -0
- package/types/src/charts/viz/labelDefaults.d.ts +11 -0
- package/types/src/charts/viz/reserveContainerSize.d.ts +15 -0
- package/types/src/charts/viz/resetChromeBoxes.d.ts +4 -0
- package/types/src/charts/viz/shapeClassTargets.d.ts +25 -0
- package/types/src/charts/viz/shapeHover.d.ts +10 -0
- package/types/src/charts/viz/simpleHover.d.ts +9 -0
- package/types/src/charts/viz/vizDefaults.d.ts +10 -0
- package/types/src/charts/viz/vizFields.d.ts +199 -0
- package/types/src/charts/viz/vizTypes.d.ts +107 -39
- package/types/src/components/Axis/Axis.d.ts +59 -4
- package/types/src/components/Axis/axisBreak.d.ts +86 -0
- package/types/src/components/Axis/axisDefaults.d.ts +11 -0
- package/types/src/components/Axis/axisEndLabels.d.ts +37 -0
- package/types/src/components/Axis/axisLabelThinning.d.ts +48 -0
- package/types/src/components/Axis/axisLayout.d.ts +10 -0
- package/types/src/components/Axis/axisLayoutLabels.d.ts +30 -0
- package/types/src/components/Axis/axisLayoutScale.d.ts +13 -2
- package/types/src/components/Axis/axisRender.d.ts +1 -30
- package/types/src/components/Axis/axisRounding.d.ts +14 -0
- package/types/src/components/Axis/axisScene.d.ts +33 -0
- package/types/src/components/Axis/brokenScale.d.ts +66 -0
- package/types/src/components/Axis/gridStroke.d.ts +8 -0
- package/types/src/components/Axis/timeValues.d.ts +63 -0
- package/types/src/components/Axis/yearValues.d.ts +21 -0
- package/types/src/components/TextBox.d.ts +1 -36
- package/types/src/components/textBoxLayout.d.ts +45 -0
- package/types/src/components/tooltipDom.d.ts +30 -0
- package/types/src/fluent.d.ts +103 -34
- package/types/src/shapes/Box.d.ts +12 -1
- package/types/src/shapes/Shape.d.ts +2 -3
- package/types/src/shapes/Whisker.d.ts +4 -1
- package/types/src/shapes/emitLabels.d.ts +15 -0
- package/types/src/shapes/shapeConfig.d.ts +35 -5
- package/types/src/shapes/shapeOwners.d.ts +10 -0
- package/types/src/shapes/shapeStandalone.d.ts +7 -0
- package/types/src/shapes/uniqueIds.d.ts +6 -0
- package/types/src/shapes/validateShapeConfig.d.ts +20 -3
- package/types/src/utils/BaseClass.d.ts +6 -0
- package/types/src/utils/D3Scale.d.ts +3 -0
- package/types/src/utils/D3plusConfig.d.ts +940 -99
- package/types/src/utils/configPrep.d.ts +3 -2
- package/types/src/utils/configWarnings.d.ts +5 -0
- package/types/src/utils/index.d.ts +1 -1
- package/types/src/utils/wholeWords.d.ts +28 -0
- package/umd/d3plus-core.full.js +74785 -75059
- package/umd/d3plus-core.full.min.js +2 -10702
- package/umd/d3plus-core.js +44707 -23629
- package/umd/d3plus-core.min.js +2 -6671
- package/es/index.js.map +0 -1
- package/es/internal.js.map +0 -1
- package/es/src/charts/AreaPlot/index.js.map +0 -1
- package/es/src/charts/BarChart/index.js.map +0 -1
- package/es/src/charts/BoxWhisker/index.js.map +0 -1
- package/es/src/charts/BumpChart/index.js.map +0 -1
- package/es/src/charts/Chord/applyLayout.js.map +0 -1
- package/es/src/charts/Chord/emit.js.map +0 -1
- package/es/src/charts/Chord/index.js.map +0 -1
- package/es/src/charts/Donut/index.js.map +0 -1
- package/es/src/charts/Geomap/applyLayout.js.map +0 -1
- package/es/src/charts/Geomap/basemapTheme.js.map +0 -1
- package/es/src/charts/Geomap/emit.js.map +0 -1
- package/es/src/charts/Geomap/index.js.map +0 -1
- package/es/src/charts/Histogram/binData.js.map +0 -1
- package/es/src/charts/Histogram/index.js.map +0 -1
- package/es/src/charts/LinePlot/index.js.map +0 -1
- package/es/src/charts/Matrix/applyLayout.js.map +0 -1
- package/es/src/charts/Matrix/emit.js.map +0 -1
- package/es/src/charts/Matrix/index.js.map +0 -1
- package/es/src/charts/Network/applyLayout.js.map +0 -1
- package/es/src/charts/Network/emit.js.map +0 -1
- package/es/src/charts/Network/index.js.map +0 -1
- package/es/src/charts/Pack/applyLayout.js.map +0 -1
- package/es/src/charts/Pack/emit.js.map +0 -1
- package/es/src/charts/Pack/index.js.map +0 -1
- package/es/src/charts/Pack/recursionCircles.js.map +0 -1
- package/es/src/charts/Pie/applyLayout.js.map +0 -1
- package/es/src/charts/Pie/emit.js.map +0 -1
- package/es/src/charts/Pie/index.js.map +0 -1
- package/es/src/charts/Plot/discreteSpan.js.map +0 -1
- package/es/src/charts/Plot/draw.js.map +0 -1
- package/es/src/charts/Plot/index.js.map +0 -1
- package/es/src/charts/Plot/insetRegion.js.map +0 -1
- package/es/src/charts/Plot/labelPlacement.js.map +0 -1
- package/es/src/charts/Plot/pipeline.js.map +0 -1
- package/es/src/charts/Plot/pipelineDomains.js.map +0 -1
- package/es/src/charts/Plot/pipelineLineLabels.js.map +0 -1
- package/es/src/charts/Plot/plotZoom.js.map +0 -1
- package/es/src/charts/Plot/shapeDefaults.js.map +0 -1
- package/es/src/charts/Plot/sharedHover.js.map +0 -1
- package/es/src/charts/Plot/sharedHoverScene.js.map +0 -1
- package/es/src/charts/Plot/sharedTooltip.js.map +0 -1
- package/es/src/charts/Plot/stackHelpers.js.map +0 -1
- package/es/src/charts/Plot/stackShareLabels.js.map +0 -1
- package/es/src/charts/Plot/stackShareTooltip.js.map +0 -1
- package/es/src/charts/Plot/trendLines.js.map +0 -1
- package/es/src/charts/Plot/trendProjection.js.map +0 -1
- package/es/src/charts/Plot/trendScene.js.map +0 -1
- package/es/src/charts/Plot/trendTooltip.js.map +0 -1
- package/es/src/charts/Priestley/applyLayout.js.map +0 -1
- package/es/src/charts/Priestley/emit.js.map +0 -1
- package/es/src/charts/Priestley/index.js.map +0 -1
- package/es/src/charts/Radar/applyLayout.js.map +0 -1
- package/es/src/charts/Radar/emit.js.map +0 -1
- package/es/src/charts/Radar/index.js.map +0 -1
- package/es/src/charts/RadialMatrix/applyLayout.js.map +0 -1
- package/es/src/charts/RadialMatrix/emit.js.map +0 -1
- package/es/src/charts/RadialMatrix/index.js.map +0 -1
- package/es/src/charts/Rings/applyLayout.js.map +0 -1
- package/es/src/charts/Rings/emit.js.map +0 -1
- package/es/src/charts/Rings/index.js.map +0 -1
- package/es/src/charts/Rings/ringsSizing.js.map +0 -1
- package/es/src/charts/Sankey/applyLayout.js.map +0 -1
- package/es/src/charts/Sankey/emit.js.map +0 -1
- package/es/src/charts/Sankey/index.js.map +0 -1
- package/es/src/charts/StackedArea/index.js.map +0 -1
- package/es/src/charts/Tree/applyLayout.js.map +0 -1
- package/es/src/charts/Tree/emit.js.map +0 -1
- package/es/src/charts/Tree/index.js.map +0 -1
- package/es/src/charts/Treemap/applyLayout.js.map +0 -1
- package/es/src/charts/Treemap/emit.js.map +0 -1
- package/es/src/charts/Treemap/index.js.map +0 -1
- package/es/src/charts/Treemap/thresholdFunction.js.map +0 -1
- package/es/src/charts/definition/ChartDefinition.js.map +0 -1
- package/es/src/charts/definition/applyDefinition.js.map +0 -1
- package/es/src/charts/definition/makeChart.js.map +0 -1
- package/es/src/charts/drawSteps/backControl.js.map +0 -1
- package/es/src/charts/drawSteps/bottomRightControls.js.map +0 -1
- package/es/src/charts/drawSteps/bottomRightControlsMarkup.js.map +0 -1
- package/es/src/charts/drawSteps/controlButtonStyle.js.map +0 -1
- package/es/src/charts/drawSteps/minimap.js.map +0 -1
- package/es/src/charts/drawSteps/minimapMarkup.js.map +0 -1
- package/es/src/charts/drawSteps/searchControls.js.map +0 -1
- package/es/src/charts/drawSteps/searchControlsMarkup.js.map +0 -1
- package/es/src/charts/drawSteps/tableView.js.map +0 -1
- package/es/src/charts/drawSteps/tableViewControl.js.map +0 -1
- package/es/src/charts/drawSteps/tableViewMarkup.js.map +0 -1
- package/es/src/charts/drawSteps/topLeftControls.js.map +0 -1
- package/es/src/charts/drawSteps/topLeftControlsMarkup.js.map +0 -1
- package/es/src/charts/drawSteps/zoomControls.js.map +0 -1
- package/es/src/charts/drawSteps/zoomControlsMarkup.js.map +0 -1
- package/es/src/charts/events/click.legend.js.map +0 -1
- package/es/src/charts/events/click.shape.js.map +0 -1
- package/es/src/charts/events/mouseenter.js.map +0 -1
- package/es/src/charts/events/mouseleave.js.map +0 -1
- package/es/src/charts/events/mousemove.legend.js.map +0 -1
- package/es/src/charts/events/mousemove.shape.js.map +0 -1
- package/es/src/charts/events/touchstart.body.js.map +0 -1
- package/es/src/charts/features/attributionFeature.js.map +0 -1
- package/es/src/charts/features/axes.js.map +0 -1
- package/es/src/charts/features/chartGeometry.js.map +0 -1
- package/es/src/charts/features/colorScaleBucket.js.map +0 -1
- package/es/src/charts/features/edgeArrows.js.map +0 -1
- package/es/src/charts/features/emitHelpers.js.map +0 -1
- package/es/src/charts/features/ensureZoomDom.js.map +0 -1
- package/es/src/charts/features/features.js.map +0 -1
- package/es/src/charts/features/featuresColorScale.js.map +0 -1
- package/es/src/charts/features/featuresLegend.js.map +0 -1
- package/es/src/charts/features/insetState.js.map +0 -1
- package/es/src/charts/features/legendLabel.js.map +0 -1
- package/es/src/charts/features/lineLabels.js.map +0 -1
- package/es/src/charts/features/plotPaint.js.map +0 -1
- package/es/src/charts/features/sceneBounds.js.map +0 -1
- package/es/src/charts/features/shapeEmit.js.map +0 -1
- package/es/src/charts/features/tooltipSwatch.js.map +0 -1
- package/es/src/charts/features/zoomExtent.js.map +0 -1
- package/es/src/charts/helpers/matrixData.js.map +0 -1
- package/es/src/charts/helpers/tileAttributions.js.map +0 -1
- package/es/src/charts/index.js.map +0 -1
- package/es/src/charts/pipeline/drillMorph.js.map +0 -1
- package/es/src/charts/pipeline/insetPlacement.js.map +0 -1
- package/es/src/charts/pipeline/resolveSpec.js.map +0 -1
- package/es/src/charts/pipeline/runChartDraw.js.map +0 -1
- package/es/src/charts/pipeline/runVizPipeline.js.map +0 -1
- package/es/src/charts/pipeline/stages.js.map +0 -1
- package/es/src/charts/pipeline/vizContext.js +0 -29
- package/es/src/charts/pipeline/vizContext.js.map +0 -1
- package/es/src/charts/pipeline/vizDraw.js.map +0 -1
- package/es/src/charts/pipeline/vizDrawPure.js +0 -220
- package/es/src/charts/pipeline/vizDrawPure.js.map +0 -1
- package/es/src/charts/pipeline/vizPreDraw.js.map +0 -1
- package/es/src/charts/pipeline/vizPreDrawPure.js +0 -279
- package/es/src/charts/pipeline/vizPreDrawPure.js.map +0 -1
- package/es/src/charts/plotBuffers/Bar.js.map +0 -1
- package/es/src/charts/plotBuffers/Box.js.map +0 -1
- package/es/src/charts/plotBuffers/Circle.js.map +0 -1
- package/es/src/charts/plotBuffers/Line.js.map +0 -1
- package/es/src/charts/plotBuffers/Rect.js.map +0 -1
- package/es/src/charts/plotBuffers/discreteBuffer.js.map +0 -1
- package/es/src/charts/plotBuffers/numericBuffer.js.map +0 -1
- package/es/src/charts/viz/Viz.js.map +0 -1
- package/es/src/charts/viz/VizBase.js.map +0 -1
- package/es/src/charts/viz/VizBaseConfig.js +0 -538
- package/es/src/charts/viz/VizBaseConfig.js.map +0 -1
- package/es/src/charts/viz/interactionOpacity.js.map +0 -1
- package/es/src/charts/viz/linkGroup.js.map +0 -1
- package/es/src/charts/viz/ordinalColor.js.map +0 -1
- package/es/src/charts/viz/sceneRows.js.map +0 -1
- package/es/src/charts/viz/trailCatchup.js.map +0 -1
- package/es/src/charts/viz/vizDefaults.js.map +0 -1
- package/es/src/charts/viz/vizRender.js.map +0 -1
- package/es/src/charts/viz/vizTypes.js.map +0 -1
- package/es/src/charts/viz/vizVisibility.js.map +0 -1
- package/es/src/components/Axis/Axis.js.map +0 -1
- package/es/src/components/Axis/AxisBottom.js.map +0 -1
- package/es/src/components/Axis/AxisLeft.js.map +0 -1
- package/es/src/components/Axis/AxisRight.js.map +0 -1
- package/es/src/components/Axis/AxisTop.js.map +0 -1
- package/es/src/components/Axis/axisLayout.js.map +0 -1
- package/es/src/components/Axis/axisLayoutLabels.js.map +0 -1
- package/es/src/components/Axis/axisLayoutScale.js.map +0 -1
- package/es/src/components/Axis/axisRender.js.map +0 -1
- package/es/src/components/ColorScale/ColorScale.js.map +0 -1
- package/es/src/components/ColorScale/colorScaleRender.js.map +0 -1
- package/es/src/components/ColorScale/colorScaleScale.js.map +0 -1
- package/es/src/components/Legend/Legend.js.map +0 -1
- package/es/src/components/Legend/legendConfig.js.map +0 -1
- package/es/src/components/Legend/legendRender.js.map +0 -1
- package/es/src/components/Message.js.map +0 -1
- package/es/src/components/SizeLegend/SizeLegend.js.map +0 -1
- package/es/src/components/SizeLegend/sizeLegendLayout.js.map +0 -1
- package/es/src/components/TextBox.js.map +0 -1
- package/es/src/components/Timeline/Timeline.js.map +0 -1
- package/es/src/components/Timeline/timelineConfig.js.map +0 -1
- package/es/src/components/Timeline/timelineRender.js.map +0 -1
- package/es/src/components/Tooltip.js.map +0 -1
- package/es/src/components/index.js.map +0 -1
- package/es/src/fluent.js.map +0 -1
- package/es/src/shapes/Area.js.map +0 -1
- package/es/src/shapes/Bar.js.map +0 -1
- package/es/src/shapes/Box.js.map +0 -1
- package/es/src/shapes/Circle.js.map +0 -1
- package/es/src/shapes/Image.js.map +0 -1
- package/es/src/shapes/Line.js.map +0 -1
- package/es/src/shapes/Path.js.map +0 -1
- package/es/src/shapes/Rect.js.map +0 -1
- package/es/src/shapes/Shape.js.map +0 -1
- package/es/src/shapes/Whisker.js.map +0 -1
- package/es/src/shapes/buildLabelData.js.map +0 -1
- package/es/src/shapes/emitLabels.js.map +0 -1
- package/es/src/shapes/hitAreaNode.js.map +0 -1
- package/es/src/shapes/index.js.map +0 -1
- package/es/src/shapes/interactionPoints.js.map +0 -1
- package/es/src/shapes/sceneSort.js.map +0 -1
- package/es/src/shapes/shapeConfig.js.map +0 -1
- package/es/src/shapes/textureKey.js.map +0 -1
- package/es/src/shapes/validateShapeConfig.js.map +0 -1
- package/es/src/utils/AccessorFn.js.map +0 -1
- package/es/src/utils/BaseClass.js.map +0 -1
- package/es/src/utils/D3Scale.js.map +0 -1
- package/es/src/utils/D3plusConfig.js.map +0 -1
- package/es/src/utils/RESET.js.map +0 -1
- package/es/src/utils/accessor.js.map +0 -1
- package/es/src/utils/configDefault.js.map +0 -1
- package/es/src/utils/configPrep.js.map +0 -1
- package/es/src/utils/configWarnings.js.map +0 -1
- package/es/src/utils/constant.js.map +0 -1
- package/es/src/utils/getProp.js.map +0 -1
- package/es/src/utils/index.js.map +0 -1
- package/es/src/utils/paintComponentScene.js.map +0 -1
- package/es/umd-entry.js +0 -16
- package/es/umd-entry.js.map +0 -1
- package/types/src/charts/AreaPlot.d.ts +0 -16
- package/types/src/charts/BarChart.d.ts +0 -16
- package/types/src/charts/BoxWhisker.d.ts +0 -11
- package/types/src/charts/BumpChart.d.ts +0 -36
- package/types/src/charts/ChartDefinition.d.ts +0 -75
- package/types/src/charts/Donut.d.ts +0 -11
- package/types/src/charts/Geomap.d.ts +0 -126
- package/types/src/charts/LinePlot.d.ts +0 -15
- package/types/src/charts/Matrix.d.ts +0 -48
- package/types/src/charts/Network.d.ts +0 -54
- package/types/src/charts/Pack.d.ts +0 -34
- package/types/src/charts/Pie.d.ts +0 -17
- package/types/src/charts/Plot.d.ts +0 -150
- package/types/src/charts/Priestley.d.ts +0 -37
- package/types/src/charts/Radar.d.ts +0 -38
- package/types/src/charts/RadialMatrix.d.ts +0 -63
- package/types/src/charts/Rings.d.ts +0 -61
- package/types/src/charts/Sankey.d.ts +0 -77
- package/types/src/charts/StackedArea.d.ts +0 -14
- package/types/src/charts/Tree.d.ts +0 -17
- package/types/src/charts/Treemap.d.ts +0 -42
- package/types/src/charts/Viz.d.ts +0 -90
- package/types/src/charts/VizBase.d.ts +0 -158
- package/types/src/charts/VizBaseConfig.d.ts +0 -148
- package/types/src/charts/applyDefinition.d.ts +0 -13
- package/types/src/charts/axes.d.ts +0 -134
- package/types/src/charts/chartGeometry.d.ts +0 -58
- package/types/src/charts/drawSteps/drawAttribution.d.ts +0 -7
- package/types/src/charts/drawSteps/drawBack.d.ts +0 -6
- package/types/src/charts/drawSteps/drawColorScale.d.ts +0 -6
- package/types/src/charts/drawSteps/drawLegend.d.ts +0 -12
- package/types/src/charts/drawSteps/drawSubtitle.d.ts +0 -7
- package/types/src/charts/drawSteps/drawTimeline.d.ts +0 -7
- package/types/src/charts/drawSteps/drawTitle.d.ts +0 -7
- package/types/src/charts/drawSteps/drawTotal.d.ts +0 -7
- package/types/src/charts/emitHelpers.d.ts +0 -122
- package/types/src/charts/ensureZoomDom.d.ts +0 -39
- package/types/src/charts/factories.d.ts +0 -73
- package/types/src/charts/features/colorScaleBucketShare.d.ts +0 -16
- package/types/src/charts/features.d.ts +0 -152
- package/types/src/charts/featuresLegend.d.ts +0 -12
- package/types/src/charts/legendLabel.d.ts +0 -11
- package/types/src/charts/lineLabels.d.ts +0 -40
- package/types/src/charts/makeChart.d.ts +0 -22
- package/types/src/charts/pipeline/vizContext.d.ts +0 -45
- package/types/src/charts/pipeline/vizDrawPure.d.ts +0 -46
- package/types/src/charts/pipeline/vizPreDrawPure.d.ts +0 -68
- package/types/src/charts/plotPaint.d.ts +0 -233
- package/types/src/charts/resolveSpec.d.ts +0 -50
- package/types/src/charts/runChartDraw.d.ts +0 -38
- package/types/src/charts/runVizPipeline.d.ts +0 -31
- package/types/src/charts/shapeEmit.d.ts +0 -61
- package/types/src/charts/stages.d.ts +0 -117
- package/types/src/charts/viz/VizBaseConfig.d.ts +0 -175
- package/types/src/charts/vizContext.d.ts +0 -46
- package/types/src/charts/vizDefaults.d.ts +0 -8
- package/types/src/charts/vizDraw.d.ts +0 -25
- package/types/src/charts/vizDrawPure.d.ts +0 -17
- package/types/src/charts/vizPreDraw.d.ts +0 -22
- package/types/src/charts/vizPreDrawPure.d.ts +0 -40
- package/types/src/charts/vizRender.d.ts +0 -8
- package/types/src/charts/vizTypes.d.ts +0 -202
- package/types/src/components/Axis.d.ts +0 -183
- package/types/src/components/AxisBottom.d.ts +0 -11
- package/types/src/components/AxisLeft.d.ts +0 -11
- package/types/src/components/AxisRight.d.ts +0 -11
- package/types/src/components/AxisTop.d.ts +0 -11
- package/types/src/components/ColorScale.d.ts +0 -80
- package/types/src/components/Legend.d.ts +0 -93
- package/types/src/components/Timeline.d.ts +0 -83
- package/types/src/components/axisLayout.d.ts +0 -27
- package/types/src/components/axisLayoutLabels.d.ts +0 -42
- package/types/src/components/axisLayoutScale.d.ts +0 -12
- package/types/src/components/axisRender.d.ts +0 -65
- package/types/src/components/colorScaleRender.d.ts +0 -15
- package/types/src/components/colorScaleScale.d.ts +0 -19
- package/types/src/components/legendConfig.d.ts +0 -7
- package/types/src/components/legendRender.d.ts +0 -16
- package/types/src/components/timelineConfig.d.ts +0 -6
- package/types/src/components/timelineRender.d.ts +0 -14
- package/umd/d3plus-core.full.js.map +0 -1
- package/umd/d3plus-core.js.map +0 -1
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Candlestick — a Plot of financial periods along a time axis. Each row's
|
|
3
|
+
open, high, low, and close draw as a candle (a wick from the high to the
|
|
4
|
+
low around a body from the open to the close) or, with `variant: "ohlc"`,
|
|
5
|
+
as an OHLC bar (a high-low line with the open ticked left and the close
|
|
6
|
+
ticked right), colored by whether the period rose or fell.
|
|
7
|
+
*/ import accessor from "../../utils/accessor.js";
|
|
8
|
+
import constant from "../../utils/constant.js";
|
|
9
|
+
import { makeChart } from "../definition/makeChart.js";
|
|
10
|
+
import { columnHighlight } from "../Plot/columnHighlight.js";
|
|
11
|
+
import Plot from "../Plot/index.js";
|
|
12
|
+
import { fieldAccessor, installAggregation, keyedAccessor, rememberKey, syncChartAggs } from "./aggregate.js";
|
|
13
|
+
import { candlestickBuffer } from "./buffer.js";
|
|
14
|
+
import { CANDLESTICK_SHAPE, emitCandlesticks } from "./emit.js";
|
|
15
|
+
import { bandAxisDefaults, periodDate } from "./periods.js";
|
|
16
|
+
import { candleTooltipRows } from "./tooltip.js";
|
|
17
|
+
import { installVolumeStrip, noteVolumeTop, VOLUME_DEFAULTS, volumeAccessor } from "./volume.js";
|
|
18
|
+
const candleState = (viz)=>viz.ctx.candlestick;
|
|
19
|
+
/**
|
|
20
|
+
Routes `x` through a Date parse when periods are evenly spaced, and makes
|
|
21
|
+
`y` an alias of `close`: reading `viz._y` reads the close, and setting `y`
|
|
22
|
+
sets it.
|
|
23
|
+
*/ function interceptAccessors(viz) {
|
|
24
|
+
const state = candleState(viz);
|
|
25
|
+
const close = fieldAccessor(viz, "close");
|
|
26
|
+
Object.defineProperty(viz, "_x", {
|
|
27
|
+
configurable: true,
|
|
28
|
+
enumerable: true,
|
|
29
|
+
get: ()=>viz.schema.skipGaps ? state.xDate : state.x,
|
|
30
|
+
set: (fn)=>{
|
|
31
|
+
if (fn !== state.xDate && fn !== state.x) state.x = fn;
|
|
32
|
+
}
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(viz, "_y", {
|
|
35
|
+
configurable: true,
|
|
36
|
+
enumerable: true,
|
|
37
|
+
get: ()=>close,
|
|
38
|
+
set: (fn)=>{
|
|
39
|
+
if (fn !== close) viz.schema.close = fn;
|
|
40
|
+
}
|
|
41
|
+
});
|
|
42
|
+
Object.defineProperty(viz, "_yKey", {
|
|
43
|
+
configurable: true,
|
|
44
|
+
enumerable: true,
|
|
45
|
+
get: ()=>state.yKey ?? viz.schema.translate("Close"),
|
|
46
|
+
set: (key)=>{
|
|
47
|
+
state.yKey = key === "y" ? undefined : key;
|
|
48
|
+
// `y(key)` sets the close from that key, which then merges through `aggs`.
|
|
49
|
+
if (state.yKey !== undefined && typeof viz.schema.close === "function") rememberKey(viz.schema.close, key);
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
Points `time` at the period accessor on a continuous time axis, so the
|
|
55
|
+
axis reads dates; evenly spaced periods are categories and get none. A
|
|
56
|
+
user's own `time` is left alone.
|
|
57
|
+
*/ function syncTime(viz) {
|
|
58
|
+
const state = candleState(viz);
|
|
59
|
+
const current = viz.schema.time;
|
|
60
|
+
if (current !== undefined && current !== state.time) return;
|
|
61
|
+
state.time = viz.schema.skipGaps ? undefined : (d, i)=>viz._x(d, i);
|
|
62
|
+
viz.schema.time = state.time;
|
|
63
|
+
}
|
|
64
|
+
export const candlestickDef = {
|
|
65
|
+
name: "Candlestick",
|
|
66
|
+
paintDriven: true,
|
|
67
|
+
facet: {
|
|
68
|
+
aspect: 16 / 9
|
|
69
|
+
},
|
|
70
|
+
setup: (viz)=>{
|
|
71
|
+
const x = accessor("date");
|
|
72
|
+
viz.ctx.candlestick = {
|
|
73
|
+
x,
|
|
74
|
+
xDate: (d, i)=>periodDate(candleState(viz).x(d, i))
|
|
75
|
+
};
|
|
76
|
+
viz._xKey = "date";
|
|
77
|
+
interceptAccessors(viz);
|
|
78
|
+
installAggregation(viz);
|
|
79
|
+
installVolumeStrip(viz);
|
|
80
|
+
viz._buffer = {
|
|
81
|
+
...viz._buffer,
|
|
82
|
+
[CANDLESTICK_SHAPE]: candlestickBuffer
|
|
83
|
+
};
|
|
84
|
+
viz._plotShapeEmitters = {
|
|
85
|
+
[CANDLESTICK_SHAPE]: emitCandlesticks
|
|
86
|
+
};
|
|
87
|
+
// Each period is its own mark: hovering one highlights its candle and
|
|
88
|
+
// volume bar and dims the other periods, though they share a series id.
|
|
89
|
+
viz._plotColumnHighlight = columnHighlight(viz);
|
|
90
|
+
// The tooltip's own rows list the period and its values.
|
|
91
|
+
viz._tooltipAxisRows = false;
|
|
92
|
+
// The value axis spans every period's range, so it takes no title from `close`.
|
|
93
|
+
viz._yTitle = null;
|
|
94
|
+
const preDraw = viz._preDraw.bind(viz);
|
|
95
|
+
viz._preDraw = ()=>{
|
|
96
|
+
syncTime(viz);
|
|
97
|
+
syncChartAggs(viz);
|
|
98
|
+
preDraw();
|
|
99
|
+
};
|
|
100
|
+
// Evenly spaced periods tick on calendar boundaries, per panel when faceted.
|
|
101
|
+
const draw = viz._draw.bind(viz);
|
|
102
|
+
viz._draw = (callback)=>{
|
|
103
|
+
viz._plotAxisDefaults = viz.schema.skipGaps ? {
|
|
104
|
+
x: bandAxisDefaults(viz)
|
|
105
|
+
} : undefined;
|
|
106
|
+
// Facet panels sharing scales share the volume strip's, from every panel's rows.
|
|
107
|
+
if (viz._facetStep === "chrome") noteVolumeTop(viz);
|
|
108
|
+
return draw(callback);
|
|
109
|
+
};
|
|
110
|
+
},
|
|
111
|
+
ctx: {},
|
|
112
|
+
fields: [
|
|
113
|
+
/**
|
|
114
|
+
Accessor (or data key) for each period's opening value. Defaults to
|
|
115
|
+
`"open"`; a row without one opens at its close. Rows that share a
|
|
116
|
+
series and a period merge into one candle, taking the first row's
|
|
117
|
+
open (in data order, so sort rows oldest first). Override with an
|
|
118
|
+
`aggs` entry on the data key, or, for a function accessor, on
|
|
119
|
+
`"open"`.
|
|
120
|
+
*/ {
|
|
121
|
+
key: "open",
|
|
122
|
+
coerce: keyedAccessor,
|
|
123
|
+
default: "open"
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
Accessor (or data key) for each period's highest value. Defaults to
|
|
127
|
+
`"high"`; the high always reaches the open and close. Merged rows
|
|
128
|
+
take the highest high; `aggs` overrides it as it does for `open`.
|
|
129
|
+
*/ {
|
|
130
|
+
key: "high",
|
|
131
|
+
coerce: keyedAccessor,
|
|
132
|
+
default: "high"
|
|
133
|
+
},
|
|
134
|
+
/**
|
|
135
|
+
Accessor (or data key) for each period's lowest value. Defaults to
|
|
136
|
+
`"low"`; the low always reaches the open and close. Merged rows
|
|
137
|
+
take the lowest low; `aggs` overrides it as it does for `open`.
|
|
138
|
+
*/ {
|
|
139
|
+
key: "low",
|
|
140
|
+
coerce: keyedAccessor,
|
|
141
|
+
default: "low"
|
|
142
|
+
},
|
|
143
|
+
/**
|
|
144
|
+
Accessor (or data key) for each period's closing value. Defaults to
|
|
145
|
+
`"close"`. The close is the chart's `y`: setting `y` sets it, rows
|
|
146
|
+
without one are skipped, and hover snaps to it. Merged rows take
|
|
147
|
+
the last row's close; `aggs` overrides it as it does for `open`.
|
|
148
|
+
*/ {
|
|
149
|
+
key: "close",
|
|
150
|
+
coerce: keyedAccessor,
|
|
151
|
+
default: "close"
|
|
152
|
+
},
|
|
153
|
+
/**
|
|
154
|
+
Accessor (or data key) for each period's traded volume. Off by
|
|
155
|
+
default; when set, a strip under the candles draws one bar per
|
|
156
|
+
candle, as tall as its volume on the strip's own axis (ticks
|
|
157
|
+
abbreviated, e.g. "1.2M"), in its candle's up or down color, and the
|
|
158
|
+
tooltip adds a Volume row. Bars are always filled, hollow candles
|
|
159
|
+
included, and take `shapeConfig.texture` and
|
|
160
|
+
`shapeConfig.backgroundImage` like filled candles; they hover with
|
|
161
|
+
their candle. The price axis shrinks to make room, and the x axis
|
|
162
|
+
sits under the strip. Merged rows add their volumes; an `aggs` entry
|
|
163
|
+
overrides it as it does for `open`. Set `false` to turn it off.
|
|
164
|
+
*/ {
|
|
165
|
+
key: "volume",
|
|
166
|
+
coerce: volumeAccessor
|
|
167
|
+
},
|
|
168
|
+
/**
|
|
169
|
+
The volume strip's layout and styling: `height`, its height as a
|
|
170
|
+
share of the plot's (default `0.2`; pixels when above 1; at most
|
|
171
|
+
half the plot); `gap`, the pixels between the candles and the strip
|
|
172
|
+
(default `16`); `axisConfig`, Axis config for the strip's value axis;
|
|
173
|
+
and `shapeConfig`, Path config for the bars (default
|
|
174
|
+
`{fillOpacity: 0.5}`).
|
|
175
|
+
*/ {
|
|
176
|
+
key: "volumeConfig",
|
|
177
|
+
merge: true,
|
|
178
|
+
default: VOLUME_DEFAULTS
|
|
179
|
+
},
|
|
180
|
+
/**
|
|
181
|
+
How each period draws: `"candlestick"` (default), a wick from the high
|
|
182
|
+
to the low around a body from the open to the close; or `"ohlc"`, a
|
|
183
|
+
line from the high to the low with the open ticked to the left and the
|
|
184
|
+
close ticked to the right.
|
|
185
|
+
*/ {
|
|
186
|
+
key: "variant",
|
|
187
|
+
default: "candlestick"
|
|
188
|
+
},
|
|
189
|
+
/**
|
|
190
|
+
The color of periods that closed at or above their open: a color
|
|
191
|
+
string, or an accessor of the row. Defaults to green.
|
|
192
|
+
*/ {
|
|
193
|
+
key: "upColor",
|
|
194
|
+
default: "#2f9e44"
|
|
195
|
+
},
|
|
196
|
+
/**
|
|
197
|
+
The color of periods that closed below their open: a color string, or
|
|
198
|
+
an accessor of the row. Defaults to red.
|
|
199
|
+
*/ {
|
|
200
|
+
key: "downColor",
|
|
201
|
+
default: "#e03131"
|
|
202
|
+
},
|
|
203
|
+
/**
|
|
204
|
+
Draws rising candles as outlines and falling candles filled (default
|
|
205
|
+
`true`), so direction reads without relying on color; `false` fills
|
|
206
|
+
both. OHLC bars are never filled. An unfilled candle or bar takes no
|
|
207
|
+
`shapeConfig.texture` or `shapeConfig.backgroundImage`; filled ones
|
|
208
|
+
take both, with a texture's lines a shade darker than the body unless
|
|
209
|
+
the texture sets its own `stroke`.
|
|
210
|
+
*/ {
|
|
211
|
+
key: "hollow",
|
|
212
|
+
default: true
|
|
213
|
+
},
|
|
214
|
+
/** The share of each period's room the candle body (or OHLC ticks) spans, from 0 to 1. Defaults to 0.7. */ {
|
|
215
|
+
key: "bodyWidth",
|
|
216
|
+
default: 0.7
|
|
217
|
+
},
|
|
218
|
+
/**
|
|
219
|
+
Places periods one slot apart in date order (default `true`), so days
|
|
220
|
+
without data (weekends, holidays) leave no gap; `false` places each
|
|
221
|
+
period at its date on a continuous time axis.
|
|
222
|
+
*/ {
|
|
223
|
+
key: "skipGaps",
|
|
224
|
+
default: true
|
|
225
|
+
},
|
|
226
|
+
{
|
|
227
|
+
key: "discrete",
|
|
228
|
+
default: "x"
|
|
229
|
+
},
|
|
230
|
+
{
|
|
231
|
+
key: "legend",
|
|
232
|
+
default: false,
|
|
233
|
+
coerce: "const"
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
key: "shape",
|
|
237
|
+
default: constant(CANDLESTICK_SHAPE),
|
|
238
|
+
coerce: "const"
|
|
239
|
+
},
|
|
240
|
+
{
|
|
241
|
+
key: "timeline",
|
|
242
|
+
default: false
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
key: "tooltipConfig",
|
|
246
|
+
merge: true,
|
|
247
|
+
factory: (viz)=>({
|
|
248
|
+
tbody: (d, i)=>candleTooltipRows(viz, d, i)
|
|
249
|
+
})
|
|
250
|
+
}
|
|
251
|
+
]
|
|
252
|
+
};
|
|
253
|
+
/**
|
|
254
|
+
Creates a candlestick (or OHLC bar) chart of financial periods, from rows
|
|
255
|
+
with a date and open, high, low, and close values. Each row's date is read
|
|
256
|
+
by `x` (default `"date"`): a Date, a timestamp, or a date string.
|
|
257
|
+
*/ export default makeChart(candlestickDef, Plot);
|
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Pure helpers for Candlestick: reading a row's open/high/low/close, its
|
|
3
|
+
direction and change, the value extent the rows span, and the SVG path
|
|
4
|
+
each period draws as.
|
|
5
|
+
|
|
6
|
+
@module
|
|
7
|
+
*/ /** `v` as a finite number, or undefined. */ export function finiteValue(v) {
|
|
8
|
+
if (v === null || v === undefined || v === "" || typeof v === "boolean") return undefined;
|
|
9
|
+
const n = typeof v === "number" ? v : Number(v);
|
|
10
|
+
return Number.isFinite(n) ? n : undefined;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
A row's open/high/low/close. A missing open reads as the close, and a
|
|
14
|
+
missing high or low as the larger or smaller of open and close, while the
|
|
15
|
+
high and low always contain the open and close. Undefined when the close
|
|
16
|
+
isn't a finite number.
|
|
17
|
+
@param d The data row.
|
|
18
|
+
@param i The row's index.
|
|
19
|
+
@param accessors The chart's `open`/`high`/`low`/`close` accessors.
|
|
20
|
+
*/ export function readOhlc(d, i, accessors) {
|
|
21
|
+
const close = finiteValue(accessors.close(d, i));
|
|
22
|
+
if (close === undefined) return undefined;
|
|
23
|
+
const open = finiteValue(accessors.open(d, i)) ?? close;
|
|
24
|
+
const high = finiteValue(accessors.high(d, i));
|
|
25
|
+
const low = finiteValue(accessors.low(d, i));
|
|
26
|
+
return {
|
|
27
|
+
open,
|
|
28
|
+
high: Math.max(high ?? -Infinity, open, close),
|
|
29
|
+
low: Math.min(low ?? Infinity, open, close),
|
|
30
|
+
close
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
Whether a period rose: `"up"` when it closed at or above its open,
|
|
35
|
+
otherwise `"down"`.
|
|
36
|
+
*/ export function candleDirection(open, close) {
|
|
37
|
+
return close >= open ? "up" : "down";
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
A period's change from open to close as a fraction of its open, e.g.
|
|
41
|
+
`0.05` for a 5% rise. Undefined when the open is zero or either value
|
|
42
|
+
isn't finite.
|
|
43
|
+
*/ export function candleChange(open, close) {
|
|
44
|
+
if (!Number.isFinite(open) || !Number.isFinite(close) || open === 0) return undefined;
|
|
45
|
+
return (close - open) / Math.abs(open);
|
|
46
|
+
}
|
|
47
|
+
/**
|
|
48
|
+
The `[lowest low, highest high]` over every row with a finite close;
|
|
49
|
+
undefined when there is none.
|
|
50
|
+
@param rows The data rows, each paired with its index.
|
|
51
|
+
@param accessors The chart's `open`/`high`/`low`/`close` accessors.
|
|
52
|
+
*/ export function ohlcExtent(rows, accessors) {
|
|
53
|
+
let lo = Infinity, hi = -Infinity;
|
|
54
|
+
for (const { d, i } of rows){
|
|
55
|
+
const v = readOhlc(d, i, accessors);
|
|
56
|
+
if (!v) continue;
|
|
57
|
+
if (v.low < lo) lo = v.low;
|
|
58
|
+
if (v.high > hi) hi = v.high;
|
|
59
|
+
}
|
|
60
|
+
return lo <= hi ? [
|
|
61
|
+
lo,
|
|
62
|
+
hi
|
|
63
|
+
] : undefined;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
The smallest gap between neighboring distinct positions (the pixel room
|
|
67
|
+
one period has); `fallback` when there are fewer than two.
|
|
68
|
+
@param positions Pixel positions along the time axis, in any order.
|
|
69
|
+
@param fallback The room a lone period gets.
|
|
70
|
+
*/ export function periodSpacing(positions, fallback) {
|
|
71
|
+
const sorted = Array.from(new Set(positions.filter(Number.isFinite))).sort((a, b)=>a - b);
|
|
72
|
+
let gap = Infinity;
|
|
73
|
+
for(let k = 1; k < sorted.length; k++)gap = Math.min(gap, sorted[k] - sorted[k - 1]);
|
|
74
|
+
return Number.isFinite(gap) && gap > 0 ? gap : fallback;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
The pixel width of a candle's body (or the span of an OHLC bar's two
|
|
78
|
+
ticks): `bodyWidth` of the period's room, at least 1px.
|
|
79
|
+
@param spacing The period's room along the time axis, in pixels.
|
|
80
|
+
@param bodyWidth The share of that room to fill, from 0 to 1.
|
|
81
|
+
*/ export function candleWidth(spacing, bodyWidth) {
|
|
82
|
+
const share = Number.isFinite(bodyWidth) ? Math.min(1, Math.max(0, bodyWidth)) : 0.7;
|
|
83
|
+
return Math.max(1, spacing * share);
|
|
84
|
+
}
|
|
85
|
+
/** Rounds `v` to the center of a pixel, so a 1px stroke there draws crisp. */ export const pixelCenter = (v)=>Math.round(v - 0.5) + 0.5;
|
|
86
|
+
/**
|
|
87
|
+
The path for one candlestick: a wick from the high to the body and from
|
|
88
|
+
the body to the low, and the body as a closed rectangle between the open
|
|
89
|
+
and close (a flat line when they meet).
|
|
90
|
+
@param cx The period's center along the time axis.
|
|
91
|
+
@param width The body's width.
|
|
92
|
+
@param px The open/high/low/close as pixel positions.
|
|
93
|
+
*/ export function candlePath(cx, width, px) {
|
|
94
|
+
const top = Math.min(px.open, px.close);
|
|
95
|
+
const bottom = Math.max(px.open, px.close);
|
|
96
|
+
const high = Math.min(px.high, top);
|
|
97
|
+
const low = Math.max(px.low, bottom);
|
|
98
|
+
const half = width / 2;
|
|
99
|
+
let d = "";
|
|
100
|
+
if (high < top) d += `M${cx},${high}V${top}`;
|
|
101
|
+
if (low > bottom) d += `M${cx},${bottom}V${low}`;
|
|
102
|
+
d += `M${cx - half},${top}H${cx + half}V${bottom}H${cx - half}Z`;
|
|
103
|
+
return d;
|
|
104
|
+
}
|
|
105
|
+
/**
|
|
106
|
+
The path for one OHLC bar: a line from the high to the low, a tick to the
|
|
107
|
+
left at the open, and a tick to the right at the close.
|
|
108
|
+
@param cx The period's center along the time axis.
|
|
109
|
+
@param width The span from the open tick's end to the close tick's end.
|
|
110
|
+
@param px The open/high/low/close as pixel positions.
|
|
111
|
+
*/ export function ohlcBarPath(cx, width, px) {
|
|
112
|
+
const half = width / 2;
|
|
113
|
+
return `M${cx},${px.high}V${px.low}M${cx - half},${px.open}H${cx}M${cx},${px.close}H${cx + half}`;
|
|
114
|
+
}
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Period dates: parsing a row's period, formatting it for tooltips, and,
|
|
3
|
+
for evenly spaced periods (`skipGaps`), the category axis's ticks: the
|
|
4
|
+
first period, then the first period of each calendar day, week, month,
|
|
5
|
+
quarter, or year (whichever is finest while its labels fit the axis),
|
|
6
|
+
labeled for it.
|
|
7
|
+
|
|
8
|
+
@module
|
|
9
|
+
*/ import { timeMonday } from "d3-time";
|
|
10
|
+
import { timeFormat } from "d3-time-format";
|
|
11
|
+
import { date } from "@d3plus/dom";
|
|
12
|
+
import { axisShownDates } from "../../components/Axis/timeValues.js";
|
|
13
|
+
/** Units from finest to coarsest. */ export const PERIOD_UNITS = [
|
|
14
|
+
"day",
|
|
15
|
+
"week",
|
|
16
|
+
"month",
|
|
17
|
+
"quarter",
|
|
18
|
+
"year"
|
|
19
|
+
];
|
|
20
|
+
/** Year intervals tried, in order, when a tick per year is too many. */ const YEAR_STEPS = [
|
|
21
|
+
2,
|
|
22
|
+
5,
|
|
23
|
+
10,
|
|
24
|
+
20,
|
|
25
|
+
50,
|
|
26
|
+
100,
|
|
27
|
+
200,
|
|
28
|
+
500,
|
|
29
|
+
1000
|
|
30
|
+
];
|
|
31
|
+
/** The least room, in pixels, the tick lists offered leave between two ticks. */ const MIN_TICK_SPACING = 72;
|
|
32
|
+
/** Room, in pixels, set aside for the value axis when estimating the time axis's width. */ const VALUE_AXIS_ROOM = 60;
|
|
33
|
+
/**
|
|
34
|
+
A period value as a Date: Dates pass through, and numbers and strings
|
|
35
|
+
parse through d3plus's `date`. A value that doesn't parse comes back as
|
|
36
|
+
given.
|
|
37
|
+
@param value The row's period value.
|
|
38
|
+
*/ export function periodDate(value) {
|
|
39
|
+
if (value instanceof Date) return value;
|
|
40
|
+
if (typeof value !== "string" && typeof value !== "number") return value;
|
|
41
|
+
const parsed = date(value);
|
|
42
|
+
return parsed instanceof Date && !isNaN(+parsed) ? parsed : value;
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
A period as a tooltip shows it: the full date (e.g. "Jan 3, 2023"), with
|
|
46
|
+
the time of day when it isn't midnight.
|
|
47
|
+
@param d The period's date.
|
|
48
|
+
*/ export function formatPeriod(d) {
|
|
49
|
+
const midnight = !d.getHours() && !d.getMinutes() && !d.getSeconds();
|
|
50
|
+
return timeFormat(midnight ? "%b %-d, %Y" : "%b %-d, %Y %-I:%M %p")(d);
|
|
51
|
+
}
|
|
52
|
+
/** The calendar `unit` a date falls in, as a comparable number. */ export function unitIndex(d, unit) {
|
|
53
|
+
const year = d.getFullYear(), month = d.getMonth();
|
|
54
|
+
switch(unit){
|
|
55
|
+
case "day":
|
|
56
|
+
return (year * 12 + month) * 31 + d.getDate();
|
|
57
|
+
case "week":
|
|
58
|
+
return +timeMonday.floor(d);
|
|
59
|
+
case "month":
|
|
60
|
+
return year * 12 + month;
|
|
61
|
+
case "quarter":
|
|
62
|
+
return year * 4 + Math.floor(month / 3);
|
|
63
|
+
default:
|
|
64
|
+
return year;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
The first period of each calendar `unit` after the one the dates start
|
|
69
|
+
in.
|
|
70
|
+
@param dates The periods' dates, ascending.
|
|
71
|
+
@param unit The calendar unit.
|
|
72
|
+
*/ export function periodBoundaries(dates, unit) {
|
|
73
|
+
const out = [];
|
|
74
|
+
for(let k = 1; k < dates.length; k++)if (unitIndex(dates[k], unit) !== unitIndex(dates[k - 1], unit)) out.push(dates[k]);
|
|
75
|
+
return out;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
The tick lists evenly spaced periods choose among, from the most ticks
|
|
79
|
+
to the fewest. For each calendar day, week, month, quarter, and year (then
|
|
80
|
+
every 2nd, 5th, 10th, … year): the first period and the first period of
|
|
81
|
+
each unit after it, then the same without the first period, for when it
|
|
82
|
+
crowds the next, as long as two remain. The axis draws the first list
|
|
83
|
+
whose labels all fit (see the axis `labels`), and its first label names
|
|
84
|
+
the year. Units with more than `maxTicks` boundaries are left out, unless
|
|
85
|
+
none has fewer, as are repeats.
|
|
86
|
+
@param dates The periods' dates, ascending.
|
|
87
|
+
@param maxTicks The most boundary ticks to offer.
|
|
88
|
+
*/ export function periodTickSets(dates, maxTicks) {
|
|
89
|
+
if (!dates.length) return [];
|
|
90
|
+
const most = Math.max(1, Math.floor(maxTicks));
|
|
91
|
+
const units = PERIOD_UNITS.map((unit)=>periodBoundaries(dates, unit));
|
|
92
|
+
const years = units[units.length - 1];
|
|
93
|
+
const lists = units.concat(YEAR_STEPS.map((step)=>years.filter((d)=>d.getFullYear() % step === 0))).filter((list, k, all)=>list.length && !(k && sameDates(list, all[k - 1])));
|
|
94
|
+
const fitting = lists.filter((list)=>list.length <= most);
|
|
95
|
+
const offered = fitting.length ? fitting : lists.slice(-1);
|
|
96
|
+
if (!offered.length) return [
|
|
97
|
+
[
|
|
98
|
+
dates[0]
|
|
99
|
+
]
|
|
100
|
+
];
|
|
101
|
+
return offered.flatMap((list)=>list.length > 1 ? [
|
|
102
|
+
[
|
|
103
|
+
dates[0],
|
|
104
|
+
...list
|
|
105
|
+
],
|
|
106
|
+
list
|
|
107
|
+
] : [
|
|
108
|
+
[
|
|
109
|
+
dates[0],
|
|
110
|
+
...list
|
|
111
|
+
]
|
|
112
|
+
]);
|
|
113
|
+
}
|
|
114
|
+
/** Whether two lists hold the same dates. */ function sameDates(a, b) {
|
|
115
|
+
return a.length === b.length && a.every((d, k)=>+d === +b[k]);
|
|
116
|
+
}
|
|
117
|
+
/**
|
|
118
|
+
A tick's label for its calendar unit: on the first tick, the date with
|
|
119
|
+
its year; on the first tick of a year, the year (or, for day and week
|
|
120
|
+
ticks, the date with its year); else the month, or for day and week ticks
|
|
121
|
+
the month and day.
|
|
122
|
+
@param d The tick's date.
|
|
123
|
+
@param prev The previous tick's date, if any.
|
|
124
|
+
@param unit The calendar unit the ticks mark.
|
|
125
|
+
*/ export function periodLabel(d, prev, unit) {
|
|
126
|
+
const newYear = !prev || prev.getFullYear() !== d.getFullYear();
|
|
127
|
+
if (unit === "year") return timeFormat("%Y")(d);
|
|
128
|
+
if (unit === "day" || unit === "week") return timeFormat(newYear ? "%b %-d, %Y" : "%b %-d")(d);
|
|
129
|
+
if (!prev) return timeFormat("%b %Y")(d);
|
|
130
|
+
return timeFormat(newYear ? "%Y" : "%b")(d);
|
|
131
|
+
}
|
|
132
|
+
/**
|
|
133
|
+
The coarsest calendar unit every shown tick after the first opens: the
|
|
134
|
+
unit the shown ticks mark.
|
|
135
|
+
@param shown The shown ticks' dates, ascending.
|
|
136
|
+
@param opens Whether a date is the first period of its unit.
|
|
137
|
+
*/ export function shownUnit(shown, opens) {
|
|
138
|
+
const units = PERIOD_UNITS.slice().reverse();
|
|
139
|
+
return units.find((unit)=>shown.slice(1).every((d)=>opens(d, unit))) ?? "day";
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
The tick formatter for evenly spaced periods. Called by an axis (as
|
|
143
|
+
`this`), it labels a tick for the unit the axis's shown ticks mark (see
|
|
144
|
+
`shownUnit`), with the year on the first shown tick and on the first
|
|
145
|
+
shown tick of each year (see `formatDate`'s `shown`); called on its own,
|
|
146
|
+
it formats the period in full.
|
|
147
|
+
@param dates The periods' dates, ascending.
|
|
148
|
+
*/ export function periodTickFormat(dates) {
|
|
149
|
+
const index = new Map(dates.map((d, k)=>[
|
|
150
|
+
+d,
|
|
151
|
+
k
|
|
152
|
+
]));
|
|
153
|
+
const opens = (d, unit)=>{
|
|
154
|
+
const k = index.get(+d);
|
|
155
|
+
return Boolean(k) && unitIndex(dates[k], unit) !== unitIndex(dates[k - 1], unit);
|
|
156
|
+
};
|
|
157
|
+
const units = new WeakMap();
|
|
158
|
+
return function(d) {
|
|
159
|
+
if (!(d instanceof Date)) return String(d);
|
|
160
|
+
const shown = this ? axisShownDates(this) : undefined;
|
|
161
|
+
if (!shown?.length) return formatPeriod(d);
|
|
162
|
+
let unit = units.get(shown);
|
|
163
|
+
if (!unit) units.set(shown, unit = shownUnit(shown, opens));
|
|
164
|
+
let prev;
|
|
165
|
+
for (const s of shown)if (+s < +d) prev = s;
|
|
166
|
+
return periodLabel(d, prev, unit);
|
|
167
|
+
};
|
|
168
|
+
}
|
|
169
|
+
/** The current rows' period dates, ascending and distinct. */ function rowDates(viz) {
|
|
170
|
+
const rows = viz._filteredData || [];
|
|
171
|
+
const seen = new Map();
|
|
172
|
+
rows.forEach((d, i)=>{
|
|
173
|
+
const v = viz._x ? viz._x(d, i) : undefined;
|
|
174
|
+
if (v instanceof Date && !isNaN(+v) && !seen.has(+v)) seen.set(+v, v);
|
|
175
|
+
});
|
|
176
|
+
return Array.from(seen.values()).sort((a, b)=>+a - +b);
|
|
177
|
+
}
|
|
178
|
+
/**
|
|
179
|
+
The time-axis config evenly spaced periods draw with, beneath the user's
|
|
180
|
+
`xConfig`: tick lists on calendar boundaries for the axis to choose
|
|
181
|
+
among, no more of them than the plot's width has room for, and their
|
|
182
|
+
labels.
|
|
183
|
+
@param viz The chart, mid-draw (its margins hold the current chart area).
|
|
184
|
+
*/ export function bandAxisDefaults(viz) {
|
|
185
|
+
const dates = rowDates(viz);
|
|
186
|
+
const width = viz.schema.width - viz._margin.left - viz._margin.right - VALUE_AXIS_ROOM;
|
|
187
|
+
return {
|
|
188
|
+
labels: periodTickSets(dates, width / MIN_TICK_SPACING),
|
|
189
|
+
tickFormat: periodTickFormat(dates)
|
|
190
|
+
};
|
|
191
|
+
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/**
|
|
2
|
+
Candlestick's tooltip rows and aria label: each period's date, open,
|
|
3
|
+
high, low, close, and change, and its volume when the chart has one.
|
|
4
|
+
|
|
5
|
+
@module
|
|
6
|
+
*/ import { formatAbbreviate } from "@d3plus/format";
|
|
7
|
+
import { axisName } from "../Plot/sharedTooltip.js";
|
|
8
|
+
import { ohlcAccessors } from "./aggregate.js";
|
|
9
|
+
import { candleChange, readOhlc } from "./ohlc.js";
|
|
10
|
+
import { formatPeriod, periodDate } from "./periods.js";
|
|
11
|
+
import { formatVolume, readVolume } from "./volume.js";
|
|
12
|
+
/**
|
|
13
|
+
A price as the tooltip shows it: two decimals for values of 1 or more
|
|
14
|
+
(e.g. `"1,234.50"`, with the locale's separators), three significant
|
|
15
|
+
digits below that.
|
|
16
|
+
@param value The price.
|
|
17
|
+
@param locale The chart's locale.
|
|
18
|
+
*/ export function formatPrice(value, locale) {
|
|
19
|
+
if (Math.abs(value) < 1) return formatAbbreviate(value, locale, ".3~g");
|
|
20
|
+
// formatAbbreviate drops trailing zeros; put the cents back.
|
|
21
|
+
const decimal = formatAbbreviate(1.5, locale, ".1f").charAt(1);
|
|
22
|
+
const [whole, cents = ""] = formatAbbreviate(value, locale, ",.2f").split(decimal);
|
|
23
|
+
return `${whole}${decimal}${cents.padEnd(2, "0")}`;
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
A fractional change as a signed percentage, e.g. `0.0123` as `"+1.23%"`.
|
|
27
|
+
@param change The change, as a fraction.
|
|
28
|
+
@param locale The chart's locale.
|
|
29
|
+
*/ export function formatChange(change, locale) {
|
|
30
|
+
const text = formatAbbreviate(change * 100, locale, ".2f");
|
|
31
|
+
return `${change > 0 ? "+" : ""}${text}%`;
|
|
32
|
+
}
|
|
33
|
+
/** The chart's price formatter: the y axis's `tickFormat` when set, else `formatPrice`. */ function priceFormat(viz) {
|
|
34
|
+
const tickFormat = viz._yConfig?.tickFormat;
|
|
35
|
+
return typeof tickFormat === "function" ? (v)=>String(tickFormat(v)) : (v)=>formatPrice(v, viz.schema.locale);
|
|
36
|
+
}
|
|
37
|
+
/** A row's period: through the x axis's `tickFormat` when set, else as a full date. */ function periodText(viz, d, i) {
|
|
38
|
+
const raw = viz._x ? viz._x(d, i) : undefined;
|
|
39
|
+
const tickFormat = viz._xConfig?.tickFormat;
|
|
40
|
+
const value = periodDate(raw);
|
|
41
|
+
if (typeof tickFormat === "function") return String(tickFormat(value));
|
|
42
|
+
return value instanceof Date ? formatPeriod(value) : String(raw ?? "");
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
The tooltip rows for one period: its date, then Open, High, Low, Close,
|
|
46
|
+
Change (open to close, as a percentage), and, with `volume` set, Volume
|
|
47
|
+
(abbreviated, e.g. "1.2M"). Empty when the row has no close.
|
|
48
|
+
@param viz The chart.
|
|
49
|
+
@param d The data row.
|
|
50
|
+
@param i The row's index.
|
|
51
|
+
*/ export function candleTooltipRows(viz, d, i) {
|
|
52
|
+
const v = readOhlc(d, i, ohlcAccessors(viz));
|
|
53
|
+
if (!v) return [];
|
|
54
|
+
const t = (s)=>viz.schema.translate(s);
|
|
55
|
+
const price = priceFormat(viz);
|
|
56
|
+
const rows = [
|
|
57
|
+
[
|
|
58
|
+
axisName(viz, "x"),
|
|
59
|
+
periodText(viz, d, i)
|
|
60
|
+
],
|
|
61
|
+
[
|
|
62
|
+
t("Open"),
|
|
63
|
+
price(v.open)
|
|
64
|
+
],
|
|
65
|
+
[
|
|
66
|
+
t("High"),
|
|
67
|
+
price(v.high)
|
|
68
|
+
],
|
|
69
|
+
[
|
|
70
|
+
t("Low"),
|
|
71
|
+
price(v.low)
|
|
72
|
+
],
|
|
73
|
+
[
|
|
74
|
+
t("Close"),
|
|
75
|
+
price(v.close)
|
|
76
|
+
]
|
|
77
|
+
];
|
|
78
|
+
const change = candleChange(v.open, v.close);
|
|
79
|
+
if (change !== undefined) rows.push([
|
|
80
|
+
t("Change"),
|
|
81
|
+
formatChange(change, viz.schema.locale)
|
|
82
|
+
]);
|
|
83
|
+
const volume = readVolume(viz, d, i);
|
|
84
|
+
if (volume !== undefined) rows.push([
|
|
85
|
+
t("Volume"),
|
|
86
|
+
formatVolume(viz, volume)
|
|
87
|
+
]);
|
|
88
|
+
return rows;
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
A screen-reader label for one period, e.g.
|
|
92
|
+
`"ACME, Jan 2, 2024: Open 101, High 104, Low 99.5, Close 103."`.
|
|
93
|
+
@param viz The chart.
|
|
94
|
+
@param d The data row.
|
|
95
|
+
@param i The row's index.
|
|
96
|
+
*/ export function candleAriaLabel(viz, d, i) {
|
|
97
|
+
const [period, ...values] = candleTooltipRows(viz, d, i);
|
|
98
|
+
return `${ariaHead(viz, d, i, period?.[1])}: ${values.map(([k, val])=>`${k} ${val}`).join(", ")}.`;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
A screen-reader label for one period's volume bar, e.g.
|
|
102
|
+
`"ACME, Jan 2, 2024: Volume 1.2M."`.
|
|
103
|
+
@param viz The chart.
|
|
104
|
+
@param d The data row.
|
|
105
|
+
@param i The row's index.
|
|
106
|
+
*/ export function volumeAriaLabel(viz, d, i) {
|
|
107
|
+
const volume = readVolume(viz, d, i);
|
|
108
|
+
const value = volume === undefined ? "" : ` ${formatVolume(viz, volume)}`;
|
|
109
|
+
return `${ariaHead(viz, d, i, periodText(viz, d, i))}: ${viz.schema.translate("Volume")}${value}.`;
|
|
110
|
+
}
|
|
111
|
+
/** An aria label's lead: the row's label, then its period. */ function ariaHead(viz, d, i, period) {
|
|
112
|
+
return [
|
|
113
|
+
viz._drawLabel(d, i),
|
|
114
|
+
period
|
|
115
|
+
].filter((s)=>s !== undefined && s !== "").join(", ");
|
|
116
|
+
}
|