{ "cells": [ { "cell_type": "code", "execution_count": 1, "metadata": {}, "outputs": [], "source": [ "(require '[clojupyter.misc.display :as display]\n", " '[hiccup.core :as hiccup]\n", " '[cheshire.core :as cheshire]\n", " '[clojure.repl :refer :all]) ;; to have all the repl goodies" ] }, { "cell_type": "code", "execution_count": 2, "metadata": {}, "outputs": [ { "data": { "text/html": [ "" ] }, "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(display/make-html (hiccup/html [:script {:src \"https://code.highcharts.com/highcharts.js\"}]))" ] }, { "cell_type": "code", "execution_count": 5, "metadata": {}, "outputs": [ { "data": { "text/plain": [ "#'user/plot-highchart" ] }, "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ "(defn plot-highchart [highchart-json]\n", " (let [id (str (java.util.UUID/randomUUID))\n", " code (format \"Highcharts.chart('%s', %s );\" id, (cheshire/encode highchart-json))\n", " html [:div [:div {:id id :style {:background-color \"red\"}}]\n", " [:script code]]]\n", " (-> html hiccup/html display/make-html)))" ] }, { "cell_type": "code", "execution_count": 6, "metadata": {}, "outputs": [ { "data": { "text/html": [ "