Skip Menu |

This queue is for tickets about the Data-Google-Visualization-DataTable CPAN distribution.

Report information
The Basics
Id: 64356
Status: resolved
Priority: 0/
Queue: Data-Google-Visualization-DataTable

People
Owner: Nobody in particular
Requestors: matthew [...] mdarwin.ca
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in: 0.06
Fixed in: (no value)



Subject: There is no way to send properties
There needs to be a way to set property values in the data. The following code adds a new method add_property() for this purpose. *** /usr/local/share/perl/5.10.1/Data/Google/Visualization/DataTable.pm.orig Thu Dec 30 21:03:21 2010 --- /usr/local/share/perl/5.10.1/Data/Google/Visualization/DataTable.pm Thu Dec 30 21:37:41 2010 *************** *** 153,162 **** sub new { my $class = shift; my $self = { columns => [], column_mapping => {}, rows => [], ! json_xs => JSON::XS->new()->canonical(1), all_columns_have_ids => 0, column_count => 0, pedantic => 1 --- 153,163 ---- sub new { my $class = shift; my $self = { + properties => {}, columns => [], column_mapping => {}, rows => [], ! json_xs => JSON::XS->new()->canonical(1)->allow_nonref, all_columns_have_ids => 0, column_count => 0, pedantic => 1 *************** *** 467,472 **** --- 468,490 ---- return $self; } + =head2 add_property + + There is the ability to add arbitrary values + + $object->add_property(key, value); + + =cut + + sub add_property { + my ($self, $key, $value) = @_; + + my $json_key = $self->json_xs_object->encode( $key ); + my $json_value = $self->json_xs_object->encode( $value ); + + ${$self->{properties}}{$json_key} = $json_value; + } + =head2 pedantic We do some data checking for sanity, and we'll issue warnings about things the *************** *** 535,540 **** --- 553,560 ---- } @$rows; my $rows_string = join ',' . $n . $t . $t, @rows; + my $properties_string = join ',' .$n.$t.$t, map { $_ .":" . ${$self->{properties}}{$_} } (keys %{$self->{properties}}); + return '{' .$n. $t. '"cols": [' .$n. *************** *** 542,548 **** $t. '],' .$n. $t. '"rows": [' .$n. $t. $t. $rows_string .$n. ! $t. ']' .$n. '}'; } --- 562,571 ---- $t. '],' .$n. $t. '"rows": [' .$n. $t. $t. $rows_string .$n. ! $t. '],' .$n. ! $t. '"p": {' .$n. ! $t. $t. $properties_string .$n. ! $t. '}' .$n. '}'; }
Subject: There is no way to send properties (diff attached)
Attached the diff
Subject: DataTable.diff
*** /usr/local/share/perl/5.10.1/Data/Google/Visualization/DataTable.pm.orig Thu Dec 30 21:03:21 2010 --- /usr/local/share/perl/5.10.1/Data/Google/Visualization/DataTable.pm Thu Dec 30 21:37:41 2010 *************** *** 153,162 **** sub new { my $class = shift; my $self = { columns => [], column_mapping => {}, rows => [], ! json_xs => JSON::XS->new()->canonical(1), all_columns_have_ids => 0, column_count => 0, pedantic => 1 --- 153,163 ---- sub new { my $class = shift; my $self = { + properties => {}, columns => [], column_mapping => {}, rows => [], ! json_xs => JSON::XS->new()->canonical(1)->allow_nonref, all_columns_have_ids => 0, column_count => 0, pedantic => 1 *************** *** 467,472 **** --- 468,490 ---- return $self; } + =head2 add_property + + There is the ability to add arbitrary values + + $object->add_property(key, value); + + =cut + + sub add_property { + my ($self, $key, $value) = @_; + + my $json_key = $self->json_xs_object->encode( $key ); + my $json_value = $self->json_xs_object->encode( $value ); + + ${$self->{properties}}{$json_key} = $json_value; + } + =head2 pedantic We do some data checking for sanity, and we'll issue warnings about things the *************** *** 535,540 **** --- 553,560 ---- } @$rows; my $rows_string = join ',' . $n . $t . $t, @rows; + my $properties_string = join ',' .$n.$t.$t, map { $_ .":" . ${$self->{properties}}{$_} } (keys %{$self->{properties}}); + return '{' .$n. $t. '"cols": [' .$n. *************** *** 542,548 **** $t. '],' .$n. $t. '"rows": [' .$n. $t. $t. $rows_string .$n. ! $t. ']' .$n. '}'; } --- 562,571 ---- $t. '],' .$n. $t. '"rows": [' .$n. $t. $t. $rows_string .$n. ! $t. '],' .$n. ! $t. '"p": {' .$n. ! $t. $t. $properties_string .$n. ! $t. '}' .$n. '}'; }
Looking in to this revealed a couple of other problems with properties. All are now fixed in 0.07. Thanks!