Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

updateChart does not properly handle responsiveOptions #38

Open
howardengelhart opened this issue May 13, 2016 · 0 comments
Open

updateChart does not properly handle responsiveOptions #38

howardengelhart opened this issue May 13, 2016 · 0 comments

Comments

@howardengelhart
Copy link

This is really an issue with the chartist library itself.

In the updateChart method if an already existing instance of this.chartist is found, its update method is called, passing the responsiveOptions into the 3rd argument.

react-chartist_index_js_at_master_ _fraserxu_react-chartist

The problem is that the 3rd argument to the Chartist.Base class update method is

{Boolean} [override] If set to true, the passed options will be used to extend the options that have been configured already. Otherwise the chart default options will be used as the base

The result is that changing charts on the same page (as my app does) does not handle changes to the responsiveOptions.

I was able to work around this by creating a ChartistGraph child class and override the updateChart method using two alternatives..

//Method 1 - Undefined ChartistGraph's chartist reference immediately before calling its updateChart.

class ChartistGraphExt extends ChartistGraph {
    updateChart(config) {
        this.chartist = undefined;
        return super.updateChart(config);
    }
}

///Method 2 - set the this.chartist.responsiveOptions property directly

class ChartistGraphExt extends ChartistGraph {
    updateChart(config) {
        if (this.chartist) {
            this.chartist.responsiveOptions = config.responsiveOptions || [];
        }
        return super.updateChart(config);
    }

}

Both work, but each obviously has its drawbacks. I believe the proper fix for this would require changes to the chartist library and this wrapper. However if there's a consensus on the best way to fix in this library, I'd be happy to implement and put up a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant