plotly / orca

Command line application for generating static images of interactive plotly charts
MIT License
295 stars 39 forks source link

Possible to have deterministic clipPath ids? #133

Open cpsievert opened 6 years ago

cpsievert commented 6 years ago

I'm working on a new visual testing framework for the plotly R package and I'm hoping to use at svg diffs via orca (if that seems like a bad idea in general, please let me know).

It looks as though the id property of <clipPath /> is semi-random -- would it be possible to add an argument to make this (and possibly other) svg properties be deterministic?

If not, would you see any problem with removing the id property before performing the diff?

etpinard commented 6 years ago

It would be possible. Sounds like a solid idea.

Off the top of my head, clip-path ids use either fullLayout._uid and/or fullData[i].uid to make them "unique" on the page.

fullData[i].uid can be optionally set by users calling Plotly.newPlot. In turn, fullLayout._uid is only generated internally. So perhaps, we could add layout.uid attribute that would be honored as fullLayout._uid downstream.

etpinard commented 5 years ago

Tagging as type: feature here, but this would of course required some plotly.js work as well.

antoinerg commented 5 years ago

This feature could be really useful to simplify testing the correctness of SVGs. In PR https://github.com/plotly/orca/pull/222, we have to resort to rendering SVGs to images in order to compare them to our baselines. This rendering step could possibly be skipped altogether.