I've been struggling with a specific issue for quite some time now, but I can't seem to pinpoint the exact problem. I'm not sure if it's related to Angular or C3.
Oddly enough, I'm unable to execute my method within the c3.generate function from the same component.
The c3 chart is being called from the template and is functioning perfectly fine. I've even tested my somethingMethod() using a button in the template, and it works as expected.
I am trying to invoke the somethingMethod() within the c3 onclick function, but it's not having any effect. Even though an alert message pops up, indicating that I may be out of scope, I'm uncertain about how to resolve this issue.
@Component({
selector: 'something',
templateUrl: 'something.component.html',
})
export class SomethingComponent{
someTypeTitle: string;
getData(input: string): Array<number>{
return data;
}
somethingMethod(input: string){
someTypeTitle = input;
}
getChart() {
var chart = c3.generate({
bindto: '#stackedbar',
data: {
x: 'x',
columns: [
this.getData(someString),
this.getData(someString) //These work
],
onclick: function (d, e) {
alert(this.internal.config.axis_x_categories[d.x]); // This works
this.someTypeTitle="asdad"; //This doesn't work.
this.someTypeTitle= this.internal.config.axis_x_categories[d.x]; //This doesn't work.
this.somethingMethod(this.internal.config.axis_x_categories[d.x]); //This doesn't work.
},
}...