trash-and-fire / svelte-lightweight-charts

Svelte wrapper for financial lightweight charts
MIT License
108 stars 15 forks source link

Graph without zooming in #64

Closed MuslemRahimi closed 1 year ago

MuslemRahimi commented 1 year ago

Hi,

Im trying to create a graph that is by default completely zoomed out and does not allow to zoom in but it fails. Can you help me out with this issue please?

my options look like this:


const options = {
    layout: {
        backgroundColor: '#1A1A27',
        textColor: '#FFFFFF',
    },
    grid: {
        vertLines: {
            color: '#1A1A27',
            visible: false,
        },
        horzLines: {
            color: '#1A1A27',
            visible: false,
        },
    },
    crosshair: {
      // hide the horizontal crosshair line
      horzLine: {
        visible: false,
        labelVisible: false,
        },
      // hide the vertical crosshair label
      vertLine: {
        labelVisible: false,
        style: 0,
        },
    },
    rightPriceScale: {
        visible: false,
        borderColor: 'rgba(197, 203, 206, 0.8)',
    },
    timeScale: {
        borderColor: '#FFFFFF',
        textColor: '#FFFFFF',
        locked: false,
        scrolling: false,
    },
};
trash-and-fire commented 1 year ago

Try following options: https://tradingview.github.io/lightweight-charts/docs/api/interfaces/ChartOptions#handlescroll https://tradingview.github.io/lightweight-charts/docs/api/interfaces/ChartOptions#handlescale

MuslemRahimi commented 1 year ago

thanks, i achieved the result by setting

const options = {
...,
handleScale: {
        mouseWheel: false
    },

Another question if i may. I dont want that the user need to swipe left or right to see further data points. Do you know how to show all the data from the dataset without swiping left or right. I know it is connected to "visibleRange" but i cant achieve the desired result

trash-and-fire commented 1 year ago

Perhaps you need timeScale.fitContent() ?

https://tradingview.github.io/lightweight-charts/docs/api/interfaces/ITimeScaleApi#fitcontent