tvjsx / trading-vue-js

💹 Hackable charting lib for traders. You can draw literally ANYTHING on top of candlestick charts. [Not Maintained]
https://tvjsx.github.io/trading-vue-demo/
MIT License
2.07k stars 629 forks source link

Possible LineTool bug #204

Closed csabaxyz closed 3 years ago

csabaxyz commented 3 years ago

Description

I've been trying to add a line to a chart via LineTool. As far as I can tell this is the correct way:

onchart: [{
  name: 'Line',
  type: 'LineTool',
  data: [],
  settings: {
    color: '#e00',
    p1: [417830400000, 61.8843108108108],
    p2: [647740800000, 30.86568918918918]
  }
}]

But this seems to add a single starting point outside of the view, and when I move the mouse around, the line follows until I click (so I assume it is waiting for an end point). The weird part is that if I console.log the p1 and p2 values in the LineTool they both have [null, null] values, which is enough to pass this condition:

if (!this.p1 || !this.p2) return;

But this obviously can't draw anything meaningful like this. I tried to pass other key-values, those seem to carry the original coordinates just fine, so possibly only p1 and p2 are affected. Although, I couldn't exactly figure out where these values get overwritten.

Let me know if I'm trying to use this incorrectly, or if you need more information. Thanks!

Demo

https://tvjs.io/play?a=jooav8h1

C451 commented 3 years ago

You forgot $state: "finished", $uuid: "<uuid>" in the settings.

csabaxyz commented 3 years ago

Yep, that fixed it. Awesome! Sorry for the false alarm. By the way, you are probably one of the most responsive developers I've seen on any project. Thank you for your hard work!