hmm ok, I sort of understand what you mean. I think working with a concrete
example might help me understand fully. Say I have this:
var data = [
[ h1, h2, h3]
[c11, c12, c13
[c21, c22, c23]
....
]
var chart = new google.visualization.ChartWrapper({
...
view: {
columns: [1, 2, 3]
}
});
Lets say I want to display the annotations: "annotation1", "annotation2",
"annotation3" on c11, c22, and c23 respectively. Where in this structure do
I put those annotations? Are you saying that I just add in another column
that is empty except for the annotation, so for example my data array might
look like:
var data = [
[ h1, null, h2, h3]
[c11, annotation1, c12, c13
[c21, null. c22, c23]
....
]
This might be a good place to ask this as well: I am really looking to
annotate the x axis, not any of the data points. So for example I want to
put a note of an event that happened at time 500ms, but so far it doesn't
seem like this is possible in the google visualization API. So a
work-around I've been using is just to annotate one of the data points at
that time, instead of the time itself. So if there is a way to do that that
would be better.
But anyway, back to the question at hand. In the above example, I thought I
would need to explicitly define column roles? Where would I put, "role:
annotation" or "role: annotationText"? Or do I not need to do that in this
example?
Thanks for your help,
Trevor
On Monday, July 15, 2013 2:50:03 PM UTC+2, Daniel LaLiberte wrote:
>
> Trevor,
>
> I may be missing something in what you are asking for, but you need to
> just treat the annotations columns like other columns and include them in
> your array of columns for the view. So if you include column 4 that has
> annotations in column 5 (that you would have added after column 4) then
> just include both 4 and 5 in the columns array. E.g. view: { columns: [
> ... 4, 5 ...] }
>
> Perhaps your concern is that you can't just list all the columns that way,
> but maybe you need to conditionally add one at a time. If so, just start
> with an empty columnsArray variable that you accumulate your columns in.
> Here is part of the code that you might use.
>
> var columnsArray = [];
> var columnIndex = 0;
>
> // One column with annotations
> columnsArray.push(columnIndex++); // for data
> columnsArray.push(columnIndex++); // for annotations
>
> // Another column with annotations
> columnsArray.push(columnIndex++); // for data
> columnsArray.push(columnIndex++); // for annotations
>
> ...
> Then just use view: { columns: columnsArray }
>
> Hope that helps.
> dan
>
>
>
> On Mon, Jul 15, 2013 at 8:12 AM, Trevor <[email protected] <javascript:>>wrote:
>
>> Since I can't seem to figure out how to edit my posts, here is a little
>> bit more information about what I mean.
>>
>> Before, I created a separate data table for each chart, by saying
>> var data = new google.visualization.DataTable();
>> data.addRow(...);
>> data.addColumn(....);
>> etc...
>>
>> In this way it is easy to add an annotaton, I could just call:
>> .addColumn({type: 'string', role: 'annotation'});
>>
>> However, now if I simply set views: { columns: [] } in the chart
>> initialization, I am simply giving it access to the main data table. How
>> can I add annotations to the data when using this method?
>>
>>
>> On Monday, July 15, 2013 1:54:21 PM UTC+2, Trevor wrote:
>>>
>>> Thanks for your replies. I have begun using the view: { columns: [] }
>>> option which is working now.
>>>
>>> The only problem is that I'm not sure how to set annotations using the
>>> view: { columns: [] } option. When procedurally generating a 2d array and
>>> passing that as the data to the charts, it was quite easy to simply append
>>> a "role: annotation" column wherever it was needed. But if I am using the
>>> view: { columns: [] } option I am unsure how to add in the annotations. Any
>>> suggestions?
>>>
>>>> --
>> You received this message because you are subscribed to the Google Groups
>> "Google Visualization API" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to [email protected]<javascript:>
>> .
>> To post to this group, send email to
>> [email protected]<javascript:>
>> .
>> Visit this group at
>> http://groups.google.com/group/google-visualization-api.
>> For more options, visit https://groups.google.com/groups/opt_out.
>>
>>
>>
>
>
>
> --
> Daniel LaLiberte <https://plus.google.com/100631381223468223275?prsrc=2>
> - 978-394-1058
> [email protected] <javascript:> 562D 5CC, Cambridge MA
> [email protected] <javascript:> 9 Juniper Ridge Road, Acton MA
>
--
You received this message because you are subscribed to the Google Groups
"Google Visualization API" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-visualization-api.
For more options, visit https://groups.google.com/groups/opt_out.