Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

335
Views
fitContent(); for rightPriceScale - lightweight-charts

is there any way to fitContent for right price scale in lightweight charts? I did not find any info for that in documentation.

I am trying to display two data series, but they are in different ranges (tens of thousands vs tens)

Here is my jsfiddle. I would appreciate any hint. https://jsfiddle.net/05zx4e76/5/

var chart = LightweightCharts.createChart(tvchart, {
    width: '600',
    height: '300',
    rightPriceScale: {
        visible: true,
    borderColor: 'rgba(197, 203, 206, 1)',
    lockVisibleTimeRangeOnResize: true,
    },
      localization: {
        locale: 'en-US',
    },
    leftPriceScale: {
        visible: true,
    borderColor: 'rgba(197, 203, 206, 1)',
    lockVisibleTimeRangeOnResize: true,
    },
    grid: {
    horzLines: {
        color: '#363C4E',
    },
    vertLines: {
        color: '#2B2B43',
    },
    },
    crosshair: {
        mode: LightweightCharts.CrosshairMode.Normal,
    },
    timeScale: {
        borderColor: 'rgba(197, 203, 206, 1)',
    },
    handleScroll: {
        vertTouchDrag: false,
    },
    layout: {
        backgroundColor: '#2B2B43',
        lineColor: '#2B2B43',
        textColor: '#D9D9D9',
    }
});

chart.applyOptions({
    timeScale: {
        rightOffset: 12,
        barSpacing: 3,
        fixLeftEdge: false,
        rightBarStaysOnScroll: false,
        borderVisible: false,
        borderColor: '#fff000',
        visible: true,
        timeVisible: true,
        secondsVisible: false        }
    }
);
about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

If you try to use development build instead of production one (just replace a string in the path to standalone bundle) you'll get an error: Error: Assertion failed: data must be asc ordered by time, index=1, time=1643907722, prev time=1643911322 that means that the data for your line series is not sorted as it should be.

If you sort your data initially or add .sort((a, b) => a.time - b.time) next to the array of line data it will work as expected.

https://jsfiddle.net/Lfegob51/

about 4 years ago · Juan Pablo Isaza Report

0

Solved by the following:

chart.priceScale('right').applyOptions({
    scaleMargins: {
        top: 0.96,
        bottom: 0,
    },
});

I have no idea how it works. Documentation has no proper description. https://tradingview.github.io/lightweight-charts/docs/api/interfaces/PriceScaleOptions

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!