-
Notifications
You must be signed in to change notification settings - Fork 20
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
Accessing char.js prototype methods #2
Comments
Hi, v0.1.5 exposed chart instance to public. You can use ViewChild or local variable to access it. |
Thanks for the update! FWIW and if anyone else wants an easy hack - I got around my particular issue (updating the chart with changing data) simply by wrapping the containing div in an *ngIf and having it removed from and re-added to the DOM each time the data changed. It sounds inefficient but there is no perceptible delay and it was ridiculously easy. None the less, I'm sure I'll find other reasons to access the chart instance. Great tool @emn178 ! Nice and flexible. Love it when people don't go too far - this allows for lots of customization without making get-going hard. |
@emn178 Thanks for the library, it's a good relief after ng2-charts... Thanks ! |
You should use
|
Thanks ! My bad for not deep diving in the library's code. |
But lets say there are 4 charts on display would |
import { ChartComponent } from 'angular2-chartjs'; It's not working on my ionic 3 project. |
@MeghaKumari2203 more detail info please |
import { ChartComponent } from 'angular2-chartjs'; I'm using Angular 5 and tried the ViewChild to get my ChartComponent. When I try to get the this.chart is undefined. I set correctly the options, the datasets are ok and the chart appears! The main goal to use the ChartComponent will be to use the native method generateLegend() of chartjs. Because I created a customize html legend. Anyone can help me? Example: this.chart.chart.generateLegend() <- I want only use this |
when do you call this.chart, maybe it's not ready |
I thought on this case, but I call this.chart after load all chart content |
post your sample code? |
Solve it! I used in Angular the ngAfterViewChecked and this.chart.chart.generateLegend() works. Many thanks |
I'm not sure if you've got a reliable way to access the chart methods such as .destroy() and .update() as described here: http://www.chartjs.org/docs/#advanced-usage-prototype-methods
If so, a little documentation would rock.
If not, it would be a great feature that would really make this tool worth while!
The text was updated successfully, but these errors were encountered: