implement drawing methods, fix horizontal line bug, continue refactor
This commit is contained in:
@ -57,7 +57,7 @@ export class HorizontalLine extends Drawing {
|
||||
}
|
||||
|
||||
_onDrag(diff: any) {
|
||||
Drawing._addDiffToPoint(this._point, 0, 0, diff.price);
|
||||
this._addDiffToPoint(this._point, 0, diff.price);
|
||||
this.requestUpdate();
|
||||
}
|
||||
|
||||
|
||||
@ -2,6 +2,7 @@ import { CanvasRenderingTarget2D } from "fancy-canvas";
|
||||
import { DrawingOptions } from "../drawing/options";
|
||||
import { DrawingPaneRenderer } from "../drawing/pane-renderer";
|
||||
import { ViewPoint } from "../drawing/pane-view";
|
||||
import { setLineStyle } from "../helpers/canvas-rendering";
|
||||
|
||||
export class HorizontalLinePaneRenderer extends DrawingPaneRenderer {
|
||||
_point: ViewPoint = {x: null, y: null};
|
||||
@ -21,6 +22,7 @@ export class HorizontalLinePaneRenderer extends DrawingPaneRenderer {
|
||||
|
||||
ctx.lineWidth = this._options.width;
|
||||
ctx.strokeStyle = this._options.lineColor;
|
||||
setLineStyle(ctx, this._options.lineStyle);
|
||||
ctx.beginPath();
|
||||
|
||||
ctx.moveTo(scaledX, scaledY);
|
||||
|
||||
@ -16,7 +16,9 @@ export class HorizontalLinePaneView extends DrawingPaneView {
|
||||
const point = this._source._point;
|
||||
const timeScale = this._source.chart.timeScale()
|
||||
const series = this._source.series;
|
||||
this._point.x = point.time ? timeScale.timeToCoordinate(point.time) : null;
|
||||
if (this._source._type == "RayLine") {
|
||||
this._point.x = timeScale.logicalToCoordinate(point.logical);
|
||||
}
|
||||
this._point.y = series.priceToCoordinate(point.price);
|
||||
}
|
||||
|
||||
|
||||
@ -2,8 +2,7 @@ import {
|
||||
DeepPartial,
|
||||
MouseEventParams
|
||||
} from "lightweight-charts";
|
||||
import { Point } from "../drawing/data-source";
|
||||
import { Drawing } from "../drawing/drawing";
|
||||
import { DiffPoint, Point } from "../drawing/data-source";
|
||||
import { DrawingOptions } from "../drawing/options";
|
||||
import { HorizontalLine } from "./horizontal-line";
|
||||
|
||||
@ -20,8 +19,8 @@ export class RayLine extends HorizontalLine {
|
||||
this.requestUpdate();
|
||||
}
|
||||
|
||||
_onDrag(diff: any) {
|
||||
Drawing._addDiffToPoint(this._point, diff.time, diff.logical, diff.price);
|
||||
_onDrag(diff: DiffPoint) {
|
||||
this._addDiffToPoint(this._point, diff.logical, diff.price);
|
||||
this.requestUpdate();
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user