Thanks for your help, i have now sorted it and the charts are displaying
correctly
for reference this is what i used
var data = response.getDataTable();
var view = new google.visualization.DataView(data);
view.setColumns([0, {calc:converttonumber, type:'number', label:
"TEST"}]);
function converttonumber(data, rowNum){
return Math.floor(data.getValue(rowNum, 1) / 1);
}
On Tuesday, March 6, 2012 5:13:45 PM UTC, R22MPM wrote:
>
> Ill check in Google Chrome this evening, i definately know there is data
> in the datatable because i can populate a table with the data. i am also
> navigate to the csv which returns the data in JSON format
>
> Thanks
> Matt
>
> On Tuesday, March 6, 2012 4:39:00 PM UTC, asgallant wrote:
>>
>> Hmm...
>>
>> You can use Chrome's developer console to get information on any errors
>> that may be occurring, and you can view the output from
>> console.log(<variable>) there (use on your DataTable object to see what it
>> contains).
>>
>> If there is no data in the DataTable or
>> the handleCsvLicenseCount function is never called, then I suspect the
>> problem is with the query. Is the java data source API located in the same
>> directory as your HTML file? If not, you need to include the path to the
>> java data source API in the query. I am also uncertain of the format the
>> API expects for the URL; using 'localhost' in the URL would normally point
>> to your own system, but in this case it probably refers to the server
>> itself, so you should make sure the CSV is in the right place. Someone who
>> is familiar with the java data source API would be able to help you more
>> than I can here.
>>
>> On Tuesday, March 6, 2012 11:05:00 AM UTC-5, R22MPM wrote:
>>>
>>> Thanks for that, i have tried but unfortunately the gauge is not
>>> showing, neither is the data in a table? is there any debugging i can put
>>> into this to step through what the code is doing?
>>>
>>> <script type="text/javascript" src="http://www.google.com/jsapi
>>> "></script>
>>>
>>> <script type="text/javascript">
>>> google.load('visualization', '1', {'packages':
>>> ['gauge','table','piechart','orgchart','barchart']});
>>>
>>>
>>> // Set a callback to run when the API is loaded.
>>> google.setOnLoadCallback(init);
>>>
>>> // Send the queries to the data sources.
>>> function init() {
>>> query = new google.visualization.Query('csv?url=
>>> http://localhost:8084/Dashboards/Data/LicenseCount.csv');
>>> query.send(handleCsvLicenseCount);
>>> }
>>>
>>> function handleCsvLicenseCount(response) {
>>> if (response.isError()) {
>>> alert('Error in query: ' + response.getMessage() + ' ' +
>>> response.getDetailedMessage());
>>> return;
>>> }
>>>
>>> var data = response.getDataTable();
>>>
>>> var view = new google.visualization.DataView(data);
>>> view.setColumns([0, {
>>> type: 'number',
>>> label: data.getColumnLabel(1),
>>> calc: function (dt, row) {
>>> return parseInt(dt.getValue(row, 1));
>>> }
>>> }]);
>>>
>>> var options = {
>>> width: 400, height: 120,
>>> redFrom: 90, redTo: 100,
>>> yellowFrom:75, yellowTo: 90,
>>> minorTicks: 5
>>> };
>>> var chart = new
>>> google.visualization.gauge(document.getElementById('csv_div'));
>>> chart.draw(view, options);
>>> }
>>>
>>>
>>>
>>> </script>
>>> <!--[if IE]>
>>> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js
>>> "></script>
>>> <![endif]-->
>>> </head>
>>> <body>
>>> SAMPLE TEXT
>>> <div id="csv_div" style="width: 400px"></div>
>>> <div id="csv_div1" style="width: 400px"></div>
>>> </body>
>>>
>>> On Friday, March 2, 2012 4:07:10 PM UTC, R22MPM wrote:
>>>>
>>>> Hi All,
>>>> I am a newbie to Coogle charts and have been running through the
>>>> following tutorial regarding connecting CSV files into charts.
>>>>
>>>>
>>>> http://code.google.com/apis/chart/interactive/docs/dev/dsl_get_started.html#webapp
>>>>
>>>> I have a question which im hoping is pretty simple (i have limited JS
>>>> knowledge)
>>>>
>>>> I would like to use Gauge and Bar charts with the CSV data but as i
>>>> understand it the columns will always be flagged as string, so my question
>>>> is how and where do i convert the value column to a number?
>>>>
>>>> Thanks
>>>> Matt
>>>>
>>>
> On Tuesday, March 6, 2012 4:39:00 PM UTC, asgallant wrote:
>>
>> Hmm...
>>
>> You can use Chrome's developer console to get information on any errors
>> that may be occurring, and you can view the output from
>> console.log(<variable>) there (use on your DataTable object to see what it
>> contains).
>>
>> If there is no data in the DataTable or
>> the handleCsvLicenseCount function is never called, then I suspect the
>> problem is with the query. Is the java data source API located in the same
>> directory as your HTML file? If not, you need to include the path to the
>> java data source API in the query. I am also uncertain of the format the
>> API expects for the URL; using 'localhost' in the URL would normally point
>> to your own system, but in this case it probably refers to the server
>> itself, so you should make sure the CSV is in the right place. Someone who
>> is familiar with the java data source API would be able to help you more
>> than I can here.
>>
>> On Tuesday, March 6, 2012 11:05:00 AM UTC-5, R22MPM wrote:
>>>
>>> Thanks for that, i have tried but unfortunately the gauge is not
>>> showing, neither is the data in a table? is there any debugging i can put
>>> into this to step through what the code is doing?
>>>
>>> <script type="text/javascript" src="http://www.google.com/jsapi
>>> "></script>
>>>
>>> <script type="text/javascript">
>>> google.load('visualization', '1', {'packages':
>>> ['gauge','table','piechart','orgchart','barchart']});
>>>
>>>
>>> // Set a callback to run when the API is loaded.
>>> google.setOnLoadCallback(init);
>>>
>>> // Send the queries to the data sources.
>>> function init() {
>>> query = new google.visualization.Query('csv?url=
>>> http://localhost:8084/Dashboards/Data/LicenseCount.csv');
>>> query.send(handleCsvLicenseCount);
>>> }
>>>
>>> function handleCsvLicenseCount(response) {
>>> if (response.isError()) {
>>> alert('Error in query: ' + response.getMessage() + ' ' +
>>> response.getDetailedMessage());
>>> return;
>>> }
>>>
>>> var data = response.getDataTable();
>>>
>>> var view = new google.visualization.DataView(data);
>>> view.setColumns([0, {
>>> type: 'number',
>>> label: data.getColumnLabel(1),
>>> calc: function (dt, row) {
>>> return parseInt(dt.getValue(row, 1));
>>> }
>>> }]);
>>>
>>> var options = {
>>> width: 400, height: 120,
>>> redFrom: 90, redTo: 100,
>>> yellowFrom:75, yellowTo: 90,
>>> minorTicks: 5
>>> };
>>> var chart = new
>>> google.visualization.gauge(document.getElementById('csv_div'));
>>> chart.draw(view, options);
>>> }
>>>
>>>
>>>
>>> </script>
>>> <!--[if IE]>
>>> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js
>>> "></script>
>>> <![endif]-->
>>> </head>
>>> <body>
>>> SAMPLE TEXT
>>> <div id="csv_div" style="width: 400px"></div>
>>> <div id="csv_div1" style="width: 400px"></div>
>>> </body>
>>>
>>> On Friday, March 2, 2012 4:07:10 PM UTC, R22MPM wrote:
>>>>
>>>> Hi All,
>>>> I am a newbie to Coogle charts and have been running through the
>>>> following tutorial regarding connecting CSV files into charts.
>>>>
>>>>
>>>> http://code.google.com/apis/chart/interactive/docs/dev/dsl_get_started.html#webapp
>>>>
>>>> I have a question which im hoping is pretty simple (i have limited JS
>>>> knowledge)
>>>>
>>>> I would like to use Gauge and Bar charts with the CSV data but as i
>>>> understand it the columns will always be flagged as string, so my question
>>>> is how and where do i convert the value column to a number?
>>>>
>>>> Thanks
>>>> Matt
>>>>
>>>
> On Tuesday, March 6, 2012 4:39:00 PM UTC, asgallant wrote:
>>
>> Hmm...
>>
>> You can use Chrome's developer console to get information on any errors
>> that may be occurring, and you can view the output from
>> console.log(<variable>) there (use on your DataTable object to see what it
>> contains).
>>
>> If there is no data in the DataTable or
>> the handleCsvLicenseCount function is never called, then I suspect the
>> problem is with the query. Is the java data source API located in the same
>> directory as your HTML file? If not, you need to include the path to the
>> java data source API in the query. I am also uncertain of the format the
>> API expects for the URL; using 'localhost' in the URL would normally point
>> to your own system, but in this case it probably refers to the server
>> itself, so you should make sure the CSV is in the right place. Someone who
>> is familiar with the java data source API would be able to help you more
>> than I can here.
>>
>> On Tuesday, March 6, 2012 11:05:00 AM UTC-5, R22MPM wrote:
>>>
>>> Thanks for that, i have tried but unfortunately the gauge is not
>>> showing, neither is the data in a table? is there any debugging i can put
>>> into this to step through what the code is doing?
>>>
>>> <script type="text/javascript" src="http://www.google.com/jsapi
>>> "></script>
>>>
>>> <script type="text/javascript">
>>> google.load('visualization', '1', {'packages':
>>> ['gauge','table','piechart','orgchart','barchart']});
>>>
>>>
>>> // Set a callback to run when the API is loaded.
>>> google.setOnLoadCallback(init);
>>>
>>> // Send the queries to the data sources.
>>> function init() {
>>> query = new google.visualization.Query('csv?url=
>>> http://localhost:8084/Dashboards/Data/LicenseCount.csv');
>>> query.send(handleCsvLicenseCount);
>>> }
>>>
>>> function handleCsvLicenseCount(response) {
>>> if (response.isError()) {
>>> alert('Error in query: ' + response.getMessage() + ' ' +
>>> response.getDetailedMessage());
>>> return;
>>> }
>>>
>>> var data = response.getDataTable();
>>>
>>> var view = new google.visualization.DataView(data);
>>> view.setColumns([0, {
>>> type: 'number',
>>> label: data.getColumnLabel(1),
>>> calc: function (dt, row) {
>>> return parseInt(dt.getValue(row, 1));
>>> }
>>> }]);
>>>
>>> var options = {
>>> width: 400, height: 120,
>>> redFrom: 90, redTo: 100,
>>> yellowFrom:75, yellowTo: 90,
>>> minorTicks: 5
>>> };
>>> var chart = new
>>> google.visualization.gauge(document.getElementById('csv_div'));
>>> chart.draw(view, options);
>>> }
>>>
>>>
>>>
>>> </script>
>>> <!--[if IE]>
>>> <script src="http://html5shim.googlecode.com/svn/trunk/html5.js
>>> "></script>
>>> <![endif]-->
>>> </head>
>>> <body>
>>> SAMPLE TEXT
>>> <div id="csv_div" style="width: 400px"></div>
>>> <div id="csv_div1" style="width: 400px"></div>
>>> </body>
>>>
>>> On Friday, March 2, 2012 4:07:10 PM UTC, R22MPM wrote:
>>>>
>>>> Hi All,
>>>> I am a newbie to Coogle charts and have been running through the
>>>> following tutorial regarding connecting CSV files into charts.
>>>>
>>>>
>>>> http://code.google.com/apis/chart/interactive/docs/dev/dsl_get_started.html#webapp
>>>>
>>>> I have a question which im hoping is pretty simple (i have limited JS
>>>> knowledge)
>>>>
>>>> I would like to use Gauge and Bar charts with the CSV data but as i
>>>> understand it the columns will always be flagged as string, so my question
>>>> is how and where do i convert the value column to a number?
>>>>
>>>> Thanks
>>>> Matt
>>>>
>>>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/nXsFdSEucDIJ.
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.