27.10.2015 Views

AJAX and PHP

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

<strong>AJAX</strong> Real-Time Charting with SVG<br />

// initializes chart<br />

function init(evt)<br />

{<br />

/**** Prepare the group that will contain all chart data ****/<br />

// obtain SVG document h<strong>and</strong>ler<br />

documentSVG = evt.target.ownerDocument;<br />

// create the element that groups all chart elements<br />

chartGroup = documentSVG.createElementNS(svgNS, "g");<br />

chartGroup.setAttribute("transform", "translate(" + x + " " + y + ")");<br />

/**** Prepare the group that will store the Y <strong>and</strong> Y axis <strong>and</strong> numbers ****/<br />

axisGroup = documentSVG.createElementNS(svgNS, "g");<br />

// create the X axis line as a element<br />

axisPath = documentSVG.createElementNS(svgNS, "path");<br />

// the axis lines will be black, 2 pixels wide<br />

axisPath.setAttribute("stroke", "black");<br />

axisPath.setAttribute("stroke-width", "2");<br />

/**** Create the division lines for the X <strong>and</strong> Y axis ****/<br />

// create the path definition text for the X axis division lines<br />

pathText = "M 0 " + height;<br />

// adds divisions to the X axis (differently for last division)<br />

for (var i = 0; i

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!