-
Notifications
You must be signed in to change notification settings - Fork 57
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
No way to access chart object #34
Comments
This plugin just loads Chart.js via a Ruby gem. You'll need to ask on the Chart.js repo how to update your chart with new data. |
Thank you! Actually Chart.js includes the updateData function. There is some way to access to the chart object generated by chartjs-ror? |
Hello, I just achieved my goal. I'm not an expert in javascript but I modified the file "chart_helpers.rb", in line 42, to remove the "var" prefix on "chart" variable so now I am able to access to the chart object from another piece of javascript on the same page, for instance: <script type="text/javascript"> chart.data.datasets[0].data[6] = 2500; chart.update(); </script>I'm not sure if this change could provoke some inestable performance on the plugin, but it worked for me. Thank you very much, this plugin is awesome because it supports the complete set of options of Chart.js, such as the multi Y axis or the time format X axis. |
Glad you got it working for you. You're right, there isn't a way to access the |
I did a small hack where I am using the global window object and adding charts object to it
I don't think it is completely safe but it's an idea |
+1 to find a way to access the chart object. |
Was there a pull request ever submitted for your changes @vijayj ? |
@jdefrance-stessa - I just added that code to my project so no clone or fork. I am still not convinced whether this is the safest way to access chart object. I am not sure this merits a pull request |
EDIT: SORRY i realized my mistake that the google search led me to a ruby project in search of accessing chartjs objects at a later time! @BlackBeast593 , @vijayj , @AlainPilon
|
Hello,
There are some built-in function to auto update the chart with new data?
If not, please do you have any sugestions to auto update the chartjs-ror graphic?
Please let me know, thank you very much!
The text was updated successfully, but these errors were encountered: