Hi,

I have a requirement to get the value of column 6 from always the last row 
of a CSV file and display that value as a gauge chart. I have written the 
below code for this requirement however this does seem to display the graph.

<!DOCTYPE html>
<html>
<head>
   <title>Google Chart Example</title>
   <script src="https://www.google.com/jsapi";></script>
   <script src="http://code.jquery.com/jquery-1.10.1.min.js";></script>
   <script src="http://localhost/jquery.csv-0.71.js";></script>
   <script type="text/javascript">
      google.load("visualization", "1", {packages:["corechart" , "gauge"]});
  //google.load("visualization", "1", {packages:["gauge"]});
</script>
<script>
function Initalize()
{
drawGauge();
}
function drawGauge()
{
var queryOptions =
{
csvColumns: 
['string','string','string','string','string','number','number','number','string','string','string','number','string','string','string','string'],
 
csvHasHeader: true
}
 csvUrl= 'http://localhost/output.csv'; 
var query = new google.visualization.Query(csvUrl,queryOptions); 
query.send(handleGaugeResponse);
function handleGaugeResponse(response)
{  
if (response.isError()) 
{ 
alert('Error in query: ' + response.getMessage() + ' ' + 
response.getDetailedMessage());
return;
} 
var GaugeData = response.getDataTable();
var RowId = GaugeData.getNumberOfRows()-1; 
var dataView2 = new google.visualization.DataView(GaugeData);
//console.log(RowId);
dataView2.setRows([RowId]);
dataView2.setColumns(6);
var FilteredView = dataView2.toDataTable(); 
 var GaugeChart = new 
google.visualization.Gauge(document.getElementById('gaugechart')); 
GaugeChart.draw(FilteredView,{width: 400, height: 250,redFrom: 18, redTo: 
20,yellowFrom:15, yellowTo: 17,minorTicks: 5,min: 1,max: 
20,animation:{duration: 400,easing: 'linear'}}); 
} 
}
google.setOnLoadCallback(Initalize);     
   </script>
</head>
<body>
   <div id="chart"></div>
   <div id="gaugechart">test</div>
</body>
</html>

Find below the CSV file format with one sample row.

 Component Version Day Date Time Logging Type Keys in Usage Usage Time User 
Name Host LMLibVer License Used    FunctionalTesting 
Mon ######## 14:58:15 0 1 0 XXX XXX8.3.0.900 1 - -

- - - 

-- 
You received this message because you are subscribed to the Google Groups 
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to