plotly / orca

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

text attribute appears on bar traces with plotly.js 2.0 #374

Closed cpsievert closed 3 years ago

cpsievert commented 3 years ago

Bumping plotly.js from 1.58.4 to 2.0.0 with latest release of orca (1.3.1) introduces a regression where the text attribute now appears on bar traces:

cd ~/tmp
wget https://cdn.plot.ly/plotly-1.58.4.min.js ./
orca graph '{ "data": [ { "x": [1, 2], "y": [10, 11.5], "text": ["cond: control<br />result: 10.0", "cond: treatment<br />result: 11.5"], "type": "bar" } ] }' -o before.png --plotly plotly-1.58.4.min.js 
open before.png

before

wget https://cdn.plot.ly/plotly-2.0.0.min.js ./
orca graph '{ "data": [ { "x": [1, 2], "y": [10, 11.5], "text": ["cond: control<br />result: 10.0", "cond: treatment<br />result: 11.5"], "type": "bar" } ] }' -o after.png --plotly plotly-2.0.0.min.js 
open after.png

after

antoinerg commented 3 years ago

cc @archmoj @nicolaskruchten

archmoj commented 3 years ago

This is the expected behaviour in plotly.js v2. Related PR: https://github.com/plotly/plotly.js/pull/5638 In order to drop text on bars, the textposition could be set to "none" similar to other traces.

nicolaskruchten commented 3 years ago

Correct. The rationale here was that setting text should be enough to actually have text appear, whereas previously it would only appear in the hoverlabel, controlled via hoverinfo. The recommended thing to do now if you want stuff in the hoverlabel is to use hovertemplate (possibly in conjunction with customdata but that's optional ofc). In general this leads to smaller figures due to less repetition of values in text.

cpsievert commented 3 years ago

Ah ok, that's fair. For some reason I thought the static export had different behavior but I goofed up versions, thanks!