Comments (6)
So temporarily solution is to change the HTML directly through adding these lines.
In the long term, wait for the API
change in MathJAX
.
Thanks for your help!
from plotly.net.
@Wongboo Watch out for the next release, you will be able to use Chart.WithMathTex
:
[
Chart.Line([(1.,2.)],@"$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$")
Chart.Line([(1.,2.)],@"$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$")
]
|> Chart.Combine
|> Chart.withTitle @"$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$"
|> Chart.WithMathTex(true)
from plotly.net.
Hi @Wongboo
I would really appreciate a full code example, but i managed latex output to work in principle.
The problem is MathJax (the tex rendering engine used in plotly tex examples) not being referenced in our HTML scaffold. For a workaround until this is properly implemented, add these script tags to the html:
<script type="text/x-mathjax-config;executed=true">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true}});</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML%2CSafe.js&ver=4.1"></script>
Additionally, as tex uses a lot of \
characters, your tex strings should be escaped using @
:
[
Chart.Line([(1.,2.)],@"$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$")
Chart.Line([(1.,2.)],@"$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$")
]
|> Chart.Combine
|> Chart.Show
Which will then look like this:
From our side it is most likely the best to set this on the Config
level of GenericChart
, providing a Chart.withMathTex
function indicating that the mathtex script should be contained in the html scaffold.
from plotly.net.
@kMutagene
I kind of understand, so this generally means that until the official support is established, We have to change the source code of Plotly.NET
or manually add
<script type="text/x-mathjax-config;executed=true">MathJax.Hub.Config({tex2jax: {inlineMath: [['$','$'], ['\\(','\\)']], processEscapes: true}});</script>
<script type="text/javascript" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.5/MathJax.js?config=TeX-AMS-MML_HTMLorMML%2CSafe.js&ver=4.1"></script>
to the chart which might be too complicated since no API
in GenericChart
supports directly adding these script tags. Am I right?
from plotly.net.
or manually add [script tags]
to the chart which might be too complicated since noAPI
inGenericChart
supports directly adding these script tags. Am I right?
I can think of two workarounds that might work for you in the meantime:
-
The output of
Chart.Show
is a html text file like any other, so you can open the files programmatically and add those lines. -
The
GenericChart.toChartHTML
returns the contents of that file as a string, so you can add these lines there and then write the content to a file like this:[ Chart.Line([(1.,2.)],@"$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$") Chart.Line([(1.,2.)],@"$\beta_{1c} = 25 \pm 11 \text{ km s}^{-1}$") ] |> Chart.Combine |> Chart.toChartHTML |> `add the missing lines` |> `write to a .html file`
from plotly.net.
Exactly, i don't imagine this feature taking too long to implement though
from plotly.net.
Related Issues (20)
- Generate C# bindings via code generation based on the core F# API
- Chart descriptions do not work if Cytoscape.NET.Interactive is referenced simultaneously HOT 4
- Contours should be accessible for PointDensity charts HOT 1
- How to create polar plots with Csharp HOT 3
- Suggestion: Documentation / Examples / Extensions for working with DataFrame objects HOT 1
- Exception when using .NET Polyglot Notebook due to strong naming HOT 3
- Add `WithTraceStyle` extension member to Plotly.NET.CSharp
- Plotly.Net.ImageExport ToBase64JPGString hangs in Blazor Server Application HOT 4
- load a custom font from file (ttf, woff, ...others) HOT 9
- With lastest plotly.net version (4.2), when plotting a Bubble3D chart ( or Scatter3D), x/y axis cannot be renamed HOT 4
- Unable to change the legend font size when global font size is defined in layout HOT 1
- plotly.js v2.28.0 compatibility needs huge rework of core API HOT 1
- Rework docs to use polyglot notebooks HOT 5
- Pie Chart's background doesnt change HOT 7
- No way to add guidelines (plotly.js has them) HOT 3
- Update documentation to dotnet interactive to 4.2.1 HOT 1
- `StyleParam.HoverInfo` is missing enum bindings
- Charts marked as `Responsive = true` are not responsive HOT 9
- Annotation not showing in C# HOT 2
- LinearAxis CategoryOrder not working as expected HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from plotly.net.