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

Data binding for params other than data #51

Closed
benoror opened this issue Apr 5, 2016 · 8 comments
Closed

Data binding for params other than data #51

benoror opened this issue Apr 5, 2016 · 8 comments

Comments

@benoror
Copy link

benoror commented Apr 5, 2016

Hi @Glavin001, kudos for such a great addon 😄

I have a use case where I need data binding for the donut chart title:

screen shot 2016-04-05 at 11 48 14

similarly to the Gauge's example:

screen shot 2016-04-05 at 11 49 21

I infer that data binding is not triggered because only the data parameter is observed: https://github.com/Glavin001/ember-c3/blob/master/addon/components/c3-chart.js#L193, while Gauge's title is extracted from data parameter itself, Donut's title is not (donut param)

I'm somewhat new to Ember, maybe you can hint me if there's a workaround for this, or maybe I'd be happy to work on a PR for it.

Thanks in advance, cheers!

@Glavin001
Copy link
Owner

As you noted, currently only changes to data update the chart.
This functionality could be improved.

When the component is initialized it creates a chart and passes the configuration from _config property to generate it: https://github.com/Glavin001/ember-c3/blob/master/addon/components/c3-chart.js#L118-L119

I am unfamiliar with a C3 API method that would allow you to load a changed donut or other parameters, only chart.load(data) for the changed data.
I recommend you first contact C3 maintainer(s) and figure out how C3 would like you do this: https://github.com/masayuki0812/c3
Afterwards, let me know and we can discuss further how you will change Ember-C3 to allow other parameters to be updated by bindings.
Thanks!

@jsvg
Copy link
Collaborator

jsvg commented Apr 16, 2016

I'm working on a PR that should allow for this. Problem with updating pies/donuts is that data loaded into the chart object is appended. However, you should be able to specify whether you'd like the current data to be unloaded before the new data is loaded in.

@janyk
Copy link

janyk commented Oct 17, 2016

@jsvg any luck with that PR regarding this issue?

@andyo729
Copy link
Collaborator

I believe this is covered in #51

@andyo729
Copy link
Collaborator

Sorry, #52

@maxwondercorn
Copy link
Collaborator

If you only have one donut chart, you can access the title via its class.

document.getElementsByClassName("c3-chart-arcs-title")[0].innerHTML = "my new title"

The c3 developers suggest using the classes for some uses or even falling back to d3 functions in some applications. Sorry I don't have any links to reference. Can't seem to find what I have read in the past.

@maxwondercorn
Copy link
Collaborator

Please see the drill down demo in release 1.0.0. ref pr #88

@maxwondercorn
Copy link
Collaborator

Really old issue but wanted to show this is now possible by setting the title in the donut argument.

See donut example in the dummy app:

donut = { title: "Iris Petal Width" };

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

No branches or pull requests

6 participants