-
Notifications
You must be signed in to change notification settings - Fork 91
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Does GenericChart.toChartHTML work in version 4.0? #373
Comments
The cause seems to be that
I understand why you'd want that as the default given that you reference plotly explicitly in your |
Changing the way the html output is rendered in general was intentional, especially getting rid of the require code that spams the head tags of pages with references once you have more than one chart per page. The previous template used both cdn and require at once, which was unnecessary. However, the default plotly reference should be always set to CDN here: Plotly.NET/src/Plotly.NET/Defaults.fs Lines 27 to 47 in 1e5fec1
Although that still will not fix your issue, as the cdn is referenced in the document head, which is only present in You can either use a global reference in the template header or change the global default DisplayOptions to use require again. For fsdocs, i'd recommend the former, as you load the reference only once across the page. |
@nhirschey do the proposed methods work for you? |
Hi @kMutagene, thanks for the context.
I prefer using the default fsdocs template when possible; creating a custom
Given option 2. using |
I guess I'll close this, with the suggestions being either:
|
I think we can try another solution: One suggestion could be doing this in the first rendered document. Plotly.NET/docs/00_2_display-options.fsx Lines 18 to 19 in 8ec8c3c
Plotly.NET.Defaults.DefaultDisplayOptions <-
Plotly.NET.DisplayOptions.init (PlotlyJSReference = Require "https://cdn.plot.ly/plotly-2.18.2.min.js") (or this if you want to preserve the other defaults): Plotly.NET.Defaults.DefaultDisplayOptions <-
Plotly.NET.Defaults.DefaultDisplayOptions
|> DisplayOptions.setPlotlyReference(Require "https://cdn.plot.ly/plotly-2.18.2.min.js") Global defaults should persist across fsdocs files IIRC, otherwise you can do it in every file just to be safe, that's how i do it, but the other way around to make sure we use This will add the require part to the scripts, and is also how charts are rendered in Plotly.NET.IOnteractive. |
Ok, that's a good option too. Thank you! |
Description
I cannot get
GenericChart.toChartHTML
to render in fsdocs generated pages with Plotly.NET 4.0. I think it's because 4.0 is not producing thefsharpPlotlyRequire
javascript in the output.Repro steps
If I do this in a blank docs folder index.fsx I get a nice plot produced in the html
However, with 4.0 no chart gets displayed:
Comparing the html output vs. 3.0, I think 4.0 missing the
fsharpPlotlyRequire ...
code?see that in 4.0 there is no
fsharpPlotlyRequire
code before the data declaration in the output:There is an
fsharpPlotlyRequire
function in the 3.0 output:Related information
The text was updated successfully, but these errors were encountered: