highcharts 6.1.4 → 6.2.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/bower.json +1 -1
- package/css/highcharts.css +17 -0
- package/css/highcharts.scss +14 -0
- package/css/themes/dark-unica.css +17 -0
- package/css/themes/grid-light.css +17 -0
- package/css/themes/sand-signika.css +17 -0
- package/es-modules/indicators/momentum.src.js +1 -1
- package/es-modules/indicators/pivot-points.src.js +6 -1
- package/es-modules/masters/highcharts-gantt.src.js +11 -0
- package/es-modules/masters/modules/annotations.src.js +1 -1
- package/es-modules/masters/modules/arrow-symbols.src.js +12 -0
- package/es-modules/masters/modules/broken-axis.src.js +1 -1
- package/es-modules/masters/modules/current-date-indicator.src.js +12 -0
- package/es-modules/masters/modules/data.src.js +1 -1
- package/es-modules/masters/modules/draggable-points.src.js +9 -0
- package/es-modules/masters/modules/export-data.src.js +1 -1
- package/es-modules/masters/modules/exporting.src.js +1 -1
- package/es-modules/masters/modules/funnel.src.js +1 -1
- package/es-modules/masters/modules/gantt.src.js +2 -1
- package/es-modules/masters/modules/grid-axis.src.js +1 -1
- package/es-modules/masters/modules/heatmap.src.js +1 -1
- package/es-modules/masters/modules/item-series.src.js +1 -1
- package/es-modules/masters/modules/map.src.js +1 -1
- package/es-modules/masters/modules/overlapping-datalabels.src.js +1 -1
- package/es-modules/masters/modules/pathfinder.src.js +12 -0
- package/es-modules/masters/modules/sankey.src.js +1 -1
- package/es-modules/masters/modules/series-label.src.js +1 -1
- package/es-modules/masters/modules/solid-gauge.src.js +1 -1
- package/es-modules/masters/modules/stock.src.js +1 -1
- package/es-modules/masters/modules/streamgraph.src.js +1 -1
- package/es-modules/masters/modules/treegrid.src.js +12 -0
- package/es-modules/masters/modules/variwide.src.js +1 -1
- package/es-modules/masters/modules/vector.src.js +1 -1
- package/es-modules/masters/modules/windbarb.src.js +1 -1
- package/es-modules/masters/modules/xrange.src.js +1 -1
- package/es-modules/masters/themes/dark-blue.src.js +1 -1
- package/es-modules/masters/themes/dark-green.src.js +1 -1
- package/es-modules/masters/themes/dark-unica.src.js +1 -1
- package/es-modules/masters/themes/gray.src.js +1 -1
- package/es-modules/masters/themes/grid-light.src.js +1 -1
- package/es-modules/masters/themes/grid.src.js +1 -1
- package/es-modules/masters/themes/sand-signika.src.js +1 -1
- package/es-modules/masters/themes/skies.src.js +1 -1
- package/es-modules/mixins/centered-series.js +1 -1
- package/es-modules/mixins/on-series.js +1 -1
- package/es-modules/modules/boost.src.js +22 -14
- package/es-modules/modules/broken-axis.src.js +169 -134
- package/es-modules/modules/data.src.js +2 -2
- package/es-modules/modules/draggable-points.src.js +2257 -0
- package/es-modules/modules/drilldown.src.js +1 -0
- package/es-modules/modules/export-data.src.js +1 -1
- package/es-modules/modules/exporting.src.js +1 -1
- package/es-modules/modules/funnel.src.js +1 -1
- package/es-modules/modules/item-series.src.js +1 -1
- package/es-modules/modules/no-data-to-display.src.js +5 -5
- package/es-modules/modules/oldie.src.js +1 -1
- package/es-modules/modules/overlapping-datalabels.src.js +38 -22
- package/es-modules/modules/parallel-coordinates.src.js +3 -2
- package/es-modules/modules/sankey.src.js +1 -1
- package/es-modules/modules/series-label.src.js +2 -2
- package/es-modules/modules/solid-gauge.src.js +1 -1
- package/es-modules/modules/static-scale.src.js +67 -28
- package/es-modules/modules/streamgraph.src.js +1 -1
- package/es-modules/modules/tilemap.src.js +231 -134
- package/es-modules/modules/variwide.src.js +1 -1
- package/es-modules/modules/vector.src.js +92 -22
- package/es-modules/modules/windbarb.src.js +1 -1
- package/es-modules/modules/xrange.src.js +257 -77
- package/es-modules/parts/AreaSeries.js +77 -77
- package/es-modules/parts/AreaSplineSeries.js +64 -27
- package/es-modules/parts/Axis.js +160 -67
- package/es-modules/parts/BarSeries.js +68 -51
- package/es-modules/parts/CandlestickSeries.js +1 -1
- package/es-modules/parts/Chart.js +31 -55
- package/es-modules/parts/Color.js +29 -18
- package/es-modules/parts/ColumnSeries.js +264 -142
- package/es-modules/parts/DataGrouping.js +9 -6
- package/es-modules/parts/DataLabels.js +261 -210
- package/es-modules/parts/DateTimeAxis.js +26 -7
- package/es-modules/parts/Dynamics.js +5 -2
- package/es-modules/parts/FlagsSeries.js +1 -1
- package/es-modules/parts/Globals.js +1 -1
- package/es-modules/parts/Html.js +64 -12
- package/es-modules/parts/Interaction.js +187 -63
- package/es-modules/parts/Legend.js +7 -3
- package/es-modules/parts/LogarithmicAxis.js +35 -4
- package/es-modules/parts/MSPointer.js +1 -1
- package/es-modules/parts/Navigator.js +27 -5
- package/es-modules/parts/OHLCSeries.js +1 -1
- package/es-modules/parts/Options.js +15 -13
- package/es-modules/parts/OrdinalAxis.js +1 -1
- package/es-modules/parts/PieSeries.js +256 -140
- package/es-modules/parts/PlotBandSeries.experimental.js +1 -1
- package/es-modules/parts/PlotLineOrBand.js +7 -40
- package/es-modules/parts/Point.js +28 -4
- package/es-modules/parts/Pointer.js +8 -6
- package/es-modules/parts/RangeSelector.js +1 -1
- package/es-modules/parts/Responsive.js +82 -36
- package/es-modules/parts/ScatterSeries.js +57 -25
- package/es-modules/parts/ScrollablePlotArea.js +17 -7
- package/es-modules/parts/Scrollbar.js +9 -2
- package/es-modules/parts/Series.js +22 -9
- package/es-modules/parts/SplineSeries.js +51 -29
- package/es-modules/parts/Stacking.js +100 -6
- package/es-modules/parts/StockChart.js +9 -3
- package/es-modules/parts/SvgRenderer.js +15 -10
- package/es-modules/parts/Tick.js +150 -30
- package/es-modules/parts/Time.js +23 -5
- package/es-modules/parts/Tooltip.js +2 -2
- package/es-modules/parts/TouchPointer.js +1 -1
- package/es-modules/parts/Utilities.js +16 -1
- package/es-modules/parts-3d/Axis.js +1 -1
- package/es-modules/parts-3d/Chart.js +1 -1
- package/es-modules/parts-3d/Column.js +1 -1
- package/es-modules/parts-3d/Math.js +1 -1
- package/es-modules/parts-3d/Pie.js +1 -1
- package/es-modules/parts-3d/SVGRenderer.js +1 -1
- package/es-modules/parts-3d/Scatter.js +1 -1
- package/es-modules/parts-3d/Series.js +1 -1
- package/es-modules/parts-3d/VMLRenderer.js +1 -1
- package/es-modules/parts-gantt/ArrowSymbols.js +110 -0
- package/es-modules/parts-gantt/CurrentDateIndicator.js +92 -0
- package/es-modules/parts-gantt/GanttChart.js +111 -0
- package/es-modules/parts-gantt/GanttSeries.js +376 -0
- package/es-modules/parts-gantt/GridAxis.js +965 -0
- package/es-modules/parts-gantt/Pathfinder.js +1247 -0
- package/es-modules/parts-gantt/PathfinderAlgorithms.js +746 -0
- package/es-modules/parts-gantt/Tree.js +146 -0
- package/es-modules/parts-gantt/TreeGrid.js +917 -0
- package/es-modules/parts-map/ColorAxis.js +1 -1
- package/es-modules/parts-map/ColorSeriesMixin.js +1 -1
- package/es-modules/parts-map/GeoJSON.js +1 -1
- package/es-modules/parts-map/HeatmapSeries.js +124 -53
- package/es-modules/parts-map/Map.js +1 -1
- package/es-modules/parts-map/MapAxis.js +1 -1
- package/es-modules/parts-map/MapBubbleSeries.js +1 -1
- package/es-modules/parts-map/MapLineSeries.js +1 -1
- package/es-modules/parts-map/MapNavigation.js +1 -1
- package/es-modules/parts-map/MapPointSeries.js +1 -1
- package/es-modules/parts-map/MapPointer.js +1 -1
- package/es-modules/parts-map/MapSeries.js +2 -2
- package/es-modules/parts-more/AreaRangeSeries.js +80 -38
- package/es-modules/parts-more/AreaSplineRangeSeries.js +1 -1
- package/es-modules/parts-more/BoxPlotSeries.js +1 -1
- package/es-modules/parts-more/BubbleSeries.js +1 -1
- package/es-modules/parts-more/ColumnRangeSeries.js +1 -1
- package/es-modules/parts-more/ErrorBarSeries.js +1 -1
- package/es-modules/parts-more/GaugeSeries.js +1 -1
- package/es-modules/parts-more/Pane.js +2 -1
- package/es-modules/parts-more/Polar.js +1 -1
- package/es-modules/parts-more/PolygonSeries.js +1 -1
- package/es-modules/parts-more/RadialAxis.js +5 -4
- package/es-modules/parts-more/WaterfallSeries.js +1 -1
- package/es-modules/supplemental.docs.js +0 -1955
- package/es-modules/themes/dark-blue.js +1 -1
- package/es-modules/themes/dark-green.js +1 -1
- package/es-modules/themes/dark-unica.js +1 -1
- package/es-modules/themes/gray.js +1 -1
- package/es-modules/themes/grid-light.js +1 -1
- package/es-modules/themes/grid.js +1 -1
- package/es-modules/themes/sand-signika.js +1 -1
- package/es-modules/themes/skies.js +1 -1
- package/highcharts-3d.js +1 -1
- package/highcharts-3d.src.js +10 -10
- package/highcharts-gantt.js +503 -0
- package/highcharts-gantt.js.map +1 -0
- package/highcharts-gantt.src.js +49289 -0
- package/highcharts-more.js +65 -64
- package/highcharts-more.js.map +1 -1
- package/highcharts-more.src.js +97 -53
- package/highcharts.js +415 -410
- package/highcharts.js.map +1 -1
- package/highcharts.src.js +2170 -1128
- package/highmaps.js +443 -438
- package/highmaps.js.map +1 -1
- package/highmaps.src.js +1647 -849
- package/highstock.js +553 -548
- package/highstock.js.map +1 -1
- package/highstock.src.js +2398 -1283
- package/indicators/accumulation-distribution.js +1 -1
- package/indicators/accumulation-distribution.src.js +1 -1
- package/indicators/atr.js +1 -1
- package/indicators/atr.src.js +1 -1
- package/indicators/bollinger-bands.js +1 -1
- package/indicators/bollinger-bands.src.js +1 -1
- package/indicators/cci.js +1 -1
- package/indicators/cci.src.js +1 -1
- package/indicators/cmf.js +1 -1
- package/indicators/cmf.src.js +1 -1
- package/indicators/ema.js +1 -1
- package/indicators/ema.src.js +1 -1
- package/indicators/ichimoku-kinko-hyo.js +1 -1
- package/indicators/ichimoku-kinko-hyo.src.js +1 -1
- package/indicators/indicators.js +1 -1
- package/indicators/indicators.src.js +1 -1
- package/indicators/macd.js +1 -1
- package/indicators/macd.src.js +1 -1
- package/indicators/mfi.js +1 -1
- package/indicators/mfi.src.js +1 -1
- package/indicators/momentum.js +1 -1
- package/indicators/momentum.src.js +2 -2
- package/indicators/pivot-points.js +4 -4
- package/indicators/pivot-points.js.map +1 -1
- package/indicators/pivot-points.src.js +7 -2
- package/indicators/price-envelopes.js +1 -1
- package/indicators/price-envelopes.src.js +1 -1
- package/indicators/psar.js +1 -1
- package/indicators/psar.src.js +1 -1
- package/indicators/roc.js +1 -1
- package/indicators/roc.src.js +1 -1
- package/indicators/rsi.js +1 -1
- package/indicators/rsi.src.js +1 -1
- package/indicators/stochastic.js +1 -1
- package/indicators/stochastic.src.js +1 -1
- package/indicators/volume-by-price.js +1 -1
- package/indicators/volume-by-price.src.js +1 -1
- package/indicators/vwap.js +1 -1
- package/indicators/vwap.src.js +1 -1
- package/indicators/wma.js +1 -1
- package/indicators/wma.src.js +1 -1
- package/indicators/zigzag.js +1 -1
- package/indicators/zigzag.src.js +1 -1
- package/js/es-modules/indicators/momentum.src.js +1 -1
- package/js/es-modules/indicators/pivot-points.src.js +6 -1
- package/js/es-modules/masters/highcharts-gantt.src.js +11 -0
- package/js/es-modules/masters/modules/annotations.src.js +1 -1
- package/js/es-modules/masters/modules/arrow-symbols.src.js +12 -0
- package/js/es-modules/masters/modules/broken-axis.src.js +1 -1
- package/js/es-modules/masters/modules/current-date-indicator.src.js +12 -0
- package/js/es-modules/masters/modules/data.src.js +1 -1
- package/js/es-modules/masters/modules/draggable-points.src.js +9 -0
- package/js/es-modules/masters/modules/export-data.src.js +1 -1
- package/js/es-modules/masters/modules/exporting.src.js +1 -1
- package/js/es-modules/masters/modules/funnel.src.js +1 -1
- package/js/es-modules/masters/modules/gantt.src.js +2 -1
- package/js/es-modules/masters/modules/grid-axis.src.js +1 -1
- package/js/es-modules/masters/modules/heatmap.src.js +1 -1
- package/js/es-modules/masters/modules/item-series.src.js +1 -1
- package/js/es-modules/masters/modules/map.src.js +1 -1
- package/js/es-modules/masters/modules/overlapping-datalabels.src.js +1 -1
- package/js/es-modules/masters/modules/pathfinder.src.js +12 -0
- package/js/es-modules/masters/modules/sankey.src.js +1 -1
- package/js/es-modules/masters/modules/series-label.src.js +1 -1
- package/js/es-modules/masters/modules/solid-gauge.src.js +1 -1
- package/js/es-modules/masters/modules/stock.src.js +1 -1
- package/js/es-modules/masters/modules/streamgraph.src.js +1 -1
- package/js/es-modules/masters/modules/treegrid.src.js +12 -0
- package/js/es-modules/masters/modules/variwide.src.js +1 -1
- package/js/es-modules/masters/modules/vector.src.js +1 -1
- package/js/es-modules/masters/modules/windbarb.src.js +1 -1
- package/js/es-modules/masters/modules/xrange.src.js +1 -1
- package/js/es-modules/masters/themes/dark-blue.src.js +1 -1
- package/js/es-modules/masters/themes/dark-green.src.js +1 -1
- package/js/es-modules/masters/themes/dark-unica.src.js +1 -1
- package/js/es-modules/masters/themes/gray.src.js +1 -1
- package/js/es-modules/masters/themes/grid-light.src.js +1 -1
- package/js/es-modules/masters/themes/grid.src.js +1 -1
- package/js/es-modules/masters/themes/sand-signika.src.js +1 -1
- package/js/es-modules/masters/themes/skies.src.js +1 -1
- package/js/es-modules/mixins/centered-series.js +1 -1
- package/js/es-modules/mixins/on-series.js +1 -1
- package/js/es-modules/modules/boost.src.js +22 -14
- package/js/es-modules/modules/broken-axis.src.js +169 -134
- package/js/es-modules/modules/data.src.js +2 -2
- package/js/es-modules/modules/draggable-points.src.js +2257 -0
- package/js/es-modules/modules/drilldown.src.js +1 -0
- package/js/es-modules/modules/export-data.src.js +1 -1
- package/js/es-modules/modules/exporting.src.js +1 -1
- package/js/es-modules/modules/funnel.src.js +1 -1
- package/js/es-modules/modules/item-series.src.js +1 -1
- package/js/es-modules/modules/no-data-to-display.src.js +5 -5
- package/js/es-modules/modules/oldie.src.js +1 -1
- package/js/es-modules/modules/overlapping-datalabels.src.js +38 -22
- package/js/es-modules/modules/parallel-coordinates.src.js +3 -2
- package/js/es-modules/modules/sankey.src.js +1 -1
- package/js/es-modules/modules/series-label.src.js +2 -2
- package/js/es-modules/modules/solid-gauge.src.js +1 -1
- package/js/es-modules/modules/static-scale.src.js +67 -28
- package/js/es-modules/modules/streamgraph.src.js +1 -1
- package/js/es-modules/modules/tilemap.src.js +231 -134
- package/js/es-modules/modules/variwide.src.js +1 -1
- package/js/es-modules/modules/vector.src.js +92 -22
- package/js/es-modules/modules/windbarb.src.js +1 -1
- package/js/es-modules/modules/xrange.src.js +255 -68
- package/js/es-modules/parts/AreaSeries.js +77 -77
- package/js/es-modules/parts/AreaSplineSeries.js +64 -27
- package/js/es-modules/parts/Axis.js +160 -67
- package/js/es-modules/parts/BarSeries.js +68 -51
- package/js/es-modules/parts/CandlestickSeries.js +1 -1
- package/js/es-modules/parts/Chart.js +31 -55
- package/js/es-modules/parts/Color.js +29 -18
- package/js/es-modules/parts/ColumnSeries.js +231 -123
- package/js/es-modules/parts/DataGrouping.js +9 -6
- package/js/es-modules/parts/DataLabels.js +230 -182
- package/js/es-modules/parts/DateTimeAxis.js +26 -7
- package/js/es-modules/parts/Dynamics.js +5 -2
- package/js/es-modules/parts/FlagsSeries.js +1 -1
- package/js/es-modules/parts/Globals.js +1 -1
- package/js/es-modules/parts/Html.js +64 -12
- package/js/es-modules/parts/Interaction.js +178 -61
- package/js/es-modules/parts/Legend.js +7 -3
- package/js/es-modules/parts/LogarithmicAxis.js +35 -4
- package/js/es-modules/parts/MSPointer.js +1 -1
- package/js/es-modules/parts/Navigator.js +27 -5
- package/js/es-modules/parts/OHLCSeries.js +1 -1
- package/js/es-modules/parts/Options.js +13 -12
- package/js/es-modules/parts/OrdinalAxis.js +1 -1
- package/js/es-modules/parts/PieSeries.js +245 -132
- package/js/es-modules/parts/PlotBandSeries.experimental.js +1 -1
- package/js/es-modules/parts/PlotLineOrBand.js +7 -40
- package/js/es-modules/parts/Point.js +28 -4
- package/js/es-modules/parts/Pointer.js +8 -6
- package/js/es-modules/parts/RangeSelector.js +1 -1
- package/js/es-modules/parts/Responsive.js +82 -36
- package/js/es-modules/parts/ScatterSeries.js +56 -25
- package/js/es-modules/parts/ScrollablePlotArea.js +17 -7
- package/js/es-modules/parts/Scrollbar.js +9 -2
- package/js/es-modules/parts/Series.js +22 -9
- package/js/es-modules/parts/SplineSeries.js +51 -29
- package/js/es-modules/parts/Stacking.js +100 -6
- package/js/es-modules/parts/StockChart.js +9 -3
- package/js/es-modules/parts/SvgRenderer.js +15 -10
- package/js/es-modules/parts/Tick.js +150 -30
- package/js/es-modules/parts/Time.js +23 -5
- package/js/es-modules/parts/Tooltip.js +2 -2
- package/js/es-modules/parts/TouchPointer.js +1 -1
- package/js/es-modules/parts/Utilities.js +16 -1
- package/js/es-modules/parts-3d/Axis.js +1 -1
- package/js/es-modules/parts-3d/Chart.js +1 -1
- package/js/es-modules/parts-3d/Column.js +1 -1
- package/js/es-modules/parts-3d/Math.js +1 -1
- package/js/es-modules/parts-3d/Pie.js +1 -1
- package/js/es-modules/parts-3d/SVGRenderer.js +1 -1
- package/js/es-modules/parts-3d/Scatter.js +1 -1
- package/js/es-modules/parts-3d/Series.js +1 -1
- package/js/es-modules/parts-3d/VMLRenderer.js +1 -1
- package/js/es-modules/parts-gantt/ArrowSymbols.js +110 -0
- package/js/es-modules/parts-gantt/CurrentDateIndicator.js +92 -0
- package/js/es-modules/parts-gantt/GanttChart.js +111 -0
- package/js/es-modules/parts-gantt/GanttSeries.js +371 -0
- package/js/es-modules/parts-gantt/GridAxis.js +962 -0
- package/js/es-modules/parts-gantt/Pathfinder.js +1225 -0
- package/js/es-modules/parts-gantt/PathfinderAlgorithms.js +746 -0
- package/js/es-modules/parts-gantt/Tree.js +146 -0
- package/js/es-modules/parts-gantt/TreeGrid.js +891 -0
- package/js/es-modules/parts-map/ColorAxis.js +1 -1
- package/js/es-modules/parts-map/ColorSeriesMixin.js +1 -1
- package/js/es-modules/parts-map/GeoJSON.js +1 -1
- package/js/es-modules/parts-map/HeatmapSeries.js +122 -52
- package/js/es-modules/parts-map/Map.js +1 -1
- package/js/es-modules/parts-map/MapAxis.js +1 -1
- package/js/es-modules/parts-map/MapBubbleSeries.js +1 -1
- package/js/es-modules/parts-map/MapLineSeries.js +1 -1
- package/js/es-modules/parts-map/MapNavigation.js +1 -1
- package/js/es-modules/parts-map/MapPointSeries.js +1 -1
- package/js/es-modules/parts-map/MapPointer.js +1 -1
- package/js/es-modules/parts-map/MapSeries.js +2 -2
- package/js/es-modules/parts-more/AreaRangeSeries.js +80 -38
- package/js/es-modules/parts-more/AreaSplineRangeSeries.js +1 -1
- package/js/es-modules/parts-more/BoxPlotSeries.js +1 -1
- package/js/es-modules/parts-more/BubbleSeries.js +1 -1
- package/js/es-modules/parts-more/ColumnRangeSeries.js +1 -1
- package/js/es-modules/parts-more/ErrorBarSeries.js +1 -1
- package/js/es-modules/parts-more/GaugeSeries.js +1 -1
- package/js/es-modules/parts-more/Pane.js +2 -1
- package/js/es-modules/parts-more/Polar.js +1 -1
- package/js/es-modules/parts-more/PolygonSeries.js +1 -1
- package/js/es-modules/parts-more/RadialAxis.js +5 -4
- package/js/es-modules/parts-more/WaterfallSeries.js +1 -1
- package/js/es-modules/supplemental.docs.js +0 -1955
- package/js/es-modules/themes/dark-blue.js +1 -1
- package/js/es-modules/themes/dark-green.js +1 -1
- package/js/es-modules/themes/dark-unica.js +1 -1
- package/js/es-modules/themes/gray.js +1 -1
- package/js/es-modules/themes/grid-light.js +1 -1
- package/js/es-modules/themes/grid.js +1 -1
- package/js/es-modules/themes/sand-signika.js +1 -1
- package/js/es-modules/themes/skies.js +1 -1
- package/js/highcharts-3d.js +1 -1
- package/js/highcharts-3d.src.js +10 -10
- package/js/highcharts-gantt.js +480 -0
- package/js/highcharts-gantt.js.map +1 -0
- package/js/highcharts-gantt.src.js +47011 -0
- package/js/highcharts-more.js +62 -61
- package/js/highcharts-more.js.map +1 -1
- package/js/highcharts-more.src.js +97 -53
- package/js/highcharts.js +394 -390
- package/js/highcharts.js.map +1 -1
- package/js/highcharts.src.js +2083 -1070
- package/js/highmaps.js +420 -416
- package/js/highmaps.js.map +1 -1
- package/js/highmaps.src.js +1569 -798
- package/js/highstock.js +526 -520
- package/js/highstock.js.map +1 -1
- package/js/highstock.src.js +2311 -1225
- package/js/indicators/accumulation-distribution.js +1 -1
- package/js/indicators/accumulation-distribution.src.js +1 -1
- package/js/indicators/atr.js +1 -1
- package/js/indicators/atr.src.js +1 -1
- package/js/indicators/bollinger-bands.js +1 -1
- package/js/indicators/bollinger-bands.src.js +1 -1
- package/js/indicators/cci.js +1 -1
- package/js/indicators/cci.src.js +1 -1
- package/js/indicators/cmf.js +1 -1
- package/js/indicators/cmf.src.js +1 -1
- package/js/indicators/ema.js +1 -1
- package/js/indicators/ema.src.js +1 -1
- package/js/indicators/ichimoku-kinko-hyo.js +1 -1
- package/js/indicators/ichimoku-kinko-hyo.src.js +1 -1
- package/js/indicators/indicators.js +1 -1
- package/js/indicators/indicators.src.js +1 -1
- package/js/indicators/macd.js +1 -1
- package/js/indicators/macd.src.js +1 -1
- package/js/indicators/mfi.js +1 -1
- package/js/indicators/mfi.src.js +1 -1
- package/js/indicators/momentum.js +1 -1
- package/js/indicators/momentum.src.js +2 -2
- package/js/indicators/pivot-points.js +4 -4
- package/js/indicators/pivot-points.js.map +1 -1
- package/js/indicators/pivot-points.src.js +7 -2
- package/js/indicators/price-envelopes.js +1 -1
- package/js/indicators/price-envelopes.src.js +1 -1
- package/js/indicators/psar.js +1 -1
- package/js/indicators/psar.src.js +1 -1
- package/js/indicators/roc.js +1 -1
- package/js/indicators/roc.src.js +1 -1
- package/js/indicators/rsi.js +1 -1
- package/js/indicators/rsi.src.js +1 -1
- package/js/indicators/stochastic.js +1 -1
- package/js/indicators/stochastic.src.js +1 -1
- package/js/indicators/volume-by-price.js +1 -1
- package/js/indicators/volume-by-price.src.js +1 -1
- package/js/indicators/vwap.js +1 -1
- package/js/indicators/vwap.src.js +1 -1
- package/js/indicators/wma.js +1 -1
- package/js/indicators/wma.src.js +1 -1
- package/js/indicators/zigzag.js +1 -1
- package/js/indicators/zigzag.src.js +1 -1
- package/js/modules/accessibility.js +1 -1
- package/js/modules/accessibility.src.js +1 -1
- package/js/modules/annotations.js +2 -2
- package/js/modules/annotations.src.js +2 -2
- package/js/modules/arrow-symbols.js +13 -0
- package/js/modules/arrow-symbols.js.map +1 -0
- package/js/modules/arrow-symbols.src.js +138 -0
- package/js/modules/boost-canvas.js +1 -1
- package/js/modules/boost-canvas.src.js +1 -1
- package/js/modules/boost.js +43 -43
- package/js/modules/boost.js.map +1 -1
- package/js/modules/boost.src.js +23 -15
- package/js/modules/broken-axis.js +11 -10
- package/js/modules/broken-axis.js.map +1 -1
- package/js/modules/broken-axis.src.js +171 -136
- package/js/modules/bullet.js +1 -1
- package/js/modules/bullet.src.js +1 -1
- package/js/modules/current-date-indicator.js +13 -0
- package/js/modules/current-date-indicator.js.map +1 -0
- package/js/modules/current-date-indicator.src.js +120 -0
- package/js/modules/data.js +2 -2
- package/js/modules/data.src.js +4 -4
- package/js/modules/drag-panes.js +1 -1
- package/js/modules/drag-panes.src.js +1 -1
- package/js/modules/draggable-points.js +38 -0
- package/js/modules/draggable-points.js.map +1 -0
- package/js/modules/draggable-points.src.js +2281 -0
- package/js/modules/drilldown.js +1 -1
- package/js/modules/drilldown.js.map +1 -1
- package/js/modules/drilldown.src.js +2 -1
- package/js/modules/export-data.js +2 -2
- package/js/modules/export-data.src.js +3 -3
- package/js/modules/exporting.js +2 -2
- package/js/modules/exporting.src.js +3 -3
- package/js/modules/funnel.js +2 -2
- package/js/modules/funnel.src.js +3 -3
- package/js/modules/gantt.js +80 -18
- package/js/modules/gantt.js.map +1 -1
- package/js/modules/gantt.src.js +5490 -372
- package/js/modules/grid-axis.js +15 -11
- package/js/modules/grid-axis.js.map +1 -1
- package/js/modules/grid-axis.src.js +731 -293
- package/js/modules/heatmap.js +2 -2
- package/js/modules/heatmap.js.map +1 -1
- package/js/modules/heatmap.src.js +126 -56
- package/js/modules/histogram-bellcurve.js +1 -1
- package/js/modules/histogram-bellcurve.src.js +1 -1
- package/js/modules/item-series.js +2 -2
- package/js/modules/item-series.src.js +3 -3
- package/js/modules/map.js +2 -2
- package/js/modules/map.js.map +1 -1
- package/js/modules/map.src.js +137 -67
- package/js/modules/no-data-to-display.js +1 -1
- package/js/modules/no-data-to-display.src.js +6 -6
- package/js/modules/offline-exporting.js +2 -2
- package/js/modules/offline-exporting.src.js +2 -2
- package/js/modules/oldie.js +2 -2
- package/js/modules/oldie.src.js +3 -3
- package/js/modules/overlapping-datalabels.js +2 -2
- package/js/modules/overlapping-datalabels.src.js +2 -2
- package/js/modules/parallel-coordinates.js +9 -9
- package/js/modules/parallel-coordinates.js.map +1 -1
- package/js/modules/parallel-coordinates.src.js +4 -3
- package/js/modules/pareto.js +1 -1
- package/js/modules/pareto.src.js +1 -1
- package/js/modules/pathfinder.js +34 -0
- package/js/modules/pathfinder.js.map +1 -0
- package/js/modules/pathfinder.src.js +2106 -0
- package/js/modules/pattern-fill.js +1 -1
- package/js/modules/pattern-fill.src.js +1 -1
- package/js/modules/sankey.js +2 -2
- package/js/modules/sankey.src.js +3 -3
- package/js/modules/series-label.js +2 -2
- package/js/modules/series-label.src.js +4 -4
- package/js/modules/solid-gauge.js +2 -2
- package/js/modules/solid-gauge.src.js +3 -3
- package/js/modules/static-scale.js +3 -3
- package/js/modules/static-scale.js.map +1 -1
- package/js/modules/static-scale.src.js +65 -26
- package/js/modules/stock.js +135 -134
- package/js/modules/stock.js.map +1 -1
- package/js/modules/stock.src.js +230 -157
- package/js/modules/streamgraph.js +2 -2
- package/js/modules/streamgraph.src.js +3 -3
- package/js/modules/sunburst.js +1 -1
- package/js/modules/sunburst.src.js +1 -1
- package/js/modules/tilemap.js +1 -1
- package/js/modules/tilemap.js.map +1 -1
- package/js/modules/tilemap.src.js +355 -188
- package/js/modules/treegrid.js +51 -0
- package/js/modules/treegrid.js.map +1 -0
- package/js/modules/treegrid.src.js +2759 -0
- package/js/modules/treemap.js +1 -1
- package/js/modules/treemap.src.js +1 -1
- package/js/modules/variable-pie.js +1 -1
- package/js/modules/variable-pie.src.js +1 -1
- package/js/modules/variwide.js +2 -2
- package/js/modules/variwide.src.js +3 -3
- package/js/modules/vector.js +2 -2
- package/js/modules/vector.js.map +1 -1
- package/js/modules/vector.src.js +94 -24
- package/js/modules/windbarb.js +2 -2
- package/js/modules/windbarb.src.js +4 -4
- package/js/modules/wordcloud.js +1 -1
- package/js/modules/wordcloud.src.js +1 -1
- package/js/modules/xrange.js +11 -10
- package/js/modules/xrange.js.map +1 -1
- package/js/modules/xrange.src.js +257 -70
- package/js/themes/avocado.js +1 -1
- package/js/themes/avocado.src.js +1 -1
- package/js/themes/dark-blue.js +2 -2
- package/js/themes/dark-blue.src.js +3 -3
- package/js/themes/dark-green.js +2 -2
- package/js/themes/dark-green.src.js +3 -3
- package/js/themes/dark-unica.js +2 -2
- package/js/themes/dark-unica.src.js +3 -3
- package/js/themes/gray.js +2 -2
- package/js/themes/gray.src.js +3 -3
- package/js/themes/grid-light.js +2 -2
- package/js/themes/grid-light.src.js +3 -3
- package/js/themes/grid.js +2 -2
- package/js/themes/grid.src.js +3 -3
- package/js/themes/sand-signika.js +2 -2
- package/js/themes/sand-signika.src.js +3 -3
- package/js/themes/skies.js +2 -2
- package/js/themes/skies.src.js +3 -3
- package/js/themes/sunset.js +1 -1
- package/js/themes/sunset.src.js +1 -1
- package/modules/accessibility.js +1 -1
- package/modules/accessibility.src.js +1 -1
- package/modules/annotations.js +2 -2
- package/modules/annotations.src.js +2 -2
- package/modules/arrow-symbols.js +13 -0
- package/modules/arrow-symbols.js.map +1 -0
- package/modules/arrow-symbols.src.js +138 -0
- package/modules/boost-canvas.js +1 -1
- package/modules/boost-canvas.src.js +1 -1
- package/modules/boost.js +36 -36
- package/modules/boost.js.map +1 -1
- package/modules/boost.src.js +23 -15
- package/modules/broken-axis.js +11 -10
- package/modules/broken-axis.js.map +1 -1
- package/modules/broken-axis.src.js +171 -136
- package/modules/bullet.js +1 -1
- package/modules/bullet.src.js +1 -1
- package/modules/current-date-indicator.js +13 -0
- package/modules/current-date-indicator.js.map +1 -0
- package/modules/current-date-indicator.src.js +120 -0
- package/modules/data.js +2 -2
- package/modules/data.src.js +4 -4
- package/modules/drag-panes.js +1 -1
- package/modules/drag-panes.src.js +1 -1
- package/modules/draggable-points.js +38 -0
- package/modules/draggable-points.js.map +1 -0
- package/modules/draggable-points.src.js +2281 -0
- package/modules/drilldown.js +1 -1
- package/modules/drilldown.js.map +1 -1
- package/modules/drilldown.src.js +2 -1
- package/modules/export-data.js +2 -2
- package/modules/export-data.src.js +3 -3
- package/modules/exporting.js +2 -2
- package/modules/exporting.src.js +3 -3
- package/modules/funnel.js +2 -2
- package/modules/funnel.src.js +3 -3
- package/modules/gantt.js +83 -19
- package/modules/gantt.js.map +1 -1
- package/modules/gantt.src.js +5553 -379
- package/modules/grid-axis.js +16 -11
- package/modules/grid-axis.js.map +1 -1
- package/modules/grid-axis.src.js +732 -293
- package/modules/heatmap.js +2 -2
- package/modules/heatmap.js.map +1 -1
- package/modules/heatmap.src.js +128 -57
- package/modules/histogram-bellcurve.js +1 -1
- package/modules/histogram-bellcurve.src.js +1 -1
- package/modules/item-series.js +2 -2
- package/modules/item-series.src.js +3 -3
- package/modules/map.js +2 -2
- package/modules/map.js.map +1 -1
- package/modules/map.src.js +139 -68
- package/modules/no-data-to-display.js +1 -1
- package/modules/no-data-to-display.src.js +6 -6
- package/modules/offline-exporting.js +2 -2
- package/modules/offline-exporting.src.js +2 -2
- package/modules/oldie.js +2 -2
- package/modules/oldie.src.js +3 -3
- package/modules/overlapping-datalabels.js +2 -2
- package/modules/overlapping-datalabels.src.js +2 -2
- package/modules/parallel-coordinates.js +8 -8
- package/modules/parallel-coordinates.js.map +1 -1
- package/modules/parallel-coordinates.src.js +4 -3
- package/modules/pareto.js +1 -1
- package/modules/pareto.src.js +1 -1
- package/modules/pathfinder.js +35 -0
- package/modules/pathfinder.js.map +1 -0
- package/modules/pathfinder.src.js +2128 -0
- package/modules/pattern-fill.js +1 -1
- package/modules/pattern-fill.src.js +1 -1
- package/modules/sankey.js +2 -2
- package/modules/sankey.src.js +3 -3
- package/modules/series-label.js +2 -2
- package/modules/series-label.src.js +4 -4
- package/modules/solid-gauge.js +2 -2
- package/modules/solid-gauge.src.js +3 -3
- package/modules/static-scale.js +3 -3
- package/modules/static-scale.js.map +1 -1
- package/modules/static-scale.src.js +65 -26
- package/modules/stock.js +142 -142
- package/modules/stock.js.map +1 -1
- package/modules/stock.src.js +230 -157
- package/modules/streamgraph.js +2 -2
- package/modules/streamgraph.src.js +3 -3
- package/modules/sunburst.js +1 -1
- package/modules/sunburst.src.js +1 -1
- package/modules/tilemap.js +1 -1
- package/modules/tilemap.js.map +1 -1
- package/modules/tilemap.src.js +357 -189
- package/modules/treegrid.js +52 -0
- package/modules/treegrid.js.map +1 -0
- package/modules/treegrid.src.js +2797 -0
- package/modules/treemap.js +1 -1
- package/modules/treemap.src.js +1 -1
- package/modules/variable-pie.js +1 -1
- package/modules/variable-pie.src.js +1 -1
- package/modules/variwide.js +2 -2
- package/modules/variwide.src.js +3 -3
- package/modules/vector.js +2 -2
- package/modules/vector.js.map +1 -1
- package/modules/vector.src.js +94 -24
- package/modules/windbarb.js +2 -2
- package/modules/windbarb.src.js +4 -4
- package/modules/wordcloud.js +1 -1
- package/modules/wordcloud.src.js +1 -1
- package/modules/xrange.js +12 -11
- package/modules/xrange.js.map +1 -1
- package/modules/xrange.src.js +259 -79
- package/package.json +1 -1
- package/themes/avocado.js +1 -1
- package/themes/avocado.src.js +1 -1
- package/themes/dark-blue.js +2 -2
- package/themes/dark-blue.src.js +3 -3
- package/themes/dark-green.js +2 -2
- package/themes/dark-green.src.js +3 -3
- package/themes/dark-unica.js +2 -2
- package/themes/dark-unica.src.js +3 -3
- package/themes/gray.js +2 -2
- package/themes/gray.src.js +3 -3
- package/themes/grid-light.js +2 -2
- package/themes/grid-light.src.js +3 -3
- package/themes/grid.js +2 -2
- package/themes/grid.src.js +3 -3
- package/themes/sand-signika.js +2 -2
- package/themes/sand-signika.src.js +3 -3
- package/themes/skies.js +2 -2
- package/themes/skies.src.js +3 -3
- package/themes/sunset.js +1 -1
- package/themes/sunset.src.js +1 -1
|
@@ -0,0 +1,746 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* (c) 2016 Highsoft AS
|
|
3
|
+
* Author: Øystein Moseng
|
|
4
|
+
*
|
|
5
|
+
* License: www.highcharts.com/license
|
|
6
|
+
*/
|
|
7
|
+
'use strict';
|
|
8
|
+
import H from '../parts/Globals.js';
|
|
9
|
+
import '../parts/Utilities.js';
|
|
10
|
+
|
|
11
|
+
var min = Math.min,
|
|
12
|
+
max = Math.max,
|
|
13
|
+
abs = Math.abs,
|
|
14
|
+
pick = H.pick;
|
|
15
|
+
|
|
16
|
+
/**
|
|
17
|
+
* Get index of last obstacle before xMin. Employs a type of binary search, and
|
|
18
|
+
* thus requires that obstacles are sorted by xMin value.
|
|
19
|
+
*
|
|
20
|
+
* @param {Array} obstacles Array of obstacles to search in.
|
|
21
|
+
* @param {Number} xMin The xMin threshold.
|
|
22
|
+
* @param {Number} startIx Starting index to search from. Must be within array
|
|
23
|
+
* range.
|
|
24
|
+
*
|
|
25
|
+
* @return {Number} result The index of the last obstacle element before xMin.
|
|
26
|
+
*/
|
|
27
|
+
function findLastObstacleBefore(obstacles, xMin, startIx) {
|
|
28
|
+
var left = startIx || 0, // left limit
|
|
29
|
+
right = obstacles.length - 1, // right limit
|
|
30
|
+
min = xMin - 0.0000001, // Make sure we include all obstacles at xMin
|
|
31
|
+
cursor,
|
|
32
|
+
cmp;
|
|
33
|
+
while (left <= right) {
|
|
34
|
+
cursor = (right + left) >> 1;
|
|
35
|
+
cmp = min - obstacles[cursor].xMin;
|
|
36
|
+
if (cmp > 0) {
|
|
37
|
+
left = cursor + 1;
|
|
38
|
+
} else if (cmp < 0) {
|
|
39
|
+
right = cursor - 1;
|
|
40
|
+
} else {
|
|
41
|
+
return cursor;
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
return left > 0 ? left - 1 : 0;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* Test if a point lays within an obstacle.
|
|
49
|
+
*
|
|
50
|
+
* @param {Object} obstacle Obstacle to test.
|
|
51
|
+
* @param {Object} point Point with x/y props.
|
|
52
|
+
*
|
|
53
|
+
* @return {Boolean} result Whether point is within the obstacle or not.
|
|
54
|
+
*/
|
|
55
|
+
function pointWithinObstacle(obstacle, point) {
|
|
56
|
+
return (
|
|
57
|
+
point.x <= obstacle.xMax &&
|
|
58
|
+
point.x >= obstacle.xMin &&
|
|
59
|
+
point.y <= obstacle.yMax &&
|
|
60
|
+
point.y >= obstacle.yMin
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/**
|
|
65
|
+
* Find the index of an obstacle that wraps around a point.
|
|
66
|
+
* Returns -1 if not found.
|
|
67
|
+
*
|
|
68
|
+
* @param {Array} obstacles Obstacles to test.
|
|
69
|
+
* @param {Object} point Point with x/y props.
|
|
70
|
+
*
|
|
71
|
+
* @return {Number} result Ix of the obstacle in the array, or -1 if not found.
|
|
72
|
+
*/
|
|
73
|
+
function findObstacleFromPoint(obstacles, point) {
|
|
74
|
+
var i = findLastObstacleBefore(obstacles, point.x + 1) + 1;
|
|
75
|
+
while (i--) {
|
|
76
|
+
if (obstacles[i].xMax >= point.x &&
|
|
77
|
+
// optimization using lazy evaluation
|
|
78
|
+
pointWithinObstacle(obstacles[i], point)) {
|
|
79
|
+
return i;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return -1;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/**
|
|
86
|
+
* Get SVG path array from array of line segments.
|
|
87
|
+
*
|
|
88
|
+
* @param {Array} segments The segments to build the path from.
|
|
89
|
+
*
|
|
90
|
+
* @return {Array} result SVG path array as accepted by the SVG Renderer.
|
|
91
|
+
*/
|
|
92
|
+
function pathFromSegments(segments) {
|
|
93
|
+
var path = [];
|
|
94
|
+
if (segments.length) {
|
|
95
|
+
path.push('M', segments[0].start.x, segments[0].start.y);
|
|
96
|
+
for (var i = 0; i < segments.length; ++i) {
|
|
97
|
+
path.push('L', segments[i].end.x, segments[i].end.y);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return path;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
/**
|
|
104
|
+
* Limits obstacle max/mins in all directions to bounds. Modifies input
|
|
105
|
+
* obstacle.
|
|
106
|
+
*
|
|
107
|
+
* @param {Object} obstacle Obstacle to limit.
|
|
108
|
+
* @param {Object} bounds Bounds to use as limit.
|
|
109
|
+
*/
|
|
110
|
+
function limitObstacleToBounds(obstacle, bounds) {
|
|
111
|
+
obstacle.yMin = max(obstacle.yMin, bounds.yMin);
|
|
112
|
+
obstacle.yMax = min(obstacle.yMax, bounds.yMax);
|
|
113
|
+
obstacle.xMin = max(obstacle.xMin, bounds.xMin);
|
|
114
|
+
obstacle.xMax = min(obstacle.xMax, bounds.xMax);
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
|
|
118
|
+
|
|
119
|
+
// Define the available pathfinding algorithms.
|
|
120
|
+
// Algorithms take up to 3 arguments: starting point, ending point, and an
|
|
121
|
+
// options object.
|
|
122
|
+
var algorithms = {
|
|
123
|
+
|
|
124
|
+
/**
|
|
125
|
+
* Get an SVG path from a starting coordinate to an ending coordinate.
|
|
126
|
+
* Draws a straight line.
|
|
127
|
+
*
|
|
128
|
+
* @param {Object} start Starting coordinate, object with x/y props.
|
|
129
|
+
* @param {Object} end Ending coordinate, object with x/y props.
|
|
130
|
+
*
|
|
131
|
+
* @return {Object} result An object with the SVG path in Array form as
|
|
132
|
+
* accepted by the SVG renderer, as well as an array of new obstacles
|
|
133
|
+
* making up this path.
|
|
134
|
+
*/
|
|
135
|
+
straight: function (start, end) {
|
|
136
|
+
return {
|
|
137
|
+
path: ['M', start.x, start.y, 'L', end.x, end.y],
|
|
138
|
+
obstacles: [{ start: start, end: end }]
|
|
139
|
+
};
|
|
140
|
+
},
|
|
141
|
+
|
|
142
|
+
/**
|
|
143
|
+
* Find a path from a starting coordinate to an ending coordinate, using
|
|
144
|
+
* right angles only, and taking only starting/ending obstacle into
|
|
145
|
+
* consideration.
|
|
146
|
+
*
|
|
147
|
+
* Options
|
|
148
|
+
* - chartObstacles: Array of chart obstacles to avoid
|
|
149
|
+
* - startDirectionX: Optional. True if starting in the X direction.
|
|
150
|
+
* If not provided, the algorithm starts in the
|
|
151
|
+
* direction that is the furthest between
|
|
152
|
+
* start/end.
|
|
153
|
+
*
|
|
154
|
+
* @param {Object} start Starting coordinate, object with x/y props.
|
|
155
|
+
* @param {Object} end Ending coordinate, object with x/y props.
|
|
156
|
+
* @param {Object} options Options for the algorithm.
|
|
157
|
+
*
|
|
158
|
+
* @return {Object} result An object with the SVG path in Array form as
|
|
159
|
+
* accepted by the SVG renderer, as well as an array of new obstacles
|
|
160
|
+
* making up this path.
|
|
161
|
+
*/
|
|
162
|
+
simpleConnect: H.extend(function (start, end, options) {
|
|
163
|
+
var segments = [],
|
|
164
|
+
endSegment,
|
|
165
|
+
dir = pick(
|
|
166
|
+
options.startDirectionX,
|
|
167
|
+
abs(end.x - start.x) > abs(end.y - start.y)
|
|
168
|
+
) ? 'x' : 'y',
|
|
169
|
+
chartObstacles = options.chartObstacles,
|
|
170
|
+
startObstacleIx = findObstacleFromPoint(chartObstacles, start),
|
|
171
|
+
endObstacleIx = findObstacleFromPoint(chartObstacles, end),
|
|
172
|
+
startObstacle,
|
|
173
|
+
endObstacle,
|
|
174
|
+
prevWaypoint,
|
|
175
|
+
waypoint,
|
|
176
|
+
waypoint2,
|
|
177
|
+
useMax,
|
|
178
|
+
endPoint;
|
|
179
|
+
|
|
180
|
+
// Return a clone of a point with a property set from a target object,
|
|
181
|
+
// optionally with an offset
|
|
182
|
+
function copyFromPoint(from, fromKey, to, toKey, offset) {
|
|
183
|
+
var point = {
|
|
184
|
+
x: from.x,
|
|
185
|
+
y: from.y
|
|
186
|
+
};
|
|
187
|
+
point[fromKey] = to[toKey || fromKey] + (offset || 0);
|
|
188
|
+
return point;
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
// Return waypoint outside obstacle
|
|
192
|
+
function getMeOut(obstacle, point, direction) {
|
|
193
|
+
var useMax = abs(point[direction] - obstacle[direction + 'Min']) >
|
|
194
|
+
abs(point[direction] - obstacle[direction + 'Max']);
|
|
195
|
+
return copyFromPoint(
|
|
196
|
+
point,
|
|
197
|
+
direction,
|
|
198
|
+
obstacle,
|
|
199
|
+
direction + (useMax ? 'Max' : 'Min'),
|
|
200
|
+
useMax ? 1 : -1
|
|
201
|
+
);
|
|
202
|
+
}
|
|
203
|
+
|
|
204
|
+
// Pull out end point
|
|
205
|
+
if (endObstacleIx > -1) {
|
|
206
|
+
endObstacle = chartObstacles[endObstacleIx];
|
|
207
|
+
waypoint = getMeOut(endObstacle, end, dir);
|
|
208
|
+
endSegment = {
|
|
209
|
+
start: waypoint,
|
|
210
|
+
end: end
|
|
211
|
+
};
|
|
212
|
+
endPoint = waypoint;
|
|
213
|
+
} else {
|
|
214
|
+
endPoint = end;
|
|
215
|
+
}
|
|
216
|
+
|
|
217
|
+
// If an obstacle envelops the start point, add a segment to get out,
|
|
218
|
+
// and around it.
|
|
219
|
+
if (startObstacleIx > -1) {
|
|
220
|
+
startObstacle = chartObstacles[startObstacleIx];
|
|
221
|
+
waypoint = getMeOut(startObstacle, start, dir);
|
|
222
|
+
segments.push({
|
|
223
|
+
start: start,
|
|
224
|
+
end: waypoint
|
|
225
|
+
});
|
|
226
|
+
|
|
227
|
+
// If we are going back again, switch direction to get around start
|
|
228
|
+
// obstacle.
|
|
229
|
+
if (
|
|
230
|
+
waypoint[dir] > start[dir] === // Going towards max from start
|
|
231
|
+
waypoint[dir] > endPoint[dir] // Going towards min to end
|
|
232
|
+
) {
|
|
233
|
+
dir = dir === 'y' ? 'x' : 'y';
|
|
234
|
+
useMax = start[dir] < end[dir];
|
|
235
|
+
segments.push({
|
|
236
|
+
start: waypoint,
|
|
237
|
+
end: copyFromPoint(
|
|
238
|
+
waypoint,
|
|
239
|
+
dir,
|
|
240
|
+
startObstacle,
|
|
241
|
+
dir + (useMax ? 'Max' : 'Min'),
|
|
242
|
+
useMax ? 1 : -1
|
|
243
|
+
)
|
|
244
|
+
});
|
|
245
|
+
|
|
246
|
+
// Switch direction again
|
|
247
|
+
dir = dir === 'y' ? 'x' : 'y';
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
// We are around the start obstacle. Go towards the end in one
|
|
252
|
+
// direction.
|
|
253
|
+
prevWaypoint = segments.length ?
|
|
254
|
+
segments[segments.length - 1].end :
|
|
255
|
+
start;
|
|
256
|
+
waypoint = copyFromPoint(prevWaypoint, dir, endPoint);
|
|
257
|
+
segments.push({
|
|
258
|
+
start: prevWaypoint,
|
|
259
|
+
end: waypoint
|
|
260
|
+
});
|
|
261
|
+
|
|
262
|
+
// Final run to end point in the other direction
|
|
263
|
+
dir = dir === 'y' ? 'x' : 'y';
|
|
264
|
+
waypoint2 = copyFromPoint(waypoint, dir, endPoint);
|
|
265
|
+
segments.push({
|
|
266
|
+
start: waypoint,
|
|
267
|
+
end: waypoint2
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
// Finally add the endSegment
|
|
271
|
+
segments.push(endSegment);
|
|
272
|
+
|
|
273
|
+
return {
|
|
274
|
+
path: pathFromSegments(segments),
|
|
275
|
+
obstacles: segments
|
|
276
|
+
};
|
|
277
|
+
}, {
|
|
278
|
+
requiresObstacles: true
|
|
279
|
+
}),
|
|
280
|
+
|
|
281
|
+
/**
|
|
282
|
+
* Find a path from a starting coordinate to an ending coordinate, taking
|
|
283
|
+
* obstacles into consideration. Might not always find the optimal path,
|
|
284
|
+
* but is fast, and usually good enough.
|
|
285
|
+
*
|
|
286
|
+
* Options
|
|
287
|
+
* - chartObstacles: Array of chart obstacles to avoid
|
|
288
|
+
* - lineObstacles: Array of line obstacles to jump over
|
|
289
|
+
* - obstacleMetrics: Object with metrics of chartObstacles cached
|
|
290
|
+
* - hardBounds: Hard boundaries to not cross
|
|
291
|
+
* - obstacleOptions: Options for the obstacles, including margin
|
|
292
|
+
* - startDirectionX: Optional. True if starting in the X direction.
|
|
293
|
+
* If not provided, the algorithm starts in the
|
|
294
|
+
* direction that is the furthest between
|
|
295
|
+
* start/end.
|
|
296
|
+
*
|
|
297
|
+
* @param {Object} start Starting coordinate, object with x/y props.
|
|
298
|
+
* @param {Object} end Ending coordinate, object with x/y props.
|
|
299
|
+
* @param {Object} options Options for the algorithm.
|
|
300
|
+
*
|
|
301
|
+
* @return {Object} result An object with the SVG path in Array form as
|
|
302
|
+
* accepted by the SVG renderer, as well as an array of new obstacles
|
|
303
|
+
* making up this path.
|
|
304
|
+
*/
|
|
305
|
+
fastAvoid: H.extend(function (start, end, options) {
|
|
306
|
+
/*
|
|
307
|
+
Algorithm rules/description
|
|
308
|
+
- Find initial direction
|
|
309
|
+
- Determine soft/hard max for each direction.
|
|
310
|
+
- Move along initial direction until obstacle.
|
|
311
|
+
- Change direction.
|
|
312
|
+
- If hitting obstacle, first try to change length of previous line
|
|
313
|
+
before changing direction again.
|
|
314
|
+
|
|
315
|
+
Soft min/max x = start/destination x +/- widest obstacle + margin
|
|
316
|
+
Soft min/max y = start/destination y +/- tallest obstacle + margin
|
|
317
|
+
|
|
318
|
+
TODO:
|
|
319
|
+
- Make retrospective, try changing prev segment to reduce
|
|
320
|
+
corners
|
|
321
|
+
- Fix logic for breaking out of end-points - not always picking
|
|
322
|
+
the best direction currently
|
|
323
|
+
- When going around the end obstacle we should not always go the
|
|
324
|
+
shortest route, rather pick the one closer to the end point
|
|
325
|
+
*/
|
|
326
|
+
var dirIsX = pick(
|
|
327
|
+
options.startDirectionX,
|
|
328
|
+
abs(end.x - start.x) > abs(end.y - start.y)
|
|
329
|
+
),
|
|
330
|
+
dir = dirIsX ? 'x' : 'y',
|
|
331
|
+
segments,
|
|
332
|
+
useMax,
|
|
333
|
+
extractedEndPoint,
|
|
334
|
+
endSegments = [],
|
|
335
|
+
forceObstacleBreak = false, // Used in clearPathTo to keep track of
|
|
336
|
+
// when to force break through an obstacle.
|
|
337
|
+
|
|
338
|
+
// Boundaries to stay within. If beyond soft boundary, prefer to
|
|
339
|
+
// change direction ASAP. If at hard max, always change immediately.
|
|
340
|
+
metrics = options.obstacleMetrics,
|
|
341
|
+
softMinX = min(start.x, end.x) - metrics.maxWidth - 10,
|
|
342
|
+
softMaxX = max(start.x, end.x) + metrics.maxWidth + 10,
|
|
343
|
+
softMinY = min(start.y, end.y) - metrics.maxHeight - 10,
|
|
344
|
+
softMaxY = max(start.y, end.y) + metrics.maxHeight + 10,
|
|
345
|
+
|
|
346
|
+
// Obstacles
|
|
347
|
+
chartObstacles = options.chartObstacles,
|
|
348
|
+
startObstacleIx = findLastObstacleBefore(chartObstacles, softMinX),
|
|
349
|
+
endObstacleIx = findLastObstacleBefore(chartObstacles, softMaxX);
|
|
350
|
+
|
|
351
|
+
// How far can you go between two points before hitting an obstacle?
|
|
352
|
+
// Does not work for diagonal lines (because it doesn't have to).
|
|
353
|
+
function pivotPoint(fromPoint, toPoint, directionIsX) {
|
|
354
|
+
var firstPoint,
|
|
355
|
+
lastPoint,
|
|
356
|
+
highestPoint,
|
|
357
|
+
lowestPoint,
|
|
358
|
+
i,
|
|
359
|
+
searchDirection = fromPoint.x < toPoint.x ? 1 : -1;
|
|
360
|
+
|
|
361
|
+
if (fromPoint.x < toPoint.x) {
|
|
362
|
+
firstPoint = fromPoint;
|
|
363
|
+
lastPoint = toPoint;
|
|
364
|
+
} else {
|
|
365
|
+
firstPoint = toPoint;
|
|
366
|
+
lastPoint = fromPoint;
|
|
367
|
+
}
|
|
368
|
+
|
|
369
|
+
if (fromPoint.y < toPoint.y) {
|
|
370
|
+
lowestPoint = fromPoint;
|
|
371
|
+
highestPoint = toPoint;
|
|
372
|
+
} else {
|
|
373
|
+
lowestPoint = toPoint;
|
|
374
|
+
highestPoint = fromPoint;
|
|
375
|
+
}
|
|
376
|
+
|
|
377
|
+
// Go through obstacle range in reverse if toPoint is before
|
|
378
|
+
// fromPoint in the X-dimension.
|
|
379
|
+
i = searchDirection < 0 ?
|
|
380
|
+
// Searching backwards, start at last obstacle before last point
|
|
381
|
+
min(findLastObstacleBefore(chartObstacles, lastPoint.x),
|
|
382
|
+
chartObstacles.length - 1) :
|
|
383
|
+
// Forwards. Since we're not sorted by xMax, we have to look
|
|
384
|
+
// at all obstacles.
|
|
385
|
+
0;
|
|
386
|
+
|
|
387
|
+
// Go through obstacles in this X range
|
|
388
|
+
while (chartObstacles[i] && (
|
|
389
|
+
searchDirection > 0 && chartObstacles[i].xMin <= lastPoint.x ||
|
|
390
|
+
searchDirection < 0 && chartObstacles[i].xMax >= firstPoint.x
|
|
391
|
+
)) {
|
|
392
|
+
// If this obstacle is between from and to points in a straight
|
|
393
|
+
// line, pivot at the intersection.
|
|
394
|
+
if (
|
|
395
|
+
chartObstacles[i].xMin <= lastPoint.x &&
|
|
396
|
+
chartObstacles[i].xMax >= firstPoint.x &&
|
|
397
|
+
chartObstacles[i].yMin <= highestPoint.y &&
|
|
398
|
+
chartObstacles[i].yMax >= lowestPoint.y
|
|
399
|
+
) {
|
|
400
|
+
if (directionIsX) {
|
|
401
|
+
return {
|
|
402
|
+
y: fromPoint.y,
|
|
403
|
+
x: fromPoint.x < toPoint.x ?
|
|
404
|
+
chartObstacles[i].xMin - 1 :
|
|
405
|
+
chartObstacles[i].xMax + 1,
|
|
406
|
+
obstacle: chartObstacles[i]
|
|
407
|
+
};
|
|
408
|
+
}
|
|
409
|
+
// else ...
|
|
410
|
+
return {
|
|
411
|
+
x: fromPoint.x,
|
|
412
|
+
y: fromPoint.y < toPoint.y ?
|
|
413
|
+
chartObstacles[i].yMin - 1 :
|
|
414
|
+
chartObstacles[i].yMax + 1,
|
|
415
|
+
obstacle: chartObstacles[i]
|
|
416
|
+
};
|
|
417
|
+
}
|
|
418
|
+
|
|
419
|
+
i += searchDirection;
|
|
420
|
+
}
|
|
421
|
+
|
|
422
|
+
return toPoint;
|
|
423
|
+
}
|
|
424
|
+
|
|
425
|
+
/**
|
|
426
|
+
* Decide in which direction to dodge or get out of an obstacle.
|
|
427
|
+
* Considers desired direction, which way is shortest, soft and hard
|
|
428
|
+
* bounds.
|
|
429
|
+
*
|
|
430
|
+
* Returns a string, either xMin, xMax, yMin or yMax.
|
|
431
|
+
*
|
|
432
|
+
* @param {Object} obstacle Obstacle to dodge/escape.
|
|
433
|
+
* @param {Object} fromPoint Point with x/y props that's
|
|
434
|
+
* dodging/escaping.
|
|
435
|
+
* @param {Object} toPoint Goal point.
|
|
436
|
+
* @param {Boolean} dirIsX Dodge in X dimension.
|
|
437
|
+
* @param {Object} bounds Hard and soft boundaries.
|
|
438
|
+
*
|
|
439
|
+
* @return {Boolean} result Use max or not.
|
|
440
|
+
*/
|
|
441
|
+
function getDodgeDirection(
|
|
442
|
+
obstacle,
|
|
443
|
+
fromPoint,
|
|
444
|
+
toPoint,
|
|
445
|
+
dirIsX,
|
|
446
|
+
bounds
|
|
447
|
+
) {
|
|
448
|
+
var softBounds = bounds.soft,
|
|
449
|
+
hardBounds = bounds.hard,
|
|
450
|
+
dir = dirIsX ? 'x' : 'y',
|
|
451
|
+
toPointMax = { x: fromPoint.x, y: fromPoint.y },
|
|
452
|
+
toPointMin = { x: fromPoint.x, y: fromPoint.y },
|
|
453
|
+
minPivot,
|
|
454
|
+
maxPivot,
|
|
455
|
+
maxOutOfSoftBounds = obstacle[dir + 'Max'] >=
|
|
456
|
+
softBounds[dir + 'Max'],
|
|
457
|
+
minOutOfSoftBounds = obstacle[dir + 'Min'] <=
|
|
458
|
+
softBounds[dir + 'Min'],
|
|
459
|
+
maxOutOfHardBounds = obstacle[dir + 'Max'] >=
|
|
460
|
+
hardBounds[dir + 'Max'],
|
|
461
|
+
minOutOfHardBounds = obstacle[dir + 'Min'] <=
|
|
462
|
+
hardBounds[dir + 'Min'],
|
|
463
|
+
// Find out if we should prefer one direction over the other if
|
|
464
|
+
// we can choose freely
|
|
465
|
+
minDistance = abs(obstacle[dir + 'Min'] - fromPoint[dir]),
|
|
466
|
+
maxDistance = abs(obstacle[dir + 'Max'] - fromPoint[dir]),
|
|
467
|
+
// If it's a small difference, pick the one leading towards dest
|
|
468
|
+
// point. Otherwise pick the shortest distance
|
|
469
|
+
useMax = abs(minDistance - maxDistance) < 10 ?
|
|
470
|
+
fromPoint[dir] < toPoint[dir] :
|
|
471
|
+
maxDistance < minDistance;
|
|
472
|
+
|
|
473
|
+
// Check if we hit any obstacles trying to go around in either
|
|
474
|
+
// direction.
|
|
475
|
+
toPointMin[dir] = obstacle[dir + 'Min'];
|
|
476
|
+
toPointMax[dir] = obstacle[dir + 'Max'];
|
|
477
|
+
minPivot = pivotPoint(fromPoint, toPointMin, dirIsX)[dir] !==
|
|
478
|
+
toPointMin[dir];
|
|
479
|
+
maxPivot = pivotPoint(fromPoint, toPointMax, dirIsX)[dir] !==
|
|
480
|
+
toPointMax[dir];
|
|
481
|
+
useMax = minPivot ?
|
|
482
|
+
(maxPivot ? useMax : true) :
|
|
483
|
+
(maxPivot ? false : useMax);
|
|
484
|
+
|
|
485
|
+
// useMax now contains our preferred choice, bounds not taken into
|
|
486
|
+
// account. If both or neither direction is out of bounds we want to
|
|
487
|
+
// use this.
|
|
488
|
+
|
|
489
|
+
// Deal with soft bounds
|
|
490
|
+
useMax = minOutOfSoftBounds ?
|
|
491
|
+
(maxOutOfSoftBounds ? useMax : true) : // Out on min
|
|
492
|
+
(maxOutOfSoftBounds ? false : useMax); // Not out on min
|
|
493
|
+
|
|
494
|
+
// Deal with hard bounds
|
|
495
|
+
useMax = minOutOfHardBounds ?
|
|
496
|
+
(maxOutOfHardBounds ? useMax : true) : // Out on min
|
|
497
|
+
(maxOutOfHardBounds ? false : useMax); // Not out on min
|
|
498
|
+
|
|
499
|
+
return useMax;
|
|
500
|
+
}
|
|
501
|
+
|
|
502
|
+
// Find a clear path between point
|
|
503
|
+
function clearPathTo(fromPoint, toPoint, dirIsX) {
|
|
504
|
+
// Don't waste time if we've hit goal
|
|
505
|
+
if (fromPoint.x === toPoint.x && fromPoint.y === toPoint.y) {
|
|
506
|
+
return [];
|
|
507
|
+
}
|
|
508
|
+
|
|
509
|
+
var dir = dirIsX ? 'x' : 'y',
|
|
510
|
+
pivot,
|
|
511
|
+
segments,
|
|
512
|
+
waypoint,
|
|
513
|
+
waypointUseMax,
|
|
514
|
+
envelopingObstacle,
|
|
515
|
+
secondEnvelopingObstacle,
|
|
516
|
+
envelopWaypoint,
|
|
517
|
+
obstacleMargin = options.obstacleOptions.margin,
|
|
518
|
+
bounds = {
|
|
519
|
+
soft: {
|
|
520
|
+
xMin: softMinX,
|
|
521
|
+
xMax: softMaxX,
|
|
522
|
+
yMin: softMinY,
|
|
523
|
+
yMax: softMaxY
|
|
524
|
+
},
|
|
525
|
+
hard: options.hardBounds
|
|
526
|
+
};
|
|
527
|
+
|
|
528
|
+
// If fromPoint is inside an obstacle we have a problem. Break out
|
|
529
|
+
// by just going to the outside of this obstacle. We prefer to go to
|
|
530
|
+
// the nearest edge in the chosen direction.
|
|
531
|
+
envelopingObstacle =
|
|
532
|
+
findObstacleFromPoint(chartObstacles, fromPoint);
|
|
533
|
+
if (envelopingObstacle > -1) {
|
|
534
|
+
envelopingObstacle = chartObstacles[envelopingObstacle];
|
|
535
|
+
waypointUseMax = getDodgeDirection(
|
|
536
|
+
envelopingObstacle, fromPoint, toPoint, dirIsX, bounds
|
|
537
|
+
);
|
|
538
|
+
|
|
539
|
+
// Cut obstacle to hard bounds to make sure we stay within
|
|
540
|
+
limitObstacleToBounds(envelopingObstacle, options.hardBounds);
|
|
541
|
+
|
|
542
|
+
envelopWaypoint = dirIsX ? {
|
|
543
|
+
y: fromPoint.y,
|
|
544
|
+
x: envelopingObstacle[waypointUseMax ? 'xMax' : 'xMin'] +
|
|
545
|
+
(waypointUseMax ? 1 : -1)
|
|
546
|
+
} : {
|
|
547
|
+
x: fromPoint.x,
|
|
548
|
+
y: envelopingObstacle[waypointUseMax ? 'yMax' : 'yMin'] +
|
|
549
|
+
(waypointUseMax ? 1 : -1)
|
|
550
|
+
};
|
|
551
|
+
|
|
552
|
+
// If we crashed into another obstacle doing this, we put the
|
|
553
|
+
// waypoint between them instead
|
|
554
|
+
secondEnvelopingObstacle = findObstacleFromPoint(
|
|
555
|
+
chartObstacles, envelopWaypoint);
|
|
556
|
+
if (secondEnvelopingObstacle > -1) {
|
|
557
|
+
secondEnvelopingObstacle = chartObstacles[
|
|
558
|
+
secondEnvelopingObstacle
|
|
559
|
+
];
|
|
560
|
+
|
|
561
|
+
// Cut obstacle to hard bounds
|
|
562
|
+
limitObstacleToBounds(
|
|
563
|
+
secondEnvelopingObstacle,
|
|
564
|
+
options.hardBounds
|
|
565
|
+
);
|
|
566
|
+
|
|
567
|
+
// Modify waypoint to lay between obstacles
|
|
568
|
+
envelopWaypoint[dir] = waypointUseMax ? max(
|
|
569
|
+
envelopingObstacle[dir + 'Max'] - obstacleMargin + 1,
|
|
570
|
+
(
|
|
571
|
+
secondEnvelopingObstacle[dir + 'Min'] +
|
|
572
|
+
envelopingObstacle[dir + 'Max']
|
|
573
|
+
) / 2
|
|
574
|
+
) :
|
|
575
|
+
min(
|
|
576
|
+
envelopingObstacle[dir + 'Min'] + obstacleMargin - 1,
|
|
577
|
+
(
|
|
578
|
+
secondEnvelopingObstacle[dir + 'Max'] +
|
|
579
|
+
envelopingObstacle[dir + 'Min']
|
|
580
|
+
) / 2
|
|
581
|
+
);
|
|
582
|
+
|
|
583
|
+
// We are not going anywhere. If this happens for the first
|
|
584
|
+
// time, do nothing. Otherwise, try to go to the extreme of
|
|
585
|
+
// the obstacle pair in the current direction.
|
|
586
|
+
if (fromPoint.x === envelopWaypoint.x &&
|
|
587
|
+
fromPoint.y === envelopWaypoint.y) {
|
|
588
|
+
if (forceObstacleBreak) {
|
|
589
|
+
envelopWaypoint[dir] = waypointUseMax ?
|
|
590
|
+
max(
|
|
591
|
+
envelopingObstacle[dir + 'Max'],
|
|
592
|
+
secondEnvelopingObstacle[dir + 'Max']
|
|
593
|
+
) + 1 :
|
|
594
|
+
min(
|
|
595
|
+
envelopingObstacle[dir + 'Min'],
|
|
596
|
+
secondEnvelopingObstacle[dir + 'Min']
|
|
597
|
+
) - 1;
|
|
598
|
+
}
|
|
599
|
+
// Toggle on if off, and the opposite
|
|
600
|
+
forceObstacleBreak = !forceObstacleBreak;
|
|
601
|
+
} else {
|
|
602
|
+
// This point is not identical to previous.
|
|
603
|
+
// Clear break trigger.
|
|
604
|
+
forceObstacleBreak = false;
|
|
605
|
+
}
|
|
606
|
+
}
|
|
607
|
+
|
|
608
|
+
segments = [{
|
|
609
|
+
start: fromPoint,
|
|
610
|
+
end: envelopWaypoint
|
|
611
|
+
}];
|
|
612
|
+
|
|
613
|
+
} else { // If not enveloping, use standard pivot calculation
|
|
614
|
+
|
|
615
|
+
pivot = pivotPoint(fromPoint, {
|
|
616
|
+
x: dirIsX ? toPoint.x : fromPoint.x,
|
|
617
|
+
y: dirIsX ? fromPoint.y : toPoint.y
|
|
618
|
+
}, dirIsX);
|
|
619
|
+
|
|
620
|
+
segments = [{
|
|
621
|
+
start: fromPoint,
|
|
622
|
+
end: {
|
|
623
|
+
x: pivot.x,
|
|
624
|
+
y: pivot.y
|
|
625
|
+
}
|
|
626
|
+
}];
|
|
627
|
+
|
|
628
|
+
// Pivot before goal, use a waypoint to dodge obstacle
|
|
629
|
+
if (pivot[dirIsX ? 'x' : 'y'] !== toPoint[dirIsX ? 'x' : 'y']) {
|
|
630
|
+
// Find direction of waypoint
|
|
631
|
+
waypointUseMax = getDodgeDirection(
|
|
632
|
+
pivot.obstacle, pivot, toPoint, !dirIsX, bounds
|
|
633
|
+
);
|
|
634
|
+
|
|
635
|
+
// Cut waypoint to hard bounds
|
|
636
|
+
limitObstacleToBounds(pivot.obstacle, options.hardBounds);
|
|
637
|
+
|
|
638
|
+
waypoint = {
|
|
639
|
+
x: dirIsX ?
|
|
640
|
+
pivot.x :
|
|
641
|
+
pivot.obstacle[waypointUseMax ? 'xMax' : 'xMin'] +
|
|
642
|
+
(waypointUseMax ? 1 : -1),
|
|
643
|
+
y: dirIsX ?
|
|
644
|
+
pivot.obstacle[waypointUseMax ? 'yMax' : 'yMin'] +
|
|
645
|
+
(waypointUseMax ? 1 : -1) :
|
|
646
|
+
pivot.y
|
|
647
|
+
};
|
|
648
|
+
|
|
649
|
+
// We're changing direction here, store that to make sure we
|
|
650
|
+
// also change direction when adding the last segment array
|
|
651
|
+
// after handling waypoint.
|
|
652
|
+
dirIsX = !dirIsX;
|
|
653
|
+
|
|
654
|
+
segments = segments.concat(clearPathTo({
|
|
655
|
+
x: pivot.x,
|
|
656
|
+
y: pivot.y
|
|
657
|
+
}, waypoint, dirIsX));
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
|
|
661
|
+
// Get segments for the other direction too
|
|
662
|
+
// Recursion is our friend
|
|
663
|
+
segments = segments.concat(clearPathTo(
|
|
664
|
+
segments[segments.length - 1].end, toPoint, !dirIsX
|
|
665
|
+
));
|
|
666
|
+
|
|
667
|
+
return segments;
|
|
668
|
+
}
|
|
669
|
+
|
|
670
|
+
// Extract point to outside of obstacle in whichever direction is
|
|
671
|
+
// closest. Returns new point outside obstacle.
|
|
672
|
+
function extractFromObstacle(obstacle, point, goalPoint) {
|
|
673
|
+
var dirIsX = min(obstacle.xMax - point.x, point.x - obstacle.xMin) <
|
|
674
|
+
min(obstacle.yMax - point.y, point.y - obstacle.yMin),
|
|
675
|
+
bounds = {
|
|
676
|
+
soft: options.hardBounds,
|
|
677
|
+
hard: options.hardBounds
|
|
678
|
+
},
|
|
679
|
+
useMax = getDodgeDirection(
|
|
680
|
+
obstacle, point, goalPoint, dirIsX, bounds
|
|
681
|
+
);
|
|
682
|
+
|
|
683
|
+
return dirIsX ? {
|
|
684
|
+
y: point.y,
|
|
685
|
+
x: obstacle[useMax ? 'xMax' : 'xMin'] + (useMax ? 1 : -1)
|
|
686
|
+
} : {
|
|
687
|
+
x: point.x,
|
|
688
|
+
y: obstacle[useMax ? 'yMax' : 'yMin'] + (useMax ? 1 : -1)
|
|
689
|
+
};
|
|
690
|
+
}
|
|
691
|
+
|
|
692
|
+
// Cut the obstacle array to soft bounds for optimization in large
|
|
693
|
+
// datasets.
|
|
694
|
+
chartObstacles =
|
|
695
|
+
chartObstacles.slice(startObstacleIx, endObstacleIx + 1);
|
|
696
|
+
|
|
697
|
+
// If an obstacle envelops the end point, move it out of there and add
|
|
698
|
+
// a little segment to where it was.
|
|
699
|
+
if ((endObstacleIx = findObstacleFromPoint(chartObstacles, end)) > -1) {
|
|
700
|
+
extractedEndPoint = extractFromObstacle(
|
|
701
|
+
chartObstacles[endObstacleIx],
|
|
702
|
+
end,
|
|
703
|
+
start
|
|
704
|
+
);
|
|
705
|
+
endSegments.push({
|
|
706
|
+
end: end,
|
|
707
|
+
start: extractedEndPoint
|
|
708
|
+
});
|
|
709
|
+
end = extractedEndPoint;
|
|
710
|
+
}
|
|
711
|
+
// If it's still inside one or more obstacles, get out of there by
|
|
712
|
+
// force-moving towards the start point.
|
|
713
|
+
while (
|
|
714
|
+
(endObstacleIx = findObstacleFromPoint(chartObstacles, end)) > -1
|
|
715
|
+
) {
|
|
716
|
+
useMax = end[dir] - start[dir] < 0;
|
|
717
|
+
extractedEndPoint = {
|
|
718
|
+
x: end.x,
|
|
719
|
+
y: end.y
|
|
720
|
+
};
|
|
721
|
+
extractedEndPoint[dir] = chartObstacles[endObstacleIx][
|
|
722
|
+
useMax ? dir + 'Max' : dir + 'Min'
|
|
723
|
+
] + (useMax ? 1 : -1);
|
|
724
|
+
endSegments.push({
|
|
725
|
+
end: end,
|
|
726
|
+
start: extractedEndPoint
|
|
727
|
+
});
|
|
728
|
+
end = extractedEndPoint;
|
|
729
|
+
}
|
|
730
|
+
|
|
731
|
+
// Find the path
|
|
732
|
+
segments = clearPathTo(start, end, dirIsX);
|
|
733
|
+
|
|
734
|
+
// Add the end-point segments
|
|
735
|
+
segments = segments.concat(endSegments.reverse());
|
|
736
|
+
|
|
737
|
+
return {
|
|
738
|
+
path: pathFromSegments(segments),
|
|
739
|
+
obstacles: segments
|
|
740
|
+
};
|
|
741
|
+
}, {
|
|
742
|
+
requiresObstacles: true
|
|
743
|
+
})
|
|
744
|
+
};
|
|
745
|
+
|
|
746
|
+
export default algorithms;
|