@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,284 @@
|
|
|
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{DataSeriesYAxisLabelsProvider
|
|
6
|
+
import { DataSeriesYAxisLabelsProvider } from '../components/y_axis/price_labels/data-series-y-axis-labels.provider';
|
|
7
|
+
import { binarySearch, create2DArray, lastOf, slice2DArray } from '../utils/array.utils';
|
|
8
|
+
import { floorToDPR } from '../utils/device/device-pixel-ratio.utils';
|
|
9
|
+
import { MathUtils } from '../utils/math.utils';
|
|
10
|
+
import { merge } from '../utils/merge.utils';
|
|
11
|
+
import { cloneUnsafe } from '../utils/object.utils';
|
|
12
|
+
import { ChartBaseElement } from './chart-base-element';
|
|
13
|
+
import { DataSeriesView } from './data-series-view';
|
|
14
|
+
import { DEFAULT_DATA_SERIES_CONFIG, } from './data-series.config';
|
|
15
|
+
/**
|
|
16
|
+
* Properties are named in order to match VisualCandle interface
|
|
17
|
+
*/
|
|
18
|
+
export class VisualSeriesPoint {
|
|
19
|
+
constructor(centerUnit, close) {
|
|
20
|
+
this.centerUnit = centerUnit;
|
|
21
|
+
this.close = close;
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* returns y coordinate in pixels
|
|
25
|
+
*/
|
|
26
|
+
y(viewable) {
|
|
27
|
+
return floorToDPR(viewable.toY(this.close));
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* returns x coordinate in pixels
|
|
31
|
+
*/
|
|
32
|
+
x(viewable) {
|
|
33
|
+
return floorToDPR(viewable.toX(this.centerUnit));
|
|
34
|
+
}
|
|
35
|
+
clone() {
|
|
36
|
+
return new VisualSeriesPoint(this.centerUnit, this.close);
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* DataSeriesModel represents single time series chart.
|
|
41
|
+
* Usually data source is presented as a one-dimension array, but here it can be presented as two-dimension array
|
|
42
|
+
* If the data is presented as two-dim array when every data array will be drawn as a separate time-series
|
|
43
|
+
* For example, linear chart type will be drawn with gaps on the chart
|
|
44
|
+
*/
|
|
45
|
+
export class DataSeriesModel extends ChartBaseElement {
|
|
46
|
+
get dataPoints2D() {
|
|
47
|
+
return this._dataPoints;
|
|
48
|
+
}
|
|
49
|
+
get dataPoints() {
|
|
50
|
+
return this._dataPointsFlat;
|
|
51
|
+
}
|
|
52
|
+
set dataPoints(points) {
|
|
53
|
+
// createTwoDimArray here and below is needed to support two-dimension arrays
|
|
54
|
+
this._dataPoints = create2DArray(points);
|
|
55
|
+
this._dataPointsFlat = this._dataPoints.flat();
|
|
56
|
+
this.visualPoints = this._toVisualPoints(this._dataPoints);
|
|
57
|
+
}
|
|
58
|
+
get visualPoints() {
|
|
59
|
+
return this._visualPointsFlat;
|
|
60
|
+
}
|
|
61
|
+
get visualPoints2D() {
|
|
62
|
+
return this._visualPoints;
|
|
63
|
+
}
|
|
64
|
+
set visualPoints(points) {
|
|
65
|
+
this._visualPoints = create2DArray(points);
|
|
66
|
+
this._visualPointsFlat = this._visualPoints.flat();
|
|
67
|
+
}
|
|
68
|
+
constructor(extentComponent, id, _config = cloneUnsafe(DEFAULT_DATA_SERIES_CONFIG)) {
|
|
69
|
+
var _a;
|
|
70
|
+
super();
|
|
71
|
+
this.extentComponent = extentComponent;
|
|
72
|
+
this.id = id;
|
|
73
|
+
this.name = '';
|
|
74
|
+
this.hovered = false;
|
|
75
|
+
this._dataPoints = [];
|
|
76
|
+
this.pricePrecisions = [2];
|
|
77
|
+
/**
|
|
78
|
+
* Should be used for paint tools like rectangular drawing or diff cloud
|
|
79
|
+
*/
|
|
80
|
+
this.linkedDataSeriesModels = [];
|
|
81
|
+
this._dataPointsFlat = [];
|
|
82
|
+
this._visualPoints = [];
|
|
83
|
+
this._visualPointsFlat = [];
|
|
84
|
+
// start/end data index in viewport
|
|
85
|
+
this.dataIdxStart = 0;
|
|
86
|
+
this.dataIdxEnd = 0;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the paint configuration object for a specific series part, or the default paint configuration object
|
|
89
|
+
* if the specified series part is not defined in the current DataSeriesView configuration.
|
|
90
|
+
*
|
|
91
|
+
* @param {number} seriesPart - The index of the series part to get the paint configuration for.
|
|
92
|
+
* @returns {DataSeriesPaintConfig} The paint configuration object for the specified series part, or the default paint configuration object.
|
|
93
|
+
*/
|
|
94
|
+
this.getPaintConfig = (seriesPart) => {
|
|
95
|
+
var _a;
|
|
96
|
+
return (_a = this.config.paintConfig[seriesPart]) !== null && _a !== void 0 ? _a : this.config.paintConfig[0];
|
|
97
|
+
};
|
|
98
|
+
/**
|
|
99
|
+
* Returns the close value of the visual point at the given index, or 1 if the visual point is not defined.
|
|
100
|
+
* The index defaults to the data index start of the DataSeriesView.
|
|
101
|
+
*
|
|
102
|
+
* @param {number} [idx=this.dataIdxStart] - The index of the visual point to retrieve the close value for.
|
|
103
|
+
* @returns {Unit} The close value of the visual point at the given index, or 1 if the visual point is not defined.
|
|
104
|
+
*/
|
|
105
|
+
this.getBaseline = (idx = this.dataIdxStart) => { var _a, _b; return (_b = (_a = this.visualPoints[idx]) === null || _a === void 0 ? void 0 : _a.close) !== null && _b !== void 0 ? _b : 1; };
|
|
106
|
+
/**
|
|
107
|
+
* Returns the string representation of the close value of the given visual point.
|
|
108
|
+
*
|
|
109
|
+
* @param {VisualSeriesPoint} point - The visual point to get the string representation of the close value for.
|
|
110
|
+
* @returns {string} The string representation of the close value of the given visual point.
|
|
111
|
+
*/
|
|
112
|
+
this.getTextForPoint = (point) => `${point.close}`;
|
|
113
|
+
/**
|
|
114
|
+
* Returns last visible on the screen data series value
|
|
115
|
+
* @param seriesIndex
|
|
116
|
+
*/
|
|
117
|
+
this.getLastVisualSeriesPoint = () => {
|
|
118
|
+
const points = this.visualPoints;
|
|
119
|
+
const endIdx = binarySearch(points, this.scale.xEnd, i => i.centerUnit).index;
|
|
120
|
+
return points[endIdx];
|
|
121
|
+
};
|
|
122
|
+
/**
|
|
123
|
+
* Return last overall data series value (even if not visible)
|
|
124
|
+
* @param seriesIndex
|
|
125
|
+
*/
|
|
126
|
+
this.getLastDataSeriesPoint = () => {
|
|
127
|
+
const points = this.visualPoints;
|
|
128
|
+
return lastOf(points);
|
|
129
|
+
};
|
|
130
|
+
this.config = merge(_config, DEFAULT_DATA_SERIES_CONFIG);
|
|
131
|
+
this.scale = extentComponent.scale;
|
|
132
|
+
this.view = new DataSeriesView(this, this.scale, () => this.extentComponent.yAxis.getAxisType(), this.getBaseline);
|
|
133
|
+
this.yAxisLabelProvider = new DataSeriesYAxisLabelsProvider(this, this.config, extentComponent.getYAxisBounds, (_a = extentComponent.yAxis) === null || _a === void 0 ? void 0 : _a.state);
|
|
134
|
+
this.highLowProvider = createDataSeriesModelHighLowProvider(this);
|
|
135
|
+
extentComponent.addDataSeries(this);
|
|
136
|
+
this.activate();
|
|
137
|
+
}
|
|
138
|
+
doActivate() {
|
|
139
|
+
this.addRxSubscription(this.scale.xChanged.subscribe(() => this.recalculateDataViewportIndexes()));
|
|
140
|
+
this.addRxSubscription(this.scale.scaleInversedSubject.subscribe(() => this.recalculateVisualPoints()));
|
|
141
|
+
}
|
|
142
|
+
/**
|
|
143
|
+
* Sets the data points and recalculates internal state
|
|
144
|
+
* @param {DataSeriesPoint[][] | DataSeriesPoint[]} points - The data points to set for the model. Can be an array of arrays or a single array.
|
|
145
|
+
* @returns {void}
|
|
146
|
+
*/
|
|
147
|
+
setDataPoints(points) {
|
|
148
|
+
this.dataPoints = points;
|
|
149
|
+
this.extentComponent.paneComponent.updateView();
|
|
150
|
+
}
|
|
151
|
+
_toVisualPoints(data) {
|
|
152
|
+
return data.map(d => this.toVisualPoints(d));
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* Moves the DataSeriesModel to the given extent.
|
|
156
|
+
* @param extent
|
|
157
|
+
*/
|
|
158
|
+
moveToExtent(extent) {
|
|
159
|
+
var _a;
|
|
160
|
+
this.extentComponent.removeDataSeries(this);
|
|
161
|
+
this.extentComponent = extent;
|
|
162
|
+
this.scale = extent.scale;
|
|
163
|
+
this.view = new DataSeriesView(this, this.scale, () => this.extentComponent.yAxis.getAxisType(), this.getBaseline);
|
|
164
|
+
this.yAxisLabelProvider.yAxisBoundsProvider = extent.getYAxisBounds;
|
|
165
|
+
this.yAxisLabelProvider.axisState = (_a = extent.yAxis) === null || _a === void 0 ? void 0 : _a.state;
|
|
166
|
+
// shut down old subscriptions
|
|
167
|
+
this.deactivate();
|
|
168
|
+
// and apply new ones (with updated scaleModel)
|
|
169
|
+
this.activate();
|
|
170
|
+
extent.addDataSeries(this);
|
|
171
|
+
}
|
|
172
|
+
/**
|
|
173
|
+
* Transforms the given array of data points of type D into an array of visual points of type V.
|
|
174
|
+
* Each visual point object contains a centerUnit property with the index of the point in the input array,
|
|
175
|
+
* and a close property with the close value of the point.
|
|
176
|
+
*
|
|
177
|
+
* @param {D[]} data - The array of data points to transform into visual points.
|
|
178
|
+
* @returns {V[]} An array of visual points, each with a centerUnit and close property.
|
|
179
|
+
*/
|
|
180
|
+
toVisualPoints(data) {
|
|
181
|
+
// @ts-ignore
|
|
182
|
+
return data.map((point, idx) => ({ centerUnit: idx, close: point.close }));
|
|
183
|
+
}
|
|
184
|
+
setType(type) {
|
|
185
|
+
this.config.type = type;
|
|
186
|
+
this.extentComponent.dynamicObjectsCanvasModel.fireDraw();
|
|
187
|
+
}
|
|
188
|
+
/**
|
|
189
|
+
* Recalculates the visual points of the DataSeriesView based on the current data points.
|
|
190
|
+
* The visual points are stored in the visualPoints property of the DataSeriesView.
|
|
191
|
+
* Should be called 1 time when data are set / updated to chart.
|
|
192
|
+
*/
|
|
193
|
+
recalculateVisualPoints() {
|
|
194
|
+
this.visualPoints = this._toVisualPoints(this.dataPoints2D);
|
|
195
|
+
}
|
|
196
|
+
/**
|
|
197
|
+
* Recalculates the indexes of the start and end points of the data viewport,
|
|
198
|
+
* based on the current xStart and xEnd values of the scale model, or on the given xStart and xEnd parameters.
|
|
199
|
+
*
|
|
200
|
+
* @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.
|
|
201
|
+
* @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.
|
|
202
|
+
*/
|
|
203
|
+
recalculateDataViewportIndexes(xStart = this.scale.xStart, xEnd = this.scale.xEnd) {
|
|
204
|
+
const { dataIdxStart, dataIdxEnd } = this.calculateDataViewportIndexes(xStart, xEnd);
|
|
205
|
+
this.dataIdxStart = dataIdxStart;
|
|
206
|
+
this.dataIdxEnd = dataIdxEnd;
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* Calculates and returns the indexes of the start and end points of the data viewport,
|
|
210
|
+
* based on the given start and end units on the x-axis.
|
|
211
|
+
*
|
|
212
|
+
* @param {Unit} xStart - The start value of the viewport on the x-axis.
|
|
213
|
+
* @param {Unit} xEnd - The end value of the viewport on the x-axis.
|
|
214
|
+
* @returns {DataSeriesViewportIndexes} An object containing the calculated start and end indexes of the data viewport.
|
|
215
|
+
*/
|
|
216
|
+
calculateDataViewportIndexes(xStart, xEnd) {
|
|
217
|
+
const dataIdxStart = binarySearch(this.visualPoints, xStart, i => i.centerUnit).index;
|
|
218
|
+
const dataIdxEnd = binarySearch(this.visualPoints, xEnd, i => i.centerUnit).index;
|
|
219
|
+
return {
|
|
220
|
+
dataIdxStart,
|
|
221
|
+
dataIdxEnd,
|
|
222
|
+
};
|
|
223
|
+
}
|
|
224
|
+
/**
|
|
225
|
+
* Formats the given numerical value using the default value formatter.
|
|
226
|
+
*
|
|
227
|
+
* @param {number} value - The numerical value to be formatted.
|
|
228
|
+
* @returns {string} The formatted value as a string.
|
|
229
|
+
*/
|
|
230
|
+
valueFormatter(value) {
|
|
231
|
+
return defaultValueFormatter(value);
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Returns a two-dimensional array of the visual points in the viewport of the DataSeriesView.
|
|
235
|
+
* The viewport range can be customized by providing start and end units on the x-axis.
|
|
236
|
+
* If start or end units are not provided, the current viewport range of the DataSeriesView is used.
|
|
237
|
+
*
|
|
238
|
+
* @param {number} [xStart] - The start value of the viewport range on the x-axis.
|
|
239
|
+
* @param {number} [xEnd] - The end value of the viewport range on the x-axis.
|
|
240
|
+
* @returns {V[][]} A two-dimensional array of the visual points in the viewport of the DataSeriesView.
|
|
241
|
+
*/
|
|
242
|
+
getSeriesInViewport(xStart, xEnd) {
|
|
243
|
+
let dataIdxStart = this.dataIdxStart;
|
|
244
|
+
let dataIdxEnd = this.dataIdxEnd;
|
|
245
|
+
if (xEnd !== undefined && xStart !== undefined) {
|
|
246
|
+
const res = this.calculateDataViewportIndexes(xStart, xEnd);
|
|
247
|
+
dataIdxStart = res.dataIdxStart;
|
|
248
|
+
dataIdxEnd = res.dataIdxEnd;
|
|
249
|
+
}
|
|
250
|
+
return slice2DArray(this.visualPoints2D, dataIdxStart, dataIdxEnd);
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
export const calculateDataSeriesHighLow = (visualCandles) => {
|
|
254
|
+
const result = {
|
|
255
|
+
high: Number.MIN_SAFE_INTEGER,
|
|
256
|
+
low: Number.MAX_SAFE_INTEGER,
|
|
257
|
+
highIdx: 0,
|
|
258
|
+
lowIdx: 0,
|
|
259
|
+
};
|
|
260
|
+
for (let i = 0; i < visualCandles.length; i++) {
|
|
261
|
+
const candle = visualCandles[i];
|
|
262
|
+
if (candle.close > result.high) {
|
|
263
|
+
result.high = candle.close;
|
|
264
|
+
result.highIdx = i;
|
|
265
|
+
}
|
|
266
|
+
if (candle.close < result.low) {
|
|
267
|
+
result.low = candle.close;
|
|
268
|
+
result.lowIdx = i;
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return result;
|
|
272
|
+
};
|
|
273
|
+
const createDataSeriesModelHighLowProvider = (dataSeries) => ({
|
|
274
|
+
isHighLowActive: () => dataSeries.config.highLowActive,
|
|
275
|
+
calculateHighLow: state => {
|
|
276
|
+
const highLow = calculateDataSeriesHighLow(dataSeries.getSeriesInViewport(state === null || state === void 0 ? void 0 : state.xStart, state === null || state === void 0 ? void 0 : state.xEnd).flat());
|
|
277
|
+
return Object.assign(Object.assign({}, highLow), { high: dataSeries.view.toAxisUnits(highLow.high), low: dataSeries.view.toAxisUnits(highLow.low) });
|
|
278
|
+
},
|
|
279
|
+
});
|
|
280
|
+
export const defaultValueFormatter = (value) => {
|
|
281
|
+
const DEFAULT_PRECISION = 5;
|
|
282
|
+
const calcFraction = (val) => Math.ceil(Math.log(Math.abs(val)) * Math.LOG10E);
|
|
283
|
+
const calcPrecision = (val, maxPrecision = DEFAULT_PRECISION) => Math.max(0, maxPrecision - Math.max(0, calcFraction(val)));
|
|
284
|
+
const resPrecision = calcPrecision(value);
|
|
285
|
+
return MathUtils.makeDecimal(value, resPrecision);
|
|
286
|
+
};
|
|
@@ -3,4 +3,154 @@
|
|
|
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 defaultDateTimeFormatter
|
|
6
|
+
export const defaultDateTimeFormatter = () => (date) => date.toString();
|
|
7
|
+
/**
|
|
8
|
+
* Default chart-core time formatter.
|
|
9
|
+
* @param config
|
|
10
|
+
* @param offsetFunction
|
|
11
|
+
* @doc-tags chart-core,default-config,date-formatter
|
|
12
|
+
*/
|
|
13
|
+
export const dateTimeFormatterFactory = (config, offsetFunction) => {
|
|
14
|
+
var _a;
|
|
15
|
+
const getPrefix = 'date.get' + (offsetFunction((_a = config.timezone) !== null && _a !== void 0 ? _a : '') ? '' : 'UTC');
|
|
16
|
+
const patterns = {
|
|
17
|
+
YYYY: apply('FullYear'),
|
|
18
|
+
YY: apply('FullYear') + ' % 100',
|
|
19
|
+
MMM: from('shortMonths', 'Month'),
|
|
20
|
+
MMMM: upperCase(from('shortMonths', 'Month')),
|
|
21
|
+
M: '1+' + apply('Month'),
|
|
22
|
+
d: apply('Date'),
|
|
23
|
+
H: apply('Hours'),
|
|
24
|
+
m: apply('Minutes'),
|
|
25
|
+
s: apply('Seconds'),
|
|
26
|
+
sss: apply('Milliseconds'),
|
|
27
|
+
EEE: from('shortDays', 'Day'),
|
|
28
|
+
SSS: 'this.' + 'addTwoZeros' + '(' + apply('Milliseconds') + ')',
|
|
29
|
+
T: 'date.getTime()',
|
|
30
|
+
};
|
|
31
|
+
['s', 'm', 'H', 'd', 'M'].forEach(function (k) {
|
|
32
|
+
patterns[k + k] = 'this.' + 'addZero' + '(' + patterns[k] + ')';
|
|
33
|
+
});
|
|
34
|
+
const re = new RegExp(Object.keys(patterns).sort().reverse().join('|'), 'g');
|
|
35
|
+
/**
|
|
36
|
+
* Returns a string that concatenates the result of the function getPrefix with the input string fn and the string '()'.
|
|
37
|
+
* @param {string} fn - The input string to concatenate.
|
|
38
|
+
* @returns {string} - The resulting string.
|
|
39
|
+
*/
|
|
40
|
+
function apply(fn) {
|
|
41
|
+
return getPrefix + fn + '()';
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Returns a string that represents an element of an array by applying a function to its index.
|
|
45
|
+
*
|
|
46
|
+
* @param {string} array - The name of the array.
|
|
47
|
+
* @param {string} fn - The name of the function to apply to the index.
|
|
48
|
+
* @returns {string} - A string that represents an element of the array.
|
|
49
|
+
*/
|
|
50
|
+
function from(array, fn) {
|
|
51
|
+
return 'this.' + array + '[' + apply(fn) + ']';
|
|
52
|
+
}
|
|
53
|
+
/**
|
|
54
|
+
* Returns a string with the function name and the '.toUpperCase()' method appended to it.
|
|
55
|
+
* @param {string} fn - The name of the function to be converted to uppercase.
|
|
56
|
+
* @returns {string} - The resulting string with the function name in uppercase.
|
|
57
|
+
*/
|
|
58
|
+
function upperCase(fn) {
|
|
59
|
+
return fn + '.toUpperCase()';
|
|
60
|
+
}
|
|
61
|
+
/**
|
|
62
|
+
* Returns a string that concatenates a pattern from an object with a string
|
|
63
|
+
* @param {string} pattern - The key of the pattern to be concatenated
|
|
64
|
+
* @returns {string} - A string that concatenates a pattern from an object with a string
|
|
65
|
+
*/
|
|
66
|
+
function applyPattern(pattern) {
|
|
67
|
+
return "' + (" + patterns[pattern] + ") + '";
|
|
68
|
+
}
|
|
69
|
+
return function (pattern) {
|
|
70
|
+
var _a;
|
|
71
|
+
const context = {
|
|
72
|
+
shortDays: getShortDays(config),
|
|
73
|
+
shortMonths: getShortMonths(config),
|
|
74
|
+
/**
|
|
75
|
+
* Adds a leading zero to a number if it is less than 10
|
|
76
|
+
* @param {number} x - The number to add a leading zero to
|
|
77
|
+
* @returns {string|number} - The number with a leading zero if it is less than 10, otherwise the original number
|
|
78
|
+
*/
|
|
79
|
+
addZero(x) {
|
|
80
|
+
return x < 10 ? '0' + x : x;
|
|
81
|
+
},
|
|
82
|
+
/**
|
|
83
|
+
* Adds two zeros to a number if it is less than 10 or 100
|
|
84
|
+
* @param {number} x - The number to add zeros to
|
|
85
|
+
* @returns {string} - The number with two zeros added if necessary
|
|
86
|
+
*/
|
|
87
|
+
addTwoZeros(x) {
|
|
88
|
+
return (x < 100 ? '0' : '') + (x < 10 ? '0' : '') + x;
|
|
89
|
+
},
|
|
90
|
+
tzDate: offsetFunction((_a = config.timezone) !== null && _a !== void 0 ? _a : '') ||
|
|
91
|
+
function (date) {
|
|
92
|
+
return date instanceof Date ? date : new Date(+date);
|
|
93
|
+
},
|
|
94
|
+
};
|
|
95
|
+
// eslint-disable-next-line no-new-func
|
|
96
|
+
return new Function('date', 'date=this.' + 'tzDate' + "(date); return '" + pattern.replace(re, applyPattern) + "'").bind(context);
|
|
97
|
+
};
|
|
98
|
+
};
|
|
99
|
+
/**
|
|
100
|
+
* Returns an array of short day names based on the provided configuration object.
|
|
101
|
+
* If the configuration object does not contain shortDays property, it returns an array of default short day names.
|
|
102
|
+
*
|
|
103
|
+
* @param {TimeFormatterConfig} config - The configuration object containing shortDays property.
|
|
104
|
+
* @returns {string[]} - An array of short day names.
|
|
105
|
+
*/
|
|
106
|
+
function getShortDays(config) {
|
|
107
|
+
var _a;
|
|
108
|
+
return (_a = config.shortDays) !== null && _a !== void 0 ? _a : ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Returns an array of short month names based on the provided configuration object.
|
|
112
|
+
* If the configuration object does not have a 'shortMonths' property, it returns the default array of short month names.
|
|
113
|
+
*
|
|
114
|
+
* @param {TimeFormatterConfig} config - The configuration object that contains the shortMonths property.
|
|
115
|
+
* @returns {string[]} - An array of short month names.
|
|
116
|
+
*/
|
|
117
|
+
function getShortMonths(config) {
|
|
118
|
+
var _a;
|
|
119
|
+
return (_a = config.shortMonths) !== null && _a !== void 0 ? _a : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
120
|
+
}
|
|
121
|
+
export const recalculateXFormatter = (xAxisLabelFormat, period, formatterFactory) => {
|
|
122
|
+
if (xAxisLabelFormat) {
|
|
123
|
+
if (typeof xAxisLabelFormat === 'string') {
|
|
124
|
+
// always same format
|
|
125
|
+
return formatterFactory(xAxisLabelFormat);
|
|
126
|
+
}
|
|
127
|
+
else if (Array.isArray(xAxisLabelFormat)) {
|
|
128
|
+
// conditional format
|
|
129
|
+
const matchingFormats = xAxisLabelFormat.filter(config => {
|
|
130
|
+
if (config.showWhen) {
|
|
131
|
+
const predicates = [];
|
|
132
|
+
if (config.showWhen.periodLessThen) {
|
|
133
|
+
predicates.push(() => { var _a, _b; return period < ((_b = (_a = config.showWhen) === null || _a === void 0 ? void 0 : _a.periodLessThen) !== null && _b !== void 0 ? _b : 0); });
|
|
134
|
+
}
|
|
135
|
+
if (config.showWhen.periodMoreThen) {
|
|
136
|
+
predicates.push(() => { var _a, _b; return period >= ((_b = (_a = config.showWhen) === null || _a === void 0 ? void 0 : _a.periodMoreThen) !== null && _b !== void 0 ? _b : 0); });
|
|
137
|
+
}
|
|
138
|
+
return predicates.every(p => p());
|
|
139
|
+
}
|
|
140
|
+
else {
|
|
141
|
+
return true;
|
|
142
|
+
}
|
|
143
|
+
});
|
|
144
|
+
if (matchingFormats.length > 0) {
|
|
145
|
+
const formatConfig = matchingFormats[0];
|
|
146
|
+
if (formatConfig.format) {
|
|
147
|
+
return formatterFactory(formatConfig.format);
|
|
148
|
+
}
|
|
149
|
+
else if (formatConfig.customFormatter) {
|
|
150
|
+
return formatConfig.customFormatter;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
return defaultDateTimeFormatter();
|
|
156
|
+
};
|
|
@@ -11,7 +11,7 @@ import { DrawingManager } from '../drawers/drawing-manager';
|
|
|
11
11
|
import EventBus from '../events/event-bus';
|
|
12
12
|
import { CanvasInputListenerComponent, Point } from '../inputlisteners/canvas-input-listener.component';
|
|
13
13
|
export type HitTestEvents = 'mousedown' | 'hover' | 'touchstart' | 'dblclick' | 'contextmenu' | 'zoom' | 'mouseup';
|
|
14
|
-
type HitTestType = 'DRAWINGS' | 'DATA_SERIES' | 'EVENTS' | 'NEWS';
|
|
14
|
+
type HitTestType = 'DRAWINGS' | 'DATA_SERIES' | 'EVENTS' | 'NEWS' | 'EXECUTED_ORDERS';
|
|
15
15
|
export declare const HIT_TEST_ID_RANGE: Record<HitTestType, [number, number]>;
|
|
16
16
|
/** HitTestCanvasModel
|
|
17
17
|
* Canvas layer for testing mouse events over the models such as Charts, Drawings, Volumes and etc.
|