Skip to content

Commit

Permalink
Merge pull request #91 from adham-omran/highcharts
Browse files Browse the repository at this point in the history
Add Highcharts Core support
  • Loading branch information
daslu authored Mar 19, 2024
2 parents 1ead186 + a5c30a6 commit f0fa9b9
Show file tree
Hide file tree
Showing 13 changed files with 1,061 additions and 881 deletions.
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,6 @@
/classes
/target
.clerk
.clay.html
.clay.html
/.clj-kondo/
/temp/
2 changes: 1 addition & 1 deletion deps.edn
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
io.github.nextjournal/markdown {:mvn/version "0.5.148"}
hiccup/hiccup {:mvn/version "2.0.0-RC2"}
clj-commons/clj-yaml {:mvn/version "1.0.27"}
org.scicloj/kindly {:mvn/version "4-alpha18"}
org.scicloj/kindly {:mvn/version "4-alpha19"}
org.scicloj/kindly-advice {:mvn/version "1-alpha6"}
org.scicloj/tempfiles {:mvn/version "1-alpha2"}
org.scicloj/kind-portal {:mvn/version "1-alpha10"}
Expand Down
1,675 changes: 872 additions & 803 deletions docs/index.html

Large diffs are not rendered by default.

189 changes: 121 additions & 68 deletions docs/index.qmd

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions docs/index_files/libs/bootstrap/bootstrap.min.css

Large diffs are not rendered by default.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 2 additions & 3 deletions docs/index_files/libs/quarto-ojs/quarto-ojs-runtime.js
Original file line number Diff line number Diff line change
Expand Up @@ -5428,7 +5428,6 @@ class QuartoInspector extends Inspector {
this._cellAst = cellAst;
}
rejected(error) {
console.error(`Error evaluating OJS cell\n${this._cellAst.input}\n${String(error)}`);
return super.rejected(error);
}
}
Expand Down Expand Up @@ -5505,8 +5504,8 @@ function extendObservableStdlib(lib) {
}

class ShinyInspector extends QuartoInspector {
constructor(node, cellAst) {
super(node, cellAst);
constructor(node) {
super(node);
}
fulfilled(value, name) {
if (shinyInputVars.has(name) && window.Shiny) {
Expand Down
2 changes: 2 additions & 0 deletions docs/notebooks/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
.table {width:auto}

code {font-family: 'Fira Code Medium', monospace;}

.clay-image img {max-width: 100%}
2 changes: 2 additions & 0 deletions notebooks/custom.scss
Original file line number Diff line number Diff line change
Expand Up @@ -4,3 +4,5 @@
.table {width:auto}

code {font-family: 'Fira Code Medium', monospace;}

.clay-image img {max-width: 100%}
40 changes: 40 additions & 0 deletions notebooks/index.clj
Original file line number Diff line number Diff line change
Expand Up @@ -760,6 +760,46 @@ nested-structure-1
{:width "300px"
:height "300px"}}))

;; ### Highcharts

(kind/highcharts
{:title {:text "Line chart"}
:subtitle {:text "By Job Category"}
:yAxis {:title {:text "Number of Employees"}}
:series [{:name "Installation & Developers"
:data [43934, 48656, 65165, 81827, 112143, 142383,
171533, 165174, 155157, 161454, 154610]}

{:name "Manufacturing",
:data [24916, 37941, 29742, 29851, 32490, 30282,
38121, 36885, 33726, 34243, 31050]}

{:name "Sales & Distribution",
:data [11744, 30000, 16005, 19771, 20185, 24377,
32147, 30912, 29243, 29213, 25663]}

{:name "Operations & Maintenance",
:data [nil, nil, nil, nil, nil, nil, nil,
nil, 11164, 11218, 10077]}

{:name "Other",
:data [21908, 5548, 8105, 11248, 8989, 11816, 18274,
17300, 13053, 11906, 10073]}]

:xAxis {:accessibility {:rangeDescription "Range: 2010 to 2020"}}

:legend {:layout "vertical",
:align "right",
:verticalAlign "middle"}

:plotOptions {:series {:label {:connectorAllowed false},
:pointStart 2010}}

:responsive {:rules [{:condition {:maxWidth 500},
:chartOptions {:legend {:layout "horizontal",
:align "center",
:verticalAlign "bottom"}}}]}})

;; ### Observable

;; [Observable](https://observablehq.com/) visualizations are supported
Expand Down
10 changes: 10 additions & 0 deletions src/scicloj/clay/v2/item.clj
Original file line number Diff line number Diff line change
Expand Up @@ -313,3 +313,13 @@
;; avoid favicon.ico request: https://stackoverflow.com/a/38917888
(hiccup/html
[:link {:rel "icon" :href "data:,"}]))

(defn highcharts
"Prepare Highcharts JSON data for plotting."
[value]
{:hiccup [:div
[:script
(format
"Highcharts.chart(document.currentScript.parentElement, %s);"
(charred/write-json-str value))]]
:deps [:highcharts]})
3 changes: 2 additions & 1 deletion src/scicloj/clay/v2/page.clj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@
[{:gh-repo "scicloj/ggplotly-deps"
:relative-path "lib"
:paths ["crosstalk-1.2.1/css/crosstalk.min.css"
"plotly-htmlwidgets-css-2.11.1/plotly-htmlwidgets.css"]}]}}})
"plotly-htmlwidgets-css-2.11.1/plotly-htmlwidgets.css"]}]}}
:highcharts {:js {:from-the-web ["https://code.highcharts.com/highcharts.js"]}}})

(def include
{:js hiccup.page/include-js
Expand Down
4 changes: 4 additions & 0 deletions src/scicloj/clay/v2/prepare.clj
Original file line number Diff line number Diff line change
Expand Up @@ -451,3 +451,7 @@
(add-preparer-from-value-fn!
:kind/htmlwidgets-ggplotly
#'item/ggplotly)

(add-preparer-from-value-fn!
:kind/highcharts
#'item/highcharts)

0 comments on commit f0fa9b9

Please sign in to comment.