Skip Menu |

Preferred bug tracker

Please visit the preferred bug tracker to report your issue.

This queue is for tickets about the Chart-Clicker CPAN distribution.

Report information
The Basics
Id: 57372
Status: resolved
Priority: 0/
Queue: Chart-Clicker

People
Owner: Nobody in particular
Requestors: rod.taylor [...] gmail.com
Cc:
AdminCc:

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



Subject: get_all_series_keys to be sorted
With small test data sets it just, coincidentally, worked . Large datasets need to be sorted. *** ./Clicker/Data/DataSet.pm.orig 2010-05-11 08:45:28.000000000 -0400 --- ./Clicker/Data/DataSet.pm 2010-05-11 08:47:12.000000000 -0400 *************** *** 38,44 **** for my $series (@{$self->series}) { foreach (@{$series->keys}) { $keys{$_} = 1}; } ! return keys %keys; } sub get_series_keys { --- 38,44 ---- for my $series (@{$self->series}) { foreach (@{$series->keys}) { $keys{$_} = 1}; } ! return sort{$a <=> $b} keys %keys; } sub get_series_keys {
From: ngreen [...] ideaworks.com
On Tue May 11 08:50:25 2010, rtaylor wrote: Show quoted text
> With small test data sets it just, coincidentally, worked . Large > datasets need to be sorted.
Assuming the symptom seen was stackedbar charts' data being out of order, I think the bug is really with accessing the series values (the value passed to get_series_values needs to match the one passed to mark). Sorting the datasets might still be useful for other reasons though.
Subject: StackedBar.diff
Index: StackedBar.pm =================================================================== --- StackedBar.pm (revision 5173) +++ StackedBar.pm (working copy) @@ -87,11 +87,11 @@ for (my $i = 0; $i < scalar(@keys); $i++) { # Get all the values from every dataset's series for each key my @values; foreach my $ds (@{ $dses }) { - push(@values, $ds->get_series_values($i)); + push(@values, $ds->get_series_values($keys[$i])); } # Mark the x, since it's the same for each Y value my $x = $domain->mark($width, $keys[$i],); my $accum = 0;
From: rod.taylor [...] gmail.com
On Wed Jun 16 12:40:02 2010, ngreen wrote: Show quoted text
> On Tue May 11 08:50:25 2010, rtaylor wrote:
> > With small test data sets it just, coincidentally, worked . Large > > datasets need to be sorted.
> > Assuming the symptom seen was stackedbar charts' data being out of order, > I think the bug is really with accessing the series values (the value > passed to get_series_values needs to match the one passed to mark). > Sorting the datasets might still be useful for other reasons though.
Indeed. The issue is that the values are out of order. The issue is that get_all_series_keys makes a hash to determine distinct values in all sets, then takes an array from that which changes the order from the specified values. Another option might be to use a merge mechanism (iterate through each series and merge lowest values) but this also requires the concept of order.
From: marc.chbx [...] gmail.com
Le Ven 25 Juin 2010 13:10:50, rtaylor a écrit : Show quoted text
> On Wed Jun 16 12:40:02 2010, ngreen wrote:
> > On Tue May 11 08:50:25 2010, rtaylor wrote:
> > > With small test data sets it just, coincidentally, worked . Large > > > datasets need to be sorted.
> > > > Assuming the symptom seen was stackedbar charts' data being out of
order, Show quoted text
> > I think the bug is really with accessing the series values (the
value Show quoted text
> > passed to get_series_values needs to match the one passed to mark). > > Sorting the datasets might still be useful for other reasons though.
> > Indeed. The issue is that the values are out of order. The issue is
that Show quoted text
> get_all_series_keys makes a hash to determine distinct values in all > sets, then takes an array from that which changes the order from the > specified values. > > Another option might be to use a merge mechanism (iterate through each > series and merge lowest values) but this also requires the concept of
order. Hi, I encounter the same issue, and here's what I did (attached). Please bear with my bad coding, i'm just beginning :) I also think that the issue comes from get_series_values, so I created another function in DataSet.pm, named get_series_values_by_key, that I call from StackedBar.pm. (The name of this function is self explanatory :)) It helps me, because I had to be sure that the stacked elements had the same key, because all my series in my DataSet have neither the same length nor the same keys, so I ended up with all the nth elements stacked, even when the nth element of serie1 hasn't the same key as the nth element of serie2. (that's why I don't think ordering get_all_series_keys will solve my issue) I encounter another issue very similar to this one so I just add it here. It's with the value returned by largest_value_slice(). The value is not always the largest slice, because it sums values that haven't the same key. For instance if my series are serie1 = { '2010' => 1, '2009' => 2} and serie2 = {'2009' => 4, '2008' => 3}, I get a largest slice value equal to serie1[0]+serie2[0] = 5, when I should get 6 (2+4). So I came up with the same solution as above : use of get_series_values_by_key (see the end of "dataset.diff"). I hope I'm not completely wrong ! Sorry if my explanations weren't very clear, I did my best :(. Cheers, Marc
Subject: dataset.diff
56,71d55 < sub get_series_values_by_key { < my ($self, $key) = @_; < my @res; < foreach my $serie ( @{ $self->series } ){ < my $position = -1; < for (my $i = 0; $i < scalar( @{ $serie->keys } ); $i++){ < $position = $i if ( $serie->keys->[$i] eq "$key" ); < } < if ( $position != -1) { < push(@res, $serie->values->[$position] ) < } < else { push ( @res , 0 );} < } < return @res; < } < 76c60,61 < my $big = 0; --- > my $big; > foreach ($self->get_series_values(0)) { $big += $_; } 79c64 < for my $i ( $self->get_all_series_keys() ) { --- > for my $i (0 .. $self->max_key_count - 1) { 81c66 < foreach ($self->get_series_values_by_key($i)) { $t += $_ if defined($_); } --- > foreach ($self->get_series_values($i)) { $t += $_ if defined($_); }
Subject: stackedbar.diff
92c92 < push(@values, $ds->get_series_values_by_key($keys[$i])); --- > push(@values, $ds->get_series_values($i));
From: mikelaurense [...] gmail.com
This issue is still present in 2.69. The fix given above by marc.chbx works perfectly. Any idea when this will be incorporated in the current releases? I'd rather not mess around in the Chart::Clicker source itself, because we'd also have to make changes in the source when moving code to production, and any Debian package updates might undo the changes made.
Can someone provide me with an example for testing? The solutions presented don't work in my test case, so I must be misunderstanding the problem.
Nevermind, I've reproduced it.
This is fixed in 2.70, which I'll be uploading shortly.