Google visualization 谷歌折线图
我目前正在从Google工作表导入数据,以便编辑可以进行简单的更新 我遇到的问题是无法使标签/注释显示在图表上。我希望它能显示列名,最好是列名和数据(如果可能的话) 感谢您的帮助。Google visualization 谷歌折线图,google-visualization,Google Visualization,我目前正在从Google工作表导入数据,以便编辑可以进行简单的更新 我遇到的问题是无法使标签/注释显示在图表上。我希望它能显示列名,最好是列名和数据(如果可能的话) 感谢您的帮助。 draw方法的第一个参数应该是数据表/视图。 在这种情况下,将ticketsData替换为view chart.draw(view, options); draw方法的第一个参数应该是数据表/视图。 在这种情况下,将ticketsData替换为view chart.draw(view, options); 谢谢
draw
方法的第一个参数应该是数据表/视图。在这种情况下,将
ticketsData
替换为view
chart.draw(view, options);
draw
方法的第一个参数应该是数据表/视图。在这种情况下,将
ticketsData
替换为view
chart.draw(view, options);
谢谢whitehat的帮助。只需要为每个列添加json数据。若您希望这样做,我还添加了另一列,其中标题行作为列,以显示这两段数据
google.charts.load("current", {
packages: ['corechart']
});
google.charts.setOnLoadCallback(initialize);
function initialize() {
// The URL of the spreadsheet to source data from.
var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1uD7OFv6xDKJdvB7gLBm5WMjeE8442NWZE3XP8gvpqhc/edit#gid=0&range=A1:I7');
query.send(draw);
}
function draw(response) {
var ticketsData = response.getDataTable();
var options = {
legend: 'top',
};
var view = new google.visualization.DataView(ticketsData);
view.setColumns([0,
1,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
2,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
3,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
4,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
5,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
6,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
7,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
]);
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(view, options );
}
谢谢whitehat的帮助。只需要为每个列添加json数据。若您希望这样做,我还添加了另一列,其中标题行作为列,以显示这两段数据
google.charts.load("current", {
packages: ['corechart']
});
google.charts.setOnLoadCallback(initialize);
function initialize() {
// The URL of the spreadsheet to source data from.
var query = new google.visualization.Query('https://docs.google.com/spreadsheets/d/1uD7OFv6xDKJdvB7gLBm5WMjeE8442NWZE3XP8gvpqhc/edit#gid=0&range=A1:I7');
query.send(draw);
}
function draw(response) {
var ticketsData = response.getDataTable();
var options = {
legend: 'top',
};
var view = new google.visualization.DataView(ticketsData);
view.setColumns([0,
1,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
2,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
3,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
4,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
5,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
6,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
7,
{
calc: "stringify",
sourceColumn: 1,
type: "string",
role: "annotation",
},
{
calc: "stringify",
sourceColumn: 9,
type: "string",
role: "annotation",
},
]);
var chart = new google.visualization.LineChart(document.getElementById('chart_div'));
chart.draw(view, options );
}
100%谢谢,所以我只需要修改为:view.setColumns([0,1,{calc:“stringify”,sourceColumn:1,类型:“string”,角色:“annotation”},2,{calc:“stringify”,sourceColumn:1,类型:“string”,角色:“annotation”});100%谢谢,所以我只需要修改为:view.setColumns([0,1,{calc:“stringify”,sourceColumn:1,类型:“string”,角色:“annotation”},2,{calc:“stringify”,sourceColumn:1,类型:“string”,角色:“annotation”});