project-nv / night-vision

Highly customizable charting library, created for professional traders
https://nightvision.dev
MIT License
250 stars 58 forks source link

Real time data and navi scripts #120

Open KatarinaSmirnova opened 6 months ago

KatarinaSmirnova commented 6 months ago

Describe the bug

Hi, I've been working with the library and it looks great. I have a problem adding a script with ‘navi’ when using real time data.

` // Navy ~ 0.1-lite

// Meta tag [OVERLAY name=Custom, ctx=Canvas, author=ChartMaster, version=1.0.0] console.log("Draw function called");
draw(ctx) { console.log("Draw function called");
}

`

` let chart = new NightVision("chart-container", { autoResize: true, colors: { back: "#111113", grid: "#2e2f3055", }, scripts: [Custom] });

`

I just want to be able to log a message at that time and it never arrives. Previously adding data to a test JSON file bugged the whole graph, any solutions, thanks! I make a clarification, in sandbox I seem to have some problems updating the ws, the client blocks it.

Reproduction

https://codesandbox.io/p/sandbox/playing-around-10-forked-problem-kg6gtq?file=%2Fmain.js

Steps to reproduce

No response

Javascript Framework

no-framework (vanilla-js)

Logs

No response

Validations

vattevaii commented 4 months ago

I think you need to add this. I'm not totally sure if type and name are correct tho.. Since you have added in the script, you have to attach a overlay for that script.

chart.data.panes[0].overlays.push({
    type: "Custom",
    name: "Custom",
    data: [],
    props: {},
    settings: {
      zIndex: 1
    }
  })