-
Notifications
You must be signed in to change notification settings - Fork 21
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
Add API for background images #49
Comments
Hi, @Omnieboer we did not add this feature because we believed it is rarely used. We will add it in the future (reference API page: https://plotly.com/javascript/images/). Meanwhile, you do not have to wait for it. You can use our "unsupported feature" feature and add a block, describing the image model directly. Here is a working the code sample: Plotly.plot {
trace{
x(1,2,3)
y(1,2,3)
}
layout{
config["images"] = listOf(
Meta{
"source" put "https://images.plot.ly/language-icons/api-home/python-logo.png"
"xref" put "paper"
"yref" put "paper"
"x" put 0
"y" put 1
"sizex" put 0.2
"sizey" put 0.2
"xanchor" put "right"
"yanchor" put "bottom"
},
Meta{
"source" put "https://images.plot.ly/language-icons/api-home/js-logo.png"
"xref" put "x"
"yref" put "y"
"x" put 1.5
"y" put 2
"sizex" put 1
"sizey" put 1
"xanchor" put "right"
"yanchor" put "bottom"
}
)
}
} You have to enter at least two elements, otherwise, the block is reduced to a single element and is not recognized by Plotly. If you need only one image, you can use |
Thanks very much! I love the addition of a unsupported feature feature :D Thanks for adding the image feature on the todo list! |
It depends on where do you host the image. The image is not uploaded, so it must be accessible in the environment, where you plot your image. Local files should be OK for file plots. For a notebook, I am not sure, they could be blocked by browser security, but you can try. |
For future reference, for a local file this works. I ended up encoding the local image to Base64 like this: "source" put "data:image/png;base64,${
Base64.getEncoder().encodeToString(File("src/main/resources/BigMap.PNG").readBytes())
}" Any other way didn't seem to load the image from an offline source. |
As in this plotly behaviour.
This would be greatly helpful, as I can see no other way at the moment to display a map behind a set of coordinates. If there is such a method in PlotlyKt, please tell me and feel free to close the issue.
Thank you.
The text was updated successfully, but these errors were encountered: