Skip to content

[Bug]: Using responsive options fails on some browsers #1390

@s-szabo

Description

@s-szabo

Would you like to work on a fix?

  • Check this if you would like to implement a PR, we are more than happy to help you go through the process.

Current and expected behavior

For specified media types the responsiveOptions (4th option of a chart function e.g. LineChart(..., ..., ..., responsiveOptions)) can be set. In case of some browsers (e.g. Safari 13.1.2 on macOS High Sierra 10.13.6) when you use the responsive Options chartist stops with error. The root cause of the error is the matchMedia function, because in case of some browsers the result object of the matchMedia has only an addListener function instead of the addEventListener function.

Reproduction

Use responsiveOption with e.g. a LineChart in Safari 13.1.2 with macOS High Sierra 10.13.6

Chartist version

v1.3.0

Possible solution

Change the mql.addEventListener("change", updateCurrentOptions); row in the } else if (responsiveOptions) {...} block of chartist to

if (mql.addEventListener) {
    mql.addEventListener("change", updateCurrentOptions);
} else {
    mql.addListener(updateCurrentOptions);
}

This can be found in the row # 1440 of the index.js of npm package of chartist.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions