Reputation: 2118
I'm building a line chart that records a reading of the number of steps each walker has taken each day where each member is a series and the with the x axis being the dates and the y axis being the amount of steps taken.
However, a walker may or may not have readings for each of the days and this is causing problems. I'm getting an error message when the chart is displayed saying Data column(s) for axis #0 cannot be of type string.
Here is a sample of my json
{
"cols" : [{
"id" : null,
"label" : "Date",
"type" : "string"
}, {
"id" : null,
"label" : "Joe Bloggs",
"type" : "string"
}, {
"id" : null,
"label" : "John Doe",
"type" : "string"
}, {
"id" : null,
"label" : "Jane Doe",
"type" : "string"
}, {
"id" : null,
"label" : "John Bloggs",
"type" : "string"
}, {
"id" : null,
"label" : "Jane Bloggs",
"type" : "string"
}, {
"id" : null,
"label" : "Ann Walker",
"type" : "string"
}, {
"id" : null,
"label" : "Andy Walker",
"type" : "string"
}, {
"id" : null,
"label" : "Tom Jones",
"type" : "string"
}, {
"id" : null,
"label" : "Foo Bar",
"type" : "string"
}, {
"id" : null,
"label" : "Bar Foo",
"type" : "string"
}
],
"rows" : [{
"c" : [{
"v" : "02 Sep 13",
"f" : null
}, {
"v" : 6787,
"f" : null
}, {
"v" : 1558,
"f" : null
}, {
"v" : null,
"f" : null
}, {
"v" : null,
"f" : null
}, {
"v" : 9913,
"f" : null
}, {
"v" : null,
"f" : null
}, {
"v" : null,
"f" : null
}, {
"v" : 27881,
"f" : null
}, {
"v" : null,
"f" : null
}, {
"v" : null,
"f" : null
}, {
"v" : 7410,
"f" : null
}, {
"v" : null,
"f" : null
}, {
"v" : null,
"f" : null
}, {
"v" : 2126,
"f" : null
}
]
}]
}
I've omitted additional rows to keep it short. I'm treating dates as strings deliberately for formatting purposes and simplicity
In this scenario, where I may or may not have values for rows, how should I represent it?
Upvotes: 0
Views: 1955
Reputation: 1409
You're defining your columns as string for y axis when it should be number. Besides the first column (your date column), change all the others to "type: number" instead and it should work.
The JSON format for google charts can be a bit tricky sometimes. A good way to test it out is creating a google spreadsheet as a source and play around with it changing values on the spreadsheet and loading as json through your browser as it will give you the correct format expected by the google charts api. For more information about how to do that, check out my answer for this post.
Data Set that can be used for statistics
I hope it helps
Upvotes: 2