[Solved] Varying Bar Width on BarChart panning – Achartengine


I was able to resolve the changing bar width issue by ensuring the serie was a “perfect” suite for x values, changing

this : {17, 4, 24, 3, 25, 7, 26, 10, 27, 4}

to this : {17, 4, 18, 0, 19, 0, 20, 0, 21, 0, 22, 0, 23, 0, 24, 3, 25, 7, 26, 10, 27, 4}

To achieve that, I modified my first for loop to check for missing x values :

for (int x = 0; x<statsSize; x++){
        routeLevel = currentLevel;
        x++;
        currentLevel++;
        climbsQuantity = stats.get(x);
        xySerie.add(routeLevel, climbsQuantity);

        //if not at the last x/y couple of the array, fill the blanks in the serie
        if (x<statsSize-1){ 
            while (stats.get(x+1)>currentLevel){
                routeLevel = currentLevel;
                climbsQuantity = 0;
                xySerie.add(routeLevel, climbsQuantity);
                currentLevel++;
            }
        }
}

Now the bar width doesn’t change at all when I scroll. This is more a workaround, though, because now the “filling” couples I added are all showing 0 as value, which I find a bit odd. If I find a way to hide these 0 values, I’ll edit my answer…

CURRENT APPEARANCE OF THE GRAPH
enter image description here

2

solved Varying Bar Width on BarChart panning – Achartengine