question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lines and Annotations

See original GitHub issue

I’m trying to plot simple horizontal lines, referencing data stored externally, and via a loop.

As there are no documented drawing tools, so I’m opting to add datapoints to a line series, on demand.

Sample data: {xe: 1562713200, xs: 1561834800, ye: 12835.97409692, ys: 12244}

The code is designed to add one or more line series dependent on the data returned, although in the examples with static code, I can see that the chart line does not cope with missing data for the timeframe resulting in a solid horizontal line, when the data should start and stop in the middle of the chart.

This is the code in question: ` function loadTrendLines() {

                const url = "/api/trendlines/" + symbol.replace("/", "_") + "/" + timeframe;

                $.ajax({
                    type: 'GET',
                    url: url,
                    contentType: 'application/json',
                    dataType: 'json',
                    responseType: 'application/json',


                    success: function (jdata)
                    {
                        console.log(jdata);

                        var i;
                        for (i = 0; i < jdata.TrendLines.length; ++i) {
                            console.log(jdata.TrendLines[i]);

                            var tldata = [];

                            tldata.push({ time: jdata.TrendLines[i].xe, value: jdata.TrendLines[i].ye });
                            tldata.push({ time: jdata.TrendLines[i].xs, value: jdata.TrendLines[i].ue });

                            var lineSeries = chart.addLineSeries({
                                lastValueVisible: false
                            });

                            lineSeries.setData(tldata);

                        }

                    }

                });
            }`

I’m receiving the following error:

Uncaught Error: Value is undefined at h (lightweight-charts.standalone.production.js:7) at p (lightweight-charts.standalone.production.js:7) at t.updateSeriesData (lightweight-charts.standalone.production.js:7) at t.updateData (lightweight-charts.standalone.production.js:7) at e.t.update (lightweight-charts.standalone.production.js:7) at Object.success (HTMLPage1.html?symbol=BINANCE:BTC/USDT&barstoshow=100&timeframe=60&trendlines=1:252) at c (jquery-3.4.1.min.js:2) at Object.fireWith [as resolveWith] (jquery-3.4.1.min.js:2) at l (jquery-3.4.1.min.js:2) at XMLHttpRequest.<anonymous> (jquery-3.4.1.min.js:2)

If I manually define the xe, xs, ye and ue values, running the same inner loop logic, but placing this outside of the loop, it is successful, however this is not referencing any live data, merely static examples.

Can you please advise on a) whether this workaround should be viable, and b) if there are drawing tools that can be leveraged?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:15 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
jimeneycommented, Jul 10, 2019

No problem. To confirm, I’ve replaced, in my local, static example, the histogram with an area series and the results are perfect for my use - I will test this shortly against the dynamic data

0reactions
timocovcommented, Jul 10, 2019
Read more comments on GitHub >

github_iconTop Results From Across the Web

Line Annotations | chartjs-plugin-annotation
Line annotations are used to draw lines on the chart area. This can be useful for highlighting information such as a threshold. options...
Read more >
Annotation - Las Positas College
Annotation will help you identify different types of lines that suit different purposes. It will also help you engage in active reading. Annotation...
Read more >
Line Annotation - PDF Editor PDF Studio User Guide
The Line tool allows you to draw a line on the document. Hold the Shift key while drawing to make horizontal, vertical, or...
Read more >
About Annotating Components and Lines | AutoCAD Plant 3D ...
Annotation is text placed in a drawing to describe a component or line. It displays the properties or tag data of a component...
Read more >
Line Annotations - Vertafore
Line Annotations. There are three line annotation tools. Straight Line –; Freehand Line –; Polyline –. In our example, we are going to...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found