Skip to content

Commit

Permalink
removing custom price line draggable. It was messing with grid vertic…
Browse files Browse the repository at this point in the history
…al lines and it seemed to fail some graphical tests pertaining to gradients and or transparency. I dont know why. Someone is already working on implementing it to V4 here

tradingview/lightweight-charts#1086  So i am deferring to that.
  • Loading branch information
difurious committed Jun 12, 2023
1 parent 3b1f96b commit 140da15
Show file tree
Hide file tree
Showing 10 changed files with 14 additions and 227 deletions.
31 changes: 2 additions & 29 deletions src/api/chart-api.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ChartWidget, CustomPriceLineDraggedEventParamsImpl, CustomPriceLineDraggedEventParamsImplSupplier, LineToolsAfterEditEventParamsImpl, LineToolsAfterEditEventParamsImplSupplier, LineToolsDoubleClickEventParamsImpl, LineToolsDoubleClickEventParamsImplSupplier, MouseEventParamsImpl, MouseEventParamsImplSupplier } from '../gui/chart-widget';
import { ChartWidget, LineToolsAfterEditEventParamsImpl, LineToolsAfterEditEventParamsImplSupplier, LineToolsDoubleClickEventParamsImpl, LineToolsDoubleClickEventParamsImplSupplier, MouseEventParamsImpl, MouseEventParamsImplSupplier } from '../gui/chart-widget';

import { ensureDefined } from '../helpers/assertions';
import { Delegate } from '../helpers/delegate';
Expand Down Expand Up @@ -35,7 +35,7 @@ import {
import { CandlestickSeriesApi } from './candlestick-series-api';
import { DataUpdatesConsumer, SeriesDataItemTypeMap } from './data-consumer';
import { DataLayer, DataUpdateResponse, SeriesChanges } from './data-layer';
import { CustomPriceLineDraggedEventHandler, CustomPriceLineDraggedEventParams, IChartApi, LineToolsAfterEditEventHandler, LineToolsAfterEditEventParams, LineToolsDoubleClickEventHandler, LineToolsDoubleClickEventParams, MouseEventHandler, MouseEventParams } from './ichart-api';
import { IChartApi, LineToolsAfterEditEventHandler, LineToolsAfterEditEventParams, LineToolsDoubleClickEventHandler, LineToolsDoubleClickEventParams, MouseEventHandler, MouseEventParams } from './ichart-api';
import { IPriceScaleApi } from './iprice-scale-api';
import { ISeriesApi } from './iseries-api';
import { ITimeScaleApi } from './itime-scale-api';
Expand Down Expand Up @@ -164,7 +164,6 @@ export class ChartApi implements IChartApi, DataUpdatesConsumer<SeriesType> {

private readonly _clickedDelegate: Delegate<MouseEventParams> = new Delegate();
private readonly _crosshairMovedDelegate: Delegate<MouseEventParams> = new Delegate();
private readonly _customPriceLineDraggedDelegate: Delegate<CustomPriceLineDraggedEventParams> = new Delegate();
private readonly _lineToolsDoubleClickDelegate: Delegate<LineToolsDoubleClickEventParams> = new Delegate();
private readonly _lineToolsAfterEditDelegate: Delegate<LineToolsAfterEditEventParams> = new Delegate();

Expand Down Expand Up @@ -194,15 +193,6 @@ export class ChartApi implements IChartApi, DataUpdatesConsumer<SeriesType> {
this
);

this._chartWidget.customPriceLineDragged().subscribe(
(paramSupplier: CustomPriceLineDraggedEventParamsImplSupplier) => {
if (this._customPriceLineDraggedDelegate.hasListeners()) {
this._customPriceLineDraggedDelegate.fire(this._convertCustomPriceLineDraggedParams(paramSupplier()));
}
},
this
);

this._chartWidget.lineToolsDoubleClick().subscribe(
(paramSupplier: LineToolsDoubleClickEventParamsImplSupplier) => {
if (this._lineToolsDoubleClickDelegate.hasListeners()) {
Expand Down Expand Up @@ -236,7 +226,6 @@ export class ChartApi implements IChartApi, DataUpdatesConsumer<SeriesType> {
public remove(): void {
this._chartWidget.clicked().unsubscribeAll(this);
this._chartWidget.crosshairMoved().unsubscribeAll(this);
this._chartWidget.customPriceLineDragged().unsubscribeAll(this);
this._chartWidget.lineToolsDoubleClick().unsubscribeAll(this);
this._chartWidget.lineToolsAfterEdit().unsubscribeAll(this);

Expand All @@ -248,7 +237,6 @@ export class ChartApi implements IChartApi, DataUpdatesConsumer<SeriesType> {

this._clickedDelegate.destroy();
this._crosshairMovedDelegate.destroy();
this._customPriceLineDraggedDelegate.destroy();
this._lineToolsDoubleClickDelegate.destroy();
this._lineToolsAfterEditDelegate.destroy();
this._dataLayer.destroy();
Expand Down Expand Up @@ -487,14 +475,6 @@ export class ChartApi implements IChartApi, DataUpdatesConsumer<SeriesType> {
this._crosshairMovedDelegate.unsubscribe(handler);
}

public subscribeCustomPriceLineDragged(handler: CustomPriceLineDraggedEventHandler): void {
this._customPriceLineDraggedDelegate.subscribe(handler);
}

public unsubscribeCustomPriceLineDragged(handler: CustomPriceLineDraggedEventHandler): void {
this._customPriceLineDraggedDelegate.unsubscribe(handler);
}

public subscribeLineToolsDoubleClick(handler: LineToolsDoubleClickEventHandler): void {
this._lineToolsDoubleClickDelegate.subscribe(handler);
}
Expand Down Expand Up @@ -570,13 +550,6 @@ export class ChartApi implements IChartApi, DataUpdatesConsumer<SeriesType> {
};
}

private _convertCustomPriceLineDraggedParams(param: CustomPriceLineDraggedEventParamsImpl): CustomPriceLineDraggedEventParams {
return {
customPriceLine: param.customPriceLine,
fromPriceString: param.fromPriceString,
};
}

private _convertLineToolsDoubleClickParams(param: LineToolsDoubleClickEventParamsImpl): LineToolsDoubleClickEventParams {
return {
selectedLineTool: param.selectedLineTool,
Expand Down
22 changes: 0 additions & 22 deletions src/api/ichart-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ import { DeepPartial } from '../helpers/strict-type-checks';

import { BarPrice, BarPrices } from '../model/bar';
import { ChartOptions } from '../model/chart-model';
import { CustomPriceLine } from '../model/custom-price-line';
import { LineToolExport, LineToolPoint } from '../model/line-tool';
import { LineToolPartialOptionsMap, LineToolType } from '../model/line-tool-options';
import { Point } from '../model/point';
Expand Down Expand Up @@ -62,13 +61,6 @@ export interface MouseEventParams {
*/
export type MouseEventHandler = (param: MouseEventParams) => void;

export interface CustomPriceLineDraggedEventParams {
customPriceLine: CustomPriceLine;
fromPriceString: string;
}

export type CustomPriceLineDraggedEventHandler = (param: CustomPriceLineDraggedEventParams) => void;

export interface LineToolsDoubleClickEventParams {
selectedLineTool: LineToolExport<LineToolType>;
}
Expand Down Expand Up @@ -291,20 +283,6 @@ export interface IChartApi {
*/
unsubscribeCrosshairMove(handler: MouseEventHandler): void;

/**
* Adds a subscription to receive notifications on custom price lines being dragged
*
* @param handler - handler (function) to be called on dragged
*/
subscribeCustomPriceLineDragged(handler: CustomPriceLineDraggedEventHandler): void;

/**
* Removes custom price line dragged subscription
*
* @param handler - previously subscribed handler
*/
unsubscribeCustomPriceLineDragged(handler: CustomPriceLineDraggedEventHandler): void;

/**
* Adds a subscription to receive notifications on linetools being double clicked
*
Expand Down
2 changes: 0 additions & 2 deletions src/api/iprice-scale-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@ export interface IPriceScaleApi {
*/
options(): Readonly<PriceScaleOptions>;

formatPrice(price: number, firstValue: number): string;

/**
* Returns a width of the price scale if it's visible or 0 if invisible.
*/
Expand Down
1 change: 0 additions & 1 deletion src/api/options/price-line-options-defaults.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ export const priceLineOptionsDefaults: PriceLineOptions = {
lineVisible: true,
axisLabelVisible: true,
title: '',
draggable: false,
ray: false,
rayStart: 0,
};
4 changes: 0 additions & 4 deletions src/api/price-scale-api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,6 @@ export class PriceScaleApi implements IPriceScaleApi {
return this._chartWidget.getPriceAxisWidth(this._priceScaleId === DefaultPriceScaleId.Left ? 'left' : 'right');
}

public formatPrice(price: number, firstValue: number = 0): string {
return this._priceScale().formatPrice(price, firstValue);
}

private _priceScale(): PriceScale {
return ensureNotNull(this._chartWidget.model().findPriceScale(this._priceScaleId)).priceScale;
}
Expand Down
26 changes: 0 additions & 26 deletions src/gui/chart-widget.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import { DeepPartial } from '../helpers/strict-type-checks';
import { BarPrice, BarPrices } from '../model/bar';
import { ChartModel, ChartOptionsInternal } from '../model/chart-model';
import { Coordinate } from '../model/coordinate';
import { CustomPriceLine } from '../model/custom-price-line';
import {
InvalidateMask,
InvalidationLevel,
Expand Down Expand Up @@ -37,13 +36,6 @@ export interface MouseEventParamsImpl {

export type MouseEventParamsImplSupplier = () => MouseEventParamsImpl;

export interface CustomPriceLineDraggedEventParamsImpl {
customPriceLine: CustomPriceLine;
fromPriceString: string;
}

export type CustomPriceLineDraggedEventParamsImplSupplier = () => CustomPriceLineDraggedEventParamsImpl;

export interface LineToolsDoubleClickEventParamsImpl {
selectedLineTool: LineToolExport<LineToolType>;
}
Expand Down Expand Up @@ -74,7 +66,6 @@ export class ChartWidget implements IDestroyable {
private _drawPlanned: boolean = false;
private _clicked: Delegate<MouseEventParamsImplSupplier> = new Delegate();
private _crosshairMoved: Delegate<MouseEventParamsImplSupplier> = new Delegate();
private _customPriceLineDragged: Delegate<CustomPriceLineDraggedEventParamsImplSupplier> = new Delegate();
private _lineToolsDoubleClick: Delegate<LineToolsDoubleClickEventParamsImplSupplier> = new Delegate();
private _lineToolsAfterEdit: Delegate<LineToolsAfterEditEventParamsImplSupplier> = new Delegate();
private _onWheelBound: (event: WheelEvent) => void;
Expand All @@ -101,7 +92,6 @@ export class ChartWidget implements IDestroyable {
this._options
);
this.model().crosshairMoved().subscribe(this._onPaneWidgetCrosshairMoved.bind(this), this);
this.model().customPriceLineDragged().subscribe(this._onCustomPriceLineDragged.bind(this), this);
this.model().lineToolsDoubleClick().subscribe(this._onLineToolsDoubleClick.bind(this), this);
this.model().lineToolsAfterEdit().subscribe(this._onLineToolsAfterEdit.bind(this), this);

Expand Down Expand Up @@ -163,7 +153,6 @@ export class ChartWidget implements IDestroyable {
}

this._model.crosshairMoved().unsubscribeAll(this);
this._model.customPriceLineDragged().unsubscribeAll(this);
this._model.lineToolsDoubleClick().unsubscribeAll(this);
this._model.timeScale().optionsApplied().unsubscribeAll(this);
this._model.priceScalesOptionsChanged().unsubscribeAll(this);
Expand Down Expand Up @@ -250,10 +239,6 @@ export class ChartWidget implements IDestroyable {
return this._crosshairMoved;
}

public customPriceLineDragged(): ISubscription<CustomPriceLineDraggedEventParamsImplSupplier> {
return this._customPriceLineDragged;
}

public lineToolsDoubleClick(): ISubscription<LineToolsDoubleClickEventParamsImplSupplier> {
return this._lineToolsDoubleClick;
}
Expand Down Expand Up @@ -688,13 +673,6 @@ export class ChartWidget implements IDestroyable {
};
}

private _getCustomPriceLineDraggedEventParamsImpl(customPriceLine: CustomPriceLine, fromPriceString: string): CustomPriceLineDraggedEventParamsImpl {
return {
customPriceLine: customPriceLine,
fromPriceString: fromPriceString,
};
}

private _getLineToolsDoubleClickEventParamsImpl(selectedLineTool: LineToolExport<LineToolType>): LineToolsDoubleClickEventParamsImpl {
return {
selectedLineTool: selectedLineTool,
Expand All @@ -716,10 +694,6 @@ export class ChartWidget implements IDestroyable {
this._crosshairMoved.fire(() => this._getMouseEventParamsImpl(time, point));
}

private _onCustomPriceLineDragged(customPriceLine: CustomPriceLine, fromPriceString: string): void {
this._customPriceLineDragged.fire(() => this._getCustomPriceLineDraggedEventParamsImpl(customPriceLine, fromPriceString));
}

private _onLineToolsDoubleClick(selectedLineTool: LineToolExport<LineToolType>): void {
this._lineToolsDoubleClick.fire(() => this._getLineToolsDoubleClickEventParamsImpl(selectedLineTool));
}
Expand Down
Loading

0 comments on commit 140da15

Please sign in to comment.