2013-10-08 27 views
2

我使用perl chart clicker module來生成一個基於小時使用率的圖表。它似乎工作得很好。 enter image description here 我所提供的數據,如:圖表點擊每日與每小時

sub createcch { 
    my ($keys,$name) = @_; 
    my @lh = ([email protected]{$keys}); 
    my $am = Chart::Clicker::Data::Series->new(
    keys => \@lh, 
    values => $keys, 
    name => $name, 
    range => $range, 
); 
} 

#$data contains series generated by the sub 
my $ds = Chart::Clicker::Data::DataSet->new(series => [$data]); 

我的數據看起來如何在圖表上的化妝品的問題,我還沒有找到一種方法來糾正它。我可以更改X軸以數週或數天而不是數小時列出數據,而不影響數據嗎?

回答

3

創建數據集($ ds)後,必須創建圖表和上下文對象。然後,您可以編輯這些軸'標籤',而無需更改數據視圖。

 
    my $dataSets = Chart::Clicker::Data::DataSet->new(series => \@datasets,); 
    $chart->title->text($name); 
    $chart->title->padding->bottom(5); 
    $chart->add_to_datasets($dataSets); 
    my $context = $chart->get_context('default'); 

    $context->range_axis->label('Counts'); # side 
    $context->range_axis->format('%d'); 

    $context->domain_axis->label($bottom); # bottom 
    $context->domain_axis->format('%s'); 
    $context->domain_axis->tick_labels(\@Lables); 
    $context->domain_axis->ticks($cnt); 

您應該創建一個用於構建@Labels數組的子例程,因爲它可能是動態的。 .axis-> format('%s')對存儲在@Lables數組中的標量執行類似於printf()的轉換,因此重要的是匹配內容。

查看Chart::Clicker::Context瞭解更多詳情。

+0

這比我想象的要容易得多。他們的文檔不是很好,但模塊是。謝謝您的幫助。 – salparadise