d3plus / d3plus-shape

Fancy SVG shapes for visualizations
MIT License
20 stars 2 forks source link

text labels are off when direction style changes after page load #62

Closed jspeis closed 6 years ago

jspeis commented 7 years ago

Expected Behavior

Expected: after changing body style from LTR to RTL, labels in viz will fit within visualization boundaries

Current Behavior

When changing direction of body style after page load, labels extend past shape boundaries

Steps to Reproduce (for bugs)

See https://jsfiddle.net/0k5arcL0/ and click the button that says "Change Body Direction to RTL" screen shot 2017-09-11 at 11 14 14 am

Your Environment

davelandry commented 6 years ago

Thanks for the fiddle @jspeis, helped a lot in debugging this.

The bad news: because of the way that d3plus-text handles RTL positioning, the visualization needs to be re-rendered whenever the direction is changed: https://jsfiddle.net/0k5arcL0/1/

The good news: are you running into this because you have to manually set the direction after page load in datawheel-canon? If so, I can just bake that into canon fairly quickly so that the page gets rendered with the correct direction (I'm going to go do that right now regardless).

jspeis commented 6 years ago

Sounds good to me!

Yes, I was running into this when I was reading the locale from the state.i18n.locale variable in App.jsx then was doing something along the lines of style={{direction: locale === "ar" ? "rtl": "ltr"}} on the container div. But if cannon could automatically do this based on the locale that would be amazing