Giter VIP home page Giter VIP logo

Comments (8)

trash-and-fire avatar trash-and-fire commented on May 24, 2024 1

Try the <details> tag or conditional rendering.

from svelte-lightweight-charts.

trash-and-fire avatar trash-and-fire commented on May 24, 2024 1

Your fiddle uses an unofficial fork of lightweight-charts with the moveCrosshair extension method. You can provide it to svelte-lightweight-charts via a bundler alias or a package manager alias.

I can only give an example of charts with synchronized scroll.

from svelte-lightweight-charts.

trash-and-fire avatar trash-and-fire commented on May 24, 2024

Yes it is possible.

<div id="chart" on:mousemove={handleChartContainerMouseMove}>
    <Chart on:crosshairMove={handleChartCrosshairMove} ref={(ref) => chart = ref}>
        <BarSeries/>
        <TimeScale on:visibleLogicalRangeChange={syncWithAxis}/>
    </Chart>
</div>
<div id="axis" on:mousemove={handleAxisContainerMouseMove}>
    <Chart on:crosshairMove={handleAxisCrosshairMove} ref={(ref) => axis = ref}>
        <LineSeries/>
        <TimeScale on:visibleLogicalRangeChange={syncWithChart}/>
    </Chart>
</div>

from svelte-lightweight-charts.

trash-and-fire avatar trash-and-fire commented on May 24, 2024

Example of event handler:

<TimeScale on:visibleLogicalRangeChange={(e) => axis.timeScale().setVisibleLogicalRange(e.detail)}/>

from svelte-lightweight-charts.

trash-and-fire avatar trash-and-fire commented on May 24, 2024

Your request is quite interesting, I will add the full implementation to the gallery of examples a bit later.

from svelte-lightweight-charts.

MuslemRahimi avatar MuslemRahimi commented on May 24, 2024

thanks for the solution. Please keep up the updates. The repo is really good.

Another question. Is it possible to close one of the multiple panes. For example the first graph is the main graph that shows the stock movement. Below is the second graph that is a indicator of that stock. I want to close the second graph with a button. How should i do this in svelte-lightweight-charts?

from svelte-lightweight-charts.

MuslemRahimi avatar MuslemRahimi commented on May 24, 2024

Yes it is possible.

<div id="chart" on:mousemove={handleChartContainerMouseMove}>
    <Chart on:crosshairMove={handleChartCrosshairMove} ref={(ref) => chart = ref}>
        <BarSeries/>
        <TimeScale on:visibleLogicalRangeChange={syncWithAxis}/>
    </Chart>
</div>
<div id="axis" on:mousemove={handleAxisContainerMouseMove}>
    <Chart on:crosshairMove={handleAxisCrosshairMove} ref={(ref) => axis = ref}>
        <LineSeries/>
        <TimeScale on:visibleLogicalRangeChange={syncWithChart}/>
    </Chart>
</div>

Can you provide a full simple example of how to use it. Since i dont know how syncwithCart, handleAxisCrosshairMove etc are defined

from svelte-lightweight-charts.

MuslemRahimi avatar MuslemRahimi commented on May 24, 2024

Just for the record. If you have more than two graphs (e.g. Chart, RSI and MACD) and you want them sync then you have to modify the above code in the following way:

`
let axisRSI;
let axisMACD;
let chart;

const handleChartLogicalRangeChange = (e) => {
    const range = e.detail;
    try
    { 
    axisRSI.timeScale().setVisibleLogicalRange(range);
    }
    catch(error) {
      //pass;
    }

    try
    { 
    axisMACD.timeScale().setVisibleLogicalRange(range);
    }
    catch(error) {
      //pass;
    }
}

const handleAxisLogicalRangeChange = (e) => {
    const range = e.detail;
    chart.timeScale().setVisibleLogicalRange(range)
}`

from svelte-lightweight-charts.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.