For better understading, I deleted the commented code at the end: > Code: > <script type="text/javascript" > src="http://www.google.com/jsapi"></ > script> > <script type="text/javascript" src="lib/jquery.js"></script> > <script type="text/javascript"> > $(document).ready(function(){ > // Get TIER1Tickets > $.ajax({ > type: "POST", > url: "getTIER1Tickets.php", > data: "", > success: function(html){ > // Succesful, load > visualization API and send data > google.load('visualization', > '1', {'packages': > ['annotatedtimeline']}); > > google.setOnLoadCallback(drawData(html)); > } > }); > }); > > function drawData(response){ > // Data comes from PHP like: <CSV ticket > count for each day>*<CSV > dates for ticket counts>*<total number of days counted> > // So it has to be split first by * then by , > var dataArray = response.split("*"); > var dataTickets = dataArray[0]; > var dataDates = dataArray[1]; > var dataCount = dataArray[2]; > > // The comma separation now splits the ticket > counts and the dates > var dataTicketArray = dataTickets.split(","); > var dataDatesArray = > dataDates.split(","); > > // Visualization data > try { > var data = new > google.visualization.DataTable(); > data.addColumn('date', 'Date'); > data.addColumn('number', 'Tickets'); > data.addRows(dataCount); > } catch (err){ > alert(err.description); > } > > var dateSplit = new Array(); > for(var i = 0 ; i < dataCount ; i++){ > // Separating the data because must > be entered as "new > Date(YYYY,M,D)" > dateSplit = > dataDatesArray[i].split("-"); > //alert(dateSplit[2] + " " + > dateSplit[1] + " " + dateSplit[0])); > data.setValue(i, 0, new > Date(dateSplit[2],dateSplit[1],dateSplit[0])); > data.setValue(i, 1, > dataTicketArray[i]); > } > > var annotatedtimeline = new > google.visualization.AnnotatedTimeLine(document.getElementById('divTendency > ')); > annotatedtimeline.draw(data, > {displayAnnotations: true}); > } > </script>
-- You received this message because you are subscribed to the Google Groups "Google Visualization API" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/google-visualization-api?hl=en.
