=pod

=encoding utf8

=head1 NAME

L<SimpleR::Reshape::ChartData>

将统计数据转换为画图数据，让SimpleCall::ChartDirector调用

=head1 FUNCTION

=head2  read_chart_data_dim3

    my ($r, %opt) = read_chart_data_dim3('02.dim3.csv', 
        skip_head=> 1, 
        label => [0], 
        legend => [1], 
        data => [2], 
        sep=> ',', 
        charset => 'utf8', 

        #legend_remember_order => 1,  #1 : 默认值，用原有的顺序，0 : 直接sort
        #label_remember_order => 1, 

        #legend_sort => [ qw/ ... / ], # 指定固定顺序
        #label_sort => [ qw/ ... / ], 

        #chart_data_sub => sub { my ($h, $legend, $label) = @_; ... } 


        #finally,  resort label ....
#        resort_label_by_chart_data_map => sub { my ($r) = @_; 
#                 my ($good, $normal, $bad) = @$r;  #good/normal/bad => legend name, $good/$normal/$bad => chart data
#                 my $s = $good+$normal+$bad;
#                 return [ $bad/$s, $normal/$s ];
#        }, 
#        resort_label_by_chart_data_sort => sub { my ($x, $y) = @_; 
#                return ($x->[0] <=> $y->[0]) or ($x->[1] <=> $y->[1])
#        }, 
    );
    #$r = [[3, 2], [0, 1], [3, 0]],
    #%opt = ("legend",
    #["\xE4\xBC\x98", "\xE5\xB7\xAE", "\xE8\x89\xAF"],
    #"label",
    #["\xE7\x94\xB5\xE4\xBF\xA1", "\xE8\x81\x94\xE9\x80\x9A"], )
  
=begin html

<p>实例参考 <a href="xt/">xt子文件夹</a></p>

<p> default chart : </p>

<img src="xt/02.dim3.png"></img>

<img src="xt/05.dim3_resort_label.nosort.png"></img>

<p> resort_label_by_chart_data_map </p> 

<img src="xt/05.dim3_resort_label.sort.png"></img>

=end html

=head2 read_chart_data_dim2

   my ($r, %opt) = read_chart_data_dim2('01.dim2.csv', 
        skip_head=> 1, 
        label => [0], 
        data => [1], 
        sep=> ','
    );
  #$r = [4, 3, 5],
  #%opt = ("legend", [
    #"\xE6\x9D\x8E\xE5\xAD\x90",
    #"\xE6\xA1\x83\xE5\xAD\x90",
    #"\xE8\x8B\xB9\xE6\x9E\x9C", ],
  #"label", [
    #"\xE6\x9D\x8E\xE5\xAD\x90",
    #"\xE6\xA1\x83\xE5\xAD\x90",
    #"\xE8\x8B\xB9\xE6\x9E\x9C", ], )
  
=begin html

<img src="xt/01.dim2.png"></img>

=end html


=head2  read_chart_data_dim3_horizon

    my ($r, %opt) = read_chart_data_dim3_horizon('03.dim3_horizon.csv', 
        skip_head=> 1, 
        label => [0], 
        legend => [1 .. 3], 
        names => [ qw/time good normal bad/ ], 
        sep=> ','
    );
    #$r = [[1, 4, 3, 7], [3, 2, 2, 9], [4, 2, 3, 8]],
    #%opt = ("legend",
    #["bad", "good", "normal"],
    #"label",
    #["2013-08-01", "2013-08-02", "2013-08-03", "2013-08-04"],)

=begin html

<img src="xt/03.dim3_horizon.png"></img>

=end html

=head2  read_chart_data_dim3_scatter

    my ($r, %opt) = read_chart_data_dim3_scatter('04.dim3_scatter.csv', 
        skip_head=> 1, 
        label => [1], 
        legend => [0], 
        data => [2], 
        label_sort => [  1 .. 20 ], 
        #legend_sort => [ '类', '型' ], 

        sep=> ',', 
        charset => 'utf8', 
    );

    #(
      #[
        #[
          #[6, 11, 7, 9, 12, 8, 4, 3.5, 10],
          #[65, 105, 70, 80, 100, 60, 40, 45, 90],
        #],
        #[
          #[6, 10.5, 12, 14, 15, 8, 10, 13, 16],
          #[80, 125, 125, 110, 150, 105, 130, 115, 170],
        #],
      #],
      #"legend",
      #["\x{578B}", "\x{7C7B}"],
      #"label",
      #[1 .. 20],
    #)

=begin html

<img src="xt/04.dim3_scatter.png"></img>

=end html

=cut
