Coder Social home page Coder Social logo

gregr / iracket Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rmculpepper/iracket

0.0 2.0 0.0 508 KB

IPython/Jupyter kernel for Racket and Gamble.

License: BSD 3-Clause "New" or "Revised" License

Racket 89.58% Shell 5.29% JavaScript 5.13%

iracket's Introduction

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.

iracket's People

Contributors

tgiannak avatar rmculpepper avatar gregr avatar

Watchers

 avatar James Cloos avatar

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.