I think your problem is with this line:

dataView2.setColumns(6);

The setColumns method takes an array of column indices, and the Gauges 
require two columns of data, not one.  There should be one string and one 
number type:

dataView2.setColumns([<string column>, <number column>]);

Incidentally, you don't need to convert the view to a DataTable unless you 
have some specific need to do so; the chart will draw just fine using the 
view:

GaugeChart.draw(dataView2,{width: 400, height: 250,redFrom: 18, redTo: 
20,yellowFrom:15, yellowTo: 17,minorTicks: 5,min: 1,max: 
20,animation:{duration: 400,easing: 'linear'}});

On Wednesday, February 12, 2014 2:08:02 PM UTC-5, Ashok Kumar wrote:
>
> It displays the entire datatable. Attached the screenshot of the browser 
> javascript console for reference.
>
>
>
> On Wednesday, 12 February 2014 16:56:22 UTC+1, asgallant wrote:
>>
>> In the handleGaugeResponse function, add this line:
>>
>> console.dir(response);
>>
>> then open the page in Chrome or Firefox, and open the developer's console 
>> (ctrl+shift+j to open in Chrome, ctrl+shift+k to open in Firefox).  What is 
>> output by the console.dir call?  You may need to refresh the page after 
>> opening the console.
>>
>> On Wednesday, February 12, 2014 10:18:04 AM UTC-5, Ashok Kumar wrote:
>>>
>>> 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