@devexperts/dxcharts-lite 2.7.5 → 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.
@@ -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({}, this.panes[CHART_UUID].yAxis.state), { align }) : undefined;
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, { order, initialYAxisState });
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 extent = this.createExtentComponent();
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]);
@@ -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 textColor = getPrimaryLabelTextColor(series.lastPriceMovement, colors);
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: boolean): void;
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();
@@ -30,6 +30,7 @@ export default class VisualCandle extends VisualSeriesPoint {
30
30
  name: PriceMovement;
31
31
  candle: Candle;
32
32
  startUnit: Unit;
33
+ endUnit: Unit;
33
34
  hasBorder: boolean;
34
35
  isActive: boolean;
35
36
  isHollow: boolean;
@@ -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;