• This repository has been archived on 22/Dec/2023
  • Stars
    star
    72
  • Rank 438,337 (Top 9 %)
  • Language
    Perl
  • Created almost 16 years ago
  • Updated almost 8 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Extensible, Beautiful Charts for Perl

NAME

Chart::Clicker - Powerful, extensible charting.

VERSION

version 2.90

SYNOPSIS

use Chart::Clicker;

my $cc = Chart::Clicker->new;

my @values = (42, 25, 86, 23, 2, 19, 103, 12, 54, 9);
$cc->add_data('Sales', \@values);

# alternately, you can add data one bit at a time...
foreach my $v (@values) {
  $cc->add_data('Sales', $v);
}

# Or, if you want to specify the keys you can use a hashref
my $data = { 12 => 123, 13 => 341, 14 => 1241 };
$cc->add_data('Sales', $data);

$cc->write_output('foo.png');

DESCRIPTION

Chart::Clicker aims to be a powerful, extensible charting package that creates really pretty output. Charts can be saved in png, svg, pdf and postscript format.

Clicker leverages the power of Graphics::Primitive to create snazzy graphics without being tied to specific backend. You may want to begin with Chart::Clicker::Tutorial.

EXAMPLES

For code examples see the examples repository on GitHub: http://github.com/gphat/chart-clicker-examples/

FEATURES

Renderers

Clicker supports the following renderers:

  • Line
  • StackedLine
  • Bar
  • StackedBar
  • Area
  • StackedArea
  • Bubble
  • CandleStick
  • Point
  • Pie
  • PolarArea

ADDING DATA

The synopsis shows the simple way to add data.

my @values = (42, 25, 86, 23, 2, 19, 103, 12, 54, 9);
foreach my $v (@values) {
  $cc->add_data('Sales', $v);
}

This is a convenience method provided to make simple cases much simpler. Adding multiple Series to a chart is as easy as changing the name argument of add_data. Each unique first argument will result in a separate series. See the docs for add_data to learn more.

If you'd like to use the more advanced features of Clicker you'll need to shake off this simple method and build Series & DataSets explicitly.

use Chart::Clicker::Data::Series;
use Chart::Clicker::Data::DataSet;

...

my $series = Chart::Clicker::Data::Series->new(
  keys    => [ 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 ],
  values  => [ 42, 25, 86, 23, 2, 19, 103, 12, 54, 9 ],
);

my $ds = Chart::Clicker::Data::DataSet->new(series => [ $series ]);

$cc->add_to_datasets($ds);

This used to be the only way to add data, but repeated requests to make the common case easier resulted in the inclusion of add_data.

CONTEXTS

The normal use case for a chart is a couple of datasets on the same axes. Sometimes you want to chart one or more datasets on different axes. A common need for this is when you are comparing two datasets of vastly different scale such as the number of employees in an office (1-10) to monthly revenues (10s of thousands). On a normal chart the number of employees would show up as a flat line at the bottom of the chart.

To correct this, Clicker has contexts. A context is a pair of axes, a renderer and a name. The name is the 'key' by which you will refer to the context.

my $context = Chart::Clicker::Context->new( name => 'sales' );
$clicker->add_to_contexts($context);

$dataset->context('sales');

$clicker->add_to_datasets($dataset);

New contexts provide a fresh domain and range axis and default to a Line renderer.

Caveat: Clicker expects that the default context (identified by the string "default") will always be present. It is from this context that some of Clicker's internals draw their values. You should use the default context unless you need more than one, in which case you should use "default" as the base context.

FORMATS & OUTPUT

Clicker supports PNG, SVG, PDF and PostScript output. To change your output type, specificy it when you create your Clicker object:

my $cc = Chart::Clicker->new(format => 'pdf', ...);
# ...
$cc->write_output('chart.pdf');

If you are looking to get a scalar of the output for use with HTTP or similar things, you can use:

# ... make your chart
$cc->draw;
my $image_data = $cc->rendered_data;

If you happen to be using Catalyst then take a look at Catalyst::View::Graphics::Primitive.

ATTRIBUTES

background_color

Set/Get the background color. Defaults to white.

border

Set/Get the border.

color_allocator

Set/Get the color_allocator for this chart.

contexts

Set/Get the contexts for this chart.

datasets

Get/Set the datasets for this chart.

driver

Set/Get the driver used to render this Chart. Defaults to Graphics::Primitive::Driver::Cairo.

format

Get the format for this Chart. Required in the constructor. Must be on of Png, Pdf, Ps or Svg.

plot_mode

Fast or slow plot mode. When in fast mode, data elements that are deemed to be superfluous or invisible will not be drawn. Default is 'slow'

grid_over

Flag controlling if the grid is rendered over the data. Defaults to 0. You probably want to set the grid's background color to an alpha of 0 if you enable this flag.

height

Set/Get the height. Defaults to 300.

layout_manager

Set/Get the layout manager. Defaults to Layout::Manager::Compass.

legend

Set/Get the legend that will be used with this chart.

legend_position

The position the legend will be added. Should be one of north, south, east, west or center as required by Layout::Manager::Compass.

marker_overlay

Set/Get the marker overlay object that will be used if this chart has markers. This is lazily constructed to save time.

over_decorations

Set/Get an arrayref of "over decorations", or things that are drawn OVER the chart. This is an advanced feature. See overaxis-bar.pl in the examples.

padding

Set/Get the padding. Defaults to 3px on all sides.

plot

Set/Get the plot on which things are drawn.

subgraphs

You can add "child" graphs to this one via add_subgraph. These must be Chart::Clicker objects and they will be added to the bottom of the existing chart. This is a rather esoteric feature.

title

Set/Get the title component for this chart. This is a Graphics::Primitive::TextBox, not a string. To set the title of a chart you should access the TextBox's text method.

$cc->title->text('A Title!');
$cc->title->font->size(20);
# etc, etc

If the title has text then it is added to the chart in the position specified by title_position.

You should consult the documentation for Graphics::Primitive::TextBox for things like padding and text rotation. If you are adding it to the top and want some padding between it and the plot, you can:

$cc->title->padding->bottom(5);

title_position

The position the title will be added. Should be one of north, south, east, west or center as required by Layout::Manager::Compass.

Note that if no angle is set for the title then it will be changed to -1.5707 if the title position is east or west.

width

Set/Get the width. Defaults to 500.

METHODS

context_count

Get a count of contexts.

context_names

Get a list of context names.

delete_context ($name)

Remove the context with the specified name.

get_context ($name)

Get the context with the specified name

set_context ($name, $context)

Set a context of the specified name.

add_to_datasets

Add the specified dataset (or arrayref of datasets) to the chart.

dataset_count

Get a count of datasets.

get_dataset ($index)

Get the dataset at the specified index.

rendered_data

Returns the data for this chart as a scalar. Suitable for 'streaming' to a client.

add_to_over_decorations

Add an over decoration to the list.

get_over_decoration ($index)

Get the over decoration at the specified index.

over_decoration_count

Get a count of over decorations.

add_to_contexts

Add the specified context to the chart.

add_subgraph

Add a subgraph to this chart.

draw

Draw this chart.

get_datasets_for_context

Returns an arrayref containing all datasets for the given context. Used by renderers to get a list of datasets to chart.

add_data ($name, $data)

Convenience method for adding data to the chart. Can be called one of three ways.

  • scalar

    Passing a name and a scalar will append the scalar data to that series' data.

      $cc->add_data('Sales', 1234);
      $cc->add_data('Sales', 1235);
    

    This will result in a Series named 'Sales' with two values.

  • arrayref

    Passing a name and an arrayref works much the same as the scalar method discussed above, but appends the supplied arrayref to the existing one. It may be mixed with the scalar method.

      $cc->add_data('Sales', \@some_sales);
      $cc->add_data('Sales', \@some_more_sales);
      # This works still!
      $cc->add_data('Sales', 1234);
    
  • hashref

    This allows you to pass both keys and values in all at once.

      $cc->add_data('Sales', { 2009 => 1234, 2010 => 1235 });
      # appends to last call
      $cc->add_data('Sales', { 2011 => 1234, 2012 => 1235 });
    

    You may call the hashref version after the scalar or arrayref versions, but you may not add a scalar or arrayref after adding a hashref (as it's not clear what indices should be used for the new data).

set_renderer ($renderer_object, [ $context ]);

Sets the renderer on the specified context. If no context is provided then 'default' is assumed.

write

This method is passed through to the underlying driver. It is only necessary that you call this if you manually called draw beforehand. You likely want to use write_output.

write_output ($path)

Write the chart output to the specified location. Output is written in the format provided to the constructor (which defaults to Png). Internally calls draw for you. If you use this method, do not call draw first!

$c->write_output('/path/to/the.png');

inside_width

Get the width available in this container after taking away space for insets and borders.

inside_height

Get the height available in this container after taking away space for insets and borders.

ISSUES WITH CENTOS

I've had numerous reports of problems with Chart::Clicker when using CentOS. This problem has usually be solved by updating the version of cairo. I've had reports that upgrading to at least cairo-1.8.8-3 makes thinks work properly.

I hesitate to provide any other data with this because it may get out of date fast. If you have trouble feel free to drop me an email and I'll tell you what I know.

CONTRIBUTORS

Many thanks to the individuals who have contributed various bits:

Ash Berlin

Brian Cassidy

Guillermo Roditi

Torsten Schoenfeld

Yuval Kogman

SOURCE

Chart::Clicker is on github:

http://github.com/gphat/chart-clicker/tree/master

AUTHOR

Cory G Watson [email protected]

COPYRIGHT AND LICENSE

This software is copyright (c) 2016 by Cory G Watson.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.

More Repositories

1

wabisabi

Scala Asynchronous ElasticSearch HTTP Client
Scala
97
star
2

chart-clicker-examples

Examples of Chart::Clicker Usage
Perl
33
star
3

datadog-scala

Datadog library for Scala
Scala
24
star
4

solicitor

Feature flags and dynamic configuration for Scala with pluggable backends.
Scala
23
star
5

censorinus

Censorinus is a Scala *StatsD client with multiple personalities.
Scala
21
star
6

babyvm

Baby's First Garbage Collector
C
15
star
7

data-verifier

Data::Verifier
Perl
12
star
8

pagerduty-full

gem for access to the full pagerduty api
Ruby
10
star
9

io-storm

Perl support for Twitter's Storm distributed computational system.
Perl
9
star
10

falconry

Browser-based Kestrel monitor
JavaScript
9
star
11

jira-client-rest

JIRA REST Client
Perl
8
star
12

guru

System monitoring daemon for Metrics 2.0
Go
7
star
13

test-net-rabbitmq

Test Mock Object for Net::RabbitMQ that implements a really stupid broker
Perl
7
star
14

kestrel-client

Java client for Kestrel's text protocol
Java
6
star
15

moosex-undeftolerant

Makes your attributes tolerant to undef initialization
Perl
6
star
16

emperor

Project management and bug tracking.
Scala
6
star
17

bullfinch

Kestrel Workers
Java
5
star
18

data-searchengine-solr

Data::SearchEngine wrapper for Solr
Perl
5
star
19

message-stack

Message::Stack
Perl
5
star
20

graphics-primitive

Driver agnostic 2D Graphics in Perl
Perl
5
star
21

data-searchengine

SearchEngine API and Roles
Perl
4
star
22

dist-zilla-plugin-changelogfromgit-debian

Debian changelog formatter
Perl
4
star
23

chi-driver-redis

Redis driver for CHI
Perl
4
star
24

document-presentation

Document model for Presentations (based on Document::Writer)
Perl
4
star
25

catalyst-view-graphics-primitive

Graphics::Primitive view for Catalyst
Perl
3
star
26

graphics-color

Work with various color spaces in perl.
Perl
3
star
27

log-log4perl-appender-dbix-class

DBIx::Class appender for Log::Log4perl
Perl
3
star
28

geometry-primitive

Geometry primitives for Perl.
Perl
3
star
29

net-limelight-purge

LimeLight Purge API for Perl
Perl
3
star
30

dist-zilla-plugin-version-git-flowish

Git Flow style version finder for Dist::Zilla
Perl
3
star
31

data-manager

Manage multiple Data::Verifier objects and a single Message::Stack
Perl
3
star
32

provost

Side by side testing of code paths in Scala using Futures.
Scala
3
star
33

bullfinch3

Scala
3
star
34

kiokudb-backend-redis

Redis backend for KiokuDB
Perl
3
star
35

graphics-primitive-driver-cairopango

Cairo+Pango Driver for Graphics::Primitive
Perl
3
star
36

dist-zilla-plugin-dpkg

Dist::Zilla plugin for generating dpkg files
Perl
3
star
37

catalyst-plugin-session-store-withcache

Caching layer for catalyst sessions
Perl
3
star
38

honeybird

Event storage, query and filtering service.
Scala
3
star
39

geo-address-mail-standardizer-usps

Offline implementation of USPS addressing standards according to Publication 28
Perl
3
star
40

data-searchengine-elasticsearch

ElasticSearch backend for Data::SearchEngine
Perl
3
star
41

dist-zilla-pluginbundle-gphat

Dist::Zilla plugin bundle for gphat
Perl
3
star
42

Business-Payment

Payment Processor Abstraction
Perl
3
star
43

net-flowdock

API wrapper for Flowdock in Perl
Perl
3
star
44

dbix-class-querylog

Query Logging for DBIx::Class
Perl
3
star
45

business-onlinepayment-paymentech-orbital

Business::OnlinePayment module for Chase/PaymenTech's Orbital Gateway
Perl
3
star
46

viscount

Dashboard creation and management for KairosDB
JavaScript
2
star
47

document-writer

Document creation in Perl with Graphics::Primitive
Perl
2
star
48

dbix-class-resultset-faceter

Faceting of DBIx::Class::ResultSets
Perl
2
star
49

layout-manager

Layout Management for 2D scenes in Perl.
Perl
2
star
50

dnd-something-amiss

2
star
51

rule-engine

Rule::Engine
Perl
2
star
52

dist-zilla-plugin-dpkg-perlbrewstarman

Generate dpkg files for your perlbrew-backed, starman-based perl app
Perl
2
star
53

message-stack-parser

Parse things into Message::Stacks!
Perl
2
star
54

api-assembla

Perl access to Assembla API
Perl
2
star
55

hrt

hrt
HTML
2
star
56

begum

Synthetic HTTP metric generator with runtime-adjustable parameters
Go
2
star
57

net-kestrel

Kestrel Client for Perl
Perl
2
star
58

graphics-primitive-driver-cairo

Cairo driver for Graphics::Primitive
Perl 6
2
star
59

business-payment-processor-orbital

PaymentTech Orbital Processor for Business::Payment
Perl
1
star
60

data-money-converter-webservicex

WebserviceX currency converter for Data::Currency
Perl
1
star
61

jira-plugin-linkbrowser

Java
1
star
62

app-beckley

Asset retrieval and processing server
Perl
1
star
63

scene-graph

A Pure-Perl Scene Graph
Perl
1
star
64

catalyst-plugin-session-store-mongodb

Perl
1
star
65

graphics-primitive-driver-imager

Imager driver for Graphics::Primitive
Perl
1
star
66

moosex-meta-attribute-searchable

Searchable attributes for Moose objects
Perl
1
star
67

baron

Link management for teams.
Scala
1
star
68

catalyst-plugin-messagestack

Catalyst plugin for Message::Stack
Perl
1
star
69

experiment-python

Python experiments inspired by GitHub's dat-science
Python
1
star
70

graphics-primitive-driver-gd

GD driver for Graphics::Primitive
Perl 6
1
star
71

event-processor

Event Processing in Perl
Perl
1
star
72

treasurer

A directory service API for managing projects, artifacts and deploy information.
Scala
1
star
73

template-plugin-string-truncate

String::Truncate plugin for TT
Perl
1
star
74

graphics-primitive-driver-canvas

Canvas Driver for Graphics::Primitive
Perl
1
star
75

template-plugin-time-duration

Time::Duration plugin for TT
Perl
1
star
76

data-money-converter

Conversion role for Data::Currency
Perl
1
star
77

lowed

A DogStatsD Metrics Generator for Testing
Go
1
star
78

dotfiles

My dotfiles
Vim Script
1
star
79

moosex-role-data-verifier

Generate Data::Verifier profiles from Moose objects.
Perl
1
star
80

utilities

Utilities of mine
Shell
1
star
81

graphics-primitive-css

CSS Styling for Graphics::Primitive
Perl
1
star
82

api-beanstalk

Perl interface to the Beanstalk API (the code hosting, not the queue)
Perl
1
star
83

redis-easy

Easier bindings for Redis
Perl
1
star
84

elasticsearch-river-kestrel

Kestrel river for ElasticSearch
Java
1
star
85

version-finder-metacpan

Perl
1
star
86

data-paginator

Moose Pagination
Perl
1
star
87

Scatter

Scala Web Framework Experiment
Scala
1
star
88

business-payment-clearinghouse

ClearingHouse module for Business::Payment
Perl
1
star
89

catalyst-plugin-session-store-redis

Redis store for Catalyst Sessions
Perl
1
star
90

event-processor-service-redis

Redis storage service for Event::Processor
Perl
1
star
91

software-release

Perl module that wraps the abstract of a software release
Perl
1
star