Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

make rendering more configurable

  • Loading branch information...
commit 7a0caaa2506e598ec03fc2b6c97ff96684a91e85 1 parent 3d30bbc
Moritz Lenz authored

Showing 1 changed file with 8 additions and 7 deletions. Show diff stats Hide diff stats

  1. +8 7 lib/Math/Model.pm
15 lib/Math/Model.pm
@@ -119,16 +119,17 @@ method integrate($from = 0, $to = 10, $min-resolution = ($to - $from) / 20) {
119 119 %!results;
120 120 }
121 121
122   -method render-svg($filename) {
  122 +method render-svg($filename, :$x-axis = 'time', :$width = 800, :$height = 600, :$title = 'Model output') {
123 123 my $f = open $filename, :w
124 124 or die "Can't open file '$filename' for writing: $!";
125   - my @data = map { %!results{$_} }, @.captures;
  125 + my @values = map { %!results{$_} }, @.captures;
  126 + my @x = $x-axis eq 'time' ?? @!time !! %!results{$x-axis};
126 127 my $svg = SVG::Plot.new(
127   - width => 800,
128   - height => 600,
129   - x => @!time,
130   - values => @data,
131   - title => 'Model output',
  128 + :$width,
  129 + :$height,
  130 + :@x,
  131 + :@values,
  132 + :$title,
132 133 ).plot(:xy-lines);
133 134 $f.say(SVG.serialize($svg));
134 135 $f.close;

0 comments on commit 7a0caaa

Please sign in to comment.
Something went wrong with that request. Please try again.