Giter VIP home page Giter VIP logo

p5-devel-iperl-plugin-chart-plotly's Introduction

NAME

Devel::IPerl::Plugin::Chart::PlotlyPod - Inline display of plotly charts in Jupyter notebooks using Devel::IPerl kernel

VERSION

version 0.007

SYNOPSIS

# In notebook
IPerl->load_plugin('Chart::Plotly');

# Trace objects get displayed automatically
use Chart::Plotly::Trace::Scatter;
my $scatter_trace = Chart::Plotly::Trace::Scatter->new( x => [ 1 .. 5 ], y => [ 1 .. 5 ] );

# Also Plot objects
use Chart::Plotly::Trace::Box;
use Chart::Plotly::Plot;

my $x = [ 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3 ];
my $box1 = Chart::Plotly::Trace::Box->new( x => $x, y => [ map { rand() } ( 1 .. ( scalar(@$x) ) ) ], name => "box1" );
my $box2 = Chart::Plotly::Trace::Box->new( x => $x, y => [ map { rand() } ( 1 .. ( scalar(@$x) ) ) ], name => "box2" );
my $plot = Chart::Plotly::Plot->new( traces => [ $box1, $box2 ], layout => { boxmode => 'group' } );

DESCRIPTION

Plugin to display automatically Chart::Plotly plot objects in Jupyter notebooks using kernel Devel::IPerl

The example above can be viewed in nbviewer

This plugin is now integrated with Chart::Plotly and this package is just a placeholder for backwards compatibility.

The repo can be found on Chart::Plotly Github

AUTHOR

Pablo Rodríguez González [email protected]

COPYRIGHT AND LICENSE

This software is Copyright (c) 2019 by Pablo Rodríguez González.

This is free software, licensed under:

The MIT (X11) License

CONTRIBUTOR

Roy Storey [email protected]

p5-devel-iperl-plugin-chart-plotly's People

Contributors

kiwiroy avatar pablrod avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

Forkers

kiwiroy

p5-devel-iperl-plugin-chart-plotly's Issues

Javascript loading error

  • $Devel::IPerl::VERSION 0.009
  • $Devel::IPerl::Plugin::Chart::Plotly::VERSION 0.02
  • Jupyter 4.3.0 (Jupyterhub)

Occasionally the behaviour below presents. Once a notebook is affected it appears to remain no matter shutdown, restarting etc... Copy paste to another notebook results in expected behaviour. Is there some ways to debug this?

Code

# In notebook
IPerl->load_plugin('Chart::Plotly');
# Trace objects get displayed automatically
use Chart::Plotly::Trace::Scatter;
my $scatter_trace = Chart::Plotly::Trace::Scatter->new( x => [ 1 .. 5 ], y => [ 1 .. 5 ] );

Actual behaviour

Javascript error adding output!
TypeError: Plotly.plot is not a function. (In 'Plotly.plot(document.getElementById('8c038704-12cc-11e8-957c-a91b0801ed74'),[{"x":[1,2,3,4,5],"type":"scatter","y":[1,2,3,4,5]}] )', 'Plotly.plot' is undefined)
See your browser Javascript console for more details.

JS Console shows

TypeError: Plotly.plot is not a function. (In 'Plotly.plot(document.getElementById('8c038704-12cc-11e8-957c-a91b0801ed74'),[{"x":[1,2,3,4,5],"type":"scatter","y":[1,2,3,4,5]}] )', 'Plotly.plot' is undefined)

_safe_append() in outputarea.js:443

Expected behaviour

A plotly chart.

Charts doesn't get displayed using nbviewer

Trying to display the example notebook in nbviewer charts doesn't show.

There is a problem loading plotly.js via require. The javascript console says:

Error: Mismatched anonymous define() module: function (){var t;return function t(e,r,n){function i(o,s){if(!r[o]){if(!e[o]){var l="function"==typeof require&&require;if(!s&&l)return l(o,!0);if(a)return a(o,!0);var u=new Error("Cannot find module '"+o+"'");throw u.code="MODULE_NOT_FOUND",u}var c=r[o]={exports:{}};e[o][0].call(c.exports,function(t){var r=e[o][1][t];return i(r?r:t)},c,c.exports,t,e,r,n)}return r[o].exports}for(var a="function"==typeof require&&require,o=0;o<n.length;o++)i(n[o]);return i}({1:[function(t,e,r){"use strict";var n=t("../src/lib"),i={"X,X div":"font-family:'Open Sans', verdana, arial, sans-serif;margin:0;padding:0;","X input,X button":"font-family:'Open Sans', verdana, arial, sans-serif;","X input:focus,X button:focus":"outline:none;","X a":"text-decoration:none;","X a:hover":"text-decoration:none;","X .crisp":"shape-rendering:crispEdges;","X .user-select-none":"-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:

It seems like nbviewer is loading javascript libraries only from local

Can't locate object method "register" via package "Devel::IPerl::Plugin::Chart::Plotly" at /usr/local/share/perl5/IPerl.pm line 36.

I installed from CPAN, and hit this:-

IPerl->load_plugin('Chart::Plotly');
Can't locate object method "register" via package "Devel::IPerl::Plugin::Chart::Plotly" at /usr/local/share/perl5/IPerl.pm line 36.

As best I can tell - my setup is OK?

use Chart::Plotly::Trace::Scatter;
my $scatter_trace = Chart::Plotly::Trace::Scatter->new( x => [ 1 .. 5 ], y => [ 1 .. 5 ] );
Chart::Plotly::Trace::Scatter=HASH(0x4114428)

This appears to be a bug either in the code, or in the documentation that didn't tell me something I probably needed to do :-)

require.js load plotly timeout

I sometimes get this error in my browser.

Uncaught Error: Load timeout for modules: plotly
http://requirejs.org/docs/errors.html#timeout

I guess it's about this https://metacpan.org/release/Devel-IPerl-Plugin-Chart-Plotly/source/lib/Devel/IPerl/Plugin/Chart/Plotly.pm#L20, but not sure what the problem is. Running Chart::Plotly without Jupyter Notebook is all good.

Many Python Jupyter Notebook extensions are in a "nbextension" form, and you can run jupyter nbextensions install/enable ... to install it, and if there are js files they will be installed into ~/.local/share/jupyter/nbextensions/$extension/ and be hosted by the Jupyter Notebook service. I wonder if we can do similar thing for this plugin...

I just remember that Python plotly package can be used in offline mode in Jupyter Notebook: https://plot.ly/python/offline So we probably can see how that's implemented and we might take the same approach as recent Chart::Plotly has been shipping plotly.js.min.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.