[英]Google Charts Line Chart
I'm new to google charts and can't seem to figure out how i would do something of the following: 我是Google图表的新手,似乎无法弄清楚我将如何执行以下操作:
I want to make a data table that has my xcord,ycord,legendlabel. 我想制作一个具有我的xcord,ycord,legendlabel的数据表。 I'm trying the following:
我正在尝试以下方法:
var data = google.visualization.arrayToDataTable([]);
data.addColumn("number","reps");
data.addColumn("number","weight");
data.addColumn("string","legendlabel")
data.addColumn("string","workoutname");
data.addRows([[150, 10,"workoutA"],
[300, 2,"workoutB"], //format [xcord,ycord,legendlabel]
]);
However, it isn't working obviously because we have two different types, number and string. 但是,它显然不起作用,因为我们有两种不同的类型,数字和字符串。
Is there a way i can specify the xcord, ycord then have a label for this point, then if there are multiple labels that are the same it forms a line graph? 有没有一种方法可以指定xcord,ycord然后为该点指定一个标签,那么如果有多个相同的标签,它会形成一个折线图?
Thanks in advance guys! 在此先感谢大家!
With a line chart each data line has to have a value for every point on the domain or else the line will be broken, What you want is a scatter chart 使用折线图,每条数据线必须在域中的每个点都具有一个值,否则该线将被折断,您想要的是散点图
Then data for you graph should look something like this: 然后,用于您的图形的数据应如下所示:
var data = google.visualization.arrayToDataTable([]);
data.addColumn("number","reps");
data.addColumn("number","workout1");
data.addColumn("number","workout2");
data.addRows([
[150, 10, null],
[300, null, 2,]
]);
you will want to set the lineWidth to see the trending curve 您将需要设置lineWidth来查看趋势曲线
chart.draw(data, {
lineWidth: 2,
vAxis: {title: "reps"},
hAxis: {title: "weight"}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.