• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Chart clicker presentation
 

Chart clicker presentation

on

  • 2,496 views

 

Statistics

Views

Total Views
2,496
Views on SlideShare
2,494
Embed Views
2

Actions

Likes
0
Downloads
4
Comments
0

1 Embed 2

http://paper.li 2

Accessibility

Upload Details

Uploaded via as OpenOffice

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Chart clicker presentation Chart clicker presentation Presentation Transcript

    • Chart::Clicker A plotting module for Perl
    • As the author says: “Chart::Clicker aims to be a powerful, extensible charting package that creates really pretty output.” Why Chart::Clicker?
    • Chart::Clicker underlying technologies
      • Overall code base: Moose classes.
      • Renderers are written in Cairo.
      • ColorAllocator is developed from Color::Scheme
      • Color objects can use Color::Library named colors.
      • Geometric entities represented as Geometry::Primitive objects.
    • Installation
      • Via CPAN
      • Unavailable in Active Perl currently
        • Though chk out Perl Monks thread on this topic.
      • Tends to be long (30-45 mins to install).
      • Works best if you preinstall the Cairo module.
        • The package libcairo-perl in Ubuntu
        • Issues with Cairo cause install issues with CENTOS.
    • Output
      • PNG, SVG, PDF and Postscript
      • Specify when you create your clicker object.
      • my $cc = Chart::Clicker->new( format => 'pdf', ..
      • When specifying format, can specify size as well.
      • If you expect to post-process the file, then bigger is better.You can shrink the image after the fact.
    • Resources
      • Author's github: http://github.com/gphat/chart-clicker
        • Esp: https://github.com/gphat/chart-clicker/tree/master/example
      • Github forks (and more) of clicker
        • https://github.com/tomlanyon/chart-clicker
      • Chart::Clicker::Tutorial
      • Blog: http://www.onemogin.com/blog/category/chartclicker
    • Chart::Clicker components
      • Clicker Object
        • Handles titles, datasets, data writes, contexts.
      • Series Objects
        • X data (keys), Y data (values), labels
      • Dataset objects
        • Contain 1 or more series objects, and will be assigned a context.
      • DON'T AVOID using Series and Datasets.
        • Otherwise you'll be stuck with trivial graphs.
    • my $cc = Chart::Clicker->new( format =>'png', height => 480, width => 640 ); my $series1 = Chart::Clicker::Data::Series->new( keys => @x_data,, values => @y_data, ); $series1->name('First Line'); # # lots more series # my $ds = Chart::Clicker::Data::DataSet->new( series => [ $series1, $series2, $series3, $series4, $series5, $series6, $series7, $series8 ] ); $cc->add_to_datasets($ds);
    • Axes and Contexts
      • Contexts contain 2 axes, a renderer, and a name. Contexts can/will be assigned to a dataset.
      • Axis objects:Can set tick count, and upper and lower bounds.
      • For some reason, pie charts still require a nonzero axis length.
      • If you mix plot types (lines and points), you'll need more than one context.
        • Turn off the extra axes if necessary.
    • Renderers
      • Plenty of Renderer objects
        • Point, Pie, Bubble, Bar, Area, Line
        • StackedArea, StackedBar, PolarArea, CandleStick, HeatMap, etc.
      • The default renderer is a line. If you don't see one initialized, that's why.
    • my $context = Chart::Clicker::Context->new( name => 'sales' ); $clicker->add_to_contexts($context); $dataset->context('sales'); $clicker->add_to_datasets($dataset);
    • # # Creating a context and then setting up Axis values. # %cfg values are assigned via a Config::Simple object. # my $defctx = $cc->get_context('default'); $defctx->domain_axis->label($cfg{"default.X_Axis"}); $defctx->domain_axis->range( Chart::Clicker::Data::Range->new( lower => $cfg{"default.X_Lower"}, upper => $cfg{"default.X_Upper"} ) ); $defctx->domain_axis->ticks( $cfg{"default.X_Ticks"}); $defctx->range_axis->label($cfg{"default.Y_Axis"}); $defctx->range_axis->range( Chart::Clicker::Data::Range->new( lower => $cfg{"default.Y_Lower"}, upper => $cfg{"default.Y_Upper"} ) ); $defctx->range_axis->ticks($cfg{"default.Y_Ticks"}); $defctx->renderer(Chart::Clicker::Renderer::Point->new);
    • Contexts: sharing axes Contexts can share axes. The Chart::Clicker::Context perldocs shows this method: $context_a->share_axes_with($context_b); Also possible is $self->range_axis($other_context->range_axis); $self->domain_axis($other_context->domain_axis);
    • Colors and ColorAllocators
      • Chart::Clicker has good default colors
      • That said, Chart::Clicker::Drawing::ColorAllocator exists.
        • The Allocator is designed to choose color values equally spaced on the color chart.
      • Colors can specified with rgb floating point values and an alpha value (floating) (object), or by a number between 0 and 359.
        • Red = 0, Green = 180, Yellow = 90, Blue = 270
        • Default order = 270,90,180,0, 45, 135, 215, 305, etc.
    • More color notes
      • By creating color objects and then using the method add_to_colors with your ColorAllocator, then those colors will be stacked in order of the series collected in your dataset.
      • Named colors can be accessed through the from_color_library method of the Graphics::Color::RGB object.
    • my $ca = Chart::Clicker::Drawing::ColorAllocator->new; # this hash is simply here to make things readable and cleaner, you can always call G::C::R inline my $red = Graphics::Color::RGB->new({ red => .75, green => 0, blue => 0, alpha => .8 }); my $green = Graphics::Color::RGB->new({ red => 0,green => .75, blue=> 0, alpha=> .8 }); my $blue = Graphics::Color::RGB->new({ red => 0, green => 0, blue => .75, alpha => .8 }), my $chart = Chart::Clicker->new; # Create an empty dataset that we can add to my $dataset = Chart::Clicker::Data::DataSet->new; $dataset->add_to_series(Chart::Clicker::Data::Series->new( keys => [ 1,2,3,4,5 ], values => [ 52,74,52,82,14 ] )); # add a color - note that the order of colors and the order of the # series must match, the first series will use the first color and so on # see contexts and axes for alternate ways of doing this $ca->add_to_colors($blue);
    • # # if $colorlist non-empty, it contains Color::Library # colors. # if ( scalar @{$colorlist} > 0 ) { my $rgb = new Graphics::Color::RGB; my $colors; for (@{$colorlist}) { push @{$colors}, $rgb->from_color_library( $_ ); } my $ca = Chart::Clicker::Drawing::ColorAllocator->new( { colors => $colors }); $cc->color_allocator( $ca ); }
    • Complementary Tools
      • Configuration Modules – soft code your graphs.
        • Config::Simple, Config::General, etc.
      • PDL and PDL::Stats – curve fitting, numerical methods, statistics.
      • Image::Magick – The Annotate method can be used to label graphs (will have to DIY the Geometry)
      • GIMP/Photoshop – format translation. Tiling multiple images as a PDF. Simple inset graphs.
      • Fedex-Kinkos – next day online color prints
    • Acknowledgements
      • Cory G. Watson, for Graph::Clicker and many of the code examples shown in this slide show.
      • Bruce Gray, who suggested I look at this module.
      • Stephen Cristol, who puts up with my off topic statistics questions.
      • Atlanta Perl Mongers, for giving me the opportunity to present to their membership.