var data = new google.visualization.DataTable();
data.addColumn('string', 'Month'); // Implicit domain label col.
data.addColumn('number', 'Sales'); // Implicit series 1 data col.
data.addColumn({type:'number', role:'interval'}); // interval role col.
data.addColumn({type:'number', role:'interval'}); // interval role col.
data.addColumn({type:'string', role:'annotation'}); // annotation role col.
data.addColumn({type:'string', role:'annotationText'}); // annotationText col.
data.addColumn({type:'boolean',role:'certainty'}); // certainty col.
data.addRows([
['April',1000, 900, 1100, 'A','Stolen data', true],
['May', 1170, 1000, 1200, 'B','Coffee spill', true],
['June', 660, 550, 800, 'C','Wumpus attack', true],
['July', 1030, null, null, null, null, false]
]);
but rather THIS one where I don't know ho to proceed:
// Load the Visualization API and the corechart package.
google.charts.load('current', {'packages':['corechart']});
// Set a callback to run when the Google Visualization API is loaded.
google.charts.setOnLoadCallback(drawGID);
function drawGID() {
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/***/gviz/tq?gid=0&sheet=****');
query.setQuery('select A, H, P, Q, R, S, T, U, E, F, G limit 40 offset 2');
query.send(handleQueryResponse);
}
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
// Set chart options
var options = {'title':'Mon graphique',
'width':'1300',
'height':'1000',
'hAxis':{'title':'time (mois)'},
'vAxis':{'title':'price'}
};// fine options
var data = response.getDataTable();
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(data, options);
}
We have tried on stackoverflow already but they say it's a duplicate from a previous answer already, which is not
in my opinion.
any help would be appreciated, thanks
--
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 google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/0fcb9365-c379-423a-9c04-1779779253ca%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to google-visualization-api+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/0fcb9365-c379-423a-9c04-1779779253ca%40googlegroups.com.
--dlali...@Google.com Cambridge MA
ok, let's try to solve this now. I feel like I am very close to ut but there must be someting I am missing.First of all, I've been able to implement dataview in the code and I am very happy with that since I wasn't sure I would be able to.The problem is I really can't depict annotations correctly within the chart.let's go step by step following the code.This is the whole code I am using
google.charts.load('current', {'packages':['corechart']});
google.charts.setOnLoadCallback(drawGID);
function drawGID() {
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/1-j2QlD8lXvmWQJAyjWRtHO3PSYurCSjbYkn_5K5pBj0/gviz/tq?gid=0&sheet=dca'/* + queryString*/);
//I chose to draw only a small part of the sheet, for the sake of simplicity
query.setQuery('select A, I limit 40 offset 2');
query.send(handleQueryResponse);
} //fine funzione drawGID
function handleQueryResponse(response) {
if (response.isError()) {
alert('Error in query: ' + response.getMessage() + ' ' + response.getDetailedMessage());
return;
}
// Set chart options
var options = {'title':'Ceci n est pas un graphique',
'width':'1300',
'height':'1000',
'hAxis':{'title':'time (mesi)'},
'vAxis':{'title':'price'},
'lineWidth':'2',
explorer: { actions: ['dragToZoom', 'rightClickToReset'], maxZoomIn: .01}
};// fine options
var data = response.getDataTable();
//da qui proviamo dataview
var view = new google.visualization.DataView(data);
view.setColumns([0,1/*,
2/*,
{
// calc: 'stringify',
// type: 'string',
sourceColumn: 2,
role: 'certainty'
}/*,
3,
{
calc: "stringify",
sourceColumn: 3,
type: "string",
role: "annotationText"
}*/
]);
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(view, options/*{ height: 800 }*/);
} //fine funzione handleQueryResponseand this is the sheet we'll be referring to:
this means that dataview works.
Now, if I try to include column AT (see the linked sheet ) as annotation column what happens is a blank page
this is the code I use (I'll post only the variations):
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/1-j2QlD8lXvmWQJAyjWRtHO3PSYurCSjbYkn_5K5pBj0/gviz/tq?gid=0&sheet=dca'/* + queryString*/);
query.setQuery('select A, I, AT limit 40 offset 2');
//query.setQuery('select A, H, P, Q, R, S, T, U, E, F, G limit 40 offset 2');
query.send(handleQueryResponse);
//da qui proviamo dataview
var view = new google.visualization.DataView(data);
view.setColumns([0,1,
2,
{
// calc: 'stringify',
// type: 'string',
sourceColumn: 2,
role: 'annotation'
}
]);
// calc: 'stringify',
// type: 'string',
sourceColumn
- [Optional, number] The source column to use as a value; if specified, do not specify thecalc
or thetype
property. This is similar to passing in a number instead of an object, but enables you to specify a role and properties for the new column.
var query = new google.visualization.Query(
'https://docs.google.com/spreadsheets/d/1-j2QlD8lXvmWQJAyjWRtHO3PSYurCSjbYkn_5K5pBj0/gviz/tq?gid=0&sheet=dca'/* + queryString*/);query.setQuery('select A, I, AR limit 40 offset 2');//query.setQuery('select A, H, P, Q, R, S, T, U, E, F, G limit 40 offset 2');query.send(handleQueryResponse);
//da qui proviamo dataview var view = new google.visualization.DataView(data); view.setColumns([0,1, 2, { // calc: 'stringify', // type: 'string', sourceColumn: 2, role: 'certainty' } ]);
--
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 google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/8732e176-6a7f-4a0f-970a-b2fb8fc44ab7%40googlegroups.com.
--
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 google-visualizati...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-visualization-api/a8ce1444-45e3-41c3-bf6a-bae18f3fa24b%40googlegroups.com.