Hurray! =) changing to p {role; 'domain'} did the trick! =)
Also thank you for your point about correct JSON syntax. Im using GSON to
build my JSON string up so it does actually does print double-quotations...
it was me who removed them as a part of testing if that was wrong. And I
just forgot to readd them before posting example here. But it was the p
{role; 'domain'} that made it work! Now I also see that there were a
special part in the documentation for Roles that handled JSON literatal
notation.
Im as happy as a child on xmas!
regards
bassa
Den torsdagen den 6:e september 2012 kl. 17:04:59 UTC+2 skrev asgallant:
>
> As far as debugging goes, there isn't any "good" way that I have found,
> other than familiarity with the API.
>
> On Thursday, September 6, 2012 11:02:42 AM UTC-4, asgallant wrote:
>>
>> The correct way to specify column roles in JSON is in the column
>> properties: "p: {role: "certainty"}", so your JSON should look like this:
>>
>> var grundJsonDataResultatrakning = {
>> cols: [
>> {type: 'number', p: {role: 'domain'}},
>> {type: 'number', p: {role: 'data'}},
>> {type: 'boolean', p: {role: 'certainty'}}
>> ],
>> rows: [
>> {c: [{v: 1}, {v: 7}, {v: false}]},
>> {c: [{v: 2}, {v: 8}, {v: false}]}
>> ]
>> };
>>
>> Technically, if you are returning that JSON from an AJAX request, all of
>> the properties and all of the string should be enclosed with double-quotes
>> to make it valid JSON, but it works fine as is for a test case.
>>
>> On Thursday, September 6, 2012 10:37:12 AM UTC-4, Bassa Safa wrote:
>>>
>>> I get a All series on a given axis must be of the same data type× when
>>> adding Roles Certaintity. Probably something really simple that I have
>>> missed... but 4 hours of trying with different possibilities im lost. It
>>> works when I populate DataTable with "regular" data as in the playground.
>>> But when populating with JSON it fails.
>>>
>>> As a related question? How do one debug "google chart" code?
>>>
>>> regards
>>> bassa
>>>
>>>
>>> function drawVisualization() {
>>> // Create and populate the data table.
>>>
>>>
>>> var grundJsonDataResultatrakning = {cols:[
>>> {type:'number',role:'domain'},
>>> {type:'number',role:'data'},
>>> {type:'boolean',role:
>>> 'certainty'}],
>>> rows:[
>>> {c:[{v:1},{v:7},{v:false}]},
>>> {c:[{v:2},{v:8},{v:false}]}]};
>>>
>>> var dataResultatrakning = new google.visualization.DataTable(
>>> grundJsonDataResultatrakning);
>>>
>>> // Create and draw the visualization.
>>> new google.visualization.LineChart(document.getElementById(
>>> 'visualization')).
>>> draw(dataResultatrakning , {curveType: "function",
>>> width: 500, height: 400,
>>> vAxis: {maxValue: 10}}
>>> );
>>> }
>>
>>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To view this discussion on the web visit
https://groups.google.com/d/msg/google-visualization-api/-/9FKtiLj3LHkJ.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/google-visualization-api?hl=en.