2
votes

I have a set of items with the following values: [username (string), score (number), date (datetime), comment (string)].

For example:

[['joe', 0.3, 5/5/16, "bla"],
['joe', 0.6, 6/5/16, "bli"],
['jim', 0.4, 6/5/16, "blo"],
['jim', 0.7, 7/5/16, "blu"]]

I want to plot one line for each username (I'll have more than 2) on the same line chart, with the date as the horizontal axis and the score on the vertical axis, with a different color for each line.

In the "multiple line types" example in the doc, both series have the same time ticks. Anybody can help / point me to some doc to plot multiple lines with different time values?

1

1 Answers

2
votes

in google charts, series' are determined by columns, e.g.

Label, Series 1, Series 2, Series 3

as such, recommend having each user in their own column

this will automatically create multiple lines with different colors

if a certain user doesn't have a value for a specific date, use null

then use following in config options, to prevent breaks in the line

interpolateNulls: true

resulting data table would look something like...

['Date', 'Jim', 'Joe'],
['5/5/16', null, 0.3],
['6/5/16', 0.4, 0.6],
['7/5/16', 0.7, null],

not sure what the comment is for, chart won't accept unless used as a tooltip or annotation...