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

Provide hook to get changed props along with the internal chart object #40

Merged
merged 1 commit into from
Jun 14, 2018

Conversation

jotak
Copy link
Contributor

@jotak jotak commented Jun 6, 2018

This would allow consumers to interact with the internal chart, call C3 API methods when something changed such as show/hide bools, legend, formats, etc. (anything but chart data)

This would allow consumers to interact with the internal chart, call C3 API methods when something changed such as show/hide bools, legend, formats, etc. (anything but chart data)
@jotak
Copy link
Contributor Author

jotak commented Jun 6, 2018

Hi,
An example of usage I've in my code:

From my React component that uses C3Charts

  onPropsChanged = (oldProps, newProps, chart) => {
    if (this.state.showLegend && !oldProps.legend.show) {
      chart.legend.show();
    } else if (!this.state.showLegend && oldProps.legend.show) {
      chart.legend.hide();
    }
  };

In render:

        <C3Chart
          // ...
          data={this.seriesData}
          legend={{ show: this.state.showLegend }}
          onPropsChanged={this.onPropsChanged}
        />

@jotak
Copy link
Contributor Author

jotak commented Jun 6, 2018

I think it could address issues such as #33 and #38 ?

@bcbcarl
Copy link
Owner

bcbcarl commented Jun 14, 2018

@jotak: Looks good to me. Thanks!

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

Successfully merging this pull request may close these issues.

2 participants