{ "cells": [ { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "application/vnd.vega.v2+json": { "axes": [ { "scale": "x", "type": "x" }, { "scale": "y", "type": "y" } ], "data": [ { "name": "table", "values": [ { "x": 1, "y": 28 }, { "x": 2, "y": 55 }, { "x": 3, "y": 43 }, { "x": 4, "y": 91 }, { "x": 5, "y": 81 }, { "x": 6, "y": 53 }, { "x": 7, "y": 19 }, { "x": 8, "y": 87 }, { "x": 9, "y": 52 }, { "x": 10, "y": 48 }, { "x": 11, "y": 24 }, { "x": 12, "y": 49 }, { "x": 13, "y": 87 }, { "x": 14, "y": 66 }, { "x": 15, "y": 17 }, { "x": 16, "y": 27 }, { "x": 17, "y": 68 }, { "x": 18, "y": 16 }, { "x": 19, "y": 49 }, { "x": 20, "y": 15 } ] } ], "height": 200, "marks": [ { "from": { "data": "table" }, "properties": { "enter": { "width": { "band": true, "offset": -1, "scale": "x" }, "x": { "field": "x", "scale": "x" }, "y": { "field": "y", "scale": "y" }, "y2": { "scale": "y", "value": 0 } }, "hover": { "fill": { "value": "red" } }, "update": { "fill": { "value": "steelblue" } } }, "type": "rect" } ], "padding": { "bottom": 30, "left": 30, "right": 10, "top": 10 }, "scales": [ { "domain": { "data": "table", "field": "x" }, "name": "x", "range": "width", "type": "ordinal" }, { "domain": { "data": "table", "field": "y" }, "name": "y", "nice": true, "range": "height", "type": "linear" } ], "width": 400 } }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "// bar-chart.vg.json from https://gist.github.com/hadim/629b8fde56eac74c587136139a0dd5c2#file-bar-chart-vg-json\n", "\n", "import com.twosigma.beakerx.mimetype.MIMEContainer;\n", "import groovy.json.JsonSlurper;\n", " \n", "fname = \"demoResources/bar-chart.vg.json\"\n", "fileContents = new File(fname).text\n", "def jsonSlurper = new JsonSlurper()\n", "def json = jsonSlurper.parseText(fileContents)\n", "new MIMEContainer(\"application/vnd.vega.v2+json\", json)" ] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] }, { "cell_type": "code", "execution_count": null, "metadata": { "collapsed": true }, "outputs": [], "source": [] } ], "metadata": { "kernelspec": { "display_name": "Groovy", "language": "groovy", "name": "groovy" }, "language_info": { "codemirror_mode": "groovy", "file_extension": ".groovy", "mimetype": "", "name": "Groovy", "nbconverter_exporter": "", "version": "2.4.3" } }, "nbformat": 4, "nbformat_minor": 2 }