View Full Version : Scrolling large chart data

02-05-2012, 10:33 AM
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 :

var toCheckIn:uint = Math.min(toolBar.stepChooser.value, _initialDataAsArrayLength - subArrayLength);

if(toCheckIn == 0)

// 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)
(chartRef.dataProvider as ListCollectionView).addAll(new ArrayList(_initialDataAsArray.slice(_indexesDispla yed.y+1, toCheckIn)));
_indexesDisplayed.y += toCheckIn;
else if((_initialDataAsArrayLength - _indexesDisplayed.y) > 0)
var toRight:uint = _initialDataAsArrayLength - _indexesDisplayed.y;
(chartRef.dataProvider as ListCollectionView).addAll(new ArrayList(_initialDataAsArray.slice(_indexesDispla yed.y+1, toRight)));
_indexesDisplayed.y += toRight;

var remaining:uint = toCheckIn - toRight;
(chartRef.dataProvider as ListCollectionView).addAllAt(new ArrayList(_initialDataAsArray.slice(_indexesDispla yed.x - remaining, remaining)), 0);
_indexesDisplayed.x -= remaining;
(chartRef.dataProvider as ListCollectionView).addAllAt(new ArrayList(_initialDataAsArray.slice(_indexesDispla yed.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

02-08-2012, 11:56 AM
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.