Closed btm1 closed 9 years ago
Hi @btm1 thank you for testing the directive and reporting back your findings. There was a bug, so the configuration was not reset when updating the options. I fixed this and uploaded version 0.3.1.
Please check if this suits your needs, accessing the chart directly using the service is a bigger task, if you really need it please open a new issue for this.
@maxklenk thanks for taking care of this. As for accessing the chart... I'm not sure whether or not this is a good idea. If it were me and I had written it though I might have not used an isolate as I'm not really sure it's necessary in this case and then using the method in the service could return the state of the chart via the getInstance method. This would at least allow for some more advanced use cases where a user may need to use the c3 methods stored on this object.
I would keep it in mind for the future...
We will think about a solution. It is always good to work with isolated scopes to avoid unintended behaviour. On the other hand it is not that easy to access a chart using a service, because there may be multiple charts and a way to distinguish between them has to be found.
You are creating unique IDs for to apply to the dom element so you could use that same ID as a key and store the chart objects in a variable in a service and then create a method to retrieve a chart object based on a key value.
In the dimensions if you init a dimension to "show":false and then you programmatically set it to true it should then show up on the chart... the same should be true the other way. If I set it to true and then I set it to false it should disappear from the chart.
The reason i'm asking for something like this is to achieve something like this: http://jsfiddle.net/panubear/q8h39/
Right now the only way you could do this is to remove it from the data set all together which doesn't make any sense and in a real world scenario where this is being used in a web application you wouldn't want to have to do that.
I would do this via chart.show and chart.hide but you are using an isolate scope on the directive thus making it impossible to use AngularChartService injected into my own controller in order in order to gain access to the chart object via AngularChartService.getInstance.