@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
|
@@ -3,21 +3,19 @@
|
|
|
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 default
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
</div>
|
|
23
|
-
`;
|
|
6
|
+
export default (devexpertsPromoLink) => '<div data-element="chartResizer" style="position: relative; min-height: 20px; height: 100%; width: 100%; touch-action: manipulation; z-index: 0;">\n' +
|
|
7
|
+
'\t<div data-element="chartContainer" style="position: absolute; height: 100%; width: 100%;" class="chart chartArea--graph">\n' +
|
|
8
|
+
'\t\t<div data-element="canvasArea" style="position: relative; height: 100%; width: 100%; touch-action: manipulation;">\n' +
|
|
9
|
+
'\t\t\t<canvas data-element="snapshotCanvas" style="z-index: 0"></canvas>\n' +
|
|
10
|
+
'\t\t\t<canvas data-element="backgroundCanvas" style="z-index: 1"></canvas>\n' +
|
|
11
|
+
'\t\t\t<canvas data-element="mainCanvas" style="z-index: 2"></canvas>\n' +
|
|
12
|
+
'\t\t\t<canvas data-element="dynamicObjectsCanvas" style="z-index: 3"></canvas>\n' +
|
|
13
|
+
'\t\t\t<canvas data-element="yAxisLabelsCanvas" style="z-index: 4"></canvas>\n' +
|
|
14
|
+
'\t\t\t<canvas data-element="crossToolCanvas" style="z-index: 5"></canvas>\n' +
|
|
15
|
+
'\t\t\t<canvas data-element="hitTestCanvas" style="z-index: 6"></canvas>\n' +
|
|
16
|
+
`${devexpertsPromoLink
|
|
17
|
+
? '\t\t\t<p style="position: absolute; visibility: hidden;">If you have any suggestions or are experiencing any issues, please feel free to contact us at <a href="https://devexperts.com/dxcharts/">devexperts.com</a></p>\n'
|
|
18
|
+
: ''}` +
|
|
19
|
+
'\t\t</div>\n' +
|
|
20
|
+
'\t</div>\n' +
|
|
21
|
+
'</div>\n';
|
|
@@ -8,10 +8,7 @@ export interface ChartElements {
|
|
|
8
8
|
snapshotCanvas?: HTMLCanvasElement;
|
|
9
9
|
backgroundCanvas?: HTMLCanvasElement;
|
|
10
10
|
mainCanvas?: HTMLCanvasElement;
|
|
11
|
-
|
|
12
|
-
overDataSeriesCanvas?: HTMLCanvasElement;
|
|
13
|
-
staticDrawingCanvas?: HTMLCanvasElement;
|
|
14
|
-
dynamicDrawingCanvas?: HTMLCanvasElement;
|
|
11
|
+
dynamicObjectsCanvas?: HTMLCanvasElement;
|
|
15
12
|
yAxisLabelsCanvas?: HTMLCanvasElement;
|
|
16
13
|
crossToolCanvas?: HTMLCanvasElement;
|
|
17
14
|
hitTestCanvas?: HTMLCanvasElement;
|
|
@@ -3,4 +3,25 @@
|
|
|
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 validateChartElements=
|
|
6
|
+
export const validateChartElements = (els) => {
|
|
7
|
+
const canvasAreaAvailable = els.canvasArea !== null;
|
|
8
|
+
const snapshotCanvasAvailable = els.snapshotCanvas !== null;
|
|
9
|
+
const backgroundCanvasAvailable = els.backgroundCanvas !== null;
|
|
10
|
+
const mainCanvasAvailable = els.mainCanvas !== null;
|
|
11
|
+
const yAxisLabelsCanvasAvailable = els.yAxisLabelsCanvas !== null;
|
|
12
|
+
const crossToolCanvasAvailable = els.crossToolCanvas !== null;
|
|
13
|
+
const hitTestCanvasAvailable = els.hitTestCanvas !== null;
|
|
14
|
+
const chartResizerAvailable = els.chartResizer !== null;
|
|
15
|
+
const chartContainerAvailable = els.chartContainer !== null;
|
|
16
|
+
const dynamicObjectsCanvasAvailable = els.dynamicObjectsCanvas !== null;
|
|
17
|
+
return (canvasAreaAvailable &&
|
|
18
|
+
snapshotCanvasAvailable &&
|
|
19
|
+
backgroundCanvasAvailable &&
|
|
20
|
+
mainCanvasAvailable &&
|
|
21
|
+
yAxisLabelsCanvasAvailable &&
|
|
22
|
+
crossToolCanvasAvailable &&
|
|
23
|
+
hitTestCanvasAvailable &&
|
|
24
|
+
chartResizerAvailable &&
|
|
25
|
+
chartContainerAvailable &&
|
|
26
|
+
dynamicObjectsCanvasAvailable);
|
|
27
|
+
};
|
|
@@ -3,4 +3,125 @@
|
|
|
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 { distinctUntilChanged, throttleTime } from 'rxjs/operators';
|
|
8
|
+
import { ChartBaseElement } from '../model/chart-base-element';
|
|
9
|
+
import { CanvasBoundsContainer } from './canvas-bounds-container';
|
|
10
|
+
/**
|
|
11
|
+
* This class is responsible for changing cursor for different entities which are drawn on the canvas.
|
|
12
|
+
* @doc-tags chart-core,cursor
|
|
13
|
+
*/
|
|
14
|
+
export class CursorHandler extends ChartBaseElement {
|
|
15
|
+
constructor(element, canvasInputListener, canvasBoundsContainer, hitTestCanvasModel) {
|
|
16
|
+
super();
|
|
17
|
+
this.element = element;
|
|
18
|
+
this.canvasInputListener = canvasInputListener;
|
|
19
|
+
this.canvasBoundsContainer = canvasBoundsContainer;
|
|
20
|
+
this.hitTestCanvasModel = hitTestCanvasModel;
|
|
21
|
+
this.normalLayer = new Map();
|
|
22
|
+
this.extensionLayer = new Map();
|
|
23
|
+
this.cursorChangedSubject = new Subject();
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* This method is called when the user activates the canvas. It subscribes to the mouse move event and checks if the mouse pointer is over any of the elements in the normalLayer or extensionLayer. If the mouse pointer is over any of the elements, it updates the cursor to the corresponding cursor of the element.
|
|
27
|
+
*/
|
|
28
|
+
doActivate() {
|
|
29
|
+
super.doActivate();
|
|
30
|
+
this.canvasInputListener
|
|
31
|
+
.observeMouseMoveNoDrag()
|
|
32
|
+
.pipe(throttleTime(100, undefined, { trailing: true }))
|
|
33
|
+
.subscribe(point => {
|
|
34
|
+
const cursorFromHT = this.hitTestCanvasModel.resolveCursor(point);
|
|
35
|
+
if (cursorFromHT !== undefined) {
|
|
36
|
+
this.updateCursor(cursorFromHT);
|
|
37
|
+
return;
|
|
38
|
+
}
|
|
39
|
+
if (point) {
|
|
40
|
+
this.normalLayer.forEach(val => {
|
|
41
|
+
if (val.hitTest(point.x, point.y)) {
|
|
42
|
+
this.updateCursor(val.cursor);
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
this.extensionLayer.forEach(val => {
|
|
46
|
+
if (val.hitTest(point.x, point.y)) {
|
|
47
|
+
this.updateCursor(val.cursor);
|
|
48
|
+
}
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
/***
|
|
54
|
+
* @param elId
|
|
55
|
+
* @param bounds
|
|
56
|
+
* @param cursorType
|
|
57
|
+
* @param extension is an extra area beyond the borders of the bounds
|
|
58
|
+
*/
|
|
59
|
+
setCursorForBounds(elId, bounds, cursorType, extension = 0) {
|
|
60
|
+
const hitTest = CanvasBoundsContainer.hitTestOf(bounds, { extensionY: extension });
|
|
61
|
+
if (extension) {
|
|
62
|
+
// extension layer has a higher priority, so if its hitTest intersects with other hitTests
|
|
63
|
+
// the cursor will be of type specified in extension layer
|
|
64
|
+
this.extensionLayer.set(elId, { cursor: cursorType, hitTest });
|
|
65
|
+
}
|
|
66
|
+
else {
|
|
67
|
+
this.normalLayer.set(elId, { cursor: cursorType, hitTest });
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Sets a cursor for a canvas element
|
|
72
|
+
* @param {string} canvasEl - The canvas element to add the cursor to
|
|
73
|
+
* @param {CursorType} cursor - The type of cursor to add
|
|
74
|
+
* @param {number} [extensionRadius] - The extension radius of the cursor
|
|
75
|
+
*/
|
|
76
|
+
setCursorForCanvasEl(canvasEl, cursor, extensionRadius) {
|
|
77
|
+
this.observeCursorType(canvasEl, cursor, extensionRadius);
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* Removes the cursor for a given canvas element.
|
|
81
|
+
*
|
|
82
|
+
* @param {string} canvasEl - The canvas element to remove the cursor from.
|
|
83
|
+
* @returns {void}
|
|
84
|
+
*/
|
|
85
|
+
removeCursorForCanvasEl(canvasEl) {
|
|
86
|
+
this.normalLayer.delete(canvasEl);
|
|
87
|
+
this.extensionLayer.delete(canvasEl);
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Returns an Observable that emits the latest CursorType value whenever the cursorChangedSubject emits a new value.
|
|
91
|
+
* The emitted value is guaranteed to be distinct from the previous one.
|
|
92
|
+
* @returns {Observable<CursorType>} An Observable that emits the latest CursorType value.
|
|
93
|
+
*/
|
|
94
|
+
observeCursorChanged() {
|
|
95
|
+
return this.cursorChangedSubject.pipe(distinctUntilChanged());
|
|
96
|
+
}
|
|
97
|
+
/**
|
|
98
|
+
* Sets the cursor type for a given canvas element and optionally extends the hit test area.
|
|
99
|
+
* @param {string} canvasElement - The ID of the canvas element to observe.
|
|
100
|
+
* @param {CursorType} cursorType - The type of cursor to set.
|
|
101
|
+
* @param {number} [extensionY] - Optional extension of the hit test area in the Y axis.
|
|
102
|
+
* @returns {void}
|
|
103
|
+
*/
|
|
104
|
+
observeCursorType(canvasElement, cursorType, extensionY) {
|
|
105
|
+
const hitTest = extensionY
|
|
106
|
+
? this.canvasBoundsContainer.getBoundsHitTest(canvasElement, { extensionY })
|
|
107
|
+
: this.canvasBoundsContainer.getBoundsHitTest(canvasElement);
|
|
108
|
+
if (extensionY) {
|
|
109
|
+
this.extensionLayer.set(canvasElement, { cursor: cursorType, hitTest });
|
|
110
|
+
}
|
|
111
|
+
else {
|
|
112
|
+
this.normalLayer.set(canvasElement, { cursor: cursorType, hitTest });
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Updates the cursor type of an element based on the mouse enter or leave event.
|
|
117
|
+
* @param {CursorType} cursorType - The type of cursor to be set on the element.
|
|
118
|
+
* @returns {void}
|
|
119
|
+
*/
|
|
120
|
+
updateCursor(cursorType) {
|
|
121
|
+
if (this.element.style.cursor === cursorType) {
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
this.element.style.cursor = cursorType;
|
|
125
|
+
this.cursorChangedSubject.next(cursorType);
|
|
126
|
+
}
|
|
127
|
+
}
|
|
@@ -3,4 +3,37 @@
|
|
|
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{validateChartElements
|
|
6
|
+
import { validateChartElements } from './chart-elements';
|
|
7
|
+
import generateNewCanvasChartHTML from './canvas-chart-html';
|
|
8
|
+
/**
|
|
9
|
+
* Creates a default layout template for a canvas chart.
|
|
10
|
+
* @function
|
|
11
|
+
* @returns {HTMLTemplateElement} - The default layout template for a canvas chart.
|
|
12
|
+
*/
|
|
13
|
+
export function createDefaultLayoutTemplate(config) {
|
|
14
|
+
const template = document.createElement('template');
|
|
15
|
+
template.innerHTML = generateNewCanvasChartHTML(config.devexpertsPromoLink);
|
|
16
|
+
return template;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Extracts chart elements from a given container and returns them as a validated object.
|
|
20
|
+
* @param {Element} container - The container element to search for chart elements.
|
|
21
|
+
* @returns {ValidatedChartElements} - An object containing the chart elements as properties.
|
|
22
|
+
* @throws {Error} - If some chart elements are missing.
|
|
23
|
+
*/
|
|
24
|
+
export function extractElements(container) {
|
|
25
|
+
const result = {};
|
|
26
|
+
const elements = Array.from(container.querySelectorAll('[data-element]'));
|
|
27
|
+
if (elements.length !== 0) {
|
|
28
|
+
elements.forEach(el => {
|
|
29
|
+
var _a;
|
|
30
|
+
result[(_a = el.getAttribute('data-element')) !== null && _a !== void 0 ? _a : ''] = el;
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
if (validateChartElements(result)) {
|
|
34
|
+
return result;
|
|
35
|
+
}
|
|
36
|
+
else {
|
|
37
|
+
throw new Error('Some chart elements are missing');
|
|
38
|
+
}
|
|
39
|
+
}
|
|
@@ -3,12 +3,12 @@
|
|
|
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 { YAxisConfig, FullChartConfig } from '../chart.config';
|
|
7
7
|
import { CanvasModel } from '../model/canvas.model';
|
|
8
8
|
export interface YAxisWidthContributor {
|
|
9
9
|
getLargestLabel: () => string;
|
|
10
10
|
getYAxisIndex: () => number;
|
|
11
|
-
|
|
11
|
+
getYAxisState: () => YAxisConfig;
|
|
12
12
|
getPaneUUID: () => string;
|
|
13
13
|
}
|
|
14
14
|
export type ExtentsOrder = Map<string, // uuid of the pane
|
|
@@ -3,4 +3,70 @@
|
|
|
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{getFontFromConfig
|
|
6
|
+
import { getFontFromConfig } from '../chart.config';
|
|
7
|
+
import { calculateTextWidth } from '../utils/canvas/canvas-font-measure-tool.utils';
|
|
8
|
+
export class YAxisBoundsContainer {
|
|
9
|
+
constructor(config, mainCanvasModel) {
|
|
10
|
+
this.config = config;
|
|
11
|
+
this.mainCanvasModel = mainCanvasModel;
|
|
12
|
+
this.extentsOrder = new Map();
|
|
13
|
+
this.yAxisWidthContributors = [];
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Registers a YAxisWidthContributor to the chart.
|
|
17
|
+
*
|
|
18
|
+
* @param {YAxisWidthContributor} contributor - The YAxisWidthContributor to be registered.
|
|
19
|
+
* @returns {void}
|
|
20
|
+
*/
|
|
21
|
+
registerYAxisWidthContributor(contributor) {
|
|
22
|
+
this.yAxisWidthContributors.push(contributor);
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Removes a YAxisWidthContributor from the chart.
|
|
26
|
+
*
|
|
27
|
+
* @param {YAxisWidthContributor} contributor - The YAxisWidthContributor to be removed.
|
|
28
|
+
* @returns {void}
|
|
29
|
+
*/
|
|
30
|
+
removeYAxisWidthContributor(contributor) {
|
|
31
|
+
this.yAxisWidthContributors = this.yAxisWidthContributors.filter(c => c !== contributor);
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Calculates the width of a given text using the font from the yAxis component of the chart configuration
|
|
35
|
+
* @param {string} text - The text to calculate the width of
|
|
36
|
+
* @returns {number} - The width of the text in pixels
|
|
37
|
+
*/
|
|
38
|
+
getTextWidth(text) {
|
|
39
|
+
const font = getFontFromConfig(this.config.components.yAxis);
|
|
40
|
+
return calculateTextWidth(text, this.mainCanvasModel.ctx, font);
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Updates width of Y axis.
|
|
44
|
+
* Considers max text of YAxis labels.
|
|
45
|
+
*/
|
|
46
|
+
getYAxisWidths() {
|
|
47
|
+
this.extentsOrder.clear();
|
|
48
|
+
const left = [];
|
|
49
|
+
const right = [];
|
|
50
|
+
this.yAxisWidthContributors.forEach(c => {
|
|
51
|
+
var _a, _b, _c;
|
|
52
|
+
const state = c.getYAxisState();
|
|
53
|
+
const margin = state.labelBoxMargin.start + state.labelBoxMargin.end;
|
|
54
|
+
const width = this.getTextWidth(c.getLargestLabel()) + margin;
|
|
55
|
+
const idx = c.getYAxisIndex();
|
|
56
|
+
const uuid = c.getPaneUUID();
|
|
57
|
+
const extentOrder = (_a = this.extentsOrder.get(uuid)) !== null && _a !== void 0 ? _a : { left: [], right: [] };
|
|
58
|
+
if (state.align === 'left') {
|
|
59
|
+
const i = extentOrder.left.length;
|
|
60
|
+
left[i] = Math.max((_b = left[i]) !== null && _b !== void 0 ? _b : 0, width);
|
|
61
|
+
extentOrder.left.push(idx);
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const i = extentOrder.right.length;
|
|
65
|
+
right[i] = Math.max((_c = right[i]) !== null && _c !== void 0 ? _c : 0, width);
|
|
66
|
+
extentOrder.right.push(idx);
|
|
67
|
+
}
|
|
68
|
+
this.extentsOrder.set(uuid, extentOrder);
|
|
69
|
+
});
|
|
70
|
+
return { left, right };
|
|
71
|
+
}
|
|
72
|
+
}
|
|
@@ -223,7 +223,7 @@ export interface ChartScale {
|
|
|
223
223
|
*/
|
|
224
224
|
lockPriceToBarRatio: boolean;
|
|
225
225
|
/**
|
|
226
|
-
* Inverses the Y scale vertically.
|
|
226
|
+
* Inverses the Y scale vertically.
|
|
227
227
|
*/
|
|
228
228
|
inverse: boolean;
|
|
229
229
|
/**
|
|
@@ -261,7 +261,7 @@ export interface AutoScaleDisableOnDrag {
|
|
|
261
261
|
export interface ChartComponents {
|
|
262
262
|
chart: ChartConfigComponentsChart;
|
|
263
263
|
xAxis: ChartConfigComponentsXAxis;
|
|
264
|
-
yAxis:
|
|
264
|
+
yAxis: YAxisConfig;
|
|
265
265
|
grid: GridComponentConfig;
|
|
266
266
|
volumes: ChartConfigComponentsVolumes;
|
|
267
267
|
offsets: ChartConfigComponentsOffsets;
|
|
@@ -362,7 +362,7 @@ export interface ChartConfigComponentsXAxis {
|
|
|
362
362
|
fontStyle: string;
|
|
363
363
|
}
|
|
364
364
|
export type YAxisAlign = 'left' | 'right';
|
|
365
|
-
export interface
|
|
365
|
+
export interface YAxisConfig {
|
|
366
366
|
visible: boolean;
|
|
367
367
|
/**
|
|
368
368
|
* Type of Y axis. Currently supported 'regular', 'percent', 'logarithmic'.
|
|
@@ -699,7 +699,6 @@ export interface ChartAreaTheme {
|
|
|
699
699
|
backgroundColor: string;
|
|
700
700
|
backgroundGradientTopColor: string;
|
|
701
701
|
backgroundGradientBottomColor: string;
|
|
702
|
-
axisColor: string;
|
|
703
702
|
gridColor: string;
|
|
704
703
|
}
|
|
705
704
|
export type ChartColors = DeepPartial<FullChartColors>;
|
|
@@ -771,4 +770,4 @@ export interface ChartConfigComponentsEventsIcons {
|
|
|
771
770
|
conferenceCalls?: CustomIcon;
|
|
772
771
|
}
|
|
773
772
|
export type CursorType = string;
|
|
774
|
-
export declare const getFontFromConfig: (config:
|
|
773
|
+
export declare const getFontFromConfig: (config: YAxisConfig) => string;
|