Data visualization: Creating charts using Perl (Chart::Clicker)

This page summarizes the projects mentioned and recommended in the original post on dev.to

InfluxDB - Power Real-Time Data Analytics at Scale
Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
www.influxdata.com
featured
SaaSHub - Software Alternatives and Reviews
SaaSHub helps you find the best software and product alternatives
www.saashub.com
featured
  • dash

    Data Apps & Dashboards for Python. No JavaScript Required.

  • Chart::Plotly is something which I am more interested in right now. It is based on plotly.js. I also encourage you to checkout Dash which is built on top of Plotly.js, React and Flask for building ML & data science web apps. There is something equivalent in Perl world also from same author(Chart::Plotly) - Dash which will be using Mojolicious or Dancer2. But right now it is in experimental stage and still under active development. I hope it will be ready for production soon because I can't wait to try my hands on it.

  • chart-clicker-examples

    Examples of Chart::Clicker Usage

  • While working on creating the multi-line chart, I spend a quite amount of time understanding it. The documentation is good but still I think it can be improved. Why like this and how this is happening is unanswered at some places. One good thing is there are lot of example present. So, you can look at it and found your way out.

  • InfluxDB

    Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.

    InfluxDB logo
  • chart-clicker

    Discontinued Extensible, Beautiful Charts for Perl

  • package CreateCharts; use strict; use warnings; use Chart::Clicker; use Chart::Clicker::Context; use Chart::Clicker::Data::DataSet; use Chart::Clicker::Data::Marker; use Chart::Clicker::Data::Series; use Chart::Clicker::Axis::DateTime; use Geometry::Primitive::Rectangle; use Geometry::Primitive::Circle; use Graphics::Color::RGB; use DateTime; sub new { my ($class, @arguments) = @_; my $self = {@arguments}; bless $self, $class; return $self; } sub _generate_specific_colors { my ($self) = @_; # build the color allocator # Add more colors in case your line is more than 6 my $ca = Chart::Clicker::Drawing::ColorAllocator->new; 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 $orange = Graphics::Color::RGB->new(red => .88, green => .48, blue => .09, alpha => .8); my $aqua = Graphics::Color::RGB->new(red => 0, green => 1, blue => 1, alpha => .8); my $fuchsia = Graphics::Color::RGB->new(red => 1, green => 0, blue => 1, alpha => .8); $ca->add_to_colors($green); $ca->add_to_colors($red); $ca->add_to_colors($blue); $ca->add_to_colors($orange); $ca->add_to_colors($aqua); $ca->add_to_colors($fuchsia); return $ca; } sub _genrate_random_colors { # let Chart::Clicker autmatically pick complementing colors for you # https://metacpan.org/pod/Chart::Clicker::Drawing::ColorAllocator#AUTOMATIC-COLOR-ALLOCATION my $ca = Chart::Clicker::Drawing::ColorAllocator->new({ seed_hue => 0, #red }); return $ca; } sub _add_series { my ($self, $x_axis, $y_axis) = @_; my $ds = Chart::Clicker::Data::DataSet->new; foreach my $axis (keys %{$y_axis}) { $ds->add_to_series( Chart::Clicker::Data::Series->new( keys => $x_axis, values => $y_axis->{$axis}->{data}, name => $y_axis->{$axis}->{legendName}, ) ); } return $ds; } sub _add_title { my ($self, $cc, $title) = @_; $cc->title->font->family('Helvetica'); $cc->title->text($title); $cc->title->font->size(20); $cc->title->padding->bottom(10); } sub _style_legend { my ($self, $cc) = @_; $cc->legend->font->size(20); $cc->legend->font->family('Helvetica'); } sub _add_background { my ($self, $cc) = @_; # https://metacpan.org/pod/Graphics::Color::RGB my $titan_white = Graphics::Color::RGB->new(red => .98, green => .98, blue => 1, alpha => 1); my $white = Graphics::Color::RGB->new(red => 1, green => 1, blue => 1, alpha => 1); $cc->plot->grid->visible(1); $cc->background_color($white); $cc->plot->grid->background_color($titan_white); $cc->border->width(0); } sub _add_label { my ($self, $def, $x_label, $y_label) = @_; $def->domain_axis->label($x_label); $def->range_axis->label($y_label); $def->domain_axis->label_font->size(20); $def->range_axis->label_font->size(20); } sub _add_shapes_to_lines { my ($self, $defctx) = @_; # https://metacpan.org/pod/Chart::Clicker::Renderer::Line#shape $defctx->renderer->shape(Geometry::Primitive::Circle->new({radius => 6,})); # https://metacpan.org/pod/Chart::Clicker::Renderer::Line#shape_brush $defctx->renderer->shape_brush( Graphics::Primitive::Brush->new( width => 2, color => Graphics::Color::RGB->new(red => 1, green => 1, blue => 1) ) ); $defctx->renderer->brush->width(2); } sub generate_chart { my ($self, $chart_loc, $summary_info) = @_; my $cc = Chart::Clicker->new(width => 800, height => 600, format => 'png'); my $x_axis = $summary_info->{domainAxis}; my $y_axis = $summary_info->{rangeAxis}; my (@epoch_datetime); for my $datetime (@{$x_axis->{data}}) { # https://github.com/gphat/chart-clicker/blob/master/example/date-axis.pl # Need to convert date time string to epoch time my ($y, $m, $d) = split(/-/, $datetime); my $epoch = DateTime->new(year => $y, month => $m, day => $d)->epoch; push @epoch_datetime, $epoch; } my $ds = $self->_add_series(\@epoch_datetime, $y_axis->{lines}); $cc->add_to_datasets($ds); # To generate random colors and let Chart::Clicker autmatically pick color # my $ca = $self->_genrate_random_colors(); # To generate some specific colors for lines ise this function my $ca = $self->_generate_specific_colors(); $cc->color_allocator($ca); $self->_add_title($cc, $summary_info->{title}); $self->_style_legend($cc); $self->_add_background($cc); my $defctx = $cc->get_context('default'); # For range axis $defctx->range_axis->range(Chart::Clicker::Data::Range->new(lower => 0)); $defctx->range_axis->format('%d'); # https://metacpan.org/pod/Chart::Clicker::Axis#fudge_amount # $defctx->range_axis->fudge_amount(0.02); # For domain axis $defctx->domain_axis( Chart::Clicker::Axis::DateTime->new( format => "%Y-%m-%d", ticks => scalar @{$x_axis->{data}}, position => 'bottom', tick_label_angle => 0.78539816, # 45 deg in radians orientation => 'vertical', tick_font => Graphics::Primitive::Font->new({family => 'Helvetica', slant => 'normal'}) ) ); $self->_add_label($defctx, $x_axis->{label}, $y_axis->{label}); $self->_add_shapes_to_lines($defctx); $cc->write_output($chart_loc); } 1;

  • perl-toolkit

    Perl example scripts

  • The above example is also available at github

  • Highcharts JS

    Highcharts JS, the JavaScript charting framework

  • Highcharts

  • Chart.js

    Simple HTML5 Charts using the <canvas> tag

  • Chart.js

  • d3

    Bring data to life with SVG, Canvas and HTML. :bar_chart::chart_with_upwards_trend::tada:

  • D3.js

  • SaaSHub

    SaaSHub - Software Alternatives and Reviews. SaaSHub helps you find the best software and product alternatives

    SaaSHub logo
NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts

  • Working Camp Inquiry - Glam Up my Markup

    1 project | dev.to | 23 Mar 2024
  • Frontend Developer Roadmap

    1 project | dev.to | 16 Feb 2024
  • What is the technology stack used to create these live charts?

    2 projects | /r/learnprogramming | 10 Dec 2023
  • 2023 Self-Host User Survey Results

    1 project | /r/selfhosted | 7 Oct 2023
  • Live Image editor w/ JavaScript: Canvas API and Tesseract.js(OCR)

    2 projects | dev.to | 26 Aug 2023