Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Google DataTable requires label (not id) to be set to "group" #35

Closed
Crashthatch opened this issue Oct 17, 2012 · 3 comments
Closed

Google DataTable requires label (not id) to be set to "group" #35

Crashthatch opened this issue Oct 17, 2012 · 3 comments
Labels

Comments

@Crashthatch
Copy link

At the moment, if you create a google.visualization.DataTable with columns with ids "start", "end", "content" and "group", the group column is ignored. Setting the LABEL (not ID) of the group column to "group" fixes the problem and groups are shown.

I traced the problem to timeline.js, line 266, the findColumnId function should be using dataTable.getColumnId(i) rather than dataTable.getColumnLabel(i). Or possibly both should be checked?

@RCura
Copy link

RCura commented Oct 17, 2012

Hi,

Actually, as an user, I consider this as a feature, that I do use a lot :
A DataTable column label can be changed (with DT.setColumnLabel(columnIndex, label), while an ID can't.
So, when using big tables, it's really a plus to be able to change the label, to represent different things dynamically, instead of creating a whole new table with different IDs.

So, for my part, I'm using unspecific column ids when creating my tables, and then, I set the labels according to what I want to show. And I really like the way CHAP is using Labels and not IDs 😉

@Crashthatch
Copy link
Author

Fair enough, but it's quite unintuitive (took me ~30 mins to figure out) when the following works for Start, End and Content, but not Group:

$data['cols'] = array( array( 'id' => "start", "type" => "datetime" ), array( 'id' => "end", "type" => "datetime" ), array( 'id' => "content", "type" => "string" ), array( 'id' => "group", ['label' => 'group' IS REQUIRED HERE FOR THIS COLUMN NOT TO BE IGNORED], "type" => "string" ) ); ... var data = new google.visualization.DataTable( <?php echo json_encode( $data ); ?> );

I'd suggest either changing the other columns to work the same way (use label, rather than ID), or fall back to id if label is not specified.

It should at least be mentioned in the documentation.

josdejong added a commit that referenced this issue Oct 18, 2012
… label or id, and the first three columns can have any order now. More robust and flexible.
@josdejong
Copy link
Contributor

Thanks Crashthatch, good point. Originally the columns where hard coded (start=0, end=1, content=2, optional group=3), but that changed recently by introducing a second optional column, className.

I have made the usage of columns more flexible now:

  • First the timeline tries to read the column ids.
  • if not available, it will read the column labels.
  • if both id's and column's are undefined, it will use the default columning: start=0, end=1, content=2

I see you generate your DataTable from php. Note that unless you use some specific functionality offered by Google DataTable (client side querying, sorting, filtering), or read your data from a Google SpreadSheet, it may be faster and easier use plain JSON instead of Google DataTable.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants