Skip to content
Jupyter kernel for Racket
Racket Shell JavaScript
Branch: master
Clone or download
Pull request Compare This branch is 36 commits ahead of ppaml-op3:master.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
examples update example notebook Dec 21, 2017
private remove is_complete handler, old comm handler code Oct 14, 2019
static Add an installation script. Update README. Jun 24, 2015
.gitignore added some missing things to .gitignore Jun 9, 2015
LICENSE added license file Jun 27, 2016
README.md readme tweaks Aug 3, 2017
info.rkt fix dependencies Dec 21, 2017
install.rkt packagize: add info and racket install script Aug 3, 2017
installation.sh
iracket.rkt use eprintf, remove coarse stdout->stderr redirection Oct 14, 2019

README.md

IRacket

IRacket is a Racket kernel for IPython/Jupyter. IRacket enables interactive notebook-style programming with Racket. This package also includes Racket bindings for the C3.js charting library.

Installation

First install the iracket package:

raco pkg install iracket

Then register the iracket kernel with IPython/Jupyter:

racket -l iracket/install

Requirements

Using the kernel

Run the IPython notebook server as you usually do, e.g.

ipython notebook

or

jupyter notebook

and create a new notebook with the Racket kernel, or open examples/getting-started.ipynb in the iracket source directory.

Examples

See the examples subdirectory for example notebooks.

C3 (Charts) Integration (Experimental!)

C3 support is extremely unstable. It will change in the near future.

Installing C3 Support

If you use a non-default profile, set IPYTHON_PROFILE to the name of that profile, then run the following:

IPYTHON_PROFILE=
IPYTHON_PROFILE_STATIC=$(ipython locate profile $IPYTHON_PROFILE)/static
cp ./static/ic3.js $(ipython locate)/nbextensions/ic3.js
cat ./static/custom.js >> $IPYTHON_PROFILE_STATIC/custom/custom.js
curl -L https://github.com/mbostock/d3/raw/v3.5.5/d3.min.js \
    > $IPYTHON_PROFILE_STATIC/d3.js
curl -L https://github.com/masayuki0812/c3/raw/0.4.10/c3.min.js \
    > $IPYTHON_PROFILE_STATIC/c3.js
curl -L https://github.com/masayuki0812/c3/raw/0.4.10/c3.min.css \
    > $IPYTHON_PROFILE_STATIC/c3.css

This script will

  • copy the nbextension for C3 into your IPython nbextensions folder,
  • append the code for loading the extension to your IPython profile's custom.js, and
  • add the required D3 and C3 code to your IPython profile's static resources folder.

Displaying C3 charts from IRacket

To display C3 charts, evaluate a cons cell whose car is the symbol 'c3-data and whose cdr is a jsexpr (from the json package) of the data structure to pass to C3's generate function.

Example:

(cons 'c3-data
      (hasheq 'data
              (hasheq 'columns
                      (list (list "data1" 30 200 100 400 150 250)
                            (list "data2" 50 20 10 40 15 25)))))

For more information on C3's data format, see the C3 reference, or for examples see the C3 examples page. For information on how to write JSON in Racket, see the Racket JSON package documentation.

Note that certain C3 features are not currently usable because they rely on using Javascript functions, which are not expressible in JSON.

You can’t perform that action at this time.