Chart-Plotly

 view release on metacpan or  search on metacpan

t/20-orca.t  view on Meta::CPAN


    # try create an image
    my $x       = [ 1 .. 15 ];
    my $y       = [ map { rand 10 } @$x ];
    my $scatter = Chart::Plotly::Trace::Scatter->new( x => $x, y => $y );
    my $plot    = Chart::Plotly::Plot->new();
    $plot->add_trace($scatter);

    my $tempfile = Path::Tiny->tempfile( SUFFIX => '.png' );
    Chart::Plotly::Image::Orca::orca( plot => $plot, file => $tempfile );
    my $size = ( stat($tempfile) )[7];
    ok( $size > 0, 'orca()' );
}

done_testing;

t/21-image.t  view on Meta::CPAN

$plot->add_trace($scatter);

my $has_kaleido = Chart::Plotly::Image::_has_kaleido();
my $has_orca    = Chart::Plotly::Image::_has_orca();

SKIP: {
    skip( "Have not Chart::Kaleido::Plotly", 1 ) unless $has_kaleido;

    my $tempfile = Path::Tiny->tempfile( SUFFIX => '.png' );
    save_image( plot => $plot, file => $tempfile, engine => 'kaleido' );
    my $size = ( stat($tempfile) )[7];
    ok( $size > 0, 'save_image(engine => "kaleido", ...)' );
}

SKIP: {
    skip( "Have not Alien::Plotly::Orca", 1 ) unless $has_orca;

    my $tempfile = Path::Tiny->tempfile( SUFFIX => '.png' );
    save_image( plot => $plot, file => $tempfile, engine => 'orca' );
    my $size = ( stat($tempfile) )[7];
    ok( $size > 0, 'save_image(engine => "orca", ...)' );
}

if ( $has_kaleido or $has_orca ) {
    my $tempfile = Path::Tiny->tempfile( SUFFIX => '.png' );
    save_image( plot => $plot, file => $tempfile, engine => 'auto' );
    my $size = ( stat($tempfile) )[7];
    ok( $size > 0, 'save_image(engine => "auto", ...)' );
}

done_testing;

tool/generate_images_from_examples.pl  view on Meta::CPAN

my $samples_folder = path('examples/traces');
for my $trace_example ($samples_folder->children(qr/\.pl$/)) {
    print "Trace file $trace_example\n";
    
    my $trace_name = $trace_example->basename;
    $trace_name =~ s/\.pl$//;
    
    system('perl -Ilib ' . $trace_example);
    
    my $tmp_path = path('/tmp');
    my @candidate_files = sort {(stat($b))[9] <=> (stat($a))[9]} $tmp_path->children(qr/\.html$/);
    print $candidate_files[0], "\n";
    
    $driver->get('file://' . $candidate_files[0]);
    my $image_name = $trace_name . ".png";
    sleep(30);
    $driver->capture_screenshot($samples_folder->child($image_name) . "");

    my $html_trace_file = $samples_folder->child($trace_name . ".html");
    $candidate_files[0]->copy($html_trace_file);
}



( run in 0.632 second using v1.01-cache-2.11-cpan-49f99fa48dc )