mavenUser
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 :
zonebourse.com/SOCIETE-GENERALE-4702/analyse_technique-plein/&plein=1
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)
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(_indexesDispla yed.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(_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;
}
else
{trace("cas3");
(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 ?
Ty
PS: sorry for my poor english
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 :
zonebourse.com/SOCIETE-GENERALE-4702/analyse_technique-plein/&plein=1
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)
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(_indexesDispla yed.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(_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;
}
else
{trace("cas3");
(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 ?
Ty
PS: sorry for my poor english