@devexperts/dxcharts-lite 1.0.1 → 2.0.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 +4 -4
- package/dist/chart/animation/canvas-animation.d.ts +1 -1
- package/dist/chart/animation/canvas-animation.js +135 -2
- package/dist/chart/animation/types/animation.d.ts +1 -1
- package/dist/chart/animation/types/animation.js +44 -2
- package/dist/chart/animation/types/color-alpha-animation.d.ts +2 -2
- package/dist/chart/animation/types/color-alpha-animation.js +61 -2
- package/dist/chart/animation/types/color-transition-animation.d.ts +2 -2
- package/dist/chart/animation/types/color-transition-animation.js +87 -2
- package/dist/chart/animation/types/viewport-movement-animation.d.ts +1 -1
- package/dist/chart/animation/types/viewport-movement-animation.js +64 -2
- package/dist/chart/animation/viewport-model-animation.d.ts +1 -1
- package/dist/chart/animation/viewport-model-animation.js +21 -2
- package/dist/chart/bootstrap.d.ts +52 -49
- package/dist/chart/bootstrap.js +450 -2
- package/dist/chart/canvas/canvas-bounds-container.d.ts +1 -6
- package/dist/chart/canvas/canvas-bounds-container.js +816 -2
- package/dist/chart/canvas/canvas-chart-html.d.ts +1 -1
- package/dist/chart/canvas/canvas-chart-html.js +17 -19
- package/dist/chart/canvas/chart-elements.d.ts +2 -5
- package/dist/chart/canvas/chart-elements.js +23 -2
- package/dist/chart/canvas/cursor.handler.d.ts +1 -1
- package/dist/chart/canvas/cursor.handler.js +123 -2
- package/dist/chart/canvas/layout-creator.d.ts +1 -1
- package/dist/chart/canvas/layout-creator.js +35 -2
- package/dist/chart/canvas/y-axis-bounds.container.d.ts +3 -3
- package/dist/chart/canvas/y-axis-bounds.container.js +68 -2
- package/dist/chart/chart-container.d.ts +1 -1
- package/dist/chart/chart-container.js +2 -2
- package/dist/chart/chart.config.d.ts +5 -6
- package/dist/chart/chart.config.js +646 -2
- package/dist/chart/chart.d.ts +62 -0
- package/dist/chart/chart.js +106 -0
- package/dist/chart/components/chart/basic-scale.d.ts +3 -3
- package/dist/chart/components/chart/basic-scale.js +32 -2
- package/dist/chart/components/chart/candle-transformer.functions.d.ts +1 -1
- package/dist/chart/components/chart/candle-transformer.functions.js +16 -2
- package/dist/chart/components/chart/candle-width-calculator.functions.d.ts +1 -1
- package/dist/chart/components/chart/candle-width-calculator.functions.js +3 -2
- package/dist/chart/components/chart/candle.functions.d.ts +1 -1
- package/dist/chart/components/chart/candle.functions.js +45 -2
- package/dist/chart/components/chart/chart-area-pan.handler.d.ts +4 -4
- package/dist/chart/components/chart/chart-area-pan.handler.js +198 -2
- package/dist/chart/components/chart/chart-base.model.d.ts +1 -1
- package/dist/chart/components/chart/chart-base.model.js +67 -2
- package/dist/chart/components/chart/chart.component.d.ts +8 -4
- package/dist/chart/components/chart/chart.component.js +409 -2
- package/dist/chart/components/chart/chart.model.d.ts +5 -12
- package/dist/chart/components/chart/chart.model.js +955 -2
- package/dist/chart/components/chart/data-series.high-low-provider.d.ts +1 -1
- package/dist/chart/components/chart/data-series.high-low-provider.js +35 -2
- package/dist/chart/components/chart/fake-candles.d.ts +1 -1
- package/dist/chart/components/chart/fake-candles.js +98 -2
- package/dist/chart/components/chart/price.formatter.d.ts +1 -1
- package/dist/chart/components/chart/price.formatter.js +36 -2
- package/dist/chart/components/chart/secondary-chart-colors-pool.d.ts +1 -1
- package/dist/chart/components/chart/secondary-chart-colors-pool.js +69 -2
- package/dist/chart/components/cross_tool/cross-tool.component.d.ts +1 -1
- package/dist/chart/components/cross_tool/cross-tool.component.js +86 -2
- package/dist/chart/components/cross_tool/cross-tool.drawer.d.ts +1 -1
- package/dist/chart/components/cross_tool/cross-tool.drawer.js +33 -2
- package/dist/chart/components/cross_tool/cross-tool.model.d.ts +1 -1
- package/dist/chart/components/cross_tool/cross-tool.model.js +108 -2
- package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.d.ts +1 -1
- package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +138 -2
- package/dist/chart/components/cross_tool/types/none.drawer.d.ts +1 -1
- package/dist/chart/components/cross_tool/types/none.drawer.js +4 -2
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.d.ts +1 -1
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +29 -2
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.d.ts +1 -1
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +25 -2
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.d.ts +1 -1
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +54 -2
- package/dist/chart/components/dynamic-objects/dynamic-objects.component.d.ts +13 -0
- package/dist/chart/components/dynamic-objects/dynamic-objects.component.js +20 -0
- package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.d.ts +18 -0
- package/dist/chart/components/dynamic-objects/dynamic-objects.drawer.js +23 -0
- package/dist/chart/components/dynamic-objects/dynamic-objects.model.d.ts +63 -0
- package/dist/chart/components/dynamic-objects/dynamic-objects.model.js +136 -0
- package/dist/chart/components/events/events-hit-test.drawer.d.ts +1 -1
- package/dist/chart/components/events/events-hit-test.drawer.js +64 -2
- package/dist/chart/components/events/events.component.d.ts +1 -1
- package/dist/chart/components/events/events.component.js +62 -2
- package/dist/chart/components/events/events.drawer.d.ts +1 -1
- package/dist/chart/components/events/events.drawer.js +196 -2
- package/dist/chart/components/events/events.model.d.ts +1 -1
- package/dist/chart/components/events/events.model.js +70 -2
- package/dist/chart/components/grid/grid.component.d.ts +3 -3
- package/dist/chart/components/grid/grid.component.js +32 -2
- package/dist/chart/components/grid/grid.drawer.d.ts +5 -4
- package/dist/chart/components/grid/grid.drawer.js +107 -2
- package/dist/chart/components/high_low/high-low.component.d.ts +1 -1
- package/dist/chart/components/high_low/high-low.component.js +13 -2
- package/dist/chart/components/high_low/high-low.drawer.d.ts +1 -1
- package/dist/chart/components/high_low/high-low.drawer.js +127 -2
- package/dist/chart/components/highlights/highlights.component.d.ts +1 -1
- package/dist/chart/components/highlights/highlights.component.js +47 -2
- package/dist/chart/components/highlights/highlights.drawer.d.ts +1 -1
- package/dist/chart/components/highlights/highlights.drawer.js +155 -2
- package/dist/chart/components/highlights/highlights.model.d.ts +1 -1
- package/dist/chart/components/highlights/highlights.model.js +76 -2
- package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +2 -2
- package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +200 -2
- package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +3 -3
- package/dist/chart/components/navigation_map/navigation-map-move.handler.js +109 -2
- package/dist/chart/components/navigation_map/navigation-map.component.d.ts +1 -1
- package/dist/chart/components/navigation_map/navigation-map.component.js +113 -2
- package/dist/chart/components/navigation_map/navigation-map.drawer.d.ts +1 -1
- package/dist/chart/components/navigation_map/navigation-map.drawer.js +245 -2
- package/dist/chart/components/navigation_map/navigation-map.model.d.ts +1 -1
- package/dist/chart/components/navigation_map/navigation-map.model.js +34 -3
- package/dist/chart/components/pan/chart-pan.component.d.ts +3 -3
- package/dist/chart/components/pan/chart-pan.component.js +52 -2
- package/dist/chart/components/pane/extent/y-extent-component.d.ts +13 -19
- package/dist/chart/components/pane/extent/y-extent-component.js +121 -2
- package/dist/chart/components/pane/pane-hit-test.controller.d.ts +1 -1
- package/dist/chart/components/pane/pane-hit-test.controller.js +56 -2
- package/dist/chart/components/pane/pane-manager.component.d.ts +11 -6
- package/dist/chart/components/pane/pane-manager.component.js +149 -2
- package/dist/chart/components/pane/pane.component.d.ts +18 -34
- package/dist/chart/components/pane/pane.component.js +279 -2
- package/dist/chart/components/resizer/bar-resizer.component.d.ts +1 -1
- package/dist/chart/components/resizer/bar-resizer.component.js +140 -2
- package/dist/chart/components/resizer/bar-resizer.drawer.d.ts +1 -1
- package/dist/chart/components/resizer/bar-resizer.drawer.js +47 -2
- package/dist/chart/components/snapshot/snapshot.component.d.ts +1 -1
- package/dist/chart/components/snapshot/snapshot.component.js +49 -2
- package/dist/chart/components/volumes/separate-volumes.component.d.ts +7 -11
- package/dist/chart/components/volumes/separate-volumes.component.js +64 -2
- package/dist/chart/components/volumes/volume-color-resolvers.functions.d.ts +1 -1
- package/dist/chart/components/volumes/volume-color-resolvers.functions.js +19 -2
- package/dist/chart/components/volumes/volumes.component.d.ts +9 -9
- package/dist/chart/components/volumes/volumes.component.js +95 -2
- package/dist/chart/components/volumes/volumes.drawer.d.ts +6 -13
- package/dist/chart/components/volumes/volumes.drawer.js +141 -2
- package/dist/chart/components/volumes/volumes.formatter.d.ts +1 -1
- package/dist/chart/components/volumes/volumes.formatter.js +32 -2
- package/dist/chart/components/volumes/volumes.model.d.ts +3 -3
- package/dist/chart/components/volumes/volumes.model.js +44 -2
- package/dist/chart/components/watermark/water-mark.component.d.ts +1 -1
- package/dist/chart/components/watermark/water-mark.component.js +104 -2
- package/dist/chart/components/watermark/water-mark.drawer.d.ts +1 -1
- package/dist/chart/components/watermark/water-mark.drawer.js +188 -2
- package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.d.ts +1 -1
- package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.js +28 -2
- package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.d.ts +1 -1
- package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +188 -2
- package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.d.ts +1 -1
- package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +77 -2
- package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.d.ts +1 -1
- package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.js +80 -2
- package/dist/chart/components/x_axis/time/parser/time-formats.model.d.ts +1 -1
- package/dist/chart/components/x_axis/time/parser/time-formats.model.js +15 -2
- package/dist/chart/components/x_axis/time/x-axis-weights.functions.d.ts +2 -2
- package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +144 -2
- package/dist/chart/components/x_axis/time/x-axis-weights.generator.d.ts +1 -1
- package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +74 -2
- package/dist/chart/components/x_axis/x-axis-draw.functions.d.ts +1 -1
- package/dist/chart/components/x_axis/x-axis-draw.functions.js +50 -2
- package/dist/chart/components/x_axis/x-axis-labels.drawer.d.ts +1 -1
- package/dist/chart/components/x_axis/x-axis-labels.drawer.js +71 -2
- package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +3 -3
- package/dist/chart/components/x_axis/x-axis-labels.generator.js +333 -2
- package/dist/chart/components/x_axis/x-axis-labels.model.d.ts +1 -1
- package/dist/chart/components/x_axis/x-axis-labels.model.js +36 -2
- package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +3 -3
- package/dist/chart/components/x_axis/x-axis-scale.handler.js +61 -2
- package/dist/chart/components/x_axis/x-axis-time-labels.drawer.d.ts +1 -1
- package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +83 -2
- package/dist/chart/components/x_axis/x-axis.component.d.ts +3 -3
- package/dist/chart/components/x_axis/x-axis.component.js +120 -2
- package/dist/chart/components/y_axis/label-color.functions.d.ts +1 -1
- package/dist/chart/components/y_axis/label-color.functions.js +54 -2
- package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +5 -5
- package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +34 -2
- package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +4 -4
- package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +68 -2
- package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.d.ts +1 -1
- package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +57 -2
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.d.ts +1 -1
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +96 -2
- package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +3 -3
- package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +120 -2
- package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +10 -9
- package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +202 -2
- package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +7 -8
- package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +59 -2
- package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +7 -5
- package/dist/chart/components/y_axis/y-axis-base-labels.model.js +48 -2
- package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +5 -5
- package/dist/chart/components/y_axis/y-axis-labels.drawer.js +162 -2
- package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +3 -3
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +73 -2
- package/dist/chart/components/y_axis/y-axis.component.d.ts +33 -42
- package/dist/chart/components/y_axis/y-axis.component.js +221 -2
- package/dist/chart/components/y_axis/y-axis.drawer.d.ts +10 -13
- package/dist/chart/components/y_axis/y-axis.drawer.js +97 -2
- package/dist/chart/components/y_axis/y-axis.model.d.ts +10 -18
- package/dist/chart/components/y_axis/y-axis.model.js +34 -2
- package/dist/chart/drawers/chart-background.drawer.d.ts +1 -1
- package/dist/chart/drawers/chart-background.drawer.js +70 -2
- package/dist/chart/drawers/chart-type-drawers/area.drawer.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/area.drawer.js +70 -2
- package/dist/chart/drawers/chart-type-drawers/bar.drawer.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +58 -2
- package/dist/chart/drawers/chart-type-drawers/baseline.drawer.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +85 -2
- package/dist/chart/drawers/chart-type-drawers/candle.drawer.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +163 -2
- package/dist/chart/drawers/chart-type-drawers/histogram.drawer.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +58 -2
- package/dist/chart/drawers/chart-type-drawers/line.drawer.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/line.drawer.js +39 -2
- package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.d.ts +1 -1
- package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +20 -2
- package/dist/chart/drawers/clear-canvas.drawer.d.ts +1 -1
- package/dist/chart/drawers/clear-canvas.drawer.js +15 -2
- package/dist/chart/drawers/composite.drawer.d.ts +1 -1
- package/dist/chart/drawers/composite.drawer.js +68 -2
- package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +51 -2
- package/dist/chart/drawers/data-series-drawers/color-candle.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +36 -2
- package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +17 -2
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +107 -2
- package/dist/chart/drawers/data-series-drawers/histogram.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +24 -2
- package/dist/chart/drawers/data-series-drawers/linear.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/linear.drawer.js +20 -2
- package/dist/chart/drawers/data-series-drawers/points.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/points.drawer.js +20 -2
- package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.js +8 -2
- package/dist/chart/drawers/data-series-drawers/text.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/text.drawer.js +26 -2
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +36 -2
- package/dist/chart/drawers/data-series-drawers/triangle.drawer.d.ts +1 -1
- package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +23 -2
- package/dist/chart/drawers/data-series.drawer.d.ts +6 -8
- package/dist/chart/drawers/data-series.drawer.js +57 -2
- package/dist/chart/drawers/drawing-manager.d.ts +2 -2
- package/dist/chart/drawers/drawing-manager.js +178 -2
- package/dist/chart/drawers/ht-data-series.drawer.d.ts +1 -1
- package/dist/chart/drawers/ht-data-series.drawer.js +38 -2
- package/dist/chart/events/event-bus.d.ts +1 -1
- package/dist/chart/events/event-bus.js +74 -2
- package/dist/chart/events/events.d.ts +1 -1
- package/dist/chart/events/events.js +4 -2
- package/dist/chart/inputhandlers/candle-tap.handler.d.ts +1 -1
- package/dist/chart/inputhandlers/candle-tap.handler.js +47 -2
- package/dist/chart/inputhandlers/chart-resize.handler.d.ts +1 -1
- package/dist/chart/inputhandlers/chart-resize.handler.js +99 -2
- package/dist/chart/inputhandlers/cross-event-producer.component.d.ts +1 -1
- package/dist/chart/inputhandlers/cross-event-producer.component.js +68 -2
- package/dist/chart/inputhandlers/hover-producer.component.d.ts +3 -3
- package/dist/chart/inputhandlers/hover-producer.component.js +229 -2
- package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +3 -3
- package/dist/chart/inputhandlers/main-canvas-touch.handler.js +81 -2
- package/dist/chart/inputlisteners/canvas-input-listener.component.d.ts +1 -1
- package/dist/chart/inputlisteners/canvas-input-listener.component.js +630 -2
- package/dist/chart/model/baseline.model.d.ts +1 -1
- package/dist/chart/model/baseline.model.js +89 -2
- package/dist/chart/model/bounds.model.d.ts +1 -1
- package/dist/chart/model/bounds.model.js +2 -2
- package/dist/chart/model/candle-hover.d.ts +1 -1
- package/dist/chart/model/candle-hover.js +71 -2
- package/dist/chart/model/candle-series-high-low.provider.d.ts +1 -1
- package/dist/chart/model/candle-series-high-low.provider.js +46 -2
- package/dist/chart/model/candle-series.model.d.ts +4 -4
- package/dist/chart/model/candle-series.model.js +246 -2
- package/dist/chart/model/candle.model.d.ts +1 -1
- package/dist/chart/model/candle.model.js +70 -2
- package/dist/chart/model/canvas.model.d.ts +1 -1
- package/dist/chart/model/canvas.model.js +229 -2
- package/dist/chart/model/chart-base-element.d.ts +1 -1
- package/dist/chart/model/chart-base-element.js +130 -2
- package/dist/chart/model/compare-series-hover.d.ts +1 -1
- package/dist/chart/model/compare-series-hover.js +26 -2
- package/dist/chart/model/data-series-view.d.ts +6 -6
- package/dist/chart/model/data-series-view.js +112 -2
- package/dist/chart/model/data-series.config.d.ts +1 -1
- package/dist/chart/model/data-series.config.js +15 -2
- package/dist/chart/model/data-series.model.d.ts +5 -5
- package/dist/chart/model/data-series.model.js +282 -2
- package/dist/chart/model/date-time.formatter.d.ts +1 -1
- package/dist/chart/model/date-time.formatter.js +152 -2
- package/dist/chart/model/hit-test-canvas.model.d.ts +2 -2
- package/dist/chart/model/hit-test-canvas.model.js +257 -2
- package/dist/chart/model/main-candle-series.model.d.ts +2 -2
- package/dist/chart/model/main-candle-series.model.js +30 -2
- package/dist/chart/model/scale.model.d.ts +3 -2
- package/dist/chart/model/scale.model.js +317 -2
- package/dist/chart/model/scaling/auto-scale.model.d.ts +1 -1
- package/dist/chart/model/scaling/auto-scale.model.js +98 -2
- package/dist/chart/model/scaling/constrait.functions.d.ts +1 -1
- package/dist/chart/model/scaling/constrait.functions.js +62 -2
- package/dist/chart/model/scaling/lock-ratio.model.d.ts +1 -1
- package/dist/chart/model/scaling/lock-ratio.model.js +18 -2
- package/dist/chart/model/scaling/move-chart.functions.d.ts +1 -1
- package/dist/chart/model/scaling/move-chart.functions.js +23 -2
- package/dist/chart/model/scaling/viewport.model.d.ts +3 -3
- package/dist/chart/model/scaling/viewport.model.js +280 -2
- package/dist/chart/model/scaling/x-zooming.functions.d.ts +1 -1
- package/dist/chart/model/scaling/x-zooming.functions.js +36 -2
- package/dist/chart/model/time-zone.model.d.ts +1 -1
- package/dist/chart/model/time-zone.model.js +110 -2
- package/dist/chart/model/visual-candle.d.ts +1 -1
- package/dist/chart/model/visual-candle.js +135 -2
- package/dist/chart/utils/__tests__/array.utils.test.d.ts +1 -1
- package/dist/chart/utils/__tests__/array.utils.test.js +136 -2
- package/dist/chart/utils/{perfomance/debounce.utils.js → __tests__/math.utils.test.d.ts} +2 -2
- package/dist/chart/utils/__tests__/math.utils.test.js +19 -0
- package/dist/chart/utils/__tests__/object.utils.test.d.ts +1 -1
- package/dist/chart/utils/__tests__/object.utils.test.js +12 -2
- package/dist/chart/utils/__tests__/priceIncrementsUtils.test.d.ts +1 -1
- package/dist/chart/utils/__tests__/priceIncrementsUtils.test.js +30 -2
- package/dist/chart/utils/array.utils.d.ts +2 -2
- package/dist/chart/utils/array.utils.js +270 -2
- package/dist/chart/utils/auto-period-detector.utils.d.ts +1 -1
- package/dist/chart/utils/auto-period-detector.utils.js +40 -2
- package/dist/chart/utils/candles-generator-ts.utils.d.ts +1 -1
- package/dist/chart/utils/candles-generator-ts.utils.js +21 -2
- package/dist/chart/utils/candles-generator.utils.d.ts +1 -1
- package/dist/chart/utils/candles-generator.utils.js +162 -2
- package/dist/chart/utils/candles.utils.d.ts +1 -1
- package/dist/chart/utils/candles.utils.js +43 -2
- package/dist/chart/utils/canvas/canvas-drawing-functions.utils.d.ts +1 -1
- package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +145 -2
- package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.d.ts +1 -1
- package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.js +52 -2
- package/dist/chart/utils/canvas/canvas-text-functions.utils.d.ts +1 -1
- package/dist/chart/utils/canvas/canvas-text-functions.utils.js +157 -2
- package/dist/chart/utils/color.utils.d.ts +1 -1
- package/dist/chart/utils/color.utils.js +32 -2
- package/dist/chart/utils/device/browser.utils.d.ts +1 -1
- package/dist/chart/utils/device/browser.utils.js +11 -2
- package/dist/chart/utils/device/device-detector.utils.d.ts +1 -1
- package/dist/chart/utils/device/device-detector.utils.js +25 -2
- package/dist/chart/utils/device/device-pixel-ratio.utils.d.ts +1 -1
- package/dist/chart/utils/device/device-pixel-ratio.utils.js +22 -2
- package/dist/chart/utils/device/touchpad.utils.d.ts +1 -1
- package/dist/chart/utils/device/touchpad.utils.js +92 -2
- package/dist/chart/utils/dom.utils.d.ts +1 -1
- package/dist/chart/utils/dom.utils.js +16 -2
- package/dist/chart/utils/function.utils.d.ts +1 -1
- package/dist/chart/utils/function.utils.js +17 -2
- package/dist/chart/utils/linkedList.utils.d.ts +28 -0
- package/dist/chart/utils/linkedList.utils.js +138 -0
- package/dist/chart/utils/math.utils.d.ts +1 -1
- package/dist/chart/utils/math.utils.js +116 -2
- package/dist/chart/utils/merge.utils.d.ts +1 -1
- package/dist/chart/utils/merge.utils.js +57 -2
- package/dist/chart/utils/object.utils.d.ts +1 -1
- package/dist/chart/utils/object.utils.js +44 -2
- package/dist/chart/utils/{perfomance → performance}/animation-frame-cache.utils.d.ts +1 -1
- package/dist/chart/utils/performance/animation-frame-cache.utils.js +77 -0
- package/dist/chart/utils/{perfomance → performance}/debounce.utils.d.ts +1 -1
- package/dist/chart/utils/performance/debounce.utils.js +12 -0
- package/dist/chart/utils/{perfomance → performance}/memoize.utils.d.ts +1 -1
- package/dist/chart/utils/performance/memoize.utils.js +74 -0
- package/dist/chart/utils/{perfomance → performance}/request-animation-frame-throttle.utils.d.ts +1 -1
- package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +43 -0
- package/dist/chart/utils/{perfomance → performance}/throttle.utils.d.ts +1 -1
- package/dist/chart/utils/performance/throttle.utils.js +26 -0
- package/dist/chart/utils/price-increments.utils.d.ts +2 -1
- package/dist/chart/utils/price-increments.utils.js +128 -2
- package/dist/chart/utils/uuid.utils.d.ts +1 -1
- package/dist/chart/utils/uuid.utils.js +5 -2
- package/dist/dxchart.min.js +10 -13
- package/dist/index.d.ts +4 -4
- package/dist/index.js +21 -2
- package/package.json +4 -4
- package/dist/chart/utils/perfomance/animation-frame-cache.utils.js +0 -6
- package/dist/chart/utils/perfomance/memoize.utils.js +0 -6
- package/dist/chart/utils/perfomance/request-animation-frame-throttle.utils.js +0 -6
- package/dist/chart/utils/perfomance/throttle.utils.js +0 -6
|
@@ -1,6 +1,321 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
import
|
|
6
|
+
import { Subject } from 'rxjs';
|
|
7
|
+
import { startViewportModelAnimation } from '../animation/viewport-model-animation';
|
|
8
|
+
import { cloneUnsafe } from '../utils/object.utils';
|
|
9
|
+
import { AutoScaleViewportSubModel } from './scaling/auto-scale.model';
|
|
10
|
+
import { zoomConstraint } from './scaling/constrait.functions';
|
|
11
|
+
import { lockedYEndViewportCalculator, ratioFromZoomXY } from './scaling/lock-ratio.model';
|
|
12
|
+
import { moveXStart, moveYStart } from './scaling/move-chart.functions';
|
|
13
|
+
import { ViewportModel, compareStates } from './scaling/viewport.model';
|
|
14
|
+
import { zoomXToEndViewportCalculator, zoomXToPercentViewportCalculator } from './scaling/x-zooming.functions';
|
|
15
|
+
export const getDefaultHighLowWithIndex = () => ({
|
|
16
|
+
high: Number.NEGATIVE_INFINITY,
|
|
17
|
+
low: Number.POSITIVE_INFINITY,
|
|
18
|
+
highIdx: 0,
|
|
19
|
+
lowIdx: 0,
|
|
20
|
+
});
|
|
21
|
+
/**
|
|
22
|
+
* The ScaleModel class represents the state of a chart's scale, including the current viewport, zoom level, and auto-scaling settings.
|
|
23
|
+
* It extends the ViewportModel class, which provides the underlying implementation for handling viewports and zoom levels.
|
|
24
|
+
* Controls current visible CHART viewport.
|
|
25
|
+
* Has additional logic:
|
|
26
|
+
* - auto-scale
|
|
27
|
+
* - locked scale
|
|
28
|
+
* - zooming functions
|
|
29
|
+
* - history
|
|
30
|
+
*/
|
|
31
|
+
export class ScaleModel extends ViewportModel {
|
|
32
|
+
constructor(config, getBounds, canvasAnimation) {
|
|
33
|
+
super();
|
|
34
|
+
this.config = config;
|
|
35
|
+
this.getBounds = getBounds;
|
|
36
|
+
this.canvasAnimation = canvasAnimation;
|
|
37
|
+
this.scaleInversedSubject = new Subject();
|
|
38
|
+
// y-axis component needs this subject in order to halt prev animation if axis type is percent
|
|
39
|
+
this.beforeStartAnimationSubject = new Subject();
|
|
40
|
+
// TODO rework, make a new history based on units
|
|
41
|
+
this.history = [];
|
|
42
|
+
this.zoomXYRatio = 0;
|
|
43
|
+
this.xConstraints = [];
|
|
44
|
+
this.scalePostProcessor = (initialState, state) => {
|
|
45
|
+
// for now <s>reduceRight<s/> reduce bcs ChartModel#getZoomConstrait should be invoked first
|
|
46
|
+
// if we will need more complex order handling -> add some managing
|
|
47
|
+
return this.xConstraints.reduce((acc, cur) => cur(initialState, acc), state);
|
|
48
|
+
};
|
|
49
|
+
this.state = cloneUnsafe(config.scale);
|
|
50
|
+
this.autoScaleModel = new AutoScaleViewportSubModel(this);
|
|
51
|
+
this.offsets = this.config.components.offsets;
|
|
52
|
+
this.addXConstraint((initialState, state) => zoomConstraint(initialState, state, this.config.components.chart, this.getBounds));
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* The method adds a new "constraint" to the existing list of x-axis constraints for charting.
|
|
56
|
+
* The "constrait" is expected to be an object containing information about the constraints, such as the minimum and maximum values for the x-axis.
|
|
57
|
+
* @param constraint
|
|
58
|
+
*/
|
|
59
|
+
addXConstraint(constraint) {
|
|
60
|
+
this.xConstraints = [...this.xConstraints, constraint];
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* The method updates the offsets for the scale model based on the provided "offsets" object.
|
|
64
|
+
* Note that the method modifies the offsets and triggers an autoscale
|
|
65
|
+
* @param offsets
|
|
66
|
+
*/
|
|
67
|
+
updateOffsets(offsets) {
|
|
68
|
+
this.offsets = Object.assign(Object.assign({}, this.offsets), offsets);
|
|
69
|
+
this.doAutoScale(true);
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* @returns current offsets
|
|
73
|
+
*/
|
|
74
|
+
getOffsets() {
|
|
75
|
+
return this.offsets;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Zooms the X axis of the chart to a specified percentage of the viewport.
|
|
79
|
+
* @param viewportPercent The percentage of the viewport width to zoom to.
|
|
80
|
+
* @param zoomIn Whether to zoom in or out.
|
|
81
|
+
* @param forceNoAnimation Whether to skip animation.
|
|
82
|
+
* @param zoomSensitivity The sensitivity of the zoom.
|
|
83
|
+
*/
|
|
84
|
+
zoomXToPercent(viewportPercent, zoomIn, forceNoAnimation = false, zoomSensitivity = this.config.scale.zoomSensitivity) {
|
|
85
|
+
this.beforeStartAnimationSubject.next();
|
|
86
|
+
const state = this.export();
|
|
87
|
+
zoomXToPercentViewportCalculator(this, state, viewportPercent, zoomSensitivity, zoomIn);
|
|
88
|
+
this.zoomXTo(state, forceNoAnimation);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Zooms the X axis of the chart relativly to the end of the data range.
|
|
92
|
+
* @param zoomIn - If true, the chart will be zoomed in. If false, the chart will be zoomed out.
|
|
93
|
+
* @param zoomSensitivity - The sensitivity of the zoom. Default value is taken from the configuration object.
|
|
94
|
+
*/
|
|
95
|
+
zoomXToEnd(zoomIn, zoomSensitivity = this.config.scale.zoomSensitivity) {
|
|
96
|
+
this.beforeStartAnimationSubject.next();
|
|
97
|
+
const state = this.export();
|
|
98
|
+
zoomXToEndViewportCalculator(this, state, zoomSensitivity, zoomIn);
|
|
99
|
+
this.zoomXTo(state);
|
|
100
|
+
}
|
|
101
|
+
haltAnimation() {
|
|
102
|
+
var _a;
|
|
103
|
+
if ((_a = this.currentAnimation) === null || _a === void 0 ? void 0 : _a.animationInProgress) {
|
|
104
|
+
this.currentAnimation.finishAnimation();
|
|
105
|
+
this.doAutoScale();
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
zoomXTo(state, forceNoAnimation) {
|
|
109
|
+
const initialStateCopy = Object.assign({}, state);
|
|
110
|
+
const constrainedState = this.scalePostProcessor(initialStateCopy, state);
|
|
111
|
+
if (this.state.lockPriceToBarRatio) {
|
|
112
|
+
lockedYEndViewportCalculator(constrainedState, this.zoomXYRatio);
|
|
113
|
+
}
|
|
114
|
+
if (this.state.auto) {
|
|
115
|
+
this.autoScaleModel.setAutoAndRecalculateState(constrainedState, true);
|
|
116
|
+
}
|
|
117
|
+
if (forceNoAnimation) {
|
|
118
|
+
this.apply(constrainedState);
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
startViewportModelAnimation(this.canvasAnimation, this, constrainedState);
|
|
122
|
+
}
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Moves the viewport to exactly xStart..xEnd place.
|
|
126
|
+
* (you need to fire DRAW event after this)
|
|
127
|
+
* @param xStart - viewport start in units
|
|
128
|
+
* @param xEnd - viewport end in units
|
|
129
|
+
* @param fireChanged
|
|
130
|
+
* @param forceNoAutoScale - force NOT apply auto-scaling (for lazy loading)
|
|
131
|
+
*/
|
|
132
|
+
setXScale(xStart, xEnd) {
|
|
133
|
+
const initialState = this.export();
|
|
134
|
+
super.setXScale(xStart, xEnd, false);
|
|
135
|
+
const state = this.export();
|
|
136
|
+
const constraitedState = this.scalePostProcessor(initialState, state);
|
|
137
|
+
if (this.state.lockPriceToBarRatio) {
|
|
138
|
+
lockedYEndViewportCalculator(constraitedState, this.zoomXYRatio);
|
|
139
|
+
}
|
|
140
|
+
if (this.state.auto) {
|
|
141
|
+
this.autoScaleModel.setAutoAndRecalculateState(constraitedState, true);
|
|
142
|
+
}
|
|
143
|
+
this.apply(constraitedState);
|
|
144
|
+
}
|
|
145
|
+
/**
|
|
146
|
+
* Moves both xStart and xEnd without changing the viewport width (zoom).
|
|
147
|
+
* WILL CHANGE the Y axis if scale.auto=true.
|
|
148
|
+
* @param xStart - starting point in units
|
|
149
|
+
*/
|
|
150
|
+
moveXStart(xStart) {
|
|
151
|
+
const state = this.export();
|
|
152
|
+
const initialStateCopy = Object.assign({}, state);
|
|
153
|
+
// always stop the animations
|
|
154
|
+
this.haltAnimation();
|
|
155
|
+
moveXStart(state, xStart);
|
|
156
|
+
// there we need only candles constrait
|
|
157
|
+
const constraitedState = this.scalePostProcessor(initialStateCopy, state);
|
|
158
|
+
if (this.state.auto) {
|
|
159
|
+
this.autoScaleModel.setAutoAndRecalculateState(constraitedState, true);
|
|
160
|
+
}
|
|
161
|
+
this.apply(constraitedState);
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Moves both yStart and yEnd without changing the viewport height (zoom).
|
|
165
|
+
* Will not move viewport if scale.auto=true
|
|
166
|
+
* @param yStart - starting point in units
|
|
167
|
+
*/
|
|
168
|
+
moveYStart(yStart) {
|
|
169
|
+
this.haltAnimation();
|
|
170
|
+
if (this.state.auto) {
|
|
171
|
+
return;
|
|
172
|
+
}
|
|
173
|
+
else {
|
|
174
|
+
const state = this.export();
|
|
175
|
+
moveYStart(state, yStart);
|
|
176
|
+
this.apply(state);
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Automatically scales the chart to fit the data range.
|
|
181
|
+
* @param forceApply - If true, the chart will be forcefully auto-scaled even if animation is in progress.
|
|
182
|
+
*/
|
|
183
|
+
doAutoScale(forceApply = false) {
|
|
184
|
+
// dont auto-scale if animation, otherwise - forced or config
|
|
185
|
+
if ((!this.isViewportAnimationInProgress() && this.state.auto) || forceApply) {
|
|
186
|
+
const state = this.export();
|
|
187
|
+
this.autoScaleModel.setAutoAndRecalculateState(state, true);
|
|
188
|
+
if (!compareStates(state, this.export())) {
|
|
189
|
+
this.apply(state);
|
|
190
|
+
}
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Checks if viewport animation is currently in progress.
|
|
195
|
+
* @returns returns true if viewport animation is in progress, false otherwise.
|
|
196
|
+
*/
|
|
197
|
+
isViewportAnimationInProgress() {
|
|
198
|
+
const animation = this.currentAnimation;
|
|
199
|
+
return animation === null || animation === void 0 ? void 0 : animation.animationInProgress;
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Adds an item to the scale history.
|
|
203
|
+
* @param item - The item to add to the history.
|
|
204
|
+
*/
|
|
205
|
+
pushToHistory(item) {
|
|
206
|
+
this.history.push(item);
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Removes the most recent item from the scale history and returns it.
|
|
210
|
+
* @returns - The most recent item from the history, or undefined if the history is empty.
|
|
211
|
+
*/
|
|
212
|
+
popFromHistory() {
|
|
213
|
+
return this.history.pop();
|
|
214
|
+
}
|
|
215
|
+
/**
|
|
216
|
+
* Clears the scale history.
|
|
217
|
+
*/
|
|
218
|
+
clearHistory() {
|
|
219
|
+
this.history = [];
|
|
220
|
+
}
|
|
221
|
+
/**
|
|
222
|
+
* Checks if the X axis bounds are the default values.
|
|
223
|
+
* @returns if false - it means there are candles and it's possible to do scaling and add drawings
|
|
224
|
+
*/
|
|
225
|
+
isDefaultXBounds() {
|
|
226
|
+
return this.xStart === 0 && this.xEnd === 0;
|
|
227
|
+
}
|
|
228
|
+
/**
|
|
229
|
+
* Checks if the Y axis bounds are the default values.
|
|
230
|
+
* @returns if false - it means there are candles and it's possible to do scaling and add drawings
|
|
231
|
+
*/
|
|
232
|
+
isDefaultYBounds() {
|
|
233
|
+
return this.yStart === 0 && this.yEnd === 0;
|
|
234
|
+
}
|
|
235
|
+
/**
|
|
236
|
+
* Checks if the scale is ready to be used.
|
|
237
|
+
* @returns - Returns true if the scale is ready, false otherwise.
|
|
238
|
+
*/
|
|
239
|
+
isScaleReady() {
|
|
240
|
+
return !this.isDefaultXBounds() && !this.isDefaultYBounds();
|
|
241
|
+
}
|
|
242
|
+
/**
|
|
243
|
+
* Enables or disables auto-scaling of the chart.
|
|
244
|
+
* @param auto - If true, the chart will be automatically scaled. If false, auto-scaling will be disabled.
|
|
245
|
+
*/
|
|
246
|
+
autoScale(auto = true) {
|
|
247
|
+
// TODO rework, make this a separate feature toggle, describe in docs; this should be a business-logic level
|
|
248
|
+
if (this.config.components.yAxis.type === 'percent') {
|
|
249
|
+
this.state.auto = true;
|
|
250
|
+
}
|
|
251
|
+
else {
|
|
252
|
+
this.state.auto = auto;
|
|
253
|
+
}
|
|
254
|
+
if (auto) {
|
|
255
|
+
this.clearHistory();
|
|
256
|
+
this.doAutoScale();
|
|
257
|
+
}
|
|
258
|
+
}
|
|
259
|
+
/**
|
|
260
|
+
* Sets whether the price-to-bar ratio should be locked or not.
|
|
261
|
+
* @param value - If true, the price-to-bar ratio will be locked. If false, it will not be locked.
|
|
262
|
+
*/
|
|
263
|
+
setLockPriceToBarRatio(value = false) {
|
|
264
|
+
const { type } = this.config.components.yAxis;
|
|
265
|
+
// TODO rework, why such logic? same as above, if we have business-logic like this one => make it separate code
|
|
266
|
+
if (type === 'percent' || type === 'logarithmic') {
|
|
267
|
+
this.state.lockPriceToBarRatio = false;
|
|
268
|
+
return;
|
|
269
|
+
}
|
|
270
|
+
if (value) {
|
|
271
|
+
this.recalculateZoomXYRatio();
|
|
272
|
+
}
|
|
273
|
+
this.state.lockPriceToBarRatio = value;
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* Recalculates the zoom X/Y ratio based on the current zoom levels.
|
|
277
|
+
*/
|
|
278
|
+
recalculateZoomXYRatio() {
|
|
279
|
+
this.zoomXYRatio = ratioFromZoomXY(this.zoomX, this.zoomY);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
/**
|
|
283
|
+
* The SyncedByXScaleModel class extends the ScaleModel class and adds support for synchronization with other ScaleModel instance, so both instances maintain the same X-axis bounds.
|
|
284
|
+
* This is useful for scenarios where multiple charts need to display the same X-axis data, but with different Y-axis scales.
|
|
285
|
+
*/
|
|
286
|
+
export class SyncedByXScaleModel extends ScaleModel {
|
|
287
|
+
constructor(delegate, config, getBounds, canvasAnimation) {
|
|
288
|
+
super(config, getBounds, canvasAnimation);
|
|
289
|
+
this.delegate = delegate;
|
|
290
|
+
this.config = config;
|
|
291
|
+
this.getBounds = getBounds;
|
|
292
|
+
}
|
|
293
|
+
doActivate() {
|
|
294
|
+
this.addRxSubscription(this.delegate.xChanged.subscribe(() => this.doAutoScale(this.state.auto)));
|
|
295
|
+
}
|
|
296
|
+
get xStart() {
|
|
297
|
+
return this.delegate.xStart;
|
|
298
|
+
}
|
|
299
|
+
set xStart(value) {
|
|
300
|
+
this.delegate.xStart = value;
|
|
301
|
+
}
|
|
302
|
+
get xEnd() {
|
|
303
|
+
return this.delegate.xEnd;
|
|
304
|
+
}
|
|
305
|
+
set xEnd(value) {
|
|
306
|
+
this.delegate.xEnd = value;
|
|
307
|
+
}
|
|
308
|
+
get zoomX() {
|
|
309
|
+
return this.delegate.zoomX;
|
|
310
|
+
}
|
|
311
|
+
set zoomX(value) {
|
|
312
|
+
this.delegate.zoomX = value;
|
|
313
|
+
}
|
|
314
|
+
observeXChanged() {
|
|
315
|
+
return this.delegate.xChanged;
|
|
316
|
+
}
|
|
317
|
+
fireChanged() {
|
|
318
|
+
this.delegate.changed.next();
|
|
319
|
+
this.changed.next();
|
|
320
|
+
}
|
|
321
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,102 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Auxiliary sub-model to apply X,Y auto-scaling feature.
|
|
8
|
+
* Transforms the original ViewportModel.
|
|
9
|
+
* @doc-tags auto-scale,viewport,scaling
|
|
10
|
+
*/
|
|
11
|
+
export class AutoScaleViewportSubModel {
|
|
12
|
+
constructor(delegate, highLowProviders) {
|
|
13
|
+
this.delegate = delegate;
|
|
14
|
+
// local state, used for pane X dragging
|
|
15
|
+
this.auto = true;
|
|
16
|
+
// post processors can apply some changes to high low before applying it
|
|
17
|
+
this.highLowPostPorcessor = {};
|
|
18
|
+
this.highLowProviders = highLowProviders !== null && highLowProviders !== void 0 ? highLowProviders : {};
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Sets a HighLowProvider for a given name.
|
|
22
|
+
* @param {string} name - The name of the HighLowProvider.
|
|
23
|
+
* @param {HighLowProvider} provider - The HighLowProvider to be set.
|
|
24
|
+
*/
|
|
25
|
+
setHighLowProvider(name, provider) {
|
|
26
|
+
this.highLowProviders[name] = provider;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Deletes a high-low provider from the list of high-low providers.
|
|
30
|
+
* @param {string} name - The name of the high-low provider to be deleted.
|
|
31
|
+
*/
|
|
32
|
+
deleteHighLowProvider(name) {
|
|
33
|
+
delete this.highLowProviders[name];
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Sets a HighLowPostProcessor for a given name.
|
|
37
|
+
*
|
|
38
|
+
* @param {string} name - The name of the HighLowPostProcessor.
|
|
39
|
+
* @param {HighLowPostProcessor} processor - The HighLowPostProcessor to be set.
|
|
40
|
+
* @returns {void}
|
|
41
|
+
*/
|
|
42
|
+
setHighLowPostProcessor(name, processor) {
|
|
43
|
+
this.highLowPostPorcessor[name] = processor;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Sets the auto and recalculates the state of the viewport model.
|
|
47
|
+
* @param {ViewportModelState} state - The state of the viewport model.
|
|
48
|
+
* @param {boolean} auto - The auto value to set.
|
|
49
|
+
* @returns {void}
|
|
50
|
+
*/
|
|
51
|
+
setAutoAndRecalculateState(state, auto) {
|
|
52
|
+
this.auto = auto;
|
|
53
|
+
if (auto) {
|
|
54
|
+
autoScaleYViewportTransformer(this.delegate, state, Object.values(this.highLowProviders), Object.values(this.highLowPostPorcessor));
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
/**
|
|
59
|
+
* Y auto-scale viewport transformer. Calculates highLow for all chart visuals and recalculates the Y scale.
|
|
60
|
+
* @param vm
|
|
61
|
+
* @param state
|
|
62
|
+
* @param highLowProviders
|
|
63
|
+
* @param highLowPostProcessors
|
|
64
|
+
*/
|
|
65
|
+
export const autoScaleYViewportTransformer = (vm, state, highLowProviders, highLowPostProcessors) => {
|
|
66
|
+
const highLowList = highLowProviders
|
|
67
|
+
.filter(provider => provider.isHighLowActive())
|
|
68
|
+
.map(provider => provider.calculateHighLow(state));
|
|
69
|
+
const highLow = mergeHighLow(highLowList);
|
|
70
|
+
const postProcessedHighLow = highLowPostProcessors.reduce((prevResult, postProcessor) => postProcessor(prevResult), highLow);
|
|
71
|
+
state.yStart = postProcessedHighLow.low;
|
|
72
|
+
state.yEnd = postProcessedHighLow.high;
|
|
73
|
+
state.zoomY = vm.calculateZoomY(state.yStart, state.yEnd);
|
|
74
|
+
};
|
|
75
|
+
/**
|
|
76
|
+
* Merges an array of HighLow objects into a single HighLow object.
|
|
77
|
+
* @param {HighLow[]} input - The array of HighLow objects to be merged.
|
|
78
|
+
* @returns {HighLow} - The merged HighLow object.
|
|
79
|
+
|
|
80
|
+
*/
|
|
81
|
+
export function mergeHighLow(input) {
|
|
82
|
+
if (input.length === 0) {
|
|
83
|
+
return getDefaultHighLow();
|
|
84
|
+
}
|
|
85
|
+
let max = input[0].high;
|
|
86
|
+
let min = input[0].low;
|
|
87
|
+
input.forEach(highLow => {
|
|
88
|
+
if (isFinite(highLow.high) && highLow.high >= max) {
|
|
89
|
+
max = highLow.high;
|
|
90
|
+
}
|
|
91
|
+
if (isFinite(highLow.low) && highLow.low <= min) {
|
|
92
|
+
min = highLow.low;
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
return { low: min, high: max };
|
|
96
|
+
}
|
|
97
|
+
export const getDefaultHighLow = () => {
|
|
98
|
+
return {
|
|
99
|
+
high: Number.MIN_SAFE_INTEGER,
|
|
100
|
+
low: Number.MAX_SAFE_INTEGER,
|
|
101
|
+
};
|
|
102
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,66 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
import{at
|
|
6
|
+
import { at } from '../../utils/array.utils';
|
|
7
|
+
import { calculateZoom, pixelsToUnits } from './viewport.model';
|
|
8
|
+
/**
|
|
9
|
+
* Return constraited state that handled zooming and moving chart near first/last candles
|
|
10
|
+
* this and other constraits that works with state should mutate and return state
|
|
11
|
+
* @param initialState
|
|
12
|
+
* @param state
|
|
13
|
+
* @param visualCandlesCoordinates
|
|
14
|
+
* @param candleLimit
|
|
15
|
+
* @param bounds
|
|
16
|
+
* @returns
|
|
17
|
+
* @doc-tags viewport,zoom,scaling
|
|
18
|
+
*/
|
|
19
|
+
export const candleEdgesConstrait = (state, visualCandlesCoordinates, candleLimit, bounds) => {
|
|
20
|
+
var _a, _b, _c, _d;
|
|
21
|
+
const newState = Object.assign({}, state);
|
|
22
|
+
const leftConstraitCoordinate = (_b = (_a = visualCandlesCoordinates[candleLimit]) === null || _a === void 0 ? void 0 : _a.startUnit) !== null && _b !== void 0 ? _b : 0;
|
|
23
|
+
const rightConstraintCoordinate = (_d = (_c = at(-candleLimit, visualCandlesCoordinates)) === null || _c === void 0 ? void 0 : _c.startUnit) !== null && _d !== void 0 ? _d : 0;
|
|
24
|
+
let normalizedXStart = state.xStart;
|
|
25
|
+
let normalizedXEnd = state.xEnd;
|
|
26
|
+
if (newState.xStart >= rightConstraintCoordinate) {
|
|
27
|
+
normalizedXStart = rightConstraintCoordinate;
|
|
28
|
+
normalizedXEnd = normalizedXEnd - (newState.xStart - rightConstraintCoordinate);
|
|
29
|
+
}
|
|
30
|
+
if (newState.xEnd < leftConstraitCoordinate) {
|
|
31
|
+
normalizedXStart = leftConstraitCoordinate - pixelsToUnits(bounds.width, newState.zoomX);
|
|
32
|
+
normalizedXEnd = leftConstraitCoordinate;
|
|
33
|
+
}
|
|
34
|
+
newState.xStart = normalizedXStart;
|
|
35
|
+
newState.xEnd = normalizedXEnd;
|
|
36
|
+
return newState;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* This function limits minimum and maximum chart viewport dependening on visible x-units
|
|
40
|
+
* @returns
|
|
41
|
+
* @doc-tags viewport,zoom,scaling
|
|
42
|
+
*/
|
|
43
|
+
export const zoomConstraint = (initialState, state, chartConfig, boundsProvider) => {
|
|
44
|
+
const newState = Object.assign({}, state);
|
|
45
|
+
const bounds = boundsProvider();
|
|
46
|
+
// 1 - is an average candle width: newXEnd - newXStart = avg candles amount in the viewport
|
|
47
|
+
const avgCandlesInViewport = newState.xEnd - newState.xStart;
|
|
48
|
+
const minViewportReached = avgCandlesInViewport < chartConfig.minCandles;
|
|
49
|
+
const maxCandlesInViewport = bounds.width / chartConfig.minWidth;
|
|
50
|
+
const maxViewportReached = avgCandlesInViewport > maxCandlesInViewport;
|
|
51
|
+
// rules work only if chart is shown
|
|
52
|
+
if (bounds.width > 0) {
|
|
53
|
+
if (maxViewportReached) {
|
|
54
|
+
newState.xStart = newState.xEnd - maxCandlesInViewport;
|
|
55
|
+
newState.zoomX = calculateZoom(newState.xEnd - newState.xStart, bounds.width);
|
|
56
|
+
return newState;
|
|
57
|
+
}
|
|
58
|
+
if (minViewportReached) {
|
|
59
|
+
newState.xEnd = initialState.xEnd;
|
|
60
|
+
newState.xStart = newState.xEnd - chartConfig.minCandles;
|
|
61
|
+
newState.zoomX = calculateZoom(newState.xEnd - newState.xStart, bounds.width);
|
|
62
|
+
return newState;
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
return newState;
|
|
66
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,22 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
export const ratioFromZoomXY=(
|
|
6
|
+
export const ratioFromZoomXY = (zoomX, zoomY) => zoomX / zoomY;
|
|
7
|
+
export const zoomXToZoomY = (zoomX, ratio) => zoomX / ratio;
|
|
8
|
+
export const zoomYToZoomX = (zoomY, ratio) => zoomY * ratio;
|
|
9
|
+
/**
|
|
10
|
+
* Locks the zoomY with zoomX and moves yEnd according to ratio changes.
|
|
11
|
+
* @param state
|
|
12
|
+
* @param zoomXYRatio
|
|
13
|
+
*/
|
|
14
|
+
export const lockedYEndViewportCalculator = (state, zoomXYRatio) => {
|
|
15
|
+
const prevZoomY = state.zoomY;
|
|
16
|
+
state.zoomY = zoomXToZoomY(state.zoomX, zoomXYRatio);
|
|
17
|
+
const zoomYMult = state.zoomY / prevZoomY;
|
|
18
|
+
const lastYHeight = state.yEnd - state.yStart;
|
|
19
|
+
const newYHeight = lastYHeight * zoomYMult;
|
|
20
|
+
const delta = newYHeight - lastYHeight;
|
|
21
|
+
state.yEnd = state.yEnd + delta;
|
|
22
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
@@ -1,6 +1,27 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
6
|
-
|
|
6
|
+
/**
|
|
7
|
+
* Moves both xStart and xEnd without changing the viewport width (zoomX).
|
|
8
|
+
* @param state
|
|
9
|
+
* @param xStart - left starting point in units
|
|
10
|
+
* @doc-tags scaling,viewport
|
|
11
|
+
*/
|
|
12
|
+
export const moveXStart = (state, xStart) => {
|
|
13
|
+
const prev = state.xStart;
|
|
14
|
+
state.xStart = xStart;
|
|
15
|
+
state.xEnd = state.xEnd + (xStart - prev);
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Moves both yStart and yEnd without changing the viewport height (zoomY).
|
|
19
|
+
* @param state
|
|
20
|
+
* @param yStart - starting point in units
|
|
21
|
+
* @doc-tags scaling,viewport
|
|
22
|
+
*/
|
|
23
|
+
export const moveYStart = (state, yStart) => {
|
|
24
|
+
const prev = state.yStart;
|
|
25
|
+
state.yStart = yStart;
|
|
26
|
+
state.yEnd = state.yEnd + (yStart - prev);
|
|
27
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Copyright (C)
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
3
|
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
4
4
|
* If a copy of the MPL was not distributed with this file, You can obtain one at https://mozilla.org/MPL/2.0/.
|
|
5
5
|
*/
|
|
@@ -19,8 +19,8 @@ export type Timestamp = Unit;
|
|
|
19
19
|
export type Percent = Unit;
|
|
20
20
|
export type LogValue = Unit;
|
|
21
21
|
export type YUnit = Price | Percent | LogValue;
|
|
22
|
-
export declare const unitToPercent: (value: Unit,
|
|
23
|
-
export declare const percentToUnit: (percent: Percent,
|
|
22
|
+
export declare const unitToPercent: (value: Unit, baseline: Unit) => Percent;
|
|
23
|
+
export declare const percentToUnit: (percent: Percent, baseline: Unit) => Unit;
|
|
24
24
|
export declare const calcLogValue: (value: Price) => LogValue;
|
|
25
25
|
export declare const logValueToUnit: (logValue: LogValue) => number;
|
|
26
26
|
/**
|