Welcome Guest Search | Active Topics |

redraw charts with different data
bloomingdals
#1 Posted : Wednesday, July 3, 2013 5:55:33 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/3/2013(UTC)
Posts: 9

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
hello,
I've written a script using jqchart to display 4 colum chart in the same page.
The data of every chart came from a database.
I want to use the fonction "update" to redraw to same graphs but with different data.
How can i do it ?
thanks
Dragan
#2 Posted : Wednesday, July 3, 2013 11:31:46 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
You can check this example:

http://www.jqchart.com/jquery/chart/RealTime/ChartDataPoints

the code should looks like:

Code:
                // get current series
                var series = $('#jqChart').jqChart('option', 'series');

                // set the new data
                series[0].data =  newData;

                // update (redraw) the chart
                $('#jqChart').jqChart('update');
Best Regards,
Dragan Matek
jqChart Inc.
bloomingdals
#3 Posted : Thursday, July 4, 2013 4:15:38 AM(UTC)
Rank: Newbie

Groups: Registered
Joined: 5/3/2013(UTC)
Posts: 9

Thanks: 0 times
Was thanked: 0 time(s) in 0 post(s)
hello,
i've used this syntax to redraw the chart:
[
Code:

var series4 = $('#jqChart4').jqChart('option', 'series');
                 var newaxes4 = {
                  type: 'category',
                 location: 'bottom',
                 categories: [<?php echo $categories_d ?>],
                 zoomEnabled: true,
                 labels: {
                      font: '13px sans-serif',
                      fillStyle: '#eeeeee',
                      angle: -45
                          },
                 resolveOverlappingMode: 'hide',
                };           
                var axes4 = $('#jqChart4').jqChart('option', 'axes');
                var newSeries4 = {
                    title:'Today statistics',
                    type: 'column',
                    fillStyle: 'gray',
                    data: [<?php echo $today_data; ?>],
                };   
                 series4.splice(series4.length - 1, 1);
                 series4.push(newSeries4);
                 axes4.splice(series4.length - 1, 1);
                 axes4.push(newaxes4);
                 $('#jqChart4').jqChart('update');


the redrawing is trigged when i click on a button.
I've noticed that when i click once, every thing is fine (the data series change and so do the labels on the bottom axe).
But when i click twine, i have two bottom axes displayed, i don't know why.

Thank you
Dragan
#4 Posted : Sunday, July 7, 2013 6:46:51 AM(UTC)
Rank: Advanced Member

Groups: Administrators, DataVizJavaScript, jQueryChart, jQueryDV, MvcChart, Registered
Joined: 1/3/2011(UTC)
Posts: 483

Thanks: 0 times
Was thanked: 87 time(s) in 87 post(s)
Hi,

Try replacing your line:

Code:
axes4.splice(series4.length - 1, 1);


with:

Code:
axes4.splice(axes4.length - 1, 1);
Best Regards,
Dragan Matek
jqChart Inc.
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

FlatEarth Theme by Jaben Cargman (Tiny Gecko)
Powered by YAF 1.9.4 | YAF © 2003-2010, Yet Another Forum.NET
This page was generated in 0.091 seconds.