Filtering in javascript using the built-in functions of the DataTables is much simpler to do, the downside is that you are still loading the full CSV file. If the file isn't large (say, 10000 rows or more), it probably doesn't matter. Also, writing PHP to parse and filter a CSV file would be a relatively difficult undertaking. If doing this in javascript fits your needs, I recommend that route.
On Friday, January 31, 2014 4:06:28 PM UTC-5, Sergey wrote: > > You could just use getFilteredRows on your DataTable. You can find the > documentation for it > here<https://developers.google.com/chart/interactive/docs/reference#DataTable_getFilteredRows>. > > Here is an example of how you might implement the query that you used in > your first example: > var data = response.getDataTable(); > var view = new google.visualization.DataView(data); > view.setRows(data.getFilteredRows([{minValue: 6, column: 1}])); > ... > chart.draw(view, options); > > > - Sergey > > > On Fri, Jan 31, 2014 at 3:59 PM, Ashok Kumar <[email protected]<javascript:> > > wrote: > >> Please can you help with any sample PHP code which can do this. Also is >> there any other option of achieving this in Javascript coz i saw some >> examples using JS for querying a CSV file. Since installing PHP would be a >> hassle. >> >> >> On Friday, 31 January 2014 15:09:00 UTC+1, Ashok Kumar wrote: >>> >>> Hi, >>> >>> I am not able to filter and display the gauge chart based on my query. >>> Also the gauge chart is always displayed for the entire CSV data and not >>> based on my query.Find below the code that i used. >>> >>> <!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:["gauge"]}); >>> </script> >>> <script> >>> function drawChart() >>> { >>> //$.get("http://localhost/output.csv",function(csvString) >>> //{ >>> var queryOptions = >>> { >>> //csvColumns: ['string','string','string','date','string','number',' >>> number','number','string','string','string','number',' >>> string','string','string','string','string'], >>> //csvColumns: ['string','string','string','string','string','string',' >>> string','string','string','string','string','string',' >>> string','string','string','string','string'] >>> csvColumns: ['string','number'], >>> csvHasHeader: true >>> } >>> //csvUrl= 'http://localhost/output.csv'; >>> csvUrl= 'http://localhost/temperatures.csv'; >>> var query = new google.visualization.Query(csvUrl,queryOptions); >>> //var query = new google.visualization.Query('ht >>> tp://spreadsheets.google.com/tq?key=pCQbetd- >>> CptGXxxQIG7VFIQ&range=B1:D11&pub=1'); >>> //var arrayData = $.csv.toArrays(csvString, {onParseValue: >>> $.csv.hooks.castToScalar}); >>> query.setQuery('select B,C where C > 6'); >>> query.send(handleQueryResponse); >>> function handleQueryResponse(response) >>> { >>> if (response.isError()) >>> { >>> alert('Error in query: ' + response.getMessage() + ' ' + >>> response.getDetailedMessage()); >>> return; >>> } >>> var data = response.getDataTable(); >>> //alert(data[1,1]); >>> //var dataView1 = new google.visualization.DataView(data); >>> //dataView1.setColumns([1]); >>> var chart = new google.visualization.Gauge(document.getElementById(' >>> chart')); >>> chart.draw(data,{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(drawChart); >>> </script> >>> </head> >>> <body> >>> <div id="chart"> >>> </div> >>> </body> >>> </html> >>> >>> This is my CSV Data. >>> >>> Label,License_Utilized,validation >>> License,10,5 >>> License1,18,7 >>> >>> Thanks, >>> Ashok >>> >>> >>> >>> >>> >>> -- >> 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]<javascript:> >> . >> To post to this group, send email to >> [email protected]<javascript:> >> . >> Visit this group at >> http://groups.google.com/group/google-visualization-api. >> For more options, visit https://groups.google.com/groups/opt_out. >> > > -- 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.
