-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Feature: Plot layout images #520
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
Conversation
As well as creating the attributes and defaults, a default argument has been added to `axes.coerceRef`.
There is a fair bit of code to this PR, but the commits follow a logical progression, so that's probably the best way to review through it. |
|
||
|
||
var containerIn = Array.isArray(layoutIn.images) ? | ||
layoutIn.images : [layoutIn.images], |
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.
layout.images
should only be coerced if it is an array.
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.
Ah ok. I figured as a convenience we could accept a single object.
Strict is good though 👍
source: { | ||
valType: 'string', | ||
role: 'info', | ||
description: [ |
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.
so, nothing is blocking users from inputting data:image/svg+xml;base6
as source
?
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.
Yep works fine!
I'm not 100% sure if there's a possibility for XSS here (or if it should be something that we worry about in plotly.js) but I couldn't manage to break anything or set any code to be executed - maybe I'm just not a good enough h4X0r though.
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.
Cool.
Yes, we don't worry about XSS (see PR #100).
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.
Maybe we should make things more convenient for folks wanting to use base64 strings.
Maybe we could add a sourcetype
attribute with possible values 'link'
, 'png'
or even 'svg'
?
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.
Personally I like that we use the same spec as HTML img
src
. Makes it easy to document, explain, and extend.
This PR adds the ability to add arbitrary images loaded from a url to a plot. Plot layout images follow a similar interface to shapes, but use a coordinate position with
width
andheight
rather thanx0
,x1
,y0
,y1
. Additionally, there are three sizing modes -contain
(the default),fill
, andstretch
.The intended use of this feature is mainly for logos and non-data-specific images - for image data that is tied directly to data (e.g. satellite imagery) we should/will add a new trace type to accommodate for this and enable features such as toggling from the legend and ordering.
That said, images can be added to the plot area and be forced to keep their binding to the underlying cartesian plane by setting the
xref
andyref
to their respective axes and setting thesizing
property tostretch
.