tried a couple of things to be sure it works on the github

This commit is contained in:
didier amyot committed 2017-12-06 07:28:12 -05:00
1 parent 16345cf224
commit ea3e53c0c8
3 files changed
+160 -89

No files matched your search

+85 -79
View File
@@ -9,12 +9,13 @@
},
{
"cell_type": "code",
"execution_count": 29,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"(require '[clojupyter.misc.display :as display]\n",
" '[clojure.java.io :as io]\n",
" '[hiccup.core :as hiccup]\n",
" '[cheshire.core :as cheshire]\n",
" '[clj-http.client :as client]\n",
" '[clojure.repl :refer :all]) ;; to have all the repl goodies"
@@ -24,21 +25,25 @@
"cell_type": "markdown",
"metadata": {},
"source": [
"To access plotly api, we need an api key. The standard way is to store the api key in `$HOME/.plotly/.credentials` in a json object as defined in https://plot.ly/python/getting-started/. For that you will need to create a plotly account."
"To access plotly api, we need an api key. The standard way is to store the api key in `$HOME/.plotly/.credentials` in a json object as defined in https://plot.ly/python/getting-started/. For that you will need to create a plotly account.\n",
"\n",
"(For whatever reason, I believe plotly's python api does not load the credentials automatically from this location.)"
]
},
{
"cell_type": "code",
"execution_count": 61,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"your credentials are:\n",
" {:api_key 6FaFG4sgtpLnDrvzvFT1, :username didier, :stream_ids [8rcf9eam9j zupv6k3u4k]}\n"
"data": {
"text/plain": [
"#'user/plotly-cred"
]
},
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
@@ -52,7 +57,7 @@
" {})))\n",
"\n",
"(def plotly-cred (get-plotly-credentials))\n",
"(println \"your credentials are:\\n\" plotly-cred)"
";; (println \"credentials are now loaded\" plotly-cred)"
]
},
{
@@ -66,44 +71,64 @@
},
{
"cell_type": "code",
"execution_count": 86,
"execution_count": 3,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"#'user/upload-grid"
"#'user/plot-response"
]
},
"execution_count": 86,
"execution_count": 3,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(defn upload-grid [grid cred] \n",
" (let [url \"https://api.plot.ly/v2/grids\";;\"https://api.plot.ly/v2/grids\" \"https://api.plot.ly/v2/grids\" ;;\n",
" headers {:Plotly-Client-Platform' \"curl\"}\n",
" auth \"didier:6FaFG4sgtpLnDrvzvFT1\"];;[(:username cred) (:api_key cred)]]\n",
" (println auth)\n",
"(defn post-to-endpoint\n",
" \"General method to POST to a plotly endpoint.\"\n",
" [endpoint payload cred]\n",
" (let [url endpoint\n",
" headers {:Plotly-Client-Platform \"curl\"}\n",
" auth [(:username cred) (:api_key cred)]]\n",
" (client/post url {:basic-auth auth\n",
" :headers headers\n",
" :throw-entire-message? true\n",
" :form-params grid :content-type :json})))"
" :form-params payload \n",
" :content-type :json})))\n",
"\n",
"(defn post-to-grid [grid cred] \n",
" (post-to-endpoint \"https://api.plot.ly/v2/grids\" grid cred))\n",
"\n",
"(defn post-to-plot [grid cred] \n",
" (post-to-endpoint \"https://api.plot.ly/v2/plots\" grid cred))\n",
"\n",
"(defn plot-response [plotly-data]\n",
" (let [to-iframe (fn [url] [:iframe {:src url :width \"100%\" :height 200 :scrolling \"no\" :frameborder \"0\"}])]\n",
" (-> plotly-data\n",
" (:file)\n",
" (:embed_url)\n",
" to-iframe \n",
" (hiccup/html)\n",
" (display/make-html))))\n",
" "
]
},
{
"cell_type": "code",
"execution_count": 87,
"metadata": {},
"execution_count": 4,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"#'user/my-grid"
"text/html": [
"<iframe frameborder=\"0\" height=\"200\" scrolling=\"no\" src=\"https://plot.ly/~didier/78.embed\" width=\"100%\"></iframe>"
]
},
"execution_count": 87,
"execution_count": 4,
"metadata": {},
"output_type": "execute_result"
}
@@ -112,74 +137,55 @@
"(def my-grid {:data \n",
" {:cols\n",
" {\n",
" :height {:data [10 203 102 404] :order 1}\n",
" :weight {:data [112 234 321 34] :order 2}}}})\n",
" "
" :height {:data [10 203 102 404] :order 0}\n",
" :weight1 {:data [112 234 321 34] :order 1}\n",
" :weight2 {:data [112 234 321 34] :order 2}\n",
" :weight3 {:data [112 234 321 34] :order 3}\n",
" :weight4 {:data [112 234 321 34] :order 4}}}})\n",
"\n",
"(def resp-data (-> my-grid\n",
" (post-to-grid plotly-cred)\n",
" (:body)\n",
" (cheshire/decode true)))\n",
"(def plotly-data (plot-response resp-data))\n",
"plotly-data"
]
},
{
"cell_type": "code",
"execution_count": 87,
"execution_count": 5,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"didier:6FaFG4sgtpLnDrvzvFT1\n",
"ExceptionInfo clj-http: status 401 {:request-time 908, :repeatable? false, :protocol-version {:name \"HTTP\", :major 1, :minor 1}, :streaming? true, :chunked? true, :reason-phrase \"UNAUTHORIZED\", :headers {\"Server\" \"nginx\", \"Via\" \"1.1 google\", \"Content-Type\" \"application/json\", \"Alt-Svc\" \"clear\", \"X-Frame-Options\" \"SAMEORIGIN\", \"Strict-Transport-Security\" \"max-age=31536000; includesubdomains; preload\", \"WWW-Authenticate\" \"Bearer realm=\\\"api\\\"\", \"Allow\" \"GET, POST, HEAD, OPTIONS\", \"Connection\" \"close\", \"Transfer-Encoding\" \"chunked\", \"Set-Cookie\" [\"plotly_sess_pr=z3l151u0weiecpy1jgmvp4bqaic9ksoo; Domain=.plot.ly; expires=Thu, 30-Nov-2017 03:09:02 GMT; httponly; Max-Age=1209600; Path=/; secure\" \"plotly_csrf_pr=b3rFF0ApmkYeHCK9Rjn9kKW30z2OyDkZ; Domain=.plot.ly; expires=Sat, 17-Nov-2018 03:09:02 GMT; Max-Age=31622400; Path=/; secure\" \"plotly_anoncsrf_pr=1Pv2vgnQIhIqOnw6bFy1kf4V2qAyXJ0r; Domain=.plot.ly; expires=Fri, 17-Nov-2017 03:09:02 GMT; httponly; Max-Age=86400; Path=/; secure\" \"GCLB=CNmkk46g4orXggE; path=/; HttpOnly; expires=Fri, 17-Nov-2017 03:09:02 GMT\"], \"Date\" \"Thu, 16 Nov 2017 03:09:02 GMT\", \"Vary\" \"Accept, Authorization, Cookie, Accept-Language\", \"x-xss-protection\" \"1; mode=block\", \"Content-Language\" \"en\"}, :orig-content-encoding nil, :status 401, :length -1, :body \"{\\\"errors\\\":[{\\\"code\\\":\\\"UNKNOWN\\\",\\\"message\\\":\\\"No Plotly-Client-Platform header found\\\",\\\"path\\\":null,\\\"field\\\":null}],\\\"detail\\\":\\\"No Plotly-Client-Platform header found\\\"}\", :trace-redirects []} slingshot.support/stack-trace (support.clj:201)\n"
"data": {
"text/html": [
"<iframe frameborder=\"0\" height=\"200\" scrolling=\"no\" src=\"https://plot.ly/~didier/79.embed\" width=\"100%\"></iframe>"
]
},
{
"ename": "class clojure.lang.ExceptionInfo",
"evalue": "",
"output_type": "error",
"traceback": [
" support.clj: 201 slingshot.support$stack_trace/invoke ",
" client.clj: 238 clj_http.client$exceptions_response/invokeStatic ",
" client.clj: 230 clj_http.client$exceptions_response/invoke ",
" client.clj: 248 clj_http.client$wrap_exceptions$fn__2420/invoke ",
" client.clj: 724 clj_http.client$wrap_accept$fn__2666/invoke ",
" client.clj: 746 clj_http.client$wrap_accept_encoding$fn__2673/invoke ",
" client.clj: 707 clj_http.client$wrap_content_type$fn__2660/invoke ",
" client.clj: 948 clj_http.client$wrap_form_params$fn__2769/invoke ",
" client.clj: 983 clj_http.client$wrap_nested_params$fn__2791/invoke ",
" client.clj: 882 clj_http.client$wrap_method$fn__2727/invoke ",
" cookies.clj: 131 clj_http.cookies$wrap_cookies$fn__773/invoke ",
" links.clj: 63 clj_http.links$wrap_links$fn__2196/invoke ",
" client.clj: 1009 clj_http.client$wrap_unknown_host$fn__2799/invoke ",
" client.clj: 1181 clj_http.client$request_STAR_/invokeStatic ",
" client.clj: 1174 clj_http.client$request_STAR_/invoke ",
" client.clj: 1199 clj_http.client$post/invokeStatic ",
" client.clj: 1195 clj_http.client$post/doInvoke ",
" RestFn.java: 423 clojure.lang.RestFn/invoke ",
" core.clj: 3206 clojure.core$eval/invokeStatic ",
" core.clj: 3202 clojure.core$eval/invoke ",
" main.clj: 243 clojure.main$repl$read_eval_print__8572$fn__8575/invoke",
" main.clj: 261 clojure.main$repl$fn__8581/invoke ",
" main.clj: 177 clojure.main$repl/doInvoke ",
" RestFn.java: 1523 clojure.lang.RestFn/invoke ",
" AFn.java: 152 clojure.lang.AFn/applyToHelper ",
" AFn.java: 144 clojure.lang.AFn/applyTo ",
" core.clj: 657 clojure.core$apply/invokeStatic ",
" core.clj: 1965 clojure.core$with_bindings_STAR_/invokeStatic ",
" RestFn.java: 425 clojure.lang.RestFn/invoke ",
" AFn.java: 22 clojure.lang.AFn/run ",
"ThreadPoolExecutor.java: 1149 java.util.concurrent.ThreadPoolExecutor/runWorker ",
"ThreadPoolExecutor.java: 624 java.util.concurrent.ThreadPoolExecutor$Worker/run ",
" Thread.java: 748 java.lang.Thread/run "
]
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(println (:body (upload-grid my-grid plotly-cred)))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"curl --user didier:6FaFG4sgtpLnDrvzvFT1 -H \"Content-Type: application/json\" -H \"Plotly-Client-Platform: curl\" https://api.plot.ly/v2/grids --data '{\"data\": { \"cols\": { \"first column\": {\"data\": [\"a\", \"b\", \"c\"], \"order\": 0}, \"second column\": {\"data\": [1, 2, 3], \"order\": 1} } } }'"
"(defn post-to-plot [grid cred] \n",
" (post-to-endpoint \"https://api.plot.ly/v2/plots\" grid cred))\n",
"(def bar-char {:data [\n",
" {\n",
" :xsrc \"jackp:16731:7a9501\" ;; someone else data. but we could very well use the above grid using reference\n",
" :ysrc \"jackp:16731:948d9c\" ;; someone else data. but we could very well use the above grid using reference\n",
" :hoverinfo \"none\"\n",
" :type \"bar\"\n",
" :marker {:color \"rgb(227, 119, 194)\"}}]})\n",
"\n",
"(def payload (assoc {:world_readable true} :figure bar-char))\n",
"\n",
"(def plot-data (-> payload\n",
" (post-to-plot plotly-cred)\n",
" (:body)\n",
" (cheshire/decode true)\n",
" (plot-response)))\n",
"plot-data"
]
}
],
+73 -9
View File
@@ -2,7 +2,7 @@
"cells": [
{
"cell_type": "code",
"execution_count": 43,
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
@@ -14,7 +14,7 @@
},
{
"cell_type": "code",
"execution_count": 44,
"execution_count": 2,
"metadata": {},
"outputs": [
{
@@ -23,7 +23,7 @@
"<script src=\"https://code.highcharts.com/highcharts.js\"></script>"
]
},
"execution_count": 44,
"execution_count": 2,
"metadata": {},
"output_type": "execute_result"
}
@@ -34,7 +34,7 @@
},
{
"cell_type": "code",
"execution_count": 45,
"execution_count": 5,
"metadata": {},
"outputs": [
{
@@ -43,7 +43,7 @@
"#'user/plot-highchart"
]
},
"execution_count": 45,
"execution_count": 5,
"metadata": {},
"output_type": "execute_result"
}
@@ -52,23 +52,23 @@
"(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}]\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": 63,
"execution_count": 6,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"<div><div id=\"b2087289-fc86-4ccb-8cf7-3704197ee8bc\"></div><script>Highcharts.chart('b2087289-fc86-4ccb-8cf7-3704197ee8bc', {\"chart\":{\"type\":\"line\"},\"title\":{\"text\":\"Plot of random data\"},\"series\":[{\"data\":[307.5087671164324,3048.5432765685828,4539.2994089997,6307.544109325754,7340.475495223804,9008.812104906117,11952.293451926853,13555.936842133238,14877.581203585052,16507.36729804958,18446.740324016977,20208.868609062723,20845.59793918523,22826.806946988774,24032.974265374516,26595.971193882564,27624.03584687947,29393.822635533612,31406.755586844174,33166.420640715,34867.557730237684,36939.79245820188,38985.256695095166,40253.00080084487,41685.78763792553,42920.22397875178,46062.36485308066,47264.22874044051,48418.30200450214,51471.92279939544,51902.80396533318,53252.272538754485,56086.92407888982,57255.62583014506,58843.22100312766,60806.06578306819,62641.3996908148,63659.326016826584,65432.652874356674,67685.32427652241,69930.11376127541,70651.62942967306,72580.68386098354,74478.09697012536,77000.71447990686,77963.22303578029,79445.12362511316,82244.03286501515,82862.34434360835,85113.89565564503,86266.1796376803,88641.72223647543,90485.63330530454,91924.54182880478,94100.8679105561,96027.27078538758,96538.69277579446,98302.19267751921,101105.80050258152,101576.69147594726,104193.05437638875,106297.35529478529,107338.50760164208,108930.74941306494,110226.83149415285,113250.8059667718,113813.09631410723,115491.57063474412,116927.3369438092,119195.47059879071,120839.31828459997,122219.6272945593,124715.97296229452,125858.13901986965,128571.01244005401,130091.63649767994,131628.41664591437,133055.4982404276,134634.40929228594,136448.4613548598,138234.9561156447,139755.33282135974,142302.9261721284,143391.27891921662,144535.28903830302,147020.7290225477,148700.8549492777,149470.07936865644,151117.17814594848,153916.73241389482,156133.73534523128,157578.98803029017,158061.06483552957,160975.14709854656,162866.22894401147,164567.95147249915,165491.07386668384,166616.02825800757,168538.95203688252,171012.0048788405,172984.79970998733,174985.90695047035,175349.99546087286,177991.63944749333,178715.8465943433,181416.90104251288,183328.75443313044,184178.71335466218,186350.3018318015,187217.60274465688,189279.2100978575,191107.90110215143,193735.15338741304,194451.9976155642,195686.95015824685,198131.8519459872,199583.12054451965,202390.65795548348,202624.98398536432,205293.02849778708,206458.44764469165,207881.0663009042,210861.80414176683,211780.62296106963,214309.9187083863,215237.16358888167,217495.16355640333,218180.99812596862,219940.68224997708,222184.07989580886,223550.68400054413,224858.77782610772,228113.43257904192,229932.4928834055,231359.67980569226,231731.01046354265,234316.07671224634,235878.17432120576,237457.47617558928,240086.7560799895,241169.2216895069,243062.0208332987,245286.01983312407,246970.9981781978,247670.65078517035,249072.2309775485,252206.7260954204,253326.95666441147,254251.4123092306,257107.2765264146,257767.2736524727,260170.67996259758,262283.22838585934,262553.93117326696,265347.45518378244,267292.2191937826,268195.63724212686,270028.85657750757,271498.20971286186,273910.7388992814,275649.6143861772,276545.1103853174,279264.60809853184,280712.59389295976,281608.3757035826,284764.42750911316,285971.8321777921,287179.70321654156,289329.6476490395,290258.2409615706,292949.08310903807,294526.477593167,296052.89536074566,297089.14542446187,298961.8728083464,301131.10737858457,302161.8336117883,303815.87085835316,307054.2989349738,308451.19458921184,309199.000800272,311662.8211698427,312929.67086613935,314070.51204780233,316595.25911144353,317659.8469845267,319616.251145623,321185.10009355104,323184.7908274676,324977.1587810999,327378.89425340196,329434.9606195401,330689.4928178508,331870.1510650484,333143.01102066634,335910.2846428376,337523.6278765461,339613.39568016713,339794.5545770101,342612.4508288325,343674.17451928806,346526.1761223459,347876.62031677493,349169.9571030041,351230.52279254445,352813.6726592407,354207.76972461934,355245.9992189914,357056.9962813506,359524.2717569389,361075.33475147444,363399.58533170144,364951.13799612893,365758.4613386001,367684.726678071,369999.8768820188,370857.7783273361,372422.38636399666,375433.1697381066,376303.87141539034,377737.6122279091,379719.3783247004,380971.2982417276,382686.59424794605,385271.34326185373,386139.6345567596,389294.7009660037,389932.64080839447,392420.40984513436,393733.71269337356,395869.7659889891,397662.2136271285,399614.8913708115,401371.6173837503,401812.07342362625,403801.7224318507,406202.3979313176,406863.996293252,408685.1034754239,410458.56698854105,412856.58042772824,414987.3242883186,416856.17162498983,418609.89876580355,420158.3544090097,421670.9441462959,423235.2719834055,423885.9573073304,427019.0127011691,428126.4442312382,429922.90467548487,431200.0033887229,433112.11001992645,435661.0933026573,436992.98278276395,439000.922102553,439736.3329128806,442676.91429842426,442764.Line truncated
"<div><div id=\"129fcd9b-cfbd-401c-b7f9-77e47fd4f966\" style=\"{:background-color &quot;red&quot;}\"></div><script>Highcharts.chart('129fcd9b-cfbd-401c-b7f9-77e47fd4f966', {\"chart\":{\"type\":\"line\"},\"title\":{\"text\":\"Plot of random data\"},\"series\":[{\"data\":[600.0802979890468,2785.389013339901,3724.857367908388,5985.603555749925,7334.329136017631,9634.43331036138,11632.424414838628,13018.046919330196,15172.278849084434,16677.0498215185,17290.266503995434,19078.072943776962,21724.92199871079,22962.62705156953,25315.96671303604,26112.54713621363,27657.440724070628,30699.038945326236,32369.193700334374,33800.485225470016,35039.08390962823,36238.560829416725,38805.617181208894,40104.18852326288,41966.927104944974,43760.35168683501,45669.52593257159,47931.241112593685,48093.765596453944,50552.68151757262,52618.13615096416,54538.862198847004,55615.1462957035,57871.24117925703,60018.393676455045,61546.8274448606,62934.42181064036,64203.15835133128,66802.0157215116,68506.02318771144,69307.71473189823,70771.75262450769,72162.58316457798,74740.667794496,76496.80905874955,78838.59832917634,80633.68714609183,80983.33352077876,83923.23898835508,85569.12361322394,86795.44888396862,88001.12441201405,89269.22491499192,92113.7597909834,92790.17378098961,94500.71366886036,97738.60992715358,98378.56480669587,100698.46713859537,102815.41587097303,103409.57936985882,105849.27978517415,107018.83014312397,108751.06825660712,110312.69934168007,112906.93810487595,114570.57091913065,115347.21684707148,117804.689622244,119055.43125265592,121297.80780759195,122091.95129344838,124428.34994479611,126671.84646485707,127587.40691682795,129068.70534824175,131420.18775991932,132236.92506452746,135537.88888293534,137003.43670163985,137921.54901857846,140369.65232777552,142233.6553969074,144016.82320462874,144410.43318324172,146924.77310759202,148097.32729688473,150552.46003021477,151975.67671430882,153102.93908702018,155900.55332082295,156276.51504561372,158898.81925531253,160254.2275697256,161574.33887326877,164538.89650848432,166259.71920510373,166666.93233835528,169365.7615223026,170834.71186683056,173187.8658416879,173712.8125296444,175870.88080361387,178355.64126395562,179766.3378204997,181339.39533205217,182641.71651831255,185045.8247083939,185895.48754249187,187563.46293919458,189850.36096992894,191515.95763821038,192610.6843525983,195219.51571283897,197155.6074146366,198190.5135883966,199486.8287302667,200924.78706435143,204168.9176838454,205478.35877356748,206195.8533434571,209294.29741799936,211049.11896027403,212090.4981462157,213100.05579731677,215611.46776711097,216572.91097622126,218260.2881355831,221295.8619141015,221963.97534362215,223987.080865147,225923.1748711948,227597.49725282824,228538.8184004026,230556.26524805411,233216.86497525012,234036.04805990995,236654.9663552744,237405.16424354212,239104.80682147868,241586.52267442486,242540.50873655992,243788.30471087137,245445.96005074945,247339.77737184407,249949.8739846094,251999.7659242527,252516.05176973974,255335.5501955527,257237.4768932571,258655.7217215005,260657.8671907037,260927.34958132735,263597.061474925,264692.2210935054,267352.59377282223,269051.57441553235,270665.04256238055,271891.31873620406,273076.83654297964,275453.9950288818,276675.3090468854,278024.4849221397,281312.6443705342,283006.6043241753,283326.23708383326,286491.1647689781,287242.73497592163,288458.8518022821,290122.0710574523,292472.4236559113,294274.0786791017,295417.40227119497,298484.3665774888,298602.806605945,300842.09925871535,303125.81444980117,304782.84850132786,305787.8562678689,308586.97206032113,309855.914838043,311220.8231255287,313740.1755967167,315418.8478073935,316374.14428555383,318592.19305214763,319885.48675533297,321548.3031816897,323212.78560680087,325545.1597709014,326989.83084999095,328987.9163546938,330445.7325888522,332357.8570826954,333911.86791193986,335510.588982341,337737.3411823799,339745.4454620149,341298.1788232182,342224.0834709178,343352.9069063556,346592.60684583866,347178.5372581809,349729.2169637244,350158.44062886795,352135.91462266137,354214.31068336725,355415.25128121587,358063.6711835985,359723.2131403899,361750.46599925746,363690.24076733785,363983.578819666,365999.9278991995,367444.097645974,369834.44721695094,371794.2704588695,373287.1355312797,374909.96076036216,377473.40444566775,378838.6348978555,379819.25933932234,381336.1849918871,383589.8121593502,384427.9703985433,386132.41627653106,388181.15992709546,390578.16122243693,391791.6561035207,393925.7252631345,395193.52521181235,396464.8411838699,398583.94282875146,401249.29853455117,401685.26409821084,404501.45208438905,406565.06725671684,406796.1711420384,408993.09137441183,411234.1416370062,413461.1474529966,414379.0854772839,416221.6422610484,417625.01016691845,419513.69739297393,420972.83168222406,422525.4108995704,424516.9749457561,427023.10056539567,427762.75530465116,429862.95333748753,432286.95631412824,434043.0133414028,434404.079648369,436974.56048738456,438411.8475435063Line truncated
]
},
"execution_count": 63,
"execution_count": 6,
"metadata": {},
"output_type": "execute_result"
}
@@ -83,6 +83,70 @@
" :series [{:data data-1} {:data data-2}]})"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"should print some text\n"
]
},
{
"data": {
"text/html": [
"<h1>hello world</h1>"
]
},
"execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(println \"should print some text\")\n",
"(let [html [:h1 \"hello world\"]]\n",
" (-> html hiccup/html display/make-html))"
]
},
{
"cell_type": "code",
"execution_count": 9,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"should show a svg\n"
]
},
{
"data": {
"text/html": [
"<svg height=\"100\" width=\"100\"><circle cx=\"50\" cy=\"40\" fill=\"yellow\" r=\"40\"></circle></svg>"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"(println \"should show a svg\")\n",
"\n",
";; <svg width=\"100\" height=\"100\">\n",
";; <circle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"green\" stroke-width=\"4\" fill=\"yellow\" />\n",
";; </svg>\n",
"\n",
"(let [html [:svg {:height 100 :width 100}\n",
" [:circle {:cx 50 :cy 40 :r 40 :fill \"yellow\"}]]]\n",
" (-> html hiccup/html display/make-html))"
]
},
{
"cell_type": "code",
"execution_count": null,
+2 -1
View File
@@ -4,7 +4,8 @@
:license {:name "Eclipse Public License"
:url "http://www.eclipse.org/legal/epl-v10.html"}
:dependencies [[org.clojure/clojure "1.9.0-RC1"]
[clj-http "3.7.0"]]
[clj-http "3.7.0"]
[hiccup "1.0.5"]]
:main ^:skip-aot graphly.core
:plugins [[lein-jupyter "0.1.10"]]
:target-path "target/%s"