How do you draw a horizontal line on the chart with RGraph?


« Back to message list

Enter your email address to get email updates on this topic. You can stop receiving updates by clicking the link in the update email messages.

Posted by wrox on 7th September 2015
Hi,

I want to draw horizontal line in chart as upper limit.

var myLine = new RGraph.Line('cvsChartDetails', [4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8, 4.8]);
myLine.ondraw = function (obj) {
                 var x1 = 200;
                 var y1 = myLine.getYCoord(upperThreshold);
                 var x2 = 400;
                 var y2 = y1;//obj.getYCoord(13);

                 obj.context.beginPath();
                 RGraph.DashedLine(obj.context, x1, y1, x2, y2);
                 obj.context.stroke();
             }
myLine.Draw();
Posted by Richard Heyes on 7th September 2015
Hi there,

Just made a few modifications, including defining the upperThreshold variable:

www.rgraph.net/fiddle/view.html/a-line-chart-with-a-threshold-line



Richard
If RGraph has helped you - please share the website and give your feedback - thanks!
Posted by wrox on 7th September 2015
Hi,

We wanted to draw solid line with different colors.

Can you please suggest a way.

Thanks

Posted by Richard Heyes on 7th September 2015
Hi there,

How about something like this:

www.rgraph.net/fiddle/view.html/a-line-chart-with-a-threshold-line

First it draws a solid line, then a dashed line on top of it. So in the gaps of the dashed line the solid line will show through. I've increased the lineWidth so that its easier to see. There's also a bug withe dashed line function hence one of numbers is .99



Richard
If RGraph has helped you - please share the website and give your feedback - thanks!
Posted by Rafael Cunha on 14th January 2016
Hi,

I really need this feature too... the link at the post is not working.

I used the code at the first post, but I didn't get where the values of 'x1' and 'x2' came, and didn't find the documentation to it . I just started to use RGraph today, and it seems to be a very powerful tool.

Thanks in advance
Posted by Richard on 14th January 2016
Hi,

There#s an example of a dashed line here:

www.rgraph.net/fiddle/view.html/a-dashed-line-example




Richard

Add a reply

 




« Back to message list
RGraph on social media