Skip to content
This repository was archived by the owner on Jun 3, 2024. It is now read-only.

Added MathJax CDN to enable Latex #194

Open
wants to merge 9 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

## [0.22.2] - 2018-04-30
### Fixed
- Previously, dash did not render LateX since the MathJax.js library was not loaded. This has now been fixed.
See https://github.com/plotly/dash-core-components/pull/194.

## [0.22.1] - 2018-04-09
### Fixed
- Various bugs with the `ohlc` and `candlestick` chart type in the `dcc.Graph`
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ include dash_core_components/[email protected]
include dash_core_components/[email protected]
include README.md
include LICENSE.md
include dash_core_components/mathjax-2.7.4.js
5 changes: 5 additions & 0 deletions dash_core_components/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@
_this_module = _sys.modules[__name__]

_js_dist = [
{
'external_url': 'https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.4/MathJax.js?config=TeX-MML-AM_CHTML',
'relative_package_path': 'mathjax-2.7.4.js',
Copy link
Member

@chriddyp chriddyp Apr 30, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this should be mathjax-2.7.4.min.js - it should match https://github.com/plotly/dash-core-components/pull/194/files#diff-97c91a104c431d0c365565d3ac03ac13R12

We should also rename the file dash_core_components/mathjax-2.7.4.js to dash_core_components/mathjax-2.7.4.min.js

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or vice-versa, everything could be labeled mathjax-2.7.4.js rather than mathjax-2.7.4.min.js. I don't really have a preference, but they do need to all have the same name 😄

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh my bad. I'll change it in MANIFEST.in

'namespace': 'dash_core_components'
},
{
'external_url': 'https://cdn.plot.ly/plotly-1.35.2.min.js',
'relative_package_path': 'plotly-1.35.2.min.js',
Expand Down
19 changes: 19 additions & 0 deletions dash_core_components/mathjax-2.7.4.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "dash-core-components",
"version": "0.22.1",
"version": "0.22.2",
"description": "Core component suite for Dash",
"repository": {
"type": "git",
Expand Down
24 changes: 24 additions & 0 deletions test/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -496,3 +496,27 @@ def update_graph(n_clicks):
button.click()
time.sleep(2)
self.snapshot('candlestick - 2 click')

def test_latex(self):
app = dash.Dash(__name__)
app.layout = html.Div([

html.Label('Graph'),
dcc.Graph(
id='graph',
figure={
'data': [{
'x': [1, 2, 3, 4, 5],
'y': [1, 3, 5, 9, 13]
}],
'layout': {
'title': 'sqrt{(n_\\text{c}(t|{T_\\text{early}}))}$'
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we're missing a leading $ here, I believe it should be

$sqrt{(n_\\text{c}(t|{T_\\text{early}}))}$

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I must've missed that while testing with different inputs. Fixed this. Check perci.io output now, hopefully, this should work.

}
}
),
])
self.startServer(app=app)

graph = self.wait_for_element_by_css_selector('#graph .svg-container')
time.sleep(4)
self.snapshot('latex rendering in graph')