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.

}<br />

}<br />

// sets the X <strong>and</strong> Y attributes for the node<br />

t.setAttribute("x", -30 -defaultTextWidth);<br />

t.setAttribute("y", height - i * height / yDivisions<br />

+ defaultTextHeight / 2);<br />

// when the graph first loads, we want the text nodes invisible<br />

t.setAttribute("stroke", "white");<br />

// add the node to the axis group<br />

axisGroup.appendChild(t);<br />

// add the axis group to the chart<br />

chartGroup.appendChild(axisGroup);<br />

/**** Prepare the element that will draw chart's data ****/<br />

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

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

dataPath.setAttribute("stroke-width", "1");<br />

dataPath.setAttribute("fill", "none");<br />

// add the data path to the chart group<br />

chartGroup.appendChild(dataPath);<br />

/**** Final initialization steps ****/<br />

// add the chart group to the SVG document<br />

documentSVG.documentElement.appendChild(chartGroup);<br />

// this is needed to correctly display text nodes in Firefox<br />

setTimeout("refreshXYIndexes()", 500);<br />

// initiate repetitive server requests<br />

setTimeout("updateChart()", updateInterval);<br />

Chapter 7<br />

// this function redraws the text for the axis units <strong>and</strong> makes it visible<br />

// (this is required to correctly position the text in Firefox)<br />

function refreshXYIndexes()<br />

{<br />

// redraw text nodes on the X axis<br />

for (var i = 0; i

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

Saved successfully!

Ooh no, something went wrong!