Changeset 19493

Show
Ignore:
Timestamp:
09/18/08 16:12:36 (5 years ago)
Author:
lopnor
Message:

lang/perl/Google-Chart-DBIC: now you can specify value_column

Location:
lang/perl/Google-Chart-DBIC/trunk
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • lang/perl/Google-Chart-DBIC/trunk/lib/Google/Chart/DBIC.pm

    r17840 r19493  
    7979    isa => 'Google::Chart::DBIC::KeyColumn' 
    8080); 
     81has 'value_column' => ( 
     82    is => 'rw', 
     83    isa => 'Str', 
     84); 
    8185 
    8286__PACKAGE__->meta->make_immutable; 
     
    124128        push @$axis_x, $axis unless grep {$_ eq $axis} @$axis_x; 
    125129 
    126 #        if ($axis_column && scalar @primary > 1 &&  
    127         for my $col ($row->columns) { 
     130        for my $col ($row->columns, $self->value_column) { 
     131            next unless $col; 
    128132            next unless $row->has_column_loaded($col); 
    129133            next if $axis_column && $col eq $axis_column; 
    130             my $v = $row->$col; 
     134            my $v = $row->get_column($col); 
    131135            next unless Scalar::Util::looks_like_number $v; 
    132136            my $k = $col; 
  • lang/perl/Google-Chart-DBIC/trunk/t/01_usage.t

    r17834 r19493  
    11use strict; 
    22use warnings; 
    3 use Test::More tests => 33; 
     3use Test::More tests => 37; 
    44use FindBin; 
    55use lib "$FindBin::Bin/lib"; 
     
    210210    is $h{cht}, 'bvg'; 
    211211} 
     212{ 
     213    my $rs = $resultset->search({ 
     214            place => '東京', 
     215        },{ 
     216            select => ['rainfall', 'month'], 
     217            as => ['rain', 'axis_x'], 
     218        }); 
     219    my $chart = Google::Chart::DBIC->new({ 
     220            resultset => $rs, 
     221            value_column => 'rain', 
     222            color => ['ccccff'], 
     223            size => '500x300', 
     224            type => { 
     225                module => 'Bar', 
     226                args => { 
     227                    stacked => 0, 
     228                }, 
     229            } 
     230        }); 
     231 
     232    isa_ok $chart, 'Google::Chart::DBIC'; 
     233 
     234    my $uri = URI->new($chart->as_uri); 
     235    diag $uri; 
     236    ok ($uri); 
     237    my %h = $uri->query_form; 
     238    is $h{chs}, '500x300'; 
     239    is $h{cht}, 'bvg'; 
     240} 
    212241 
    2132421;