@devexperts/dxcharts-lite 2.4.6 → 2.5.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/dist/chart/__tests__/model/date-time.formatter.test.d.ts +6 -0
- package/dist/chart/__tests__/model/date-time.formatter.test.js +30 -0
- package/dist/chart/canvas/canvas-bounds-container.d.ts +7 -3
- package/dist/chart/canvas/canvas-bounds-container.js +149 -105
- package/dist/chart/canvas/y-axis-bounds.container.js +4 -0
- package/dist/chart/chart.config.js +4 -4
- package/dist/chart/components/chart/chart-area-pan.handler.d.ts +1 -5
- package/dist/chart/components/chart/chart-area-pan.handler.js +1 -8
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.d.ts +0 -6
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-x.component.js +0 -8
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.d.ts +0 -5
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop-y.component.js +0 -7
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.d.ts +0 -11
- package/dist/chart/components/dran-n-drop_helper/drag-n-drop.component.js +0 -16
- package/dist/chart/components/pan/chart-pan.component.d.ts +3 -14
- package/dist/chart/components/pan/chart-pan.component.js +7 -21
- package/dist/chart/components/pane/pane-manager.component.d.ts +29 -0
- package/dist/chart/components/pane/pane-manager.component.js +71 -8
- package/dist/chart/components/pane/pane.component.d.ts +5 -17
- package/dist/chart/components/pane/pane.component.js +11 -28
- package/dist/chart/components/resizer/bar-resizer.component.d.ts +1 -1
- package/dist/chart/components/resizer/bar-resizer.component.js +3 -1
- package/dist/chart/components/y_axis/y-axis-scale.handler.js +3 -3
- package/dist/chart/components/y_axis/y-axis.component.js +1 -1
- package/dist/chart/inputhandlers/hover-producer.component.d.ts +1 -1
- package/dist/chart/inputhandlers/main-canvas-touch.handler.d.ts +11 -2
- package/dist/chart/inputhandlers/main-canvas-touch.handler.js +34 -2
- package/dist/chart/model/baseline.model.d.ts +3 -0
- package/dist/chart/model/baseline.model.js +5 -0
- package/dist/chart/model/chart-base-element.d.ts +2 -0
- package/dist/chart/model/chart-base-element.js +2 -0
- package/dist/chart/model/date-time.formatter.d.ts +20 -3
- package/dist/chart/model/date-time.formatter.js +62 -14
- package/dist/chart/model/scale.model.d.ts +5 -0
- package/dist/chart/model/scale.model.js +9 -1
- package/dist/chart/model/scaling/constrait.functions.d.ts +5 -7
- package/dist/chart/model/scaling/constrait.functions.js +3 -3
- package/dist/chart/model/time-zone.model.js +3 -1
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -19,6 +19,7 @@ export declare const BASELINE_RESIZER_UUID = "BASELINE_RESIZER";
|
|
|
19
19
|
*/
|
|
20
20
|
export declare class BaselineModel extends ChartBaseElement {
|
|
21
21
|
private chartModel;
|
|
22
|
+
private chartPanComponent;
|
|
22
23
|
private canvasModel;
|
|
23
24
|
private canvasInputListener;
|
|
24
25
|
private config;
|
|
@@ -29,6 +30,8 @@ export declare class BaselineModel extends ChartBaseElement {
|
|
|
29
30
|
ht: HitBoundsTest;
|
|
30
31
|
constructor(chartModel: ChartModel, chartPanComponent: ChartPanComponent, canvasModel: CanvasModel, canvasInputListener: CanvasInputListenerComponent, config: FullChartConfig, canvasBoundContainer: CanvasBoundsContainer, cursorHandler: CursorHandler);
|
|
31
32
|
protected doActivate(): void;
|
|
33
|
+
private dragStartCb;
|
|
34
|
+
private dragEndCb;
|
|
32
35
|
private dragTickCb;
|
|
33
36
|
/**
|
|
34
37
|
* Recalculates the bounds of the baseline resizer based on the current chart and y-axis bounds.
|
|
@@ -15,6 +15,7 @@ export class BaselineModel extends ChartBaseElement {
|
|
|
15
15
|
constructor(chartModel, chartPanComponent, canvasModel, canvasInputListener, config, canvasBoundContainer, cursorHandler) {
|
|
16
16
|
super();
|
|
17
17
|
this.chartModel = chartModel;
|
|
18
|
+
this.chartPanComponent = chartPanComponent;
|
|
18
19
|
this.canvasModel = canvasModel;
|
|
19
20
|
this.canvasInputListener = canvasInputListener;
|
|
20
21
|
this.config = config;
|
|
@@ -26,6 +27,8 @@ export class BaselineModel extends ChartBaseElement {
|
|
|
26
27
|
this.ht = CanvasBoundsContainer.hitTestOf(this.resizerBounds, {
|
|
27
28
|
extensionY: this.config.components.paneResizer.dragZone,
|
|
28
29
|
});
|
|
30
|
+
this.dragStartCb = () => this.chartPanComponent.deactivatePanHandlers();
|
|
31
|
+
this.dragEndCb = () => this.chartPanComponent.activateChartPanHandlers();
|
|
29
32
|
this.dragTickCb = (dragInfo) => {
|
|
30
33
|
const { delta: yDelta } = dragInfo;
|
|
31
34
|
const chart = this.canvasBoundContainer.getBounds(CanvasElement.CHART);
|
|
@@ -37,6 +40,8 @@ export class BaselineModel extends ChartBaseElement {
|
|
|
37
40
|
};
|
|
38
41
|
const dndHelper = new DragNDropYComponent(this.ht, {
|
|
39
42
|
onDragTick: this.dragTickCb,
|
|
43
|
+
onDragStart: this.dragStartCb,
|
|
44
|
+
onDragEnd: this.dragEndCb,
|
|
40
45
|
}, canvasInputListener, chartPanComponent);
|
|
41
46
|
this.addChildEntity(dndHelper);
|
|
42
47
|
}
|
|
@@ -46,12 +46,14 @@ export declare abstract class ChartBaseElement implements ChartEntity {
|
|
|
46
46
|
* Enables the functionality of an object.
|
|
47
47
|
* If the object is not currently active, it sets the state to 'deactivated' and activates it.
|
|
48
48
|
* @returns {void}
|
|
49
|
+
* @deprecated use `ChartBaseElement.activate()` instead
|
|
49
50
|
*/
|
|
50
51
|
enable(): void;
|
|
51
52
|
/**
|
|
52
53
|
* Disables the current object if it is not already disabled.
|
|
53
54
|
* If the object is not disabled, it will be deactivated and its state will be set to 'disabled'.
|
|
54
55
|
* @returns {void}
|
|
56
|
+
* @deprecated use `ChartBaseElement.deactivate()` instead
|
|
55
57
|
*/
|
|
56
58
|
disable(): void;
|
|
57
59
|
/**
|
|
@@ -34,6 +34,7 @@ export class ChartBaseElement {
|
|
|
34
34
|
* Enables the functionality of an object.
|
|
35
35
|
* If the object is not currently active, it sets the state to 'deactivated' and activates it.
|
|
36
36
|
* @returns {void}
|
|
37
|
+
* @deprecated use `ChartBaseElement.activate()` instead
|
|
37
38
|
*/
|
|
38
39
|
enable() {
|
|
39
40
|
if (this._state !== 'active') {
|
|
@@ -45,6 +46,7 @@ export class ChartBaseElement {
|
|
|
45
46
|
* Disables the current object if it is not already disabled.
|
|
46
47
|
* If the object is not disabled, it will be deactivated and its state will be set to 'disabled'.
|
|
47
48
|
* @returns {void}
|
|
49
|
+
* @deprecated use `ChartBaseElement.deactivate()` instead
|
|
48
50
|
*/
|
|
49
51
|
disable() {
|
|
50
52
|
if (this._state !== 'disabled') {
|
|
@@ -9,10 +9,10 @@ export interface TimeFormatterConfig {
|
|
|
9
9
|
shortMonths?: string[];
|
|
10
10
|
}
|
|
11
11
|
export interface DateTimeFormatter {
|
|
12
|
-
(date:
|
|
12
|
+
(date: number): string;
|
|
13
13
|
}
|
|
14
14
|
export type DateTimeFormatterFactory = (format: string) => DateTimeFormatter;
|
|
15
|
-
export declare const defaultDateTimeFormatter: () => (date:
|
|
15
|
+
export declare const defaultDateTimeFormatter: () => (date: number) => string;
|
|
16
16
|
/**
|
|
17
17
|
* Default chart-core time formatter.
|
|
18
18
|
* @param config
|
|
@@ -20,4 +20,21 @@ export declare const defaultDateTimeFormatter: () => (date: Date | number) => st
|
|
|
20
20
|
* @doc-tags chart-core,default-config,date-formatter
|
|
21
21
|
*/
|
|
22
22
|
export declare const dateTimeFormatterFactory: (config: FullChartConfig, offsetFunction: (timezone: string) => (time: number) => Date) => DateTimeFormatterFactory;
|
|
23
|
-
|
|
23
|
+
/**
|
|
24
|
+
* Returns an array of short day names based on the provided configuration object.
|
|
25
|
+
* If the configuration object does not contain shortDays property, it returns an array of default short day names.
|
|
26
|
+
*
|
|
27
|
+
* @param {TimeFormatterConfig} config - The configuration object containing shortDays property.
|
|
28
|
+
* @returns {string[]} - An array of short day names.
|
|
29
|
+
*/
|
|
30
|
+
export declare function getShortDays(config: TimeFormatterConfig): string[];
|
|
31
|
+
/**
|
|
32
|
+
* Returns an array of short month names based on the provided configuration object.
|
|
33
|
+
* If the configuration object does not have a 'shortMonths' property, it returns the default array of short month names.
|
|
34
|
+
*
|
|
35
|
+
* @param {TimeFormatterConfig} config - The configuration object that contains the shortMonths property.
|
|
36
|
+
* @returns {string[]} - An array of short month names.
|
|
37
|
+
*/
|
|
38
|
+
export declare function getShortMonths(config: TimeFormatterConfig): string[];
|
|
39
|
+
export declare const recalculateXFormatter: (xAxisLabelFormat: string | Array<DateTimeFormatConfig>, period: number, formatterFactory: (format: string) => (timestamp: number) => string) => DateTimeFormatter;
|
|
40
|
+
export declare const formatDate: (date: Date, patternStr: string, daysOfWeek: string[], months: string[]) => string;
|
|
@@ -31,7 +31,6 @@ export const dateTimeFormatterFactory = (config, offsetFunction) => {
|
|
|
31
31
|
['s', 'm', 'H', 'd', 'M'].forEach(function (k) {
|
|
32
32
|
patterns[k + k] = 'this.' + 'addZero' + '(' + patterns[k] + ')';
|
|
33
33
|
});
|
|
34
|
-
const re = new RegExp(Object.keys(patterns).sort().reverse().join('|'), 'g');
|
|
35
34
|
/**
|
|
36
35
|
* Returns a string that concatenates the result of the function getPrefix with the input string fn and the string '()'.
|
|
37
36
|
* @param {string} fn - The input string to concatenate.
|
|
@@ -58,14 +57,6 @@ export const dateTimeFormatterFactory = (config, offsetFunction) => {
|
|
|
58
57
|
function upperCase(fn) {
|
|
59
58
|
return fn + '.toUpperCase()';
|
|
60
59
|
}
|
|
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
60
|
return function (pattern) {
|
|
70
61
|
var _a;
|
|
71
62
|
const context = {
|
|
@@ -89,11 +80,10 @@ export const dateTimeFormatterFactory = (config, offsetFunction) => {
|
|
|
89
80
|
},
|
|
90
81
|
tzDate: offsetFunction((_a = config.timezone) !== null && _a !== void 0 ? _a : '') ||
|
|
91
82
|
function (date) {
|
|
92
|
-
return
|
|
83
|
+
return new Date(+date);
|
|
93
84
|
},
|
|
94
85
|
};
|
|
95
|
-
|
|
96
|
-
return new Function('date', 'date=this.' + 'tzDate' + "(date); return '" + pattern.replace(re, applyPattern) + "'").bind(context);
|
|
86
|
+
return (date) => formatDate(context.tzDate(date), pattern, context.shortDays, context.shortMonths);
|
|
97
87
|
};
|
|
98
88
|
};
|
|
99
89
|
/**
|
|
@@ -103,7 +93,7 @@ export const dateTimeFormatterFactory = (config, offsetFunction) => {
|
|
|
103
93
|
* @param {TimeFormatterConfig} config - The configuration object containing shortDays property.
|
|
104
94
|
* @returns {string[]} - An array of short day names.
|
|
105
95
|
*/
|
|
106
|
-
function getShortDays(config) {
|
|
96
|
+
export function getShortDays(config) {
|
|
107
97
|
var _a;
|
|
108
98
|
return (_a = config.shortDays) !== null && _a !== void 0 ? _a : ['Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'];
|
|
109
99
|
}
|
|
@@ -114,7 +104,7 @@ function getShortDays(config) {
|
|
|
114
104
|
* @param {TimeFormatterConfig} config - The configuration object that contains the shortMonths property.
|
|
115
105
|
* @returns {string[]} - An array of short month names.
|
|
116
106
|
*/
|
|
117
|
-
function getShortMonths(config) {
|
|
107
|
+
export function getShortMonths(config) {
|
|
118
108
|
var _a;
|
|
119
109
|
return (_a = config.shortMonths) !== null && _a !== void 0 ? _a : ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec'];
|
|
120
110
|
}
|
|
@@ -154,3 +144,61 @@ export const recalculateXFormatter = (xAxisLabelFormat, period, formatterFactory
|
|
|
154
144
|
}
|
|
155
145
|
return defaultDateTimeFormatter();
|
|
156
146
|
};
|
|
147
|
+
//#region Custom date pattern parser, transforms Date object to string by given pattern
|
|
148
|
+
// examples: dd.MM => 15.12, YYYY => 2024, HH:mm => 15:56
|
|
149
|
+
export const formatDate = (date, patternStr, daysOfWeek, months) => {
|
|
150
|
+
if (!patternStr) {
|
|
151
|
+
patternStr = 'M/d/yyyy';
|
|
152
|
+
}
|
|
153
|
+
const day = date.getDate();
|
|
154
|
+
const month = date.getMonth();
|
|
155
|
+
const year = date.getFullYear();
|
|
156
|
+
const hour = date.getHours();
|
|
157
|
+
const minute = date.getMinutes();
|
|
158
|
+
const second = date.getSeconds();
|
|
159
|
+
const miliseconds = date.getMilliseconds();
|
|
160
|
+
const h = hour % 12;
|
|
161
|
+
const hh = twoDigitPad(h);
|
|
162
|
+
const HH = twoDigitPad(hour);
|
|
163
|
+
const mm = twoDigitPad(minute);
|
|
164
|
+
const ss = twoDigitPad(second);
|
|
165
|
+
const aaa = hour < 12 ? 'AM' : 'PM';
|
|
166
|
+
const EEEE = daysOfWeek[date.getDay()];
|
|
167
|
+
const EEE = EEEE.substring(0, 3);
|
|
168
|
+
const dd = twoDigitPad(day);
|
|
169
|
+
const M = month + 1;
|
|
170
|
+
const MM = twoDigitPad(M);
|
|
171
|
+
const MMMM = months[month];
|
|
172
|
+
const MMM = MMMM.substring(0, 3);
|
|
173
|
+
const yyyy = year + '';
|
|
174
|
+
const yy = yyyy.substring(2, 4);
|
|
175
|
+
// checks to see if month name will be used
|
|
176
|
+
patternStr = patternStr
|
|
177
|
+
.replace('hh', hh + '')
|
|
178
|
+
.replace('h', h + '')
|
|
179
|
+
.replace('HH', HH + '')
|
|
180
|
+
.replace('H', hour + '')
|
|
181
|
+
.replace('mm', mm + '')
|
|
182
|
+
.replace('m', minute + '')
|
|
183
|
+
.replace('ss', ss + '')
|
|
184
|
+
.replace('s', second + '')
|
|
185
|
+
.replace('S', miliseconds + '')
|
|
186
|
+
.replace('dd', dd + '')
|
|
187
|
+
.replace('d', day + '')
|
|
188
|
+
.replace('EEEE', EEEE)
|
|
189
|
+
.replace('EEE', EEE)
|
|
190
|
+
.replace('YYYY', yyyy)
|
|
191
|
+
.replace('yyyy', yyyy)
|
|
192
|
+
.replace('YY', yy)
|
|
193
|
+
.replace('yy', yy)
|
|
194
|
+
.replace('aaa', aaa);
|
|
195
|
+
if (patternStr.indexOf('MMM') > -1) {
|
|
196
|
+
patternStr = patternStr.replace('MMMM', MMMM).replace('MMM', MMM);
|
|
197
|
+
}
|
|
198
|
+
else {
|
|
199
|
+
patternStr = patternStr.replace('MM', MM + '').replace('M', M + '');
|
|
200
|
+
}
|
|
201
|
+
return patternStr;
|
|
202
|
+
};
|
|
203
|
+
const twoDigitPad = (num) => (typeof num === 'number' && num < 10 ? '0' + num : num);
|
|
204
|
+
//#endregion
|
|
@@ -46,6 +46,10 @@ export declare class ScaleModel extends ViewportModel {
|
|
|
46
46
|
zoomXYRatio: ZoomXToZoomYRatio;
|
|
47
47
|
offsets: ChartConfigComponentsOffsets;
|
|
48
48
|
xConstraints: Constraints[];
|
|
49
|
+
maxZoomReached: {
|
|
50
|
+
zoomIn: boolean;
|
|
51
|
+
zoomOut: boolean;
|
|
52
|
+
};
|
|
49
53
|
readonly state: ChartScale;
|
|
50
54
|
constructor(config: FullChartConfig, getBounds: BoundsProvider, canvasAnimation: CanvasAnimation);
|
|
51
55
|
protected doActivate(): void;
|
|
@@ -82,6 +86,7 @@ export declare class ScaleModel extends ViewportModel {
|
|
|
82
86
|
zoomXToEnd(zoomIn: boolean, zoomSensitivity: number): void;
|
|
83
87
|
haltAnimation(): void;
|
|
84
88
|
private zoomXTo;
|
|
89
|
+
isMaxZoomXReached(zoomIn: boolean): boolean;
|
|
85
90
|
/**
|
|
86
91
|
* Moves the viewport to exactly xStart..xEnd place.
|
|
87
92
|
* (you need to fire DRAW event after this)
|
|
@@ -41,6 +41,7 @@ export class ScaleModel extends ViewportModel {
|
|
|
41
41
|
this.history = [];
|
|
42
42
|
this.zoomXYRatio = 0;
|
|
43
43
|
this.xConstraints = [];
|
|
44
|
+
this.maxZoomReached = { zoomIn: false, zoomOut: false };
|
|
44
45
|
this.scalePostProcessor = (initialState, state) => {
|
|
45
46
|
// for now <s>reduceRight<s/> reduce bcs ChartModel#getZoomConstrait should be invoked first
|
|
46
47
|
// if we will need more complex order handling -> add some managing
|
|
@@ -49,7 +50,11 @@ export class ScaleModel extends ViewportModel {
|
|
|
49
50
|
this.state = cloneUnsafe(config.scale);
|
|
50
51
|
this.autoScaleModel = new AutoScaleViewportSubModel(this);
|
|
51
52
|
this.offsets = this.config.components.offsets;
|
|
52
|
-
this.addXConstraint((initialState, state) =>
|
|
53
|
+
this.addXConstraint((initialState, state) => {
|
|
54
|
+
const { maxZoomReached, newState } = zoomConstraint(initialState, state, this.config.components.chart, this.getBounds);
|
|
55
|
+
this.maxZoomReached = maxZoomReached;
|
|
56
|
+
return newState;
|
|
57
|
+
});
|
|
53
58
|
}
|
|
54
59
|
doActivate() {
|
|
55
60
|
super.doActivate();
|
|
@@ -141,6 +146,9 @@ export class ScaleModel extends ViewportModel {
|
|
|
141
146
|
startViewportModelAnimation(this.canvasAnimation, this, constrainedState);
|
|
142
147
|
}
|
|
143
148
|
}
|
|
149
|
+
isMaxZoomXReached(zoomIn) {
|
|
150
|
+
return (this.maxZoomReached.zoomIn && zoomIn) || (this.maxZoomReached.zoomOut && !zoomIn);
|
|
151
|
+
}
|
|
144
152
|
/**
|
|
145
153
|
* Moves the viewport to exactly xStart..xEnd place.
|
|
146
154
|
* (you need to fire DRAW event after this)
|
|
@@ -33,11 +33,9 @@ export declare const candleEdgesConstrait: (state: ViewportModelState, visualCan
|
|
|
33
33
|
* @doc-tags viewport,zoom,scaling
|
|
34
34
|
*/
|
|
35
35
|
export declare const zoomConstraint: (_: ViewportModelState, state: ViewportModelState, chartConfig: ChartConfigComponentsChart, boundsProvider: BoundsProvider) => {
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
zoomY: number;
|
|
42
|
-
inverseY: boolean;
|
|
36
|
+
newState: ViewportModelState;
|
|
37
|
+
maxZoomReached: {
|
|
38
|
+
zoomIn: boolean;
|
|
39
|
+
zoomOut: boolean;
|
|
40
|
+
};
|
|
43
41
|
};
|
|
@@ -53,13 +53,13 @@ export const zoomConstraint = (_, state, chartConfig, boundsProvider) => {
|
|
|
53
53
|
if (maxViewportReached) {
|
|
54
54
|
newState.xStart = newState.xEnd - maxCandlesInViewport;
|
|
55
55
|
newState.zoomX = calculateZoom(newState.xEnd - newState.xStart, bounds.width);
|
|
56
|
-
return newState;
|
|
56
|
+
return { newState, maxZoomReached: { zoomOut: true, zoomIn: false } };
|
|
57
57
|
}
|
|
58
58
|
if (minViewportReached) {
|
|
59
59
|
newState.xStart = newState.xEnd - chartConfig.minCandles;
|
|
60
60
|
newState.zoomX = calculateZoom(newState.xEnd - newState.xStart, bounds.width);
|
|
61
|
-
return newState;
|
|
61
|
+
return { newState, maxZoomReached: { zoomOut: false, zoomIn: true } };
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
|
-
return newState;
|
|
64
|
+
return { newState, maxZoomReached: { zoomOut: false, zoomIn: false } };
|
|
65
65
|
};
|
|
@@ -87,7 +87,9 @@ export class TimeZoneModel {
|
|
|
87
87
|
// In JS Date object is created with local tz offset,
|
|
88
88
|
// so we have to subtract localOffset from current time
|
|
89
89
|
return time => {
|
|
90
|
-
return new Date(time +
|
|
90
|
+
return new Date(time +
|
|
91
|
+
getTimezoneOffset(timezone, time) +
|
|
92
|
+
new Date(time).getTimezoneOffset() * timeMultiplier);
|
|
91
93
|
};
|
|
92
94
|
}
|
|
93
95
|
}
|