@devexperts/dxcharts-lite 1.0.2 → 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 +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.js +55 -1
- package/dist/chart/components/pane/pane-manager.component.d.ts +10 -5
- package/dist/chart/components/pane/pane-manager.component.js +148 -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.js +95 -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 +9 -17
- package/dist/chart/components/y_axis/y-axis.model.js +33 -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 +2 -1
- package/dist/chart/model/scale.model.js +316 -1
- package/dist/chart/model/scaling/auto-scale.model.js +97 -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
|
@@ -3,4 +3,231 @@
|
|
|
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
|
+
* The minimum supported canvas size in chart-core (in pixels).
|
|
8
|
+
* Any size of <canvas> element below these dimensions will not be rendered (is NOT INTENDED to be rendered).
|
|
9
|
+
* @doc-tags chart-core,canvas
|
|
10
|
+
*/
|
|
11
|
+
export const MIN_SUPPORTED_CANVAS_SIZE = {
|
|
12
|
+
width: 20,
|
|
13
|
+
height: 20,
|
|
14
|
+
};
|
|
15
|
+
export class CanvasModel {
|
|
16
|
+
constructor(eventBus, canvas, drawingManager, canvasModels, resizer, options = {}) {
|
|
17
|
+
var _a;
|
|
18
|
+
this.eventBus = eventBus;
|
|
19
|
+
this.canvas = canvas;
|
|
20
|
+
this.drawingManager = drawingManager;
|
|
21
|
+
this.resizer = resizer;
|
|
22
|
+
this.width = 0;
|
|
23
|
+
this.height = 0;
|
|
24
|
+
this.prevHeight = 0;
|
|
25
|
+
this.prevWidth = 0;
|
|
26
|
+
this.type = CANDLE_TYPE;
|
|
27
|
+
canvasModels.push(this);
|
|
28
|
+
this.parent = findHeightParent(canvas);
|
|
29
|
+
const ctx = canvas.getContext('2d', options);
|
|
30
|
+
if (ctx === null) {
|
|
31
|
+
throw new Error("Couldn't get 2d context????");
|
|
32
|
+
}
|
|
33
|
+
this.context = ctx;
|
|
34
|
+
this._canvasId = (_a = canvas.getAttribute('data-element')) !== null && _a !== void 0 ? _a : '';
|
|
35
|
+
this.updateCanvasWidthHeight(canvas, this.getChartResizerElement().getBoundingClientRect());
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* About rendering for non-integer dpi
|
|
39
|
+
* https://stackoverflow.com/questions/17553557/draw-crisp-lines-on-html5-canvas-with-browser-zoom
|
|
40
|
+
* @param bcr
|
|
41
|
+
*/
|
|
42
|
+
updateDPR(bcr) {
|
|
43
|
+
const { width, height } = bcr;
|
|
44
|
+
const dpi = window.devicePixelRatio;
|
|
45
|
+
this.canvas.style.height = height + 'px';
|
|
46
|
+
this.canvas.style.width = width + 'px';
|
|
47
|
+
this.canvas.width = width * dpi;
|
|
48
|
+
this.canvas.height = height * dpi;
|
|
49
|
+
this.width = width;
|
|
50
|
+
this.height = height;
|
|
51
|
+
this.ctx.scale(dpi, dpi);
|
|
52
|
+
}
|
|
53
|
+
get canvasId() {
|
|
54
|
+
return this._canvasId;
|
|
55
|
+
}
|
|
56
|
+
get ctx() {
|
|
57
|
+
return this.context;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Clears the canvas by using the clearRect method of the canvas context.
|
|
61
|
+
* @function
|
|
62
|
+
* @name clear
|
|
63
|
+
* @memberof Canvas
|
|
64
|
+
* @returns {void}
|
|
65
|
+
*/
|
|
66
|
+
clear() {
|
|
67
|
+
this.context.clearRect(0, 0, this.width, this.height);
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Checks if the type is linked.
|
|
71
|
+
*
|
|
72
|
+
* @returns {boolean} Returns true if the type is linked, false otherwise.
|
|
73
|
+
*/
|
|
74
|
+
isLinked() {
|
|
75
|
+
var _a, _b;
|
|
76
|
+
return (_b = (_a = this.type) === null || _a === void 0 ? void 0 : _a.linked) !== null && _b !== void 0 ? _b : false;
|
|
77
|
+
}
|
|
78
|
+
/**
|
|
79
|
+
* Triggers the 'fireDraw' event on the event bus with the canvas ID as the parameter.
|
|
80
|
+
*/
|
|
81
|
+
fireDraw() {
|
|
82
|
+
this.eventBus.fireDraw([this.canvasId]);
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Updates the width and height of the canvas element based on the client width and height of the canvas element and the height of the chart resizer element.
|
|
86
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to update.
|
|
87
|
+
* @param {ClientRect | DOMRect} [bcr=this.getChartResizerElement().getBoundingClientRect()] - The bounding client rectangle of the chart resizer element.
|
|
88
|
+
* @returns {void}
|
|
89
|
+
*/
|
|
90
|
+
updateCanvasWidthHeight(canvas, bcr = this.getChartResizerElement().getBoundingClientRect()) {
|
|
91
|
+
if (canvas.clientWidth !== this.width) {
|
|
92
|
+
canvas.width = canvas.clientWidth;
|
|
93
|
+
this.width = canvas.clientWidth;
|
|
94
|
+
}
|
|
95
|
+
const height = bcr.height;
|
|
96
|
+
if (height !== this.height) {
|
|
97
|
+
canvas.style.height = height + 'px';
|
|
98
|
+
this.height = height;
|
|
99
|
+
canvas.height = height;
|
|
100
|
+
this.prevHeight = height;
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Returns the chart resizer element. If the resizer is not defined, it returns the parent element.
|
|
105
|
+
*
|
|
106
|
+
* @returns {HTMLElement} The chart resizer element.
|
|
107
|
+
*/
|
|
108
|
+
getChartResizerElement() {
|
|
109
|
+
var _a;
|
|
110
|
+
return (_a = this.resizer) !== null && _a !== void 0 ? _a : this.parent;
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Checks if the canvas is ready to be used by verifying if its width and height are greater than the minimum supported canvas size.
|
|
114
|
+
*
|
|
115
|
+
* @returns {boolean} - Returns true if the canvas is ready to be used, false otherwise.
|
|
116
|
+
*/
|
|
117
|
+
isReady() {
|
|
118
|
+
return this.width > MIN_SUPPORTED_CANVAS_SIZE.width && this.height > MIN_SUPPORTED_CANVAS_SIZE.height;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
const CANDLE_TYPE = {
|
|
122
|
+
name: 'candle',
|
|
123
|
+
};
|
|
124
|
+
const BAR_TYPE = {
|
|
125
|
+
name: 'candle',
|
|
126
|
+
};
|
|
127
|
+
const LINE_TYPE = {
|
|
128
|
+
name: 'line',
|
|
129
|
+
linked: true,
|
|
130
|
+
};
|
|
131
|
+
const AREA_TYPE = {
|
|
132
|
+
name: 'area',
|
|
133
|
+
linked: true,
|
|
134
|
+
};
|
|
135
|
+
const TYPES = {
|
|
136
|
+
candle: CANDLE_TYPE,
|
|
137
|
+
bar: BAR_TYPE,
|
|
138
|
+
line: LINE_TYPE,
|
|
139
|
+
area: AREA_TYPE,
|
|
140
|
+
};
|
|
141
|
+
/**
|
|
142
|
+
* Creates a new canvas model for the main chart canvas.
|
|
143
|
+
*
|
|
144
|
+
* @param {EventBus} eventBus - The event bus used to communicate between components.
|
|
145
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to create the model for.
|
|
146
|
+
* @param {HTMLElement} resizer - The element used to resize the canvas.
|
|
147
|
+
* @param {BarType} barType - The type of bar to use for the chart.
|
|
148
|
+
* @param {FullChartConfig} config - The configuration object for the chart.
|
|
149
|
+
* @param {DrawingManager} drawingManager - The drawing manager used to draw on the canvas.
|
|
150
|
+
* @param {CanvasModel[]} canvasModels - An array of canvas models to add the new model to.
|
|
151
|
+
*
|
|
152
|
+
* @returns {CanvasModel} The newly created canvas model.
|
|
153
|
+
|
|
154
|
+
export function createMainCanvasModel(
|
|
155
|
+
eventBus,
|
|
156
|
+
canvas,
|
|
157
|
+
resizer,
|
|
158
|
+
barType,
|
|
159
|
+
config,
|
|
160
|
+
drawingManager,
|
|
161
|
+
canvasModels,
|
|
162
|
+
) {
|
|
163
|
+
const canvasModel = createCanvasModel(eventBus, canvas, config, drawingManager, canvasModels, resizer);
|
|
164
|
+
// @ts-ignore
|
|
165
|
+
canvasModel.type = TYPES[barType] ?? CANDLE_TYPE;
|
|
166
|
+
return canvasModel;
|
|
167
|
+
}*/
|
|
168
|
+
export function createMainCanvasModel(eventBus, canvas, resizer, barType, config, drawingManager, canvasModels) {
|
|
169
|
+
var _a;
|
|
170
|
+
const canvasModel = createCanvasModel(eventBus, canvas, config, drawingManager, canvasModels, resizer);
|
|
171
|
+
// @ts-ignore
|
|
172
|
+
canvasModel.type = (_a = TYPES[barType]) !== null && _a !== void 0 ? _a : CANDLE_TYPE;
|
|
173
|
+
return canvasModel;
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Creates a new CanvasModel instance.
|
|
177
|
+
*
|
|
178
|
+
* @param {EventBus} eventBus - The event bus to use.
|
|
179
|
+
* @param {HTMLCanvasElement} canvas - The canvas element to use.
|
|
180
|
+
* @param {FullChartConfig} config - The configuration object for the chart.
|
|
181
|
+
* @param {DrawingManager} drawingManager - The drawing manager to use.
|
|
182
|
+
* @param {CanvasModel[]} canvasModels - An array of existing canvas models.
|
|
183
|
+
* @param {HTMLElement} [resizer] - The element to use for resizing the canvas.
|
|
184
|
+
*
|
|
185
|
+
* @returns {CanvasModel} A new instance of the CanvasModel class.
|
|
186
|
+
*/
|
|
187
|
+
export function createCanvasModel(eventBus, canvas, config, drawingManager, canvasModels, resizer, options) {
|
|
188
|
+
const canvasModel = new CanvasModel(eventBus, canvas, drawingManager, canvasModels, resizer, options);
|
|
189
|
+
initCanvasWithConfig(canvasModel, config);
|
|
190
|
+
return canvasModel;
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Initializes a canvas with a given configuration.
|
|
194
|
+
* @param {CanvasModel} canvasModel - The canvas model to be initialized.
|
|
195
|
+
* @param {FullChartConfig} config - The configuration object for the canvas.
|
|
196
|
+
* @returns {void}
|
|
197
|
+
|
|
198
|
+
*/
|
|
199
|
+
export function initCanvasWithConfig(canvasModel, config) {
|
|
200
|
+
const canvas = canvasModel.canvas;
|
|
201
|
+
if (config.fixedSize) {
|
|
202
|
+
canvas.width = config.fixedSize.width;
|
|
203
|
+
canvas.height = config.fixedSize.height;
|
|
204
|
+
canvas.style.width = config.fixedSize.width + 'px';
|
|
205
|
+
canvas.style.height = config.fixedSize.height + 'px';
|
|
206
|
+
canvasModel.width = config.fixedSize.width;
|
|
207
|
+
canvasModel.height = config.fixedSize.height;
|
|
208
|
+
}
|
|
209
|
+
canvas.style.position = 'absolute';
|
|
210
|
+
canvas.style.top = '0';
|
|
211
|
+
canvas.style.left = '0';
|
|
212
|
+
canvas.style.direction = 'ltr';
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Gets the first parent with "data-chart-container" attribute to compute height
|
|
216
|
+
*/
|
|
217
|
+
function findHeightParent(initial) {
|
|
218
|
+
let el = initial;
|
|
219
|
+
while (el) {
|
|
220
|
+
if (el.nodeType === 1 && el.hasAttribute('data-chart-container')) {
|
|
221
|
+
return el;
|
|
222
|
+
}
|
|
223
|
+
else {
|
|
224
|
+
if (el.parentElement !== null) {
|
|
225
|
+
el = el.parentElement;
|
|
226
|
+
}
|
|
227
|
+
else {
|
|
228
|
+
break;
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
}
|
|
232
|
+
return el;
|
|
233
|
+
}
|
|
@@ -3,4 +3,132 @@
|
|
|
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
|
+
* Base class for chart elements. Contains lifecycle support, utility methods.
|
|
8
|
+
*
|
|
9
|
+
* Chart entity state transition: INITIAL -> ACTIVE <-> DEACTIVATED -> DISPOSED
|
|
10
|
+
*/
|
|
11
|
+
export class ChartBaseElement {
|
|
12
|
+
constructor() {
|
|
13
|
+
this.subscriptions = [];
|
|
14
|
+
this._state = 'initial';
|
|
15
|
+
// substitute entities which cascade activate/deactivate
|
|
16
|
+
this.entities = [];
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* This method is used to activate a protected feature.
|
|
20
|
+
* It does not take any arguments and does not return anything.
|
|
21
|
+
*/
|
|
22
|
+
doActivate() { }
|
|
23
|
+
/**
|
|
24
|
+
* This method is used to unsubscribe from all events.
|
|
25
|
+
* It clears the subscriptions array.
|
|
26
|
+
* @returns {void}
|
|
27
|
+
*/
|
|
28
|
+
doDeactivate() {
|
|
29
|
+
// Unsubscribe from all events
|
|
30
|
+
this.subscriptions.forEach(unsub => unsub());
|
|
31
|
+
this.subscriptions = [];
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Enables the functionality of an object.
|
|
35
|
+
* If the object is not currently active, it sets the state to 'deactivated' and activates it.
|
|
36
|
+
* @returns {void}
|
|
37
|
+
*/
|
|
38
|
+
enable() {
|
|
39
|
+
if (this._state !== 'active') {
|
|
40
|
+
this._state = 'deactivated';
|
|
41
|
+
this.activate();
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Disables the current object if it is not already disabled.
|
|
46
|
+
* If the object is not disabled, it will be deactivated and its state will be set to 'disabled'.
|
|
47
|
+
* @returns {void}
|
|
48
|
+
*/
|
|
49
|
+
disable() {
|
|
50
|
+
if (this._state !== 'disabled') {
|
|
51
|
+
this.deactivate();
|
|
52
|
+
this._state = 'disabled';
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Activates the entity and all its child entities.
|
|
57
|
+
* If the entity is already active, it does nothing.
|
|
58
|
+
* If the entity is disabled, it does nothing.
|
|
59
|
+
* @returns {void}
|
|
60
|
+
*/
|
|
61
|
+
activate() {
|
|
62
|
+
if (this._state === 'disabled') {
|
|
63
|
+
return;
|
|
64
|
+
}
|
|
65
|
+
if (this._state !== 'active') {
|
|
66
|
+
this.doActivate();
|
|
67
|
+
this._state = 'active';
|
|
68
|
+
}
|
|
69
|
+
this.entities.forEach(comp => comp.activate());
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* Deactivates the entity and all its child entities.
|
|
73
|
+
* If the entity is already disabled, it does nothing.
|
|
74
|
+
* If the entity is not yet deactivated, it calls the doDeactivate method and sets the state to 'deactivated'.
|
|
75
|
+
* Finally, it deactivates all child entities.
|
|
76
|
+
* @returns {void}
|
|
77
|
+
*/
|
|
78
|
+
deactivate() {
|
|
79
|
+
if (this._state === 'disabled') {
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
if (this._state !== 'deactivated') {
|
|
83
|
+
this.doDeactivate();
|
|
84
|
+
this._state = 'deactivated';
|
|
85
|
+
}
|
|
86
|
+
this.entities.forEach(comp => comp.deactivate());
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Returns the current state of the ChartEnitity instance.
|
|
90
|
+
* @returns {ChartEntityState} The current state of the ChartEnitity instance.
|
|
91
|
+
*/
|
|
92
|
+
getState() {
|
|
93
|
+
return this._state;
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Adds default subscription
|
|
97
|
+
* @param fn - an unsubscriber function
|
|
98
|
+
* @protected
|
|
99
|
+
*/
|
|
100
|
+
addSubscription(fn) {
|
|
101
|
+
this.subscriptions.push(fn);
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Adds rxjs subscription
|
|
105
|
+
* @param subscription
|
|
106
|
+
* @protected
|
|
107
|
+
*/
|
|
108
|
+
addRxSubscription(subscription) {
|
|
109
|
+
if (subscription) {
|
|
110
|
+
this.subscriptions.push(subscription.unsubscribe.bind(subscription));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
/**
|
|
114
|
+
* Adds a new entity to the entities array and activates it if the parent entity is active.
|
|
115
|
+
*
|
|
116
|
+
* @param {Entity} entity - The entity to be added to the entities array.
|
|
117
|
+
* @returns {void}
|
|
118
|
+
*/
|
|
119
|
+
addChildEntity(entity) {
|
|
120
|
+
this.entities.push(entity);
|
|
121
|
+
if (this._state === 'active') {
|
|
122
|
+
entity.activate();
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
/**
|
|
126
|
+
* Removes a entity from the entities array.
|
|
127
|
+
*
|
|
128
|
+
* @param {ChartEntity} entity - The entity to be removed.
|
|
129
|
+
* @returns {void}
|
|
130
|
+
*/
|
|
131
|
+
removeChildEntity(entity) {
|
|
132
|
+
this.entities = this.entities.filter(c => c !== entity);
|
|
133
|
+
}
|
|
134
|
+
}
|
|
@@ -3,4 +3,28 @@
|
|
|
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 class CompareSeriesHoverProducerPart
|
|
6
|
+
export class CompareSeriesHoverProducerPart {
|
|
7
|
+
constructor(chartModel) {
|
|
8
|
+
this.chartModel = chartModel;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Returns an array of objects containing information about the series of candles at a specific x-coordinate.
|
|
12
|
+
* @param {BaseHover} hover - The hover object containing the x-coordinate.
|
|
13
|
+
* @returns {CompareSeriesHover[]} An array of objects containing the instrument symbol, price and id of each series of candles.
|
|
14
|
+
*/
|
|
15
|
+
getData(hover) {
|
|
16
|
+
const { x } = hover;
|
|
17
|
+
const candle = this.chartModel.candleFromX(x);
|
|
18
|
+
const idx = candle.idx || 0;
|
|
19
|
+
const compareSeriesHover = this.chartModel.candleSeries.map(series => {
|
|
20
|
+
const candleSecondary = series.dataPoints[idx];
|
|
21
|
+
const priceToShow = this.chartModel.pane.regularFormatter(candleSecondary === null || candleSecondary === void 0 ? void 0 : candleSecondary.close);
|
|
22
|
+
return {
|
|
23
|
+
instrument: series.instrument.symbol,
|
|
24
|
+
price: priceToShow,
|
|
25
|
+
id: series.id,
|
|
26
|
+
};
|
|
27
|
+
});
|
|
28
|
+
return compareSeriesHover;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
@@ -14,11 +14,11 @@ import { Index, Pixel, Price, Unit, Viewable } from './scaling/viewport.model';
|
|
|
14
14
|
*/
|
|
15
15
|
export declare class DataSeriesView implements Viewable {
|
|
16
16
|
private dataSeries;
|
|
17
|
-
private
|
|
17
|
+
private scale;
|
|
18
18
|
private getAxisType;
|
|
19
|
-
private
|
|
19
|
+
private getBaseline;
|
|
20
20
|
private percentAnimationHandler;
|
|
21
|
-
constructor(dataSeries: DataSeriesModel,
|
|
21
|
+
constructor(dataSeries: DataSeriesModel, scale: ScaleModel, getAxisType: () => PriceAxisType, getBaseline: (idx?: Index) => Unit);
|
|
22
22
|
/**
|
|
23
23
|
* Convert the input value to its corresponding y-pixel coordinate based on the selected price type and scale model.
|
|
24
24
|
* @param value - The value to be converted to y-pixel coordinate.
|
|
@@ -28,10 +28,10 @@ export declare class DataSeriesView implements Viewable {
|
|
|
28
28
|
/**
|
|
29
29
|
* Convert the input value to the corresponding unit based on the current axis type.
|
|
30
30
|
* @param value - The value to be converted to unit.
|
|
31
|
-
* @param
|
|
31
|
+
* @param getBaseline - A function that returns the baseline for percent.
|
|
32
32
|
* @returns - The converted value in the corresponding unit.
|
|
33
33
|
*/
|
|
34
|
-
toAxisUnits(value: Price,
|
|
34
|
+
toAxisUnits(value: Price, getBaseline?: (idx?: number | undefined) => number): Unit;
|
|
35
35
|
/**
|
|
36
36
|
* Convert the input unit to its corresponding x-pixel coordinate based on the scale model.
|
|
37
37
|
* @param unit - The unit to be converted to x-pixel coordinate.
|
|
@@ -3,4 +3,114 @@
|
|
|
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{binarySearch
|
|
6
|
+
import { binarySearch } from '../utils/array.utils';
|
|
7
|
+
import { calcLogValue, logValueToUnit, percentToUnit, unitToPercent, } from './scaling/viewport.model';
|
|
8
|
+
class PercentScaleAnimationHandler {
|
|
9
|
+
constructor(scale, dataSeries) {
|
|
10
|
+
this.scale = scale;
|
|
11
|
+
this.dataSeries = dataSeries;
|
|
12
|
+
this.prevAnimationId = '';
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* This logic calculates correct baseline helping avoid shaking during zoom animation
|
|
16
|
+
* @param getBaseline
|
|
17
|
+
* @returns
|
|
18
|
+
*/
|
|
19
|
+
getBaselineForPercent(getBaseline) {
|
|
20
|
+
const animation = this.scale.currentAnimation;
|
|
21
|
+
let baseline;
|
|
22
|
+
if (animation === null || animation === void 0 ? void 0 : animation.animationInProgress) {
|
|
23
|
+
if (animation.id !== this.prevAnimationId) {
|
|
24
|
+
this.initialBaseline = undefined;
|
|
25
|
+
this.targetBaseline = undefined;
|
|
26
|
+
this.prevAnimationId = animation.id;
|
|
27
|
+
}
|
|
28
|
+
const easedProgress = animation.easingFn(animation.getProgress());
|
|
29
|
+
if (this.initialBaseline === undefined) {
|
|
30
|
+
this.initialBaseline = getBaseline(binarySearch(this.dataSeries.visualPoints, animation.xStart, i => i.centerUnit).index);
|
|
31
|
+
}
|
|
32
|
+
if (this.targetBaseline === undefined) {
|
|
33
|
+
this.targetBaseline = getBaseline(binarySearch(this.dataSeries.visualPoints, animation.animationConfig.targetXStart, i => i.centerUnit).index);
|
|
34
|
+
}
|
|
35
|
+
baseline = this.initialBaseline + (this.targetBaseline - this.initialBaseline) * easedProgress;
|
|
36
|
+
}
|
|
37
|
+
else {
|
|
38
|
+
baseline = getBaseline();
|
|
39
|
+
}
|
|
40
|
+
return baseline;
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* A class representing a view for a data series chart.
|
|
45
|
+
* It contains methods to convert between price values and pixel coordinates using the selected scale model,
|
|
46
|
+
* as well as between price values and units based on the selected price type and axis type.
|
|
47
|
+
*/
|
|
48
|
+
export class DataSeriesView {
|
|
49
|
+
constructor(dataSeries, scale, getAxisType, getBaseline) {
|
|
50
|
+
this.dataSeries = dataSeries;
|
|
51
|
+
this.scale = scale;
|
|
52
|
+
this.getAxisType = getAxisType;
|
|
53
|
+
this.getBaseline = getBaseline;
|
|
54
|
+
/**
|
|
55
|
+
* Convert the input value to its corresponding y-pixel coordinate based on the selected price type and scale model.
|
|
56
|
+
* @param value - The value to be converted to y-pixel coordinate.
|
|
57
|
+
* @returns - The converted value in y-pixel coordinate.
|
|
58
|
+
*/
|
|
59
|
+
this.toY = (value) => {
|
|
60
|
+
return this.scale.toY(this.toAxisUnits(value));
|
|
61
|
+
};
|
|
62
|
+
/**
|
|
63
|
+
* Convert the input unit to its corresponding x-pixel coordinate based on the scale model.
|
|
64
|
+
* @param unit - The unit to be converted to x-pixel coordinate.
|
|
65
|
+
* @returns - The converted value in x-pixel coordinate.
|
|
66
|
+
*/
|
|
67
|
+
this.toX = (unit) => this.scale.toX(unit);
|
|
68
|
+
this.xPixels = (unit) => this.scale.xPixels(unit);
|
|
69
|
+
/**
|
|
70
|
+
* Pay attention! This method doesn't convert price to pixels, it converts only current axis UNITs!
|
|
71
|
+
* @param unit
|
|
72
|
+
*/
|
|
73
|
+
this.yPixels = (unit) => this.scale.yPixels(unit);
|
|
74
|
+
this.percentAnimationHandler = new PercentScaleAnimationHandler(this.scale, this.dataSeries);
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Convert the input value to the corresponding unit based on the current axis type.
|
|
78
|
+
* @param value - The value to be converted to unit.
|
|
79
|
+
* @param getBaseline - A function that returns the baseline for percent.
|
|
80
|
+
* @returns - The converted value in the corresponding unit.
|
|
81
|
+
*/
|
|
82
|
+
toAxisUnits(value, getBaseline = this.getBaseline) {
|
|
83
|
+
switch (this.getAxisType()) {
|
|
84
|
+
case 'percent':
|
|
85
|
+
const baseline = this.percentAnimationHandler.getBaselineForPercent(getBaseline);
|
|
86
|
+
return unitToPercent(value, baseline);
|
|
87
|
+
case 'logarithmic':
|
|
88
|
+
return calcLogValue(value);
|
|
89
|
+
case 'regular':
|
|
90
|
+
return value;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Converts "y" in pixels to price
|
|
95
|
+
* @param y - source value in pixels
|
|
96
|
+
*/
|
|
97
|
+
priceFromY(y) {
|
|
98
|
+
const unit = this.scale.fromY(y);
|
|
99
|
+
return this.fromAxisUnits(unit);
|
|
100
|
+
}
|
|
101
|
+
/**
|
|
102
|
+
* Convert the input unit to its corresponding price value based on the selected axis type.
|
|
103
|
+
* @param {number} unit - The unit to be converted to price value.
|
|
104
|
+
* @returns {number} - The converted value in price.
|
|
105
|
+
*/
|
|
106
|
+
fromAxisUnits(unit) {
|
|
107
|
+
switch (this.getAxisType()) {
|
|
108
|
+
case 'percent':
|
|
109
|
+
return percentToUnit(unit, this.getBaseline());
|
|
110
|
+
case 'logarithmic':
|
|
111
|
+
return logValueToUnit(unit);
|
|
112
|
+
case 'regular':
|
|
113
|
+
return unit;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
}
|
|
@@ -3,4 +3,17 @@
|
|
|
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 DEFAULT_DATA_SERIES_PAINT_CONFIG={
|
|
6
|
+
export const DEFAULT_DATA_SERIES_PAINT_CONFIG = {
|
|
7
|
+
color: '#FF00FF',
|
|
8
|
+
lineWidth: 1,
|
|
9
|
+
hoveredLineWidth: 2,
|
|
10
|
+
};
|
|
11
|
+
export const DEFAULT_DATA_SERIES_CONFIG = {
|
|
12
|
+
paintConfig: [DEFAULT_DATA_SERIES_PAINT_CONFIG],
|
|
13
|
+
type: 'LINEAR',
|
|
14
|
+
highLowActive: true,
|
|
15
|
+
visible: true,
|
|
16
|
+
labelLastValue: 'viewport',
|
|
17
|
+
labelMode: 'label',
|
|
18
|
+
labelAppearanceType: 'badge',
|
|
19
|
+
};
|
|
@@ -50,7 +50,7 @@ export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint
|
|
|
50
50
|
hovered: boolean;
|
|
51
51
|
yAxisLabelProvider: DataSeriesYAxisLabelsProvider;
|
|
52
52
|
readonly config: DataSeriesConfig;
|
|
53
|
-
|
|
53
|
+
scale: ScaleModel;
|
|
54
54
|
view: DataSeriesView;
|
|
55
55
|
protected _dataPoints: D[][];
|
|
56
56
|
pricePrecisions: number[];
|
|
@@ -112,8 +112,8 @@ export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint
|
|
|
112
112
|
* Recalculates the indexes of the start and end points of the data viewport,
|
|
113
113
|
* based on the current xStart and xEnd values of the scale model, or on the given xStart and xEnd parameters.
|
|
114
114
|
*
|
|
115
|
-
* @param {number} [xStart=this.
|
|
116
|
-
* @param {number} [xEnd=this.
|
|
115
|
+
* @param {number} [xStart=this.scale.xStart] - The start value of the viewport on the x-axis. Defaults to the current xStart value of the scale model.
|
|
116
|
+
* @param {number} [xEnd=this.scale.xEnd] - The end value of the viewport on the x-axis. Defaults to the current xEnd value of the scale model.
|
|
117
117
|
*/
|
|
118
118
|
recalculateDataViewportIndexes(xStart?: number, xEnd?: number): void;
|
|
119
119
|
/**
|
|
@@ -139,7 +139,7 @@ export declare class DataSeriesModel<D extends DataSeriesPoint = DataSeriesPoint
|
|
|
139
139
|
* @param {number} [idx=this.dataIdxStart] - The index of the visual point to retrieve the close value for.
|
|
140
140
|
* @returns {Unit} The close value of the visual point at the given index, or 1 if the visual point is not defined.
|
|
141
141
|
*/
|
|
142
|
-
|
|
142
|
+
getBaseline: (idx?: number) => Unit;
|
|
143
143
|
/**
|
|
144
144
|
* Returns the string representation of the close value of the given visual point.
|
|
145
145
|
*
|