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

chart render in success function of ajax call #75

Open
Naveedali1234 opened this issue Oct 2, 2018 · 3 comments
Open

chart render in success function of ajax call #75

Naveedali1234 opened this issue Oct 2, 2018 · 3 comments

Comments

@Naveedali1234
Copy link

Hello fxcosta and thank you so much for the amazing work.

actually this library is working perfectly when i return the $chartjs object from controller to view directly and render it there, but i am now doing it through ajax call, i have the chartjs object ready there in controller and return the object from the controller function to the ajax call success function, but how do i render in the success function of ajax call? your help would be really appreciated.

thank you

@moh586
Copy link

moh586 commented Feb 26, 2019

Hello fxcosta and thank you so much for the amazing work.

actually this library is working perfectly when i return the $chartjs object from controller to view directly and render it there, but i am now doing it through ajax call, i have the chartjs object ready there in controller and return the object from the controller function to the ajax call success function, but how do i render in the success function of ajax call? your help would be really appreciated.

thank you

hi.do you find a solution for your problem?i have same problem

@abedputra
Copy link

Hi, any solution?

@abedputra
Copy link

I found a solution.
I try to implement some functions like this. After calling the ajax, we will add the data from ajax to update our Chart with this function

function addData(chart, data, datasetIndex) {
    chart.data.datasets[datasetIndex].data = data;
    chart.update();
}

function addLabel(chart, label) {
    chart.data.labels = label;
    chart.update();
}

This is an example addData(chart, newData, 0); or addLabel(chart, newLabel);.

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

No branches or pull requests

3 participants