diff --git a/data/assets.toml b/data/assets.toml index c5033c4f..d216f198 100644 --- a/data/assets.toml +++ b/data/assets.toml @@ -73,6 +73,10 @@ version = "5.1.0" sri = "sha512-1+qUtKoh9XZW7j+6LhRMAyOrgSQKenQ4mluTR+cvxXjP1Z54RxZuzstR/H9kgPXQsVB8IW7DMDFUJpzLjvhGSQ==" url = "https://cdnjs.cloudflare.com/ajax/libs/instant.page/%s/instantpage.min.js" +[js.plotly] + version = "1.54.7" + sri = "sha512-eftiPCZn2L4fmOs+IforhSiBbW7f+fLzhqTPTD74kSOt4gcD+Q2btwLJ8V7fklVoKuSegQCKVqP/73T0tbmrmA==" + url = "https://cdnjs.cloudflare.com/ajax/libs/plotly.js/%s/plotly.min.js" # CSS diff --git a/exampleSite/content/post/writing-technical-content/index.md b/exampleSite/content/post/writing-technical-content/index.md index 5826d561..a8dcc74b 100644 --- a/exampleSite/content/post/writing-technical-content/index.md +++ b/exampleSite/content/post/writing-technical-content/index.md @@ -34,6 +34,18 @@ data = pd.read_csv("data.csv") data.head() ``` +### Charts + +Academic supports the popular [Plotly](https://plot.ly/) chart format. + +Save your Plotly JSON in your page folder, for example `chart.json`, and then add the `{{}}` shortcode where you would like the chart to appear. + +Demo: + +{{< chart data="line-chart" >}} + +You might also find the [Plotly JSON Editor](http://plotly-json-editor.getforge.io/) useful. + ### Math Academic supports a Markdown extension for $\LaTeX$ math. You can enable this feature by toggling the `math` option in your `config/_default/params.toml` file. @@ -245,9 +257,9 @@ renders as | Content Cell | Content Cell | | Content Cell | Content Cell | -### Asides +### Callouts -Academic supports a [shortcode for asides](https://sourcethemes.com/academic/docs/writing-markdown-latex/#alerts), also referred to as *notices*, *hints*, or *alerts*. By wrapping a paragraph in `{{%/* alert note */%}} ... {{%/* /alert */%}}`, it will render as an aside. +Academic supports a [shortcode for callouts](https://sourcethemes.com/academic/docs/writing-markdown-latex/#alerts), also referred to as *asides*, *hints*, or *alerts*. By wrapping a paragraph in `{{%/* alert note */%}} ... {{%/* /alert */%}}`, it will render as an aside. ```markdown {{%/* alert note */%}} diff --git a/exampleSite/content/post/writing-technical-content/line-chart.json b/exampleSite/content/post/writing-technical-content/line-chart.json new file mode 100644 index 00000000..446ce82a --- /dev/null +++ b/exampleSite/content/post/writing-technical-content/line-chart.json @@ -0,0 +1,77 @@ +{ + "data": [ + { + "uid": "babced", + "fill": "tonexty", + "mode": "none", + "name": "Col2", + "type": "scatter", + "x": [ + "2000-01-01", + "2001-01-01", + "2002-01-01", + "2003-01-01", + "2004-01-01", + "2005-01-01", + "2006-01-01", + "2007-01-01", + "2008-01-01", + "2009-01-01", + "2010-01-01", + "2011-01-01", + "2012-01-01", + "2013-01-01", + "2014-01-01", + "2015-01-01", + "2016-01-01" + ], + "y": [ + "17087182", + "29354370", + "38760373", + "40912332", + "51611646", + "64780617", + "85507314", + "121892559", + "172338726", + "238027855", + "206956723", + "346004403", + "697089489", + "672985183", + "968882453", + "863105652", + "1068513050" + ], + "fillcolor": "rgb(224, 102, 102)" + } + ], + "layout": { + "title": "Total Number of Websites", + "width": 800, + "xaxis": { + "type": "date", + "range": [ + 946702800000, + 1451624400000 + ], + "title": "Source: Scribblrs
Source: Internet Live Stats", + "showgrid": false, + "autorange": true, + "tickformat": "%Y" + }, + "yaxis": { + "type": "linear", + "range": [ + 0, + 1124750578.9473684 + ], + "title": "", + "autorange": true + }, + "height": 500, + "autosize": false + }, + "frames": [] +} diff --git a/layouts/partials/site_js.html b/layouts/partials/site_js.html index 7373cdd0..51e7ce75 100644 --- a/layouts/partials/site_js.html +++ b/layouts/partials/site_js.html @@ -133,6 +133,14 @@ {{ end }} + {{/* Charts */}} + {{ if .HasShortcode "chart" }} + + {{ printf "" (printf $js.plotly.url $js.plotly.version) $js.plotly.sri | safeHTML }} + {{ end }} + {{/* Disqus Comment Count JS. */}} {{ if and (eq site.Params.comments.engine 1) (site.Params.comments.disqus.show_count | default true) }} diff --git a/layouts/shortcodes/chart.html b/layouts/shortcodes/chart.html new file mode 100644 index 00000000..68f2d075 --- /dev/null +++ b/layouts/shortcodes/chart.html @@ -0,0 +1,17 @@ +{{ $json := printf "./%s.json" (.Get "data") }} +{{ $id := delimit (shuffle (seq 1 9)) "" }} +
+ \ No newline at end of file