@devexperts/dxcharts-lite 2.5.6 → 2.5.7

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.
Files changed (30) hide show
  1. package/dist/chart/bootstrap.js +1 -1
  2. package/dist/chart/canvas/canvas-bounds-container.d.ts +21 -0
  3. package/dist/chart/canvas/canvas-bounds-container.js +30 -0
  4. package/dist/chart/chart.js +2 -1
  5. package/dist/chart/components/chart/chart.model.d.ts +0 -21
  6. package/dist/chart/components/chart/chart.model.js +3 -33
  7. package/dist/chart/components/pan/chart-pan.component.js +2 -1
  8. package/dist/chart/components/pane/pane-manager.component.d.ts +3 -1
  9. package/dist/chart/components/pane/pane-manager.component.js +3 -2
  10. package/dist/chart/components/pane/pane.component.d.ts +3 -1
  11. package/dist/chart/components/pane/pane.component.js +3 -2
  12. package/dist/chart/components/x_axis/x-axis-scale.handler.d.ts +4 -2
  13. package/dist/chart/components/x_axis/x-axis-scale.handler.js +16 -8
  14. package/dist/chart/components/x_axis/x-axis.component.js +1 -1
  15. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.d.ts +3 -1
  16. package/dist/chart/components/y_axis/price_labels/y-axis-labels.model.js +5 -3
  17. package/dist/chart/components/y_axis/y-axis-scale.handler.d.ts +1 -0
  18. package/dist/chart/components/y_axis/y-axis-scale.handler.js +18 -1
  19. package/dist/chart/components/y_axis/y-axis.component.d.ts +3 -1
  20. package/dist/chart/components/y_axis/y-axis.component.js +3 -2
  21. package/dist/chart/components/y_axis/y-axis.model.d.ts +2 -1
  22. package/dist/chart/components/y_axis/y-axis.model.js +2 -2
  23. package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +3 -1
  24. package/dist/chart/inputhandlers/main-canvas-touch.handler.js +4 -3
  25. package/dist/chart/model/scale.model.d.ts +4 -4
  26. package/dist/chart/model/scale.model.js +14 -12
  27. package/dist/chart/utils/color.utils.d.ts +3 -0
  28. package/dist/chart/utils/color.utils.js +5 -1
  29. package/dist/dxchart.min.js +4 -4
  30. package/package.json +1 -1
@@ -25,8 +25,8 @@ export declare const getDefaultHighLowWithIndex: () => HighLowWithIndex;
25
25
  export type ViewportPercent = number;
26
26
  type Constraints = (initialState: ViewportModelState, state: ViewportModelState) => ViewportModelState;
27
27
  export interface ZoomReached {
28
- max: boolean;
29
- min: boolean;
28
+ zoomIn: boolean;
29
+ zoomOut: boolean;
30
30
  }
31
31
  /**
32
32
  * The ScaleModel class represents the state of a chart's scale, including the current viewport, zoom level, and auto-scaling settings.
@@ -86,8 +86,8 @@ export declare class ScaleModel extends ViewportModel {
86
86
  haltAnimation(): void;
87
87
  private zoomXTo;
88
88
  calculateZoomReached(zoomX: Unit, zoomIn?: boolean): {
89
- max: boolean;
90
- min: boolean;
89
+ zoomIn: boolean;
90
+ zoomOut: boolean;
91
91
  };
92
92
  /**
93
93
  * Moves the viewport to exactly xStart..xEnd place.
@@ -36,7 +36,7 @@ export class ScaleModel extends ViewportModel {
36
36
  this.scaleInversedSubject = new Subject();
37
37
  // y-axis component needs this subject in order to halt prev animation if axis type is percent
38
38
  this.beforeStartAnimationSubject = new Subject();
39
- this.zoomReached = { min: false, max: false };
39
+ this.zoomReached = { zoomIn: false, zoomOut: false };
40
40
  // TODO rework, make a new history based on units
41
41
  this.history = [];
42
42
  this.xConstraints = [];
@@ -128,7 +128,7 @@ export class ScaleModel extends ViewportModel {
128
128
  const initialStateCopy = Object.assign({}, state);
129
129
  const constrainedState = this.scalePostProcessor(initialStateCopy, state);
130
130
  this.zoomReached = this.calculateZoomReached(constrainedState.zoomX, zoomIn);
131
- if (this.zoomReached.max || this.zoomReached.min) {
131
+ if (this.zoomReached.zoomIn || this.zoomReached.zoomOut) {
132
132
  return;
133
133
  }
134
134
  if (this.state.lockPriceToBarRatio) {
@@ -148,15 +148,17 @@ export class ScaleModel extends ViewportModel {
148
148
  const chartWidth = this.getBounds().width;
149
149
  const delta = 0.001; // zoom values are very precise and should be compared with some precision delta
150
150
  if (chartWidth > 0) {
151
- const maxZoomReached = zoomX - calculateZoom(this.config.components.chart.minCandles, chartWidth) <= delta;
152
- // max zoom reached and trying to zoom in further
153
- const maxZoomDisabled = maxZoomReached && zoomIn;
154
- const minZoomReached = zoomX - calculateZoom(chartWidth / this.config.components.chart.minWidth, chartWidth) >= delta;
155
- // min zoom reached and trying to zoom out further
156
- const minZoomDisabled = minZoomReached && !zoomIn;
157
- return { max: maxZoomDisabled, min: minZoomDisabled };
151
+ const maxZoomIn = calculateZoom(this.config.components.chart.minCandles, chartWidth);
152
+ const maxZoomInReached = zoomX !== maxZoomIn && zoomX - maxZoomIn <= delta;
153
+ // max zoom in reached and trying to zoom in further
154
+ const maxZoomInDisabled = maxZoomInReached && zoomIn;
155
+ const maxZoomOut = calculateZoom(chartWidth / this.config.components.chart.minWidth, chartWidth);
156
+ const maxZoomOutReached = zoomX - maxZoomOut >= delta;
157
+ // max zoom out reached and trying to zoom out further
158
+ const maxZoomOutDisabled = maxZoomOutReached && !zoomIn;
159
+ return { zoomIn: maxZoomInDisabled, zoomOut: maxZoomOutDisabled };
158
160
  }
159
- return { max: false, min: false };
161
+ return { zoomIn: false, zoomOut: false };
160
162
  }
161
163
  /**
162
164
  * Moves the viewport to exactly xStart..xEnd place.
@@ -176,7 +178,7 @@ export class ScaleModel extends ViewportModel {
176
178
  const constrainedState = this.scalePostProcessor(initialState, state);
177
179
  const zoomIn = constrainedState.xEnd - constrainedState.xStart < initialState.xEnd - initialState.xStart;
178
180
  this.zoomReached = this.calculateZoomReached(zoomX, zoomIn);
179
- if (this.zoomReached.max || this.zoomReached.min) {
181
+ if (this.zoomReached.zoomIn || this.zoomReached.zoomOut) {
180
182
  return;
181
183
  }
182
184
  if (this.state.lockPriceToBarRatio) {
@@ -212,7 +214,7 @@ export class ScaleModel extends ViewportModel {
212
214
  }
213
215
  setLockedYScale(yStart, yEnd, fire = false, initialState) {
214
216
  const zoomIn = yEnd < initialState.yEnd;
215
- if ((this.zoomReached.min && zoomIn === false) || (this.zoomReached.max && zoomIn === true)) {
217
+ if ((this.zoomReached.zoomOut && zoomIn === false) || (this.zoomReached.zoomIn && zoomIn === true)) {
216
218
  return;
217
219
  }
218
220
  super.setYScale(yStart, yEnd, fire);
@@ -3,4 +3,7 @@
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 declare const isHex: (color: string) => RegExpExecArray | null;
7
+ export declare const isRgb: (color: string) => RegExpExecArray | null;
8
+ export declare const isRgba: (color: string) => RegExpExecArray | null;
6
9
  export declare function toRGBA(color: string, alpha: number): string;
@@ -5,8 +5,12 @@
5
5
  */
6
6
  const HEX_COLOR_REGEXP = /^(#)([0-9a-f]{2})([0-9a-f]{2})([0-9a-f]{2})$/i;
7
7
  const RGB_COLOR_REGEXP = /^\s*(rgba?)\s*[(]\s*(\d{1,3})\s*,\s*(\d{1,3})\s*,\s*(\d{1,3})\s*(?:,\s*[\d.]+\s*)?[)]\s*$/i;
8
+ const RGBA_COLOR_REGEXP = /^rgba[(](?:\s*0*(?:\d\d?(?:\.\d+)?(?:\s*%)?|\.\d+\s*%|100(?:\.0*)?\s*%|(?:1\d\d|2[0-4]\d|25[0-5])(?:\.\d+)?)\s*,){3}\s*0*(?:\.\d+|1(?:\.0*)?)\s*[)]$/;
9
+ export const isHex = (color) => HEX_COLOR_REGEXP.exec(color);
10
+ export const isRgb = (color) => RGB_COLOR_REGEXP.exec(color);
11
+ export const isRgba = (color) => RGBA_COLOR_REGEXP.exec(color);
8
12
  function parseColor(color) {
9
- const match = HEX_COLOR_REGEXP.exec(color) || RGB_COLOR_REGEXP.exec(color);
13
+ const match = isHex(color) || isRgb(color);
10
14
  let colors = [];
11
15
  if (match) {
12
16
  colors = match.slice(2, 5);