Draw Lines over image

Share RGraph:   Share or Like RGraph on Facebook!

« 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 Patrick on 26th March 2014
In the following, drawing the image eliminates the line no matter the order I draw in. Other elements like the circle I show here do not eliminate the line and are not eliminated by the image. I would like to draw labelled dashed dimension lines, preferably arrows, on the image. I have successfully drawn the dashed lines, but cannot get them to draw over the image. I show a solid line here for simplicity.

// place sketch of a car in the center of the chart area
   var carsketch = new RGraph.Drawing.Image
                  ('cvs',xCenter,yCenter,'images/carsketch.png')
                 .Set('width', carWidth)
                 .Set('height', carWidth/4)
                 .Set('halign', 'center')
                 .Set('valign', 'center')
                 .Set('alpha', .5)
                 .Draw();
 
// place circle for cg location
  var cg = new RGraph.Drawing.Circle('cvs', cgX, cgY, radius)
                .Set('strokestyle', 'black')
                .Set('fillstyle', 'rgba(255,0,0,0.7)')
                .Draw();

// draw wheelbase line
  var wbLine = document.getElementById("cvs").getContext('2d');
              wbLine.beginPath();
                wbLine.moveTo(15,15);
                wbLine.lineTo(385,15);
                wbLine.closePath();
             wbLine.stroke();
Posted by Richard on 26th March 2014
Hi there,

Try adding the line using the ondraw event of the last object that you draw:

cg.ondraw = function (obj)
{
     // draw wheelbase line
     var co = obj.context;
    
     co.beginPath();
         co.moveTo(15,15);
         co.lineTo(385,15);
     co.stroke();
}




Richard
Posted by Patrick on 26th March 2014
Thank You. That worked, but I'm not sure why. I'll place all my added lines inside the ondraw event. Is there a simple arrow line end style?
Posted by Richard on 26th March 2014
Hi there,

The only arrow end is a tickmark style for the Line chart - there's no general purpose one.






Richard

Add a reply




« Back to message list