Skip to content

Commit de013e9

Browse files
authored
Update plotly js (#80)
* update plotly and mathjax deps * fix imports + typo * update changelog
1 parent 9379276 commit de013e9

File tree

10 files changed

+81
-80
lines changed

10 files changed

+81
-80
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
2727
- `askama` to `0.11.0`.
2828
- `rand` to `0.8.4`.
2929
- `rand_distr` to `0.4.2`.
30+
- `plotly.js` to `2.12.1`
3031

3132
## [0.7.0] - 2022-01-01
3233
### Added

docs/book/book.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ create-missing = false
1414
default-theme = "Ayu"
1515
mathjax-support = true
1616
additional-css = ["ferris.css"]
17-
additional-js = ["ferris.js", "plotly-2.2.1.min.js"]
17+
additional-js = ["ferris.js", "plotly.min.js"]
1818

1919

2020
[output.html.fold]

docs/book/plotly-2.2.1.min.js

Lines changed: 0 additions & 58 deletions
This file was deleted.

plotly/templates/plotly-2.8.3.min.js renamed to docs/book/plotly.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/book/theme/header.hbs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<script src="https://cdn.plot.ly/plotly-2.2.1.min.js"></script>
1+
<script src="https://cdn.plot.ly/plotly-2.12.1.min.js"></script>

plotly/examples/jupyter_notebook_examples.ipynb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
"<div>\n",
5353
" <div id=\"LbkgUVmz2gqtoB3MWoay\" class=\"plotly-graph-div\" style=\"height:100%; width:100%;\"></div>\n",
5454
" <script type=\"text/javascript\">\n",
55-
" require(['https://cdn.plot.ly/plotly-2.2.1.min.js'], function(Plotly) {\n",
55+
" require(['https://cdn.plot.ly/plotly-2.12.1.min.js'], function(Plotly) {\n",
5656
" window.PLOTLYENV=window.PLOTLYENV || {};\n",
5757
"\n",
5858
" if (document.getElementById(\"LbkgUVmz2gqtoB3MWoay\")) {\n",

plotly/src/plot.rs

Lines changed: 4 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,13 @@ use serde::Serialize;
99
use std::env;
1010
use std::fs::File;
1111
use std::io::Write;
12-
use std::path::{Path, PathBuf};
12+
use std::path::Path;
1313

1414
use crate::{Configuration, Layout};
1515
use rand_distr::Alphanumeric;
1616

17-
const PLOTLY_JS: &str = "plotly-2.8.3.min.js";
18-
1917
#[derive(Template)]
20-
#[template(path = "plotly-2.8.3.min.js", escape = "none")]
18+
#[template(path = "plotly.min.js", escape = "none")]
2119
struct PlotlyJs;
2220

2321
#[derive(Template)]
@@ -430,12 +428,6 @@ impl Plot {
430428
.unwrap_or_else(|_| panic!("failed to export plot to {:?}", filename.as_ref()));
431429
}
432430

433-
fn plotly_js_path() -> PathBuf {
434-
let root = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap());
435-
let templates = root.join("templates");
436-
templates.join(PLOTLY_JS)
437-
}
438-
439431
fn render(
440432
&self,
441433
export_image: bool,
@@ -477,7 +469,7 @@ impl Plot {
477469
js_sys::JSON::parse(&self.to_json())
478470
.expect("Invalid JSON")
479471
.dyn_into::<js_sys::Object>()
480-
.expect("Invalid JSON structure - expected an top-level Object")
472+
.expect("Invalid JSON structure - expected a top-level Object")
481473
}
482474

483475
#[cfg(target_os = "linux")]
@@ -518,6 +510,7 @@ impl PartialEq for Plot {
518510
#[cfg(test)]
519511
mod tests {
520512
use serde_json::{json, to_value};
513+
use std::path::PathBuf;
521514

522515
use super::*;
523516
use crate::Scatter;

plotly/templates/jupyter_notebook_plot.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<div>
22
<div id="{{ plot_div_id }}" class="plotly-graph-div" style="height:100%; width:100%;"></div>
33
<script type="text/javascript">
4-
require(['https://cdn.plot.ly/plotly-2.8.3.min.js'], function(Plotly) {
4+
require(['https://cdn.plot.ly/plotly-2.12.1.min.js'], function(Plotly) {
55
window.PLOTLYENV=window.PLOTLYENV || {};
66

77
if (document.getElementById("{{ plot_div_id }}")) {

plotly/templates/plot.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77

88
<body>
99
<div>
10-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG"></script>
10+
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.0/es5/tex-mml-chtml.js"></script>
1111
<script
1212
type="text/javascript">if (window.MathJax) { MathJax.Hub.Config({ SVG: { font: "STIX-Web" } }); }</script>
1313
<script type="text/javascript">window.PlotlyConfig = { MathJaxConfig: 'local' };</script>
1414
{% if remote_plotly_js -%}
15-
<script src="https://cdn.plot.ly/plotly-2.8.3.min.js"></script>
15+
<script src="https://cdn.plot.ly/plotly-2.12.1.min.js"></script>
1616
{% else -%}
1717
<script type="text/javascript">{{ plotly_javascript }}</script>
1818
{% endif -%}

plotly/templates/plotly.min.js

Lines changed: 65 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)