Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 02-05-2012, 10:33 AM   #1
Registered User
Join Date: Feb 2012
Posts: 2
Default Scrolling large chart data

Hi all,

I'm trying to add some functionnalities to a custom chart (zoom+, zoom-, scrolling). My goal is to have some graph functionnality like this one :


I've implemented these 3 functionnalities but it's very slow to zoom and scroll (more than 10s) on a dataProvider size > 1500 whereas example graph is very fluid.

Here is zoom- implémentation :

ActionScript Code:
var toCheckIn:uint = Math.min(toolBar.stepChooser.value, _initialDataAsArrayLength - subArrayLength);                                         if(toCheckIn == 0)                         return;                                         // Si l'espace entre l'index Y et la fin du tableau en longueur est suffisant pour ajouter autant de valeur que de toCheckIn, alors on ajoute tout à droite                     // Sinon on ajoute à droite (si on peut) un maximum d'items puis à gauche                                         if((_initialDataAsArrayLength - _indexesDisplayed.y) >= toCheckIn)                     {trace("cas1");                         (chartRef.dataProvider as ListCollectionView).addAll(new ArrayList(_initialDataAsArray.slice(_indexesDisplayed.y+1, toCheckIn)));                         _indexesDisplayed.y += toCheckIn;                     }                     else if((_initialDataAsArrayLength - _indexesDisplayed.y) > 0)                     {trace("cas2");                         var toRight:uint = _initialDataAsArrayLength - _indexesDisplayed.y;                         (chartRef.dataProvider as ListCollectionView).addAll(new ArrayList(_initialDataAsArray.slice(_indexesDisplayed.y+1, toRight)));                         _indexesDisplayed.y += toRight;                                                 var remaining:uint = toCheckIn - toRight;                         (chartRef.dataProvider as ListCollectionView).addAllAt(new ArrayList(_initialDataAsArray.slice(_indexesDisplayed.x - remaining, remaining)), 0);                                                _indexesDisplayed.x -= remaining;                     }                     else                     {trace("cas3");                         (chartRef.dataProvider as ListCollectionView).addAllAt(new ArrayList(_initialDataAsArray.slice(_indexesDisplayed.x - toCheckIn, toCheckIn)), 0);                                                _indexesDisplayed.x -= toCheckIn;                     }

with :

stepChooser -> HSlider to choose number of items added/removed par a zoom (- or +)
_initialDataAsArrayLength -> size of the initial dataProvider
_subArrayLength -> size of the actual dataProvider displayed
chartRef -> reference to the chart
_indexesDisplayed -> Point referencing "coordinates" of the subArray displayed in the inital dataProvider (to keep in memory for scroll or zoom)

Everything works but it's very slow for large data.

How can I improve my algorithm please ?


PS: sorry for my poor english
mavenUser is offline   Reply With Quote
Old 02-08-2012, 11:56 AM   #2
Holosuit User
wvxvw's Avatar
Join Date: Oct 2006
Location: Tel Aviv
Posts: 4,301
Send a message via ICQ to wvxvw

I saw that graph kind before, I think it's some OSS library, so, probably, instead of trying to add on top of Adobe charts (which are frankly not so performant), maybe just look for alternatives?
Your code looks perfectly fine to me, nothing that would make me suspect the problem is there.

On a more general scale, probably, that doesn't make much sense to display 1500 element of data at once - humans will hardly be ever able to comprehend that much So, naturally, you'd like to prepare the data before it is displayed - either display it in chunks, or approximate it to something more easily comprehended.
The .NET open source editor for Flash and web developers
*This would be my contribution to the project*
couchsurfing if you need it
wvxvw is offline   Reply With Quote

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 06:50 AM.

Follow actionscriptorg on Twitter


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.