-
Notifications
You must be signed in to change notification settings - Fork 115
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
Use \fig{}
to give a PlotlyJS
plot.
#928
Conversation
thanks a lot for investigating this, will test a bit then merge |
fig["config"]["responsive"] = true | ||
|
||
Plotly.newPlot(CONTAINER, fig.data, fig.layout, fig.config); | ||
</script> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think there's a missing }
opened on line 25 but never closed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also please add this to docs/_layout/head
so that the docs work
docs/extras/plotly.md
Outdated
@@ -111,3 +128,30 @@ plt = plot(data, layout) | |||
fdplotly(json(plt)) # hide | |||
``` | |||
\textoutput{ex1} | |||
|
|||
### Use `\fig{}` |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Using `\fig{...}` (recommended)
docs/extras/plotly.md
Outdated
### Use `\fig{}` | ||
Now you might use `\fig{}` to insert graph [just like normal](/syntax/markdown/#inserting_a_figure). This also work fine with `Plots.jl` and `PlotlyBase.jl`. | ||
|
||
**Note**: `\fig{}` will call the Javascript function `PlotlyJS_json` defined [above](#pre-requisites). You might customize the behavior by modifying it. Also make sure `@def hasplotly = true` is properly set. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
by modifying the Javascript
.
Sorry for making these silly mistakes and wasting your time. I was not aware of that I can I can confirm all problems you pointed out are fixed. Some improvements are added to get consistent experience when using |
This might be useful to modify the plot afterward.
Thanks a lot for your contribution @ChasingZenith sorry for the delay I was out last week; this seems to work fine on my side and I'm happy to integrate it. |
Thank you! It is my honor to make this contribution. Would you consider depercating As an minimal example, the following extremely simple plot give a 6.9kB json with using PlotlyBase # 6.9 kB json
# using PlotlyJS # 12.4 kB
# using Plots; plotlyjs(); # 2.1 kB (BTW, it is strange that PlotlyBase and PlotlyJS give larger json than Plots)
# using Plots; plotly(); # 2.1 kB
p = Plot([0, 1]); # use function `plot` when not using PlotlyBase
savejson(p,"2num.json") The html file of a page is around 25kB, taking this page franklinjl.org/code as an example. Directly inserting the json file into the html, just like what |
No. I'd be happy for you to edit the docs to make a strong recommendation though and you could link to your comment here but I'd like the current version The next version ( |
Thank you! |
Hey everyone. I know this has merged and the Issue has been resolved. Great work by @ChasingZenith and @tlienart for this. But I am facing an interesting problem here. I am serving my static site locally on a windows machine. I am using I did some troubleshooting and found that in the function
This saves the file by merging
The location of the json file is messed up. Instead of forwardslash the location has backslash. EDIT: BTW just by editing the backslashes made the problem vanish in the HTML EDIT2: Is it possible that systempath and other path are different due to how windows define path v/s how a linux or mac would? In here: Franklin.jl/src/converter/latex/io.jl Line 148 in 1b9d571
I am using conda on windows and have julia installed the usual way if that is important. |
yes, windows is extremely annoying in this respect, and browsers use the unix style paths, so there are functions to go back and forth. Looks like it's missing here. Could you kindly try again but using |
Hey I just tried that and it is throwing the following html error: The path is missing EDIT: I checked your commit and did not identify any specefic reason for the following to not work. Franklin.jl/src/converter/latex/io.jl Line 169 in 6077d23
Can you tell me where Path separator is defined? the variable that you are using here as PATH_SEP? |
Hmm, thanks for your patience. Could I please get you to try the following?
Thanks! |
Thanks for this work, this looks almost right. Can you try reverting what I did in the previous commit so: if splitdir(p1)[2] != "output"
for ext ∈ candext
#candpath = joinpath(p1, "output", p2 * ext)
candpath= p1* "/output/" * p2*ext
@show candpath
# now candpath is in unix-style, so it should be split according to "/"
syspath = joinpath(PATHS[:site], split(candpath, "/")...)
# with join path, it should now be correct irrelevant of the platform
@show syspath
@show isfile(syspath)
# if Sys.iswindows()
# # syspath=replace(syspath,"/"=>"\\")
# isfile(syspath) && return ext == ".json" ? html_plotly(candpath) : html_img(candpath, alt)
# @show isfile(syspath)
# else
isfile(syspath) && return ext == ".json" ? html_plotly(candpath) : html_img(candpath, alt)
# end
end
end
|
Hey @tlienart It is working now. But you would need to do the same changes in other loop as well.
But the code following it works. i.e.:
Pasting the truncated output to show how the path is now being defined :
EDIT: I have edited the file io.jl so that it works for both for loops: You can check the Forked repo in my profile https://github.com/atiyabzafar/Franklin.jl I have checked both Markdown and Plotly figures and they seem to be working. EDIT2: Nevermind that seems to be a different issue. the code does not seem to be saving the svg in the location. Writing it here so that I can get back to it later. Error: It makes sense for Franklin to generate the file at |
Now, one can use
\fig{}
to give aPlotlyJS
plot.When
\fig{}
receive a json file, it will regard it as aplotlyjs
json file and plot it using a JavaScript functionPlotlyJS_json
defined insrc/_layout/head.html
(One should add it in it.)Documentation is also updated.
I suggest deprecate
fdplotly
, since it will slow down page loading. Details are described here.Closes #890