Skip to content

Commit

Permalink
Fixed tradingview#1005: gradients of baseline and area series
Browse files Browse the repository at this point in the history
  • Loading branch information
markeasting committed Feb 14, 2022
1 parent 8085baf commit 5ab39be
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 7 deletions.
13 changes: 10 additions & 3 deletions src/views/pane/area-pane-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,17 @@ export class SeriesAreaPaneView extends LinePaneViewBase<'Area', LineItem> {
}

const areaStyleProperties = this._series.options();
const priceScaleProps = this._series.priceScale().options();
const priceScale = this._series.priceScale();
const priceScaleProps = priceScale.options();
const isCustomScale = priceScale.id() !== 'right' && priceScale.id() !== 'left';

const bottom = height;
const top = priceScaleProps.scaleMargins ? priceScaleProps.scaleMargins.top * height : 0;
let top = 0;
let bottom = height;

if (isCustomScale && priceScaleProps.scaleMargins) {
bottom = height;
top = priceScaleProps.scaleMargins.top * height;
}

this._makeValid();

Expand Down
15 changes: 11 additions & 4 deletions src/views/pane/baseline-pane-view.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,22 @@ export class SeriesBaselinePaneView extends LinePaneViewBase<'Baseline', LineIte
}

const baselineProps = this._series.options();
const priceScaleProps = this._series.priceScale().options();
const priceScale = this._series.priceScale();
const priceScaleProps = priceScale.options();
const isCustomScale = priceScale.id() !== 'right' && priceScale.id() !== 'left';

this._makeValid();

const baseLevelCoordinate = this._series.priceScale().priceToCoordinate(baselineProps.baseValue.price, firstValue.value);
const baseLevelCoordinate = priceScale.priceToCoordinate(baselineProps.baseValue.price, firstValue.value);
const barWidth = this._model.timeScale().barSpacing();

const bottom = priceScaleProps.scaleMargins ? (1 - priceScaleProps.scaleMargins.bottom) * height : height;
const top = priceScaleProps.scaleMargins ? priceScaleProps.scaleMargins.top * height : 0;
let top = 0;
let bottom = height;

if (baselineProps.baseValue.type === 'price' && isCustomScale && priceScaleProps.scaleMargins) {
bottom = height * (1 - priceScaleProps.scaleMargins.bottom);
top = height * priceScaleProps.scaleMargins.top;
}

this._baselineAreaRenderer.setData({
items: this._items,
Expand Down

0 comments on commit 5ab39be

Please sign in to comment.