Skip to content

Commit e85457c

Browse files
committed
Merge remote-tracking branch 'origin/v4.0' into cam/7855/update-geo-fitbounds-default
2 parents 087b342 + 5ee0a74 commit e85457c

62 files changed

Lines changed: 1554 additions & 722 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

CONTRIBUTING.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -405,8 +405,10 @@ All traces modules set:
405405
This object is used to generate the plot-schema JSON.
406406
- `_module.supplyDefaults`: Takes in input trace settings and coerces them into "full" settings
407407
under `gd._fullData`. This one is called during the figure-wide `Plots.supplyDefaults` routine.
408-
Note that the `supplyDefaults` method performance should scale with the number of attributes (**not** the
409-
number of data points - so it should not loop over any data arrays).
408+
As a rule, `supplyDefaults` performance should scale with the number of attributes rather than
409+
the number of data points, so avoid looping over data arrays in this function. That being said,
410+
there are a few exceptions to this rule due to technical requirements (`fitbounds` on map subplots).
411+
The same guidance applies to `_module.supplyLayoutDefaults`.
410412
- `_module.calc`: Converts inputs data into "calculated" (or sanitized) data. This one is called during
411413
the figure-wide `Plots.doCalcdata` routine. The `calc` method is allowed to
412414
scale with the number of data points and is in general more costly than `supplyDefaults`.

README.md

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,17 +95,23 @@ While non-minified source files may contain characters outside UTF-8, it is reco
9595
> Please note that as of v2 the "plotly-latest" outputs (e.g. https://cdn.plot.ly/plotly-latest.min.js) will no longer be updated on the CDN, and will stay at the last v1 patch v1.58.5. Therefore, to use the CDN with plotly.js v2 and higher, you must specify an exact plotly.js version.
9696
9797
### MathJax
98-
You can load either version two or version three of MathJax files. For example:
98+
plotly.js supports using MathJax v3 or v4 to render mathematical expressions within plots.
99+
100+
MathJax is not included in the plotly.js bundle, so it must be loaded separately as a script on the webpage.
101+
102+
For MathJax v4:
99103
```html
100-
<script src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_SVG.js"></script>
104+
<script src="https://cdn.jsdelivr.net/npm/mathjax@4.1.3/tex-svg.js"></script>
101105
```
102106

107+
For MathJax v3:
103108
```html
104109
<script src="https://cdn.jsdelivr.net/npm/mathjax@3.2.2/es5/tex-svg.js"></script>
105110
```
106111

107-
> When using MathJax version 3, it is also possible to use `chtml` output on the other parts of the page in addition to `svg` output for the plotly graph.
108-
Please refer to `devtools/test_dashboard/index-mathjax3chtml.html` to see an example.
112+
When MathJax is available, any string contained within `$..$` signs will be rendered using the MathJax engine. This applies to plot titles, axis labels, tick label text, and annotations.
113+
114+
plotly.js's use of the MathJax `svg` renderer should not prevent using other MathJax renderers elsewhere on the page, nor will it affect the global MathJax config. See `devtools/test_dashboard/index-mathjax3chtml.html` for an example of a webpage which uses the MathJax `chtml` renderer in the main page, and also displays Plotly charts containing MathJax equations rendered as `svg`.
109115

110116
### Need to have several WebGL graphs on a page?
111117
You may simply load the [virtual-webgl](https://github.com/greggman/virtual-webgl) script for WebGL 1 (not WebGL 2) before loading other scripts.

devtools/test_dashboard/index-mathjax3.html

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
<section id="mocks-list"></section>
1919

20-
<p id="pWithMathJax">MathJax $V^3$ with $svg$ output on the page as well as plotly graphs</p>
20+
<p>MathJax \(V^3\) with \(svg\) output on the page as well as plotly graphs</p>
2121
<h4>no MathJax: Apple: $2, Orange: $3</h4>
2222

2323
<div id="plots">
@@ -27,18 +27,12 @@ <h4>no MathJax: Apple: $2, Orange: $3</h4>
2727

2828
<script>
2929
window.MathJax = {
30-
startup: {
31-
elements: [
32-
document.getElementById('pWithMathJax')
33-
],
34-
// typeset: false,
35-
// in case the elements array is empty one could disable startup typeset
36-
// https://docs.mathjax.org/en/latest/options/startup/startup.html#the-configuration-block
37-
}
30+
// MathJax config options can be set here, although
31+
// none are strictly needed for this page.
3832
};
3933
</script>
4034
<script src="../../node_modules/@plotly/mathjax-v3/es5/tex-svg.js"></script>
41-
<script charset="utf-8" id="source" src="../../build/plotly.js" type="module"></script>
35+
<script charset="utf-8" id="source" src="../../build/plotly.js"></script>
4236
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
4337
</body>
4438
</html>

devtools/test_dashboard/index-mathjax3chtml.html

Lines changed: 8 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -17,52 +17,24 @@
1717

1818
<section id="mocks-list"></section>
1919

20-
<p>MathJax $V^3$ with $chtml$ output on the page and <b>svg</b> output on the plotly graphs</p>
20+
<p>MathJax \(V^3\) with \(chtml\) output on the page and <b>svg</b> output on the plotly graphs</p>
2121
<div id="plots">
2222
<div id="graph"></div>
2323
</div>
2424
<div id="snapshot"></div>
2525

2626
<script>
27-
window.MathJax = window.MathJax || {
28-
// see https://github.com/mathjax/MathJax/issues/2705#issuecomment-859742446
27+
window.MathJax = {
28+
// It's possible for MathJax CHTML output to coexist on the same page with
29+
// a plotly chart with renders MathJax as SVG; *however*, the loader must be
30+
// configured to load the SVG output module so that it's available for plotly
31+
// (in addition to the CHTML output module, which is implicitly loaded by
32+
// tex-chtml.js below).
2933
loader: {load: ['output/svg']},
30-
startup: {
31-
ready() {
32-
// Get the MathJax modules that we need.
33-
const {mathjax} = MathJax._.mathjax;
34-
const {SVG} = MathJax._.output.svg_ts;
35-
36-
// Do the normal setup
37-
MathJax.startup.defaultReady();
38-
39-
// Create an SVG output jax and a new MathDocument that uses it.
40-
const svgOutput = new SVG(MathJax.config.svg);
41-
const svgDocument = mathjax.document(document, {
42-
...MathJax.config.options,
43-
InputJax: MathJax.startup.input,
44-
OutputJax: svgOutput
45-
});
46-
47-
// Define the SVG-based conversion methods
48-
MathJax.tex2svg = (math, options = {}) => {
49-
options.format = svgDocument.inputJax[0].name;
50-
return svgDocument.convert(math, options);
51-
};
52-
/*
53-
MathJax.tex2svgPromise = (math, options = {}) => {
54-
options.format = svgDocument.inputJax[0].name;
55-
return mathjax.handleRetriesFor(() => svgDocument.convert(math, options));
56-
};
57-
*/
58-
MathJax.svgStylesheet = () => svgOutput.styleSheet(svgDocument);
59-
}
60-
}
6134
};
6235
</script>
6336
<script src="../../node_modules/@plotly/mathjax-v3/es5/tex-chtml.js"></script>
64-
65-
<script charset="utf-8" id="source" src="../../build/plotly.js" type="module"></script>
37+
<script charset="utf-8" id="source" src="../../build/plotly.js"></script>
6638
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
6739
</body>
6840
</html>
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>Plotly.js Devtools - MathJax v4 loaded with chtml output</title>
5+
<meta charset="utf-8">
6+
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Open+Sans:600,400,300,200|Droid+Sans|PT+Sans+Narrow|Gravitas+One|Droid+Sans+Mono|Droid+Serif|Raleway|Old+Standard+TT"/>
7+
<link rel="stylesheet" type="text/css" href="./style.css">
8+
</head>
9+
<body>
10+
<header>
11+
<img src="http://images.plot.ly/logo/plotlyjs-logo@2x.png" onClick="Tabs.reload();" />
12+
<span id="reload-time"></span>
13+
14+
<input id="mocks-search" type="text" placeholder="mocks search" />
15+
<input id="css-transform" type="text" placeholder="css transform" />
16+
</header>
17+
18+
<section id="mocks-list"></section>
19+
20+
<p>MathJax \(V^4\) with \(chtml\) output on the page and <b>svg</b> output on the plotly graphs</p>
21+
<div id="plots">
22+
<div id="graph"></div>
23+
</div>
24+
<div id="snapshot"></div>
25+
26+
<script>
27+
window.MathJax = {
28+
// It's possible for MathJax CHTML output to coexist on the same page with
29+
// a plotly chart with renders MathJax as SVG; *however*, the loader must be
30+
// configured to load the SVG output module so that it's available for plotly
31+
// (in addition to the CHTML output module, which is implicitly loaded by
32+
// tex-chtml.js below).
33+
loader: {load: ['output/svg']},
34+
};
35+
</script>
36+
<script src="../../node_modules/@plotly/mathjax-v4/tex-chtml.js"></script>
37+
<script charset="utf-8" id="source" src="../../build/plotly.js"></script>
38+
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
39+
</body>
40+
</html>

devtools/test_dashboard/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
<!-- Update UI elements if strict mode is enabled -->
2828
<script src="./strict.js"></script>
2929

30-
<script src="../../node_modules/@plotly/mathjax-v2/MathJax.js?config=TeX-AMS-MML_SVG"></script>
30+
<script src="../../node_modules/@plotly/mathjax-v4/tex-svg.js"></script>
3131
<script charset="utf-8" id="source" src="../../build/plotly.js"></script>
3232
<script charset="utf-8" src="../../build/test_dashboard-bundle.js"></script>
3333
</body>

devtools/test_dashboard/server.mjs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ var PORT = args.port || 3000;
1111
var strict = args.strict;
1212
var mathjax3 = args.mathjax3;
1313
var mathjax3chtml = args.mathjax3chtml;
14+
var mathjax4chtml = args.mathjax4chtml;
1415

1516
if (strict) localDevConfig.entryPoints = ['./lib/index-strict.js'];
1617

@@ -60,6 +61,7 @@ function devServer() {
6061
let indexName = 'index';
6162
if (mathjax3) indexName += '-mathjax3';
6263
else if (mathjax3chtml) indexName += '-mathjax3chtml';
64+
else if (mathjax4chtml) indexName += '-mathjax4chtml';
6365
indexName += '.html';
6466

6567
// open up browser window

draftlogs/7507_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix `histogram` autobin size for single-point traces in `overlay` mode on data updates via `Plotly.react` [[#7507](https://github.com/plotly/plotly.js/pull/7507)], with thanks to @Lexachoc for the contribution!

draftlogs/7768_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Format tick labels correctly for small numbers in exponential notation [[#7768](https://github.com/plotly/plotly.js/pull/7768)], with thanks to @Hasnaathussain for the contribution!

draftlogs/7884_fix.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
- Fix `scattermap`, `densitymap` traces not showing all points by dynamically computing `center`, `zoom` values [[#7884](https://github.com/plotly/plotly.js/pull/7884)], with thanks to @palmerusaf and @DhruvGarg111 for the contributions!

0 commit comments

Comments
 (0)