Date-list-plot-examples

Date list plot examples

Introduction

CLI execution

To "run" this file using shell commands the following Raku packages have to be installed:

Here is the shell command executed in the director of this Markdown file:

file-code-chunks-eval ./Date-list-plot-examples.md && from-markdown ./Date-list-plot-examples_woven.md -o=./Date-list-plot-examples.html -t=html 

Load packages

use Data::Generators;
use Data::Reshapers;
use Data::Summarizers;
use JavaScript::D3;

Random data

Make random data time series data:

my $k=0;
my @dsXY = (^1200)>>.rand>>.sqrt.map({ %(x=>$k++, y=>$_) });

my $refDate = DateTime.new('2000-01-01');
my @dsTS = @dsXY.map({ %( date => ($refDate + $_<x> * 10e4).DateTime, value => $_<y> ) });

my @dsTS2 = @dsTS.map({ %( date => $_<date>.Str.substr(0,10), value => $_<value>, group => <a b>.pick ) }).map({ if $_<group> eq 'a' { $_<value> *= -1 }; $_ });
say records-summary(@dsTS2);
say dimensions(@dsTS2);

Convert to format understood by js-d3-date-list-plot:

my @dsTS2 = @dsTS.map({ %( date => $_<date>.Str.substr(0,10), value => $_<value>, group => <a b>.pick ) }).map({ if $_<group> eq 'a' { $_<value> *= -1 }; $_ });
say records-summary(@dsTS2);
say dimensions(@dsTS2);
js-d3-date-list-plot(@dsTS2, width=>1000, background => 'none', format=>'html');

References

[AA1] Anton Antonov "JavaScript::D3", (2022), RakuForPrediction.

[AA2] Anton Antonov "Further work on the Raku-D3.js translation", (2022), RakuForPrediction.

JavaScript::D3 v0.3.1

Generation of JavaScript's D3 code for plots and charts.

Authors

  • Anton Antonov

License

Artistic-2.0

Dependencies

JSON::Fast:ver<0.19+>Hash::Merge:ver<2.0.0+>:api<2+>Statistics::Distributions:ver<0.1.+>Data::TypeSystem:ver<0.1.4+>FEN::Grammar:ver<0.0.6+>

Test Dependencies

Provides

  • JavaScript::D3
  • JavaScript::D3::Charts
  • JavaScript::D3::Chess
  • JavaScript::D3::CodeSnippets
  • JavaScript::D3::CodeSnippets3D
  • JavaScript::D3::Gauge
  • JavaScript::D3::Graph
  • JavaScript::D3::Images
  • JavaScript::D3::Plots
  • JavaScript::D3::Plots3D
  • JavaScript::D3::Predicates
  • JavaScript::D3::Random
  • JavaScript::D3::Utilities

The Camelia image is copyright 2009 by Larry Wall. "Raku" is trademark of the Yet Another Society. All rights reserved.