jQWidgets Forums
jQuery UI Widgets › Forums › Chart › Repetitively Create jqxChart
Tagged: Angular chart, bootstrap chart, javascript chart, jquery chart, jqwidgets chart, jqxChart, refresh
This topic contains 6 replies, has 2 voices, and was last updated by Hristo 9 years, 5 months ago.
-
Author
-
Not sure if this is a bug or not.
I have a page where the view is defined from csv files (excel users are required to edit webpages). So sometimes there’s a jqxChart in a column, sometimes there is a jqxGauge, but usually there is nothing.
My issue is that the chart creates fine, but subsequent creations don’t seem to work. No error is given.
I’ve modified an example to show the behavior I’m seeing: http://jsfiddle.net/GSNPm/65/
On my browser, a single click creates the chart without problem. A second click though results in no action being performed. Each click logs the settings variable to the console to ensure that is still accessible. I’ve also made sure we’re creating a fresh settings object each time.
Thank you,
Stephen O’ConnorHello Stephen,
You could try to use this
$('#jqxChart').jqxChart('refresh');
method.
Please take a look this example: http://jsfiddle.net/txhi/dznj5dq4/
We have similar themes in forum, that could be useful:
http://www.jqwidgets.com/community/topic/refresh-chart-does-not-render-results/Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHey Hristo, thanks for the reply.
My use case is that I need to reuse the element, as in destroy the chart and _maybe_ in the future recreate it or create a completely new one. I have multiple views on a single page set dynamically by user defined and selected menus.
Is this expected behavior by the jqxChart library?
Thank you again,
StephenI figured jqxChart is probably saving its state on the element within the DOM so I tried this demo:
It seems to work. The idea here is that I build a cache of all html attributes, destroy the div, and then recreate it in the same spot using the cache of attributes. Clunky and inelegant, but it works.
Now can I modify my production code to utilize this workaround?
Hello Stephen,
Please take a look this example:
http://jspexamples.jqwidgets.com/examples/chart.htm?arctic could be useful too.
If you need of frequently changing values could use ‘update’:
http://jsfiddle.net/jqwidgets/P6q29/
You could read all about license agreement:
http://www.jqwidgets.com/licenseagreement/Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.comHristo: I’m familiar with the license agreement and my organization has purchased a developer license with premium support. I’m unclear what you are trying to imply by bringing this up. Can you please be explicit. My intentions here are to highlight unexpected behavior in an attempt to help jqWidgets get better. If this is not in line with your or jqWidgets’ goals please let me know and I’ll forward this on to my organization for consideration.
All examples posted showcase reuse of an existing a jqxChart which as I said above do not match this use case. Thank you for your time, I think I’ve found a solution by the method described above. Here’s a more production ready link with an optional timer to show that the chart is actually being recreated each click: http://jsfiddle.net/zyreL8cr/2/
Hello Stephen,
Thank you for using our product and for your feedback!
I pointed you out the license agreement page, because there are restrictions about making code modifications. If you plan to do such, make sure to read the page’s content.
Best Regards,
Hristo HristovjQWidgets team
http://www.jqwidgets.com -
AuthorPosts
You must be logged in to reply to this topic.