@devexperts/dxcharts-lite 2.7.4 → 2.7.6
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/canvas/canvas-bounds-container.js +5 -2
- package/dist/chart/components/pane/extent/y-extent-component.d.ts +2 -0
- package/dist/chart/components/pane/pane-manager.component.js +7 -2
- package/dist/chart/components/pane/pane.component.js +15 -1
- package/dist/chart/components/x_axis/x-axis-time-labels.drawer.js +3 -0
- package/dist/chart/components/y_axis/price_labels/last-candle-labels.provider.js +4 -1
- package/dist/chart/components/y_axis/y-axis.component.d.ts +1 -1
- package/dist/chart/components/y_axis/y-axis.component.js +1 -1
- package/dist/chart/model/visual-candle.d.ts +1 -0
- package/dist/chart/model/visual-candle.js +1 -0
- package/dist/dxchart.min.js +4 -4
- package/package.json +1 -1
|
@@ -367,11 +367,14 @@ export class CanvasBoundsContainer {
|
|
|
367
367
|
*/
|
|
368
368
|
getXAxisBounds(nMap, canvas) {
|
|
369
369
|
const xAxis = this.getBounds(CanvasElement.X_AXIS);
|
|
370
|
+
const isSingleYAxis = this.yAxisWidths.left.length + this.yAxisWidths.right.length === 1;
|
|
371
|
+
const leftOffset = isSingleYAxis ? 0 : this.yAxisWidths.left.reduce((acc, width) => (acc += width), 0);
|
|
372
|
+
const rightOffset = isSingleYAxis ? 0 : this.yAxisWidths.right.reduce((acc, width) => (acc += width), 0);
|
|
370
373
|
if (this.config.components.xAxis.visible) {
|
|
371
374
|
const xAxisHeight = this.getXAxisHeight();
|
|
372
|
-
xAxis.x =
|
|
375
|
+
xAxis.x = leftOffset;
|
|
373
376
|
xAxis.y = canvas.height - xAxisHeight - nMap.height;
|
|
374
|
-
xAxis.width = canvas.width;
|
|
377
|
+
xAxis.width = canvas.width - rightOffset;
|
|
375
378
|
xAxis.height = xAxisHeight;
|
|
376
379
|
}
|
|
377
380
|
else {
|
|
@@ -25,6 +25,8 @@ export interface YExtentCreationOptions {
|
|
|
25
25
|
paneFormatters: YExtentFormatters;
|
|
26
26
|
increment: number | null;
|
|
27
27
|
initialYAxisState: YAxisConfig;
|
|
28
|
+
inverse: boolean;
|
|
29
|
+
lockToPriceRatio: boolean;
|
|
28
30
|
}
|
|
29
31
|
export declare class YExtentComponent extends ChartBaseElement {
|
|
30
32
|
paneUUID: string;
|
|
@@ -195,11 +195,16 @@ export class PaneManager extends ChartBaseElement {
|
|
|
195
195
|
moveDataSeriesToPane(dataSeries, initialPane, initialExtent, options) {
|
|
196
196
|
const { paneUUID, extent, direction, align, extentIdx, isForceKeepPane, index = 0 } = options;
|
|
197
197
|
const pane = paneUUID && this.panes[paneUUID];
|
|
198
|
-
const initialYAxisState = align ? Object.assign(Object.assign({},
|
|
198
|
+
const initialYAxisState = align ? Object.assign(Object.assign({}, initialExtent.yAxis.state), { align }) : undefined;
|
|
199
199
|
const onNewScale = extentIdx && extentIdx > 0;
|
|
200
200
|
if (!pane) {
|
|
201
201
|
const order = direction && direction === 'above' ? index : index + 1;
|
|
202
|
-
const newPane = this.createPane(paneUUID, {
|
|
202
|
+
const newPane = this.createPane(paneUUID, {
|
|
203
|
+
order,
|
|
204
|
+
initialYAxisState,
|
|
205
|
+
inverse: initialExtent.scale.state.inverse,
|
|
206
|
+
lockToPriceRatio: initialExtent.scale.state.lockPriceToBarRatio,
|
|
207
|
+
});
|
|
203
208
|
newPane.moveDataSeriesToExistingExtentComponent(dataSeries, initialPane, initialExtent, newPane.mainExtent, isForceKeepPane);
|
|
204
209
|
!isForceKeepPane && initialPane.yExtentComponents.length === 0 && this.removePane(initialPane.uuid);
|
|
205
210
|
return;
|
|
@@ -9,10 +9,12 @@ import { areBoundsChanged, CanvasElement, } from '../../canvas/canvas-bounds-con
|
|
|
9
9
|
import { ChartBaseElement } from '../../model/chart-base-element';
|
|
10
10
|
import { SyncedByXScaleModel } from '../../model/scale.model';
|
|
11
11
|
import { firstOf, flatMap, lastOf } from '../../utils/array.utils';
|
|
12
|
+
import { cloneUnsafe } from '../../utils/object.utils';
|
|
12
13
|
import { createCandlesOffsetProvider } from '../chart/data-series.high-low-provider';
|
|
13
14
|
import { GridComponent } from '../grid/grid.component';
|
|
14
15
|
import { YAxisComponent } from '../y_axis/y-axis.component';
|
|
15
16
|
import { createDefaultYExtentHighLowProvider, YExtentComponent, } from './extent/y-extent-component';
|
|
17
|
+
import { merge } from '../../utils/merge.utils';
|
|
16
18
|
export class PaneComponent extends ChartBaseElement {
|
|
17
19
|
get scale() {
|
|
18
20
|
return this.mainExtent.scale;
|
|
@@ -135,6 +137,8 @@ export class PaneComponent extends ChartBaseElement {
|
|
|
135
137
|
yExtentComponent.addSubscription(unsub);
|
|
136
138
|
yExtentComponent.addSubscription(this.addCursors(extentIdx, yExtentComponent.yAxis));
|
|
137
139
|
(options === null || options === void 0 ? void 0 : options.paneFormatters) && yExtentComponent.setValueFormatters(options.paneFormatters);
|
|
140
|
+
yExtentComponent.yAxis.togglePriceScaleInverse(options === null || options === void 0 ? void 0 : options.inverse);
|
|
141
|
+
yExtentComponent.scale.setLockPriceToBarRatio(options === null || options === void 0 ? void 0 : options.lockToPriceRatio);
|
|
138
142
|
const useDefaultHighLow = (_b = options === null || options === void 0 ? void 0 : options.useDefaultHighLow) !== null && _b !== void 0 ? _b : true;
|
|
139
143
|
if (useDefaultHighLow) {
|
|
140
144
|
scaleModel.autoScaleModel.setHighLowProvider('default', createCandlesOffsetProvider(() => ({ top: 10, bottom: 10, left: 0, right: 0, visible: true }), createDefaultYExtentHighLowProvider(yExtentComponent)));
|
|
@@ -163,7 +167,17 @@ export class PaneComponent extends ChartBaseElement {
|
|
|
163
167
|
* Create new pane extent and attach data series to it
|
|
164
168
|
*/
|
|
165
169
|
moveDataSeriesToNewExtentComponent(dataSeries, initialPane, initialExtent, align = 'right') {
|
|
166
|
-
const
|
|
170
|
+
const yAxisConfigCopy = cloneUnsafe(initialExtent.yAxis.state);
|
|
171
|
+
const scaleConfigCopy = cloneUnsafe(initialExtent.scale.state);
|
|
172
|
+
const initialYAxisState = merge(yAxisConfigCopy, this.config.components.yAxis, {
|
|
173
|
+
overrideExisting: false,
|
|
174
|
+
addIfMissing: true,
|
|
175
|
+
});
|
|
176
|
+
const extent = this.createExtentComponent({
|
|
177
|
+
initialYAxisState,
|
|
178
|
+
inverse: scaleConfigCopy.inverse,
|
|
179
|
+
lockToPriceRatio: scaleConfigCopy.lockPriceToBarRatio,
|
|
180
|
+
});
|
|
167
181
|
extent.yAxis.setYAxisAlign(align);
|
|
168
182
|
dataSeries.forEach(series => series.moveToExtent(extent));
|
|
169
183
|
initialExtent.dataSeries.size === 0 && initialPane.removeExtentComponents([initialExtent]);
|
|
@@ -61,6 +61,9 @@ export class XAxisTimeLabelsDrawer {
|
|
|
61
61
|
ctx.fillStyle = color;
|
|
62
62
|
for (const label of labels) {
|
|
63
63
|
const x = this.viewportModel.toX(label.value) - calculateTextWidth(label.text, ctx, font) / 2;
|
|
64
|
+
if (x < bounds.x || x > bounds.width) {
|
|
65
|
+
continue;
|
|
66
|
+
}
|
|
64
67
|
const y = bounds.y + fontHeight - 1 + offsetTop; // -1 for font drawing inconsistency
|
|
65
68
|
const labelText = label.text;
|
|
66
69
|
ctx.font = font;
|
|
@@ -98,7 +98,10 @@ export class LastCandleLabelsProvider {
|
|
|
98
98
|
const boxColor = getLabelColorBySeries(series.lastPriceMovement, series.colors);
|
|
99
99
|
// if the label is for the main candle series
|
|
100
100
|
if (primary) {
|
|
101
|
-
const
|
|
101
|
+
const isScatterPlot = series.config.type === 'scatterPlot';
|
|
102
|
+
const textColor = isScatterPlot
|
|
103
|
+
? rectLabelTextColor
|
|
104
|
+
: getPrimaryLabelTextColor(series.lastPriceMovement, colors);
|
|
102
105
|
return {
|
|
103
106
|
bgColor: boxColor,
|
|
104
107
|
textColor: appearanceType === 'plain'
|
|
@@ -149,7 +149,7 @@ export declare class YAxisComponent extends ChartBaseElement {
|
|
|
149
149
|
* Inversion also works for candles, drawings and overlay studies.
|
|
150
150
|
* @param inverse - true or false
|
|
151
151
|
*/
|
|
152
|
-
togglePriceScaleInverse(inverse
|
|
152
|
+
togglePriceScaleInverse(inverse?: boolean): void;
|
|
153
153
|
/**
|
|
154
154
|
* Changes the visibility of the labels' descriptions.
|
|
155
155
|
* @param {boolean} descVisibility - A boolean value indicating whether the descriptions should be visible or not.
|
|
@@ -244,7 +244,7 @@ export class YAxisComponent extends ChartBaseElement {
|
|
|
244
244
|
* Inversion also works for candles, drawings and overlay studies.
|
|
245
245
|
* @param inverse - true or false
|
|
246
246
|
*/
|
|
247
|
-
togglePriceScaleInverse(inverse) {
|
|
247
|
+
togglePriceScaleInverse(inverse = false) {
|
|
248
248
|
this.scale.state.inverse = inverse;
|
|
249
249
|
this.scale.inverseY = inverse;
|
|
250
250
|
this.model.fancyLabelsModel.updateLabels();
|
|
@@ -23,6 +23,7 @@ export default class VisualCandle extends VisualSeriesPoint {
|
|
|
23
23
|
constructor(x, width, open, close, high, low, name, candle, hasBorder = false, isActive = false, isHollow = false) {
|
|
24
24
|
super(x, close);
|
|
25
25
|
this.startUnit = x - width / 2;
|
|
26
|
+
this.endUnit = x + width / 2;
|
|
26
27
|
this.width = width;
|
|
27
28
|
this.open = open;
|
|
28
29
|
this.high = high;
|