@devexperts/dxcharts-lite 1.0.2 → 2.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/chart/animation/canvas-animation.js +134 -1
- package/dist/chart/animation/types/animation.js +43 -1
- package/dist/chart/animation/types/color-alpha-animation.d.ts +1 -1
- package/dist/chart/animation/types/color-alpha-animation.js +60 -1
- package/dist/chart/animation/types/color-transition-animation.d.ts +1 -1
- package/dist/chart/animation/types/color-transition-animation.js +86 -1
- package/dist/chart/animation/types/viewport-movement-animation.js +63 -1
- package/dist/chart/animation/viewport-model-animation.js +20 -1
- package/dist/chart/bootstrap.d.ts +51 -48
- package/dist/chart/bootstrap.js +449 -1
- package/dist/chart/canvas/canvas-bounds-container.d.ts +0 -5
- package/dist/chart/canvas/canvas-bounds-container.js +815 -1
- package/dist/chart/canvas/canvas-chart-html.js +16 -18
- package/dist/chart/canvas/chart-elements.d.ts +1 -4
- package/dist/chart/canvas/chart-elements.js +22 -1
- package/dist/chart/canvas/cursor.handler.js +122 -1
- package/dist/chart/canvas/layout-creator.js +34 -1
- package/dist/chart/canvas/y-axis-bounds.container.d.ts +2 -2
- package/dist/chart/canvas/y-axis-bounds.container.js +67 -1
- package/dist/chart/chart-container.js +1 -1
- package/dist/chart/chart.config.d.ts +4 -5
- package/dist/chart/chart.config.js +645 -1
- package/dist/chart/chart.d.ts +62 -0
- package/dist/chart/chart.js +106 -0
- package/dist/chart/components/chart/basic-scale.d.ts +2 -2
- package/dist/chart/components/chart/basic-scale.js +31 -1
- package/dist/chart/components/chart/candle-transformer.functions.js +15 -1
- package/dist/chart/components/chart/candle-width-calculator.functions.js +2 -1
- package/dist/chart/components/chart/candle.functions.js +44 -1
- package/dist/chart/components/chart/chart-area-pan.handler.d.ts +3 -3
- package/dist/chart/components/chart/chart-area-pan.handler.js +197 -1
- package/dist/chart/components/chart/chart-base.model.js +66 -1
- package/dist/chart/components/chart/chart.component.d.ts +7 -3
- package/dist/chart/components/chart/chart.component.js +408 -1
- package/dist/chart/components/chart/chart.model.d.ts +4 -11
- package/dist/chart/components/chart/chart.model.js +954 -1
- package/dist/chart/components/chart/data-series.high-low-provider.js +34 -1
- package/dist/chart/components/chart/fake-candles.js +97 -1
- package/dist/chart/components/chart/price.formatter.js +35 -1
- package/dist/chart/components/chart/secondary-chart-colors-pool.js +68 -1
- package/dist/chart/components/cross_tool/cross-tool.component.js +85 -1
- package/dist/chart/components/cross_tool/cross-tool.drawer.js +32 -1
- package/dist/chart/components/cross_tool/cross-tool.model.js +107 -1
- package/dist/chart/components/cross_tool/types/cross-and-labels.drawer.js +137 -1
- package/dist/chart/components/cross_tool/types/none.drawer.js +3 -1
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +28 -1
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +24 -1
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +53 -1
- 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.js +63 -1
- package/dist/chart/components/events/events.component.js +61 -1
- package/dist/chart/components/events/events.drawer.js +195 -1
- package/dist/chart/components/events/events.model.js +69 -1
- package/dist/chart/components/grid/grid.component.d.ts +2 -2
- package/dist/chart/components/grid/grid.component.js +31 -1
- package/dist/chart/components/grid/grid.drawer.d.ts +4 -3
- package/dist/chart/components/grid/grid.drawer.js +106 -1
- package/dist/chart/components/high_low/high-low.component.js +12 -1
- package/dist/chart/components/high_low/high-low.drawer.js +126 -1
- package/dist/chart/components/highlights/highlights.component.js +46 -1
- package/dist/chart/components/highlights/highlights.drawer.js +154 -1
- package/dist/chart/components/highlights/highlights.model.js +75 -1
- package/dist/chart/components/labels_generator/numeric-axis-labels.generator.d.ts +1 -1
- package/dist/chart/components/labels_generator/numeric-axis-labels.generator.js +199 -1
- package/dist/chart/components/navigation_map/navigation-map-move.handler.d.ts +2 -2
- package/dist/chart/components/navigation_map/navigation-map-move.handler.js +108 -1
- package/dist/chart/components/navigation_map/navigation-map.component.js +112 -1
- package/dist/chart/components/navigation_map/navigation-map.drawer.js +244 -1
- package/dist/chart/components/navigation_map/navigation-map.model.js +33 -2
- package/dist/chart/components/pan/chart-pan.component.d.ts +2 -2
- package/dist/chart/components/pan/chart-pan.component.js +51 -1
- package/dist/chart/components/pane/extent/y-extent-component.d.ts +12 -18
- package/dist/chart/components/pane/extent/y-extent-component.js +120 -1
- package/dist/chart/components/pane/pane-hit-test.controller.d.ts +2 -2
- package/dist/chart/components/pane/pane-hit-test.controller.js +55 -1
- package/dist/chart/components/pane/pane-manager.component.d.ts +12 -6
- package/dist/chart/components/pane/pane-manager.component.js +149 -1
- package/dist/chart/components/pane/pane.component.d.ts +16 -32
- package/dist/chart/components/pane/pane.component.js +278 -1
- package/dist/chart/components/resizer/bar-resizer.component.js +139 -1
- package/dist/chart/components/resizer/bar-resizer.drawer.js +46 -1
- package/dist/chart/components/snapshot/snapshot.component.js +48 -1
- package/dist/chart/components/volumes/separate-volumes.component.d.ts +6 -10
- package/dist/chart/components/volumes/separate-volumes.component.js +63 -1
- package/dist/chart/components/volumes/volume-color-resolvers.functions.js +18 -1
- package/dist/chart/components/volumes/volumes.component.d.ts +6 -7
- package/dist/chart/components/volumes/volumes.component.js +94 -1
- package/dist/chart/components/volumes/volumes.drawer.d.ts +5 -12
- package/dist/chart/components/volumes/volumes.drawer.js +140 -1
- package/dist/chart/components/volumes/volumes.formatter.js +31 -1
- package/dist/chart/components/volumes/volumes.model.d.ts +2 -2
- package/dist/chart/components/volumes/volumes.model.js +43 -1
- package/dist/chart/components/watermark/water-mark.component.js +103 -1
- package/dist/chart/components/watermark/water-mark.drawer.js +187 -1
- package/dist/chart/components/x_axis/numeric-x-axis-labels.generator.js +27 -1
- package/dist/chart/components/x_axis/time/parser/time-formats-matchers.functions.js +187 -1
- package/dist/chart/components/x_axis/time/parser/time-formats-parser.functions.js +76 -1
- package/dist/chart/components/x_axis/time/parser/time-formats-validators.functions.js +79 -1
- package/dist/chart/components/x_axis/time/parser/time-formats.model.js +14 -1
- package/dist/chart/components/x_axis/time/x-axis-weights.functions.d.ts +1 -1
- package/dist/chart/components/x_axis/time/x-axis-weights.functions.js +143 -1
- package/dist/chart/components/x_axis/time/x-axis-weights.generator.js +73 -1
- package/dist/chart/components/x_axis/x-axis-draw.functions.js +49 -1
- package/dist/chart/components/x_axis/x-axis-labels.drawer.js +70 -1
- package/dist/chart/components/x_axis/x-axis-labels.generator.d.ts +2 -2
- package/dist/chart/components/x_axis/x-axis-labels.generator.js +332 -1
- package/dist/chart/components/x_axis/x-axis-labels.model.js +35 -1
- package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +2 -2
- package/dist/chart/components/x_axis/x-axis-scale.handler.js +60 -1
- package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +82 -1
- package/dist/chart/components/x_axis/x-axis.component.d.ts +2 -2
- package/dist/chart/components/x_axis/x-axis.component.js +119 -1
- package/dist/chart/components/y_axis/label-color.functions.js +53 -1
- package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.d.ts +4 -4
- package/dist/chart/components/y_axis/numeric-y-axis-labels.generator.js +33 -1
- package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.d.ts +3 -3
- package/dist/chart/components/y_axis/price_labels/data-series-y-axis-labels.provider.js +67 -1
- package/dist/chart/components/y_axis/price_labels/labels-positions-calculator.js +56 -1
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.d.ts +4 -3
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +96 -1
- package/dist/chart/components/y_axis/price_labels/price-label.drawer.d.ts +2 -2
- package/dist/chart/components/y_axis/price_labels/price-label.drawer.js +119 -1
- package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +9 -8
- package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +201 -1
- package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.d.ts +6 -7
- package/dist/chart/components/y_axis/price_labels/y-axis-price-labels.drawer.js +58 -1
- package/dist/chart/components/y_axis/y-axis-base-labels.model.d.ts +6 -4
- package/dist/chart/components/y_axis/y-axis-base-labels.model.js +47 -1
- package/dist/chart/components/y_axis/y-axis-labels.drawer.d.ts +4 -4
- package/dist/chart/components/y_axis/y-axis-labels.drawer.js +161 -1
- package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +2 -2
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +72 -1
- package/dist/chart/components/y_axis/y-axis.component.d.ts +32 -41
- package/dist/chart/components/y_axis/y-axis.component.js +220 -1
- package/dist/chart/components/y_axis/y-axis.drawer.d.ts +9 -12
- package/dist/chart/components/y_axis/y-axis.drawer.js +96 -1
- package/dist/chart/components/y_axis/y-axis.model.d.ts +10 -17
- package/dist/chart/components/y_axis/y-axis.model.js +34 -1
- package/dist/chart/drawers/chart-background.drawer.js +69 -1
- package/dist/chart/drawers/chart-type-drawers/area.drawer.js +69 -1
- package/dist/chart/drawers/chart-type-drawers/bar.drawer.js +57 -1
- package/dist/chart/drawers/chart-type-drawers/baseline.drawer.js +84 -1
- package/dist/chart/drawers/chart-type-drawers/candle.drawer.js +162 -1
- package/dist/chart/drawers/chart-type-drawers/histogram.drawer.js +57 -1
- package/dist/chart/drawers/chart-type-drawers/line.drawer.js +38 -1
- package/dist/chart/drawers/chart-type-drawers/scatter-plot.drawer.js +19 -1
- package/dist/chart/drawers/clear-canvas.drawer.js +14 -1
- package/dist/chart/drawers/composite.drawer.js +67 -1
- package/dist/chart/drawers/data-series-drawers/candle-series-wrapper.js +50 -1
- package/dist/chart/drawers/data-series-drawers/color-candle.drawer.js +35 -1
- package/dist/chart/drawers/data-series-drawers/data-series-drawers.utils.js +16 -1
- package/dist/chart/drawers/data-series-drawers/difference-cloud.drawer.js +106 -1
- package/dist/chart/drawers/data-series-drawers/histogram.drawer.js +23 -1
- package/dist/chart/drawers/data-series-drawers/linear.drawer.js +19 -1
- package/dist/chart/drawers/data-series-drawers/points.drawer.js +19 -1
- package/dist/chart/drawers/data-series-drawers/rectangular-tool.drawer.js +7 -1
- package/dist/chart/drawers/data-series-drawers/text.drawer.js +25 -1
- package/dist/chart/drawers/data-series-drawers/trend-histogram.drawer.js +35 -1
- package/dist/chart/drawers/data-series-drawers/triangle.drawer.js +22 -1
- package/dist/chart/drawers/data-series.drawer.d.ts +5 -7
- package/dist/chart/drawers/data-series.drawer.js +56 -1
- package/dist/chart/drawers/drawing-manager.d.ts +1 -1
- package/dist/chart/drawers/drawing-manager.js +177 -1
- package/dist/chart/drawers/ht-data-series.drawer.js +37 -1
- package/dist/chart/events/event-bus.js +73 -1
- package/dist/chart/events/events.js +3 -1
- package/dist/chart/inputhandlers/candle-tap.handler.js +46 -1
- package/dist/chart/inputhandlers/chart-resize.handler.js +98 -1
- package/dist/chart/inputhandlers/cross-event-producer.component.js +67 -1
- package/dist/chart/inputhandlers/hover-producer.component.d.ts +2 -2
- package/dist/chart/inputhandlers/hover-producer.component.js +228 -1
- package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +2 -2
- package/dist/chart/inputhandlers/main-canvas-touch.handler.js +80 -1
- package/dist/chart/inputlisteners/canvas-input-listener.component.js +629 -1
- package/dist/chart/model/baseline.model.js +88 -1
- package/dist/chart/model/bounds.model.js +1 -1
- package/dist/chart/model/candle-hover.js +70 -1
- package/dist/chart/model/candle-series-high-low.provider.js +45 -1
- package/dist/chart/model/candle-series.model.d.ts +3 -3
- package/dist/chart/model/candle-series.model.js +245 -1
- package/dist/chart/model/candle.model.js +69 -1
- package/dist/chart/model/canvas.model.js +228 -1
- package/dist/chart/model/chart-base-element.js +129 -1
- package/dist/chart/model/compare-series-hover.js +25 -1
- package/dist/chart/model/data-series-view.d.ts +5 -5
- package/dist/chart/model/data-series-view.js +111 -1
- package/dist/chart/model/data-series.config.js +14 -1
- package/dist/chart/model/data-series.model.d.ts +4 -4
- package/dist/chart/model/data-series.model.js +281 -1
- package/dist/chart/model/date-time.formatter.js +151 -1
- package/dist/chart/model/hit-test-canvas.model.d.ts +1 -1
- package/dist/chart/model/hit-test-canvas.model.js +256 -1
- package/dist/chart/model/main-candle-series.model.d.ts +1 -1
- package/dist/chart/model/main-candle-series.model.js +29 -1
- package/dist/chart/model/scale.model.d.ts +3 -2
- package/dist/chart/model/scale.model.js +316 -1
- package/dist/chart/model/scaling/auto-scale.model.d.ts +2 -4
- package/dist/chart/model/scaling/auto-scale.model.js +91 -1
- package/dist/chart/model/scaling/constrait.functions.js +61 -1
- package/dist/chart/model/scaling/lock-ratio.model.js +17 -1
- package/dist/chart/model/scaling/move-chart.functions.js +22 -1
- package/dist/chart/model/scaling/viewport.model.d.ts +2 -2
- package/dist/chart/model/scaling/viewport.model.js +279 -1
- package/dist/chart/model/scaling/x-zooming.functions.js +35 -1
- package/dist/chart/model/time-zone.model.js +109 -1
- package/dist/chart/model/visual-candle.js +134 -1
- package/dist/chart/utils/__tests__/array.utils.test.js +135 -1
- package/dist/chart/utils/__tests__/math.utils.test.js +14 -1
- package/dist/chart/utils/__tests__/object.utils.test.js +11 -1
- package/dist/chart/utils/__tests__/priceIncrementsUtils.test.js +29 -1
- package/dist/chart/utils/array.utils.d.ts +1 -1
- package/dist/chart/utils/array.utils.js +269 -1
- package/dist/chart/utils/auto-period-detector.utils.js +39 -1
- package/dist/chart/utils/candles-generator-ts.utils.js +20 -1
- package/dist/chart/utils/candles-generator.utils.js +161 -1
- package/dist/chart/utils/candles.utils.js +42 -1
- package/dist/chart/utils/canvas/canvas-drawing-functions.utils.js +144 -1
- package/dist/chart/utils/canvas/canvas-font-measure-tool.utils.js +51 -1
- package/dist/chart/utils/canvas/canvas-text-functions.utils.js +156 -1
- package/dist/chart/utils/color.utils.js +31 -1
- package/dist/chart/utils/device/browser.utils.js +10 -1
- package/dist/chart/utils/device/device-detector.utils.js +24 -1
- package/dist/chart/utils/device/device-pixel-ratio.utils.js +21 -1
- package/dist/chart/utils/device/touchpad.utils.js +91 -1
- package/dist/chart/utils/dom.utils.js +15 -1
- package/dist/chart/utils/function.utils.js +16 -1
- 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.js +115 -1
- package/dist/chart/utils/merge.utils.js +56 -1
- package/dist/chart/utils/object.utils.js +43 -1
- package/dist/chart/utils/performance/animation-frame-cache.utils.js +77 -0
- package/dist/chart/utils/{perfomance → performance}/debounce.utils.js +7 -1
- package/dist/chart/utils/performance/memoize.utils.js +74 -0
- package/dist/chart/utils/performance/request-animation-frame-throttle.utils.js +43 -0
- package/dist/chart/utils/performance/throttle.utils.js +26 -0
- package/dist/chart/utils/price-increments.utils.d.ts +1 -0
- package/dist/chart/utils/price-increments.utils.js +127 -1
- package/dist/chart/utils/uuid.utils.js +4 -1
- package/dist/dxchart.min.js +9 -12
- package/dist/index.d.ts +3 -3
- package/dist/index.js +20 -1
- 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
- /package/dist/chart/utils/{perfomance → performance}/animation-frame-cache.utils.d.ts +0 -0
- /package/dist/chart/utils/{perfomance → performance}/debounce.utils.d.ts +0 -0
- /package/dist/chart/utils/{perfomance → performance}/memoize.utils.d.ts +0 -0
- /package/dist/chart/utils/{perfomance → performance}/request-animation-frame-throttle.utils.d.ts +0 -0
- /package/dist/chart/utils/{perfomance → performance}/throttle.utils.d.ts +0 -0
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
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
|
+
*/
|
|
6
|
+
import ChartBootstrap from './bootstrap';
|
|
7
|
+
import { BarType, PartialChartConfig } from './chart.config';
|
|
8
|
+
import { CandleSeries } from './components/chart/chart.component';
|
|
9
|
+
import { PaneComponent, YExtentFormatters } from './components/pane/pane.component';
|
|
10
|
+
/**
|
|
11
|
+
* New shiny chart wrapper
|
|
12
|
+
*/
|
|
13
|
+
export declare class Chart extends ChartBootstrap {
|
|
14
|
+
yAxis: import("./components/y_axis/y-axis.component").YAxisComponent;
|
|
15
|
+
xAxis: import("./components/x_axis/x-axis.component").XAxisComponent;
|
|
16
|
+
watermark: import("./components/watermark/water-mark.component").WaterMarkComponent;
|
|
17
|
+
highlights: import("./components/highlights/highlights.component").HighlightsComponent;
|
|
18
|
+
events: import("./components/events/events.component").EventsComponent;
|
|
19
|
+
snapshot: import("./components/snapshot/snapshot.component").SnapshotComponent;
|
|
20
|
+
crosshair: import("./components/cross_tool/cross-tool.component").CrossToolComponent;
|
|
21
|
+
navigationMap: import("./components/navigation_map/navigation-map.component").NavigationMapComponent;
|
|
22
|
+
volumes: import("./components/volumes/volumes.component").VolumesComponent;
|
|
23
|
+
cursors: import("./canvas/cursor.handler").CursorHandler;
|
|
24
|
+
data: import("./components/chart/chart.component").ChartComponent;
|
|
25
|
+
scale: import("./model/scale.model").ScaleModel;
|
|
26
|
+
panning: import("./components/pan/chart-pan.component").ChartPanComponent;
|
|
27
|
+
constructor(element: HTMLElement, config?: PartialChartConfig);
|
|
28
|
+
/**
|
|
29
|
+
* Registers number formatters for pane
|
|
30
|
+
* @param uuid - pane's id
|
|
31
|
+
* @param formatters - object, that contains 3 fileds: 'regular', 'percent', 'logarithmic'.
|
|
32
|
+
* Each filed must have it's own formatter.
|
|
33
|
+
* If 'percent' and 'logarithmic' formatters did not provided, 'regular' will be applied.
|
|
34
|
+
*/
|
|
35
|
+
registerPaneFormatters(uuid: string, formatters: YExtentFormatters): void;
|
|
36
|
+
/**
|
|
37
|
+
* Contains tear-down logic for chart
|
|
38
|
+
* Use when you want to unmount the chart from the host app
|
|
39
|
+
*/
|
|
40
|
+
destroy(): void;
|
|
41
|
+
/**
|
|
42
|
+
* Sets the visibility of the volumes separately and updates the yAxis width.
|
|
43
|
+
* @param {boolean} separate - A boolean value indicating whether to show the volumes separately or not. Default value is false.
|
|
44
|
+
*/
|
|
45
|
+
showSeparateVolumes(separate?: boolean): void;
|
|
46
|
+
setData(data: CandleSeries | CandleSeries[]): void;
|
|
47
|
+
updateData(data: CandleSeries | CandleSeries[]): void;
|
|
48
|
+
/**
|
|
49
|
+
* Sets the auto scale property of the scale model.
|
|
50
|
+
* @param {boolean} auto - A boolean value indicating whether the auto scale is enabled or not. Default value is true.
|
|
51
|
+
*/
|
|
52
|
+
setAutoScale(auto?: boolean): void;
|
|
53
|
+
/**
|
|
54
|
+
* Sets the right-to-left (RTL) configuration of the component.
|
|
55
|
+
*
|
|
56
|
+
* @param {boolean} rtl - A boolean value indicating whether the component should be displayed in RTL mode.
|
|
57
|
+
* @returns {void}
|
|
58
|
+
*/
|
|
59
|
+
setRtl(rtl: boolean): void;
|
|
60
|
+
setChartType(type: BarType): void;
|
|
61
|
+
createPane(): PaneComponent;
|
|
62
|
+
}
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* Copyright (C) 2019 - 2023 Devexperts Solutions IE Limited
|
|
3
|
+
* This Source Code Form is subject to the terms of the Mozilla Public License, v. 2.0.
|
|
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
|
+
*/
|
|
6
|
+
import ChartBootstrap from './bootstrap';
|
|
7
|
+
/**
|
|
8
|
+
* New shiny chart wrapper
|
|
9
|
+
*/
|
|
10
|
+
export class Chart extends ChartBootstrap {
|
|
11
|
+
constructor(element, config = {}) {
|
|
12
|
+
super(element, config);
|
|
13
|
+
this.yAxis = this.yAxisComponent;
|
|
14
|
+
this.xAxis = this.xAxisComponent;
|
|
15
|
+
this.watermark = this.watermarkComponent;
|
|
16
|
+
this.highlights = this.highlightsComponent;
|
|
17
|
+
this.events = this.eventsComponent;
|
|
18
|
+
this.snapshot = this.snapshotComponent;
|
|
19
|
+
this.crosshair = this.crossToolComponent;
|
|
20
|
+
this.navigationMap = this.navigationMapComponent;
|
|
21
|
+
this.volumes = this.volumesComponent;
|
|
22
|
+
this.cursors = this.cursorHandler;
|
|
23
|
+
this.data = this.chartComponent;
|
|
24
|
+
this.scale = this.scaleModel;
|
|
25
|
+
this.panning = this.chartPanComponent;
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Registers number formatters for pane
|
|
29
|
+
* @param uuid - pane's id
|
|
30
|
+
* @param formatters - object, that contains 3 fileds: 'regular', 'percent', 'logarithmic'.
|
|
31
|
+
* Each filed must have it's own formatter.
|
|
32
|
+
* If 'percent' and 'logarithmic' formatters did not provided, 'regular' will be applied.
|
|
33
|
+
*/
|
|
34
|
+
registerPaneFormatters(uuid, formatters) {
|
|
35
|
+
var _a;
|
|
36
|
+
(_a = this.paneManager.panes[uuid]) === null || _a === void 0 ? void 0 : _a.setPaneValueFormatters(formatters);
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Contains tear-down logic for chart
|
|
40
|
+
* Use when you want to unmount the chart from the host app
|
|
41
|
+
*/
|
|
42
|
+
destroy() {
|
|
43
|
+
this.bus.setMuted(true);
|
|
44
|
+
this.chartComponents.forEach(c => c.disable());
|
|
45
|
+
this.parentElement.childNodes.forEach(n => n.remove());
|
|
46
|
+
this.parentElement.style.width = '';
|
|
47
|
+
this.parentElement.style.height = '';
|
|
48
|
+
}
|
|
49
|
+
/**
|
|
50
|
+
* Sets the visibility of the volumes separately and updates the yAxis width.
|
|
51
|
+
* @param {boolean} separate - A boolean value indicating whether to show the volumes separately or not. Default value is false.
|
|
52
|
+
*/
|
|
53
|
+
showSeparateVolumes(separate = false) {
|
|
54
|
+
if (this.volumes) {
|
|
55
|
+
this.volumes.setShowVolumesSeparatly(separate);
|
|
56
|
+
this.canvasBoundsContainer.updateYAxisWidths();
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
setData(data) {
|
|
60
|
+
if (Array.isArray(data)) {
|
|
61
|
+
if (data.length === 0) {
|
|
62
|
+
return;
|
|
63
|
+
}
|
|
64
|
+
const [mainSeries, ...restSeries] = data;
|
|
65
|
+
this.chartComponent.setAllSeries(mainSeries, restSeries);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
this.chartComponent.setMainSeries(data);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
updateData(data) {
|
|
72
|
+
if (Array.isArray(data)) {
|
|
73
|
+
if (data.length === 0) {
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
const [mainSeries, ...restSeries] = data;
|
|
77
|
+
this.chartComponent.updateAllSeries(mainSeries, restSeries);
|
|
78
|
+
}
|
|
79
|
+
else {
|
|
80
|
+
this.chartComponent.updateAllSeries(data);
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
/**
|
|
84
|
+
* Sets the auto scale property of the scale model.
|
|
85
|
+
* @param {boolean} auto - A boolean value indicating whether the auto scale is enabled or not. Default value is true.
|
|
86
|
+
*/
|
|
87
|
+
setAutoScale(auto = true) {
|
|
88
|
+
this.scale.autoScale(auto);
|
|
89
|
+
}
|
|
90
|
+
/**
|
|
91
|
+
* Sets the right-to-left (RTL) configuration of the component.
|
|
92
|
+
*
|
|
93
|
+
* @param {boolean} rtl - A boolean value indicating whether the component should be displayed in RTL mode.
|
|
94
|
+
* @returns {void}
|
|
95
|
+
*/
|
|
96
|
+
setRtl(rtl) {
|
|
97
|
+
this.config.rtl = rtl;
|
|
98
|
+
this.bus.fireDraw();
|
|
99
|
+
}
|
|
100
|
+
setChartType(type) {
|
|
101
|
+
this.chartComponent.setChartType(type);
|
|
102
|
+
}
|
|
103
|
+
createPane() {
|
|
104
|
+
return this.paneManager.createPane();
|
|
105
|
+
}
|
|
106
|
+
}
|
|
@@ -12,11 +12,11 @@ import { ChartModel } from './chart.model';
|
|
|
12
12
|
* @param scaleModel
|
|
13
13
|
* @doc-tags scaling,viewport
|
|
14
14
|
*/
|
|
15
|
-
export declare const createBasicScaleViewportTransformer: (
|
|
15
|
+
export declare const createBasicScaleViewportTransformer: (scale: ScaleModel) => (visualCandleSource: VisualCandle[]) => void;
|
|
16
16
|
/**
|
|
17
17
|
* Moves the viewport between 2 timestamps.
|
|
18
18
|
* @param scaleModel
|
|
19
19
|
* @param chartModel
|
|
20
20
|
* @param canvasAnimationContainer
|
|
21
21
|
*/
|
|
22
|
-
export declare const createTimeFrameViewportTransformer: (
|
|
22
|
+
export declare const createTimeFrameViewportTransformer: (scale: ScaleModel, chartModel: ChartModel) => (timeframe: [Timestamp, Timestamp], zoomIn?: boolean | null) => void;
|
|
@@ -3,4 +3,34 @@
|
|
|
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
|
+
* Calculates the initial viewport.
|
|
8
|
+
* @param scaleModel
|
|
9
|
+
* @doc-tags scaling,viewport
|
|
10
|
+
*/
|
|
11
|
+
export const createBasicScaleViewportTransformer = (scale) => (visualCandleSource) => {
|
|
12
|
+
if (visualCandleSource.length !== 0) {
|
|
13
|
+
const vCandles = visualCandleSource.slice(Math.max(visualCandleSource.length - scale.state.defaultViewportItems, 0));
|
|
14
|
+
const startCandle = vCandles[0];
|
|
15
|
+
const endCandle = vCandles[vCandles.length - 1];
|
|
16
|
+
scale.setXScale(startCandle.startUnit, endCandle.startUnit + endCandle.width + scale.offsets.right);
|
|
17
|
+
scale.doAutoScale(true);
|
|
18
|
+
scale.recalculateZoomXYRatio();
|
|
19
|
+
scale.fireChanged();
|
|
20
|
+
}
|
|
21
|
+
};
|
|
22
|
+
/**
|
|
23
|
+
* Moves the viewport between 2 timestamps.
|
|
24
|
+
* @param scaleModel
|
|
25
|
+
* @param chartModel
|
|
26
|
+
* @param canvasAnimationContainer
|
|
27
|
+
*/
|
|
28
|
+
export const createTimeFrameViewportTransformer = (scale, chartModel) => (timeframe, zoomIn = null) => {
|
|
29
|
+
const [firstTimestamp, lastTimestamp] = timeframe;
|
|
30
|
+
const xStart = chartModel.candleFromTimestamp(firstTimestamp).startUnit;
|
|
31
|
+
const xEnd = chartModel.candleFromTimestamp(lastTimestamp).startUnit;
|
|
32
|
+
const additionalAnimationWidth = zoomIn === null ? 0 : chartModel.mainCandleSeries.meanCandleWidth * 2;
|
|
33
|
+
const animationEffectXStart = zoomIn ? xStart - additionalAnimationWidth : xStart + additionalAnimationWidth;
|
|
34
|
+
const animationEffectXEnd = zoomIn ? xEnd + additionalAnimationWidth : xEnd - additionalAnimationWidth;
|
|
35
|
+
scale.setXScale(animationEffectXStart, animationEffectXEnd);
|
|
36
|
+
};
|
|
@@ -3,4 +3,18 @@
|
|
|
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{hollowDirection
|
|
6
|
+
import { hollowDirection, nameDirection } from '../../model/candle.model';
|
|
7
|
+
import VisualCandle from '../../model/visual-candle';
|
|
8
|
+
export const defaultCandleTransformer = (candle, { x, width, activeCandle }) => new VisualCandle(x, width, candle.open, candle.close, candle.hi, candle.lo, nameDirection(candle.open, candle.close), candle, true, getCandleIsActive(candle, activeCandle));
|
|
9
|
+
export const hollowCandleTransformer = (candle, { x, width, activeCandle, prevCandle }) => {
|
|
10
|
+
var _a;
|
|
11
|
+
return new VisualCandle(x, width, candle.open, candle.close, candle.hi, candle.lo, hollowDirection((_a = prevCandle === null || prevCandle === void 0 ? void 0 : prevCandle.close) !== null && _a !== void 0 ? _a : candle.close, candle.close), candle, true, getCandleIsActive(candle, activeCandle), candle.close > candle.open);
|
|
12
|
+
};
|
|
13
|
+
export const trendCandleTransformer = (candle, { x, width, activeCandle, prevCandle }) => {
|
|
14
|
+
var _a;
|
|
15
|
+
return new VisualCandle(x, width, candle.open, candle.close, candle.hi, candle.lo, nameDirection((_a = prevCandle === null || prevCandle === void 0 ? void 0 : prevCandle.close) !== null && _a !== void 0 ? _a : candle.close, candle.close), candle, true, getCandleIsActive(candle, activeCandle), candle.close > candle.open);
|
|
16
|
+
};
|
|
17
|
+
export const getCandleIsActive = (candle, activeCandle) => {
|
|
18
|
+
const isActive = activeCandle && activeCandle.idx === candle.idx;
|
|
19
|
+
return isActive !== null && isActive !== void 0 ? isActive : false;
|
|
20
|
+
};
|
|
@@ -3,4 +3,5 @@
|
|
|
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{BASIC_CANDLE_WIDTH
|
|
6
|
+
import { BASIC_CANDLE_WIDTH } from '../../model/candle.model';
|
|
7
|
+
export const calculateCandleWidth = () => BASIC_CANDLE_WIDTH;
|
|
@@ -3,4 +3,47 @@
|
|
|
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{finite
|
|
6
|
+
import { finite } from '../../utils/math.utils';
|
|
7
|
+
/**
|
|
8
|
+
* In the early days of Futures contract there is no much trading,
|
|
9
|
+
* so there is not enough information to build a candle: only Open/Close value available.
|
|
10
|
+
* In this case Daily candle, which we receive, must be completed to full OHLC with equal values.
|
|
11
|
+
*/
|
|
12
|
+
export const prepareCandle = (candle) => {
|
|
13
|
+
var _a;
|
|
14
|
+
const settlementPrice = finite(candle.close, candle.open, candle.hi, candle.lo);
|
|
15
|
+
if (!isFinite(settlementPrice)) {
|
|
16
|
+
throw new Error('Received candle without any price');
|
|
17
|
+
}
|
|
18
|
+
// @ts-ignore
|
|
19
|
+
const preparedCandleHi = finite(candle.hi, Math.max(candle.open, candle.close), settlementPrice);
|
|
20
|
+
// @ts-ignore
|
|
21
|
+
const preparedCandleLo = finite(candle.lo, Math.min(candle.open, candle.close), settlementPrice);
|
|
22
|
+
const preparedCandleOpen = finite(candle.open, candle.lo, settlementPrice);
|
|
23
|
+
const preparedCandleClose = finite(candle.close, candle.hi, settlementPrice);
|
|
24
|
+
return {
|
|
25
|
+
hi: preparedCandleHi,
|
|
26
|
+
lo: preparedCandleLo,
|
|
27
|
+
open: preparedCandleOpen,
|
|
28
|
+
close: preparedCandleClose,
|
|
29
|
+
timestamp: candle.timestamp,
|
|
30
|
+
volume: (_a = candle.volume) !== null && _a !== void 0 ? _a : 0,
|
|
31
|
+
expansion: candle.expansion,
|
|
32
|
+
idx: candle.idx,
|
|
33
|
+
impVolatility: candle.impVolatility,
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
/**
|
|
37
|
+
* Adds index to candles according to their array index.
|
|
38
|
+
* @param candles
|
|
39
|
+
*/
|
|
40
|
+
export const reindexCandles = (candles) => {
|
|
41
|
+
for (let i = 0; i < candles.length; ++i) {
|
|
42
|
+
candles[i].idx = i;
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
export const deleteCandlesIndex = (candles) => {
|
|
46
|
+
candles.forEach(candle => {
|
|
47
|
+
candle.idx = undefined;
|
|
48
|
+
});
|
|
49
|
+
};
|
|
@@ -39,7 +39,7 @@ export interface ChartWheelEvent {
|
|
|
39
39
|
export declare class ChartAreaPanHandler extends ChartBaseElement {
|
|
40
40
|
private bus;
|
|
41
41
|
private config;
|
|
42
|
-
private
|
|
42
|
+
private scale;
|
|
43
43
|
private mainCanvasParent;
|
|
44
44
|
private canvasInputListener;
|
|
45
45
|
private canvasBoundsContainer;
|
|
@@ -50,7 +50,7 @@ export declare class ChartAreaPanHandler extends ChartBaseElement {
|
|
|
50
50
|
xDraggedCandlesDelta: number;
|
|
51
51
|
lastXStart: number;
|
|
52
52
|
wheelTrottleTime: number;
|
|
53
|
-
constructor(bus: EventBus, config: FullChartConfig,
|
|
53
|
+
constructor(bus: EventBus, config: FullChartConfig, scale: ScaleModel, mainCanvasParent: Element, canvasInputListener: CanvasInputListenerComponent, canvasBoundsContainer: CanvasBoundsContainer, canvasAnimation: CanvasAnimation, chartPanComponent: ChartPanComponent);
|
|
54
54
|
/**
|
|
55
55
|
* It observes the wheel event on all panes of the canvas and throttles it to the specified time.
|
|
56
56
|
* It then calculates the zoom sensitivity based on whether the event was triggered by a touchpad or not.
|
|
@@ -74,7 +74,7 @@ export declare class ChartAreaPanHandler extends ChartBaseElement {
|
|
|
74
74
|
* @param {HitBoundsTest} hitTest - The hit test of the pane.
|
|
75
75
|
* @returns {DragNDropYComponent} - The drag and drop component for panning the chart along the Y-axis.
|
|
76
76
|
*/
|
|
77
|
-
registerChartYPanHandler(
|
|
77
|
+
registerChartYPanHandler(scale: ScaleModel, hitTest: HitBoundsTest): DragNDropYComponent;
|
|
78
78
|
private onXDragStart;
|
|
79
79
|
private onXDragTick;
|
|
80
80
|
}
|
|
@@ -3,4 +3,200 @@
|
|
|
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 { merge } from 'rxjs';
|
|
7
|
+
import { throttleTime } from 'rxjs/operators';
|
|
8
|
+
import { VIEWPORT_ANIMATION_ID } from '../../animation/canvas-animation';
|
|
9
|
+
import { CanvasElement } from '../../canvas/canvas-bounds-container';
|
|
10
|
+
import { MainCanvasTouchHandler } from '../../inputhandlers/main-canvas-touch.handler';
|
|
11
|
+
import { ChartBaseElement } from '../../model/chart-base-element';
|
|
12
|
+
import { pixelsToUnits } from '../../model/scaling/viewport.model';
|
|
13
|
+
import { deviceDetector } from '../../utils/device/device-detector.utils';
|
|
14
|
+
import { getTouchpadSensitivity, touchpadDetector } from '../../utils/device/touchpad.utils';
|
|
15
|
+
import { DragNDropXComponent } from '../dran-n-drop_helper/drag-n-drop-x.component';
|
|
16
|
+
import { DragNDropYComponent } from '../dran-n-drop_helper/drag-n-drop-y.component';
|
|
17
|
+
/**
|
|
18
|
+
* ChartAreaPanHandler is a class that handles the panning and zooming of the chart area.
|
|
19
|
+
* It extends the ChartBaseElement class and has the following properties:
|
|
20
|
+
* @property {MainCanvasTouchHandler} touchHandler - An instance of the MainCanvasTouchHandler class.
|
|
21
|
+
* @property {Point} currentPoint - An object that represents the current point of the chart area.
|
|
22
|
+
* @property {number} xDraggedCandlesDelta - A number that represents the number of candles delta changed during X dragging.
|
|
23
|
+
* @property {number} lastXStart - A number that represents the last X start position.
|
|
24
|
+
* @property {number} lastYStart - A number that represents the last Y start position.
|
|
25
|
+
* @property {number} wheelTrottleTime - A number that represents the time in ms for the wheel throttle.
|
|
26
|
+
* @constructor
|
|
27
|
+
* @param {EventBus} bus - An instance of the EventBus class.
|
|
28
|
+
* @param {FullChartConfig} config - An instance of the FullChartConfig class.
|
|
29
|
+
* @param {ScaleModel} scaleModel - An instance of the ScaleModel class.
|
|
30
|
+
* @param {Element} mainCanvasParent - The parent element of the main canvas.
|
|
31
|
+
* @param {CanvasInputListenerComponent} canvasInputListener - An instance of the CanvasInputListenerComponent class.
|
|
32
|
+
* @param {CanvasBoundsContainer} canvasBoundsContainer - An instance of the CanvasBoundsContainer class.
|
|
33
|
+
* @param {CanvasAnimation} canvasAnimation - An instance of the CanvasAnimation class.
|
|
34
|
+
* @param {ChartPanComponent} chartPanComponent - An instance of the ChartPanComponent class.
|
|
35
|
+
|
|
36
|
+
*/
|
|
37
|
+
export class ChartAreaPanHandler extends ChartBaseElement {
|
|
38
|
+
constructor(bus, config, scale, mainCanvasParent, canvasInputListener, canvasBoundsContainer, canvasAnimation, chartPanComponent) {
|
|
39
|
+
super();
|
|
40
|
+
this.bus = bus;
|
|
41
|
+
this.config = config;
|
|
42
|
+
this.scale = scale;
|
|
43
|
+
this.mainCanvasParent = mainCanvasParent;
|
|
44
|
+
this.canvasInputListener = canvasInputListener;
|
|
45
|
+
this.canvasBoundsContainer = canvasBoundsContainer;
|
|
46
|
+
this.canvasAnimation = canvasAnimation;
|
|
47
|
+
this.chartPanComponent = chartPanComponent;
|
|
48
|
+
this.currentPoint = { x: 0, y: 0 };
|
|
49
|
+
// number of candles delta changed during X dragging: 1, 5 or -3 for ex.
|
|
50
|
+
this.xDraggedCandlesDelta = 0;
|
|
51
|
+
this.lastXStart = 0;
|
|
52
|
+
this.wheelTrottleTime = 15; // in ms
|
|
53
|
+
/**
|
|
54
|
+
* It observes the wheel event on all panes of the canvas and throttles it to the specified time.
|
|
55
|
+
* It then calculates the zoom sensitivity based on whether the event was triggered by a touchpad or not.
|
|
56
|
+
* If the zoomToCursor configuration is set to true, it calculates the viewport percentage based on the zoomCanvasOffset and canvas width.
|
|
57
|
+
* It then calls the zoomXToPercent method of the scaleModel to zoom in or out based on the zoomIn parameter.
|
|
58
|
+
* If the zoomToCursor configuration is set to false, it calls the zoomXToEnd method of the scaleModel to zoom in or out based on the zoomIn parameter.
|
|
59
|
+
* Finally, it fires the draw event of the bus to redraw the canvas.
|
|
60
|
+
* @param {WheelEvent} e - Wheel event
|
|
61
|
+
* @returns {void}
|
|
62
|
+
*/
|
|
63
|
+
this.zoomXHandler = (e) => {
|
|
64
|
+
const isTouchpad = touchpadDetector(e);
|
|
65
|
+
const zoomIn = e.deltaY < 0;
|
|
66
|
+
const zoomSensitivity = isTouchpad ? getTouchpadSensitivity(this.config) : this.config.scale.zoomSensitivity;
|
|
67
|
+
if (this.config.scale.zoomToCursor) {
|
|
68
|
+
const b = this.canvasBoundsContainer.getBounds(CanvasElement.CANVAS);
|
|
69
|
+
const canvasW = b.width;
|
|
70
|
+
const zoomCanvasOffset = e.offsetX;
|
|
71
|
+
// 0.5 - zoom middle exactly
|
|
72
|
+
// 0..0.5 - zoom to left side
|
|
73
|
+
// 0.5..1 - zoom to right side
|
|
74
|
+
const viewportPercent = zoomCanvasOffset / canvasW;
|
|
75
|
+
this.scale.zoomXToPercent(viewportPercent, zoomIn, false, zoomSensitivity);
|
|
76
|
+
}
|
|
77
|
+
else {
|
|
78
|
+
this.scale.zoomXToEnd(zoomIn, zoomSensitivity);
|
|
79
|
+
}
|
|
80
|
+
this.bus.fireDraw();
|
|
81
|
+
};
|
|
82
|
+
this.onXDragStart = () => {
|
|
83
|
+
this.canvasAnimation.forceStopAnimation(VIEWPORT_ANIMATION_ID);
|
|
84
|
+
this.xDraggedCandlesDelta = 0;
|
|
85
|
+
this.lastXStart = this.scale.xStart;
|
|
86
|
+
};
|
|
87
|
+
this.onXDragTick = (dragInfo) => {
|
|
88
|
+
const { delta: absoluteXDelta } = dragInfo;
|
|
89
|
+
this.currentPoint.x = absoluteXDelta;
|
|
90
|
+
const unitsDelta = pixelsToUnits(absoluteXDelta, this.scale.zoomX);
|
|
91
|
+
this.scale.moveXStart(this.lastXStart - unitsDelta);
|
|
92
|
+
this.bus.fireDraw();
|
|
93
|
+
};
|
|
94
|
+
this.touchHandler = new MainCanvasTouchHandler(this.scale, this.canvasInputListener, this.mainCanvasParent);
|
|
95
|
+
const allPanesHitTest = this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.ALL_PANES);
|
|
96
|
+
//#region drag-n-drop logic
|
|
97
|
+
const dragNDropXComponent = new DragNDropXComponent(allPanesHitTest, {
|
|
98
|
+
onDragStart: this.onXDragStart,
|
|
99
|
+
onDragTick: this.onXDragTick,
|
|
100
|
+
}, this.canvasInputListener, this.chartPanComponent, {
|
|
101
|
+
disableChartPanning: false,
|
|
102
|
+
});
|
|
103
|
+
this.addChildEntity(dragNDropXComponent);
|
|
104
|
+
//#endregion
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* This method is used to activate the zoom functionality of the canvas. It extends the doActivate method of the parent class.
|
|
108
|
+
* @protected
|
|
109
|
+
* @returns {void}
|
|
110
|
+
*/
|
|
111
|
+
doActivate() {
|
|
112
|
+
super.doActivate();
|
|
113
|
+
//#region hit tests
|
|
114
|
+
const allPanesHitTest = this.canvasBoundsContainer.getBoundsHitTest(CanvasElement.ALL_PANES);
|
|
115
|
+
//#endregion
|
|
116
|
+
this.addRxSubscription(merge(this.canvasInputListener.observeWheel(allPanesHitTest), this.canvasInputListener.observePinch(allPanesHitTest))
|
|
117
|
+
.pipe(throttleTime(this.wheelTrottleTime, undefined, { trailing: true, leading: true }))
|
|
118
|
+
.subscribe(this.zoomXHandler));
|
|
119
|
+
this.addRxSubscription(this.canvasInputListener
|
|
120
|
+
.observeScrollGesture()
|
|
121
|
+
.pipe(throttleTime(this.wheelTrottleTime, undefined, { trailing: true, leading: true }))
|
|
122
|
+
.subscribe((e) => {
|
|
123
|
+
let direction = -1;
|
|
124
|
+
const device = deviceDetector();
|
|
125
|
+
if (device === 'apple' || device === 'mobile') {
|
|
126
|
+
direction = 1;
|
|
127
|
+
}
|
|
128
|
+
let deltaX = 0;
|
|
129
|
+
let deltaY = 0;
|
|
130
|
+
deltaX += e.deltaX * direction;
|
|
131
|
+
deltaY += e.deltaY * -direction;
|
|
132
|
+
if (deltaX !== 0 && Math.abs(deltaX) > Math.abs(deltaY)) {
|
|
133
|
+
const unitsDelta = pixelsToUnits(deltaX, this.scale.zoomX);
|
|
134
|
+
this.scale.moveXStart(this.scale.xStart - unitsDelta);
|
|
135
|
+
}
|
|
136
|
+
else if (deltaY !== 0 && Math.abs(deltaY) > Math.abs(deltaX)) {
|
|
137
|
+
this.zoomXHandler(e);
|
|
138
|
+
}
|
|
139
|
+
this.bus.fireDraw();
|
|
140
|
+
}));
|
|
141
|
+
this.addRxSubscription(this.chartPanComponent.chartBaseModel.dataPrependSubject
|
|
142
|
+
.asObservable()
|
|
143
|
+
.subscribe(({ prependedCandlesWidth }) => {
|
|
144
|
+
this.lastXStart += prependedCandlesWidth;
|
|
145
|
+
}));
|
|
146
|
+
this.touchHandler.activate();
|
|
147
|
+
this.addSubscription(this.touchHandler.deactivate.bind(this.touchHandler));
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* Registers a handler for panning the chart along the Y-axis.
|
|
151
|
+
* @param {ScaleModel} scaleModel - The scale model of the extent.
|
|
152
|
+
* @param {HitBoundsTest} hitTest - The hit test of the pane.
|
|
153
|
+
* @returns {DragNDropYComponent} - The drag and drop component for panning the chart along the Y-axis.
|
|
154
|
+
*/
|
|
155
|
+
registerChartYPanHandler(scale, hitTest) {
|
|
156
|
+
// we can have multiple extents which can have different yStarts, so we need to store last yStart for each extent
|
|
157
|
+
let lastYStart = scale.yStart;
|
|
158
|
+
// disable all pan handlers when hover data series
|
|
159
|
+
const onYDragStart = () => {
|
|
160
|
+
this.canvasAnimation.forceStopAnimation(VIEWPORT_ANIMATION_ID);
|
|
161
|
+
this.currentPoint = { x: 0, y: 0 };
|
|
162
|
+
lastYStart = scale.yStart;
|
|
163
|
+
};
|
|
164
|
+
const onYDragTick = (dragInfo) => {
|
|
165
|
+
const { delta: absoluteDelta } = dragInfo;
|
|
166
|
+
this.currentPoint.y = absoluteDelta;
|
|
167
|
+
if (scale.state.auto) {
|
|
168
|
+
if (shouldDisableAutoScale(this.currentPoint, scale.state.autoScaleDisableOnDrag)) {
|
|
169
|
+
scale.autoScale(false);
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
else {
|
|
173
|
+
const unitsDelta = pixelsToUnits(scale.state.inverse ? -absoluteDelta : absoluteDelta, scale.zoomY);
|
|
174
|
+
scale.moveYStart(lastYStart + unitsDelta);
|
|
175
|
+
}
|
|
176
|
+
};
|
|
177
|
+
const dragNDropYComponent = new DragNDropYComponent(hitTest, {
|
|
178
|
+
onDragTick: onYDragTick,
|
|
179
|
+
onDragStart: onYDragStart,
|
|
180
|
+
}, this.canvasInputListener, this.chartPanComponent, {
|
|
181
|
+
disableChartPanning: false,
|
|
182
|
+
});
|
|
183
|
+
this.addChildEntity(dragNDropYComponent);
|
|
184
|
+
return dragNDropYComponent;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* This function calculates angle between current point and point(0, 0), and compares the result with config values
|
|
189
|
+
* @param point
|
|
190
|
+
* @param config
|
|
191
|
+
*
|
|
192
|
+
* @doc-tags chart-core,auto-scale,y-axis
|
|
193
|
+
*/
|
|
194
|
+
export const shouldDisableAutoScale = (point, config) => {
|
|
195
|
+
if (!config.enabled) {
|
|
196
|
+
return false;
|
|
197
|
+
}
|
|
198
|
+
const absY = Math.abs(point.y);
|
|
199
|
+
const lenProduct = Math.pow((Math.pow(Math.abs(point.x), 2) + Math.pow(absY, 2)), 0.5);
|
|
200
|
+
const angle = Math.abs(Math.acos(absY / lenProduct));
|
|
201
|
+
return absY > config.yDiff && angle < config.edgeAngle;
|
|
202
|
+
};
|
|
@@ -3,4 +3,69 @@
|
|
|
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 { autoDetectPeriod } from '../../utils/auto-period-detector.utils';
|
|
8
|
+
import { searchCandleIndex } from '../../utils/candles.utils';
|
|
9
|
+
import { fakeVisualCandle, fakeVisualPoint } from './fake-candles';
|
|
10
|
+
/**
|
|
11
|
+
* This model is an abstraction which describes manipulations tied to the main data series.
|
|
12
|
+
* For example, all x-scale is based on the main data series. If we add a new data series, we need to match its coordinates to the main data series.
|
|
13
|
+
*/
|
|
14
|
+
export class ChartBaseModel {
|
|
15
|
+
constructor(type) {
|
|
16
|
+
this.type = type;
|
|
17
|
+
this.mainDataPoints = [];
|
|
18
|
+
this.mainVisualPoints = [];
|
|
19
|
+
this.dataUpdatedSubject = new Subject();
|
|
20
|
+
this.dataSetSubject = new Subject();
|
|
21
|
+
this.dataRemovedSubject = new Subject();
|
|
22
|
+
this.dataPrependSubject = new Subject();
|
|
23
|
+
/**
|
|
24
|
+
* Mean data point width in abstract units.
|
|
25
|
+
*/
|
|
26
|
+
this.meanDataWidth = 1;
|
|
27
|
+
/**
|
|
28
|
+
* Candles aggregation period in ms. Required for future candles calculation.
|
|
29
|
+
*/
|
|
30
|
+
this.period = 1;
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* For given timestamp finds the closest candle in dataset.
|
|
34
|
+
* @param timestamp
|
|
35
|
+
*/
|
|
36
|
+
// TODO think how to make this function like candleFromX
|
|
37
|
+
dataFromTimestamp(timestamp, shouldExtrapolate = true) {
|
|
38
|
+
const result = searchCandleIndex(timestamp, shouldExtrapolate, this.mainDataPoints, this.period);
|
|
39
|
+
return this.dataFromIdx(result.index);
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Recalculates the period of the main candle series based on the data points.
|
|
43
|
+
* If a period is detected, it is set as the new period.
|
|
44
|
+
*/
|
|
45
|
+
recalculatePeriod() {
|
|
46
|
+
const naivePeriod = autoDetectPeriod(this.mainDataPoints);
|
|
47
|
+
if (naivePeriod) {
|
|
48
|
+
this.period = naivePeriod;
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* For given index returns the closest visual candle, or fake candle with correct X coordinate.
|
|
53
|
+
* @param idx - index of candle
|
|
54
|
+
*/
|
|
55
|
+
dataFromIdx(idx) {
|
|
56
|
+
const vc = this.mainVisualPoints[idx];
|
|
57
|
+
if (vc) {
|
|
58
|
+
return vc;
|
|
59
|
+
}
|
|
60
|
+
// TODO think maybe to create fake candles in advance, maybe this will improve performance
|
|
61
|
+
if (this.type === 'candle') {
|
|
62
|
+
// TODO how to correctly infer type?
|
|
63
|
+
// @ts-ignore
|
|
64
|
+
return fakeVisualCandle(this.mainDataPoints, this.mainVisualPoints, this.meanDataWidth, idx, this.period);
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
// @ts-ignore
|
|
68
|
+
return fakeVisualPoint(this.mainDataPoints, this.mainVisualPoints, this.meanDataWidth, idx, this.period);
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
@@ -23,6 +23,7 @@ import { ChartPanComponent } from '../pan/chart-pan.component';
|
|
|
23
23
|
import { PaneManager } from '../pane/pane-manager.component';
|
|
24
24
|
import { CandleWidthCalculator, ChartModel, LastCandleLabelHandler, VisualCandleCalculator } from './chart.model';
|
|
25
25
|
import { PrependedCandlesData } from './chart-base.model';
|
|
26
|
+
import { DynamicObjectsComponent } from '../dynamic-objects/dynamic-objects.component';
|
|
26
27
|
/**
|
|
27
28
|
* Represents a financial instrument to be displayed on a chart
|
|
28
29
|
* @class
|
|
@@ -51,16 +52,18 @@ export declare class ChartComponent extends ChartBaseElement {
|
|
|
51
52
|
readonly chartModel: ChartModel;
|
|
52
53
|
canvasModel: CanvasModel;
|
|
53
54
|
private config;
|
|
54
|
-
private
|
|
55
|
+
private scale;
|
|
55
56
|
private canvasBoundsContainer;
|
|
56
57
|
private drawingManager;
|
|
57
58
|
private hitTestCanvasModel;
|
|
58
59
|
private canvasInputListener;
|
|
60
|
+
private paneManager;
|
|
61
|
+
private dynamicObjects;
|
|
59
62
|
readonly baselineModel: BaselineModel;
|
|
60
63
|
private readonly backgroundDrawer;
|
|
61
|
-
private readonly
|
|
64
|
+
private readonly _dataSeriesDrawers;
|
|
62
65
|
private readonly dataSeriesDrawer;
|
|
63
|
-
constructor(chartModel: ChartModel, canvasModel: CanvasModel, config: FullChartConfig,
|
|
66
|
+
constructor(chartModel: ChartModel, canvasModel: CanvasModel, config: FullChartConfig, scale: ScaleModel, canvasBoundsContainer: CanvasBoundsContainer, drawingManager: DrawingManager, hitTestCanvasModel: HitTestCanvasModel, canvasInputListener: CanvasInputListenerComponent, backgroundCanvasModel: CanvasModel, chartPanComponent: ChartPanComponent, paneManager: PaneManager, cursorHandler: CursorHandler, dynamicObjects: DynamicObjectsComponent);
|
|
64
67
|
/**
|
|
65
68
|
* This method overrides the doActivate method of the parent class and calls it.
|
|
66
69
|
* It does not take any parameters and does not return anything.
|
|
@@ -76,6 +79,7 @@ export declare class ChartComponent extends ChartBaseElement {
|
|
|
76
79
|
*/
|
|
77
80
|
private registerDefaultCandlesTransformers;
|
|
78
81
|
get barTypeValues(): Array<BarType>;
|
|
82
|
+
get dataSeriesDrawers(): Record<string, SeriesDrawer>;
|
|
79
83
|
strToBarType: (str: string) => BarType;
|
|
80
84
|
/**
|
|
81
85
|
* You can use this method to determine logic of visual candle transformation for specified chart type.
|