Skip to content

onResize doesn't fire in RTL mode #6057

@abdullahkady

Description

@abdullahkady

Expected Behavior

The onResize callback doesn't fire when the document (body) has the direction set to rtl.
This affects responsiveness as well, since the chart doesn't scale correctly when the responsive option is set.

Current Behavior

When resizing, it will work when resizing down (narrowing the chart), and will fail when scaling back up (adding more width to the screen).

Possible Solution

A hack around can be achieved by setting a global listener (on the wrapper element, or say globally on the window), and calling chart.resize() explicitly in it that listener's callback.

Steps to Reproduce (for bugs)

Live example
I sat up this quick example, open up the console and change the width in both RTL, and LTR modes and observe.

Context

Trying to use the chart in a multi-locale website didn't work for rtl languages.

Environment

  • Chart.js version: latest (2.7.3)
  • Browser name and version: chrome, latest (72)
  • Link to your project: codepen

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions