views:

254

answers:

2

Basically the default behavior of the horizontal axis of the line chart is to graph each plot "as is" for example if you had this data:

<data value="5">
<data value="6">
<data value="7">

would graph, 5|6|7

I would like to make it graph so that it is adding to a value as it goes horizontally so it would graph the numbers like this: 5|11|18 as each step it is adding the value. so first you have 5, then you have 5+6 = 11, then you have 11+7 = 18. So the graph is always going up (unless there is a negative value) as to show the growth over time.

But I would like this to be something that can be changed at runtime via a property like showGrowthOverTime = true.

I am not even sure what I would need to extend LineChart? LinearAxis?

Thanks!!!

A: 

If it were me I would use a standard chart (no extending) but change the data. Conceptually I would get the data from my remoteObject, then create a another object that loops through and creates it's datapoints with a function that measures the total growth like you want, then just change the DP of the chart at runtime.

invertedSpear
A: 

Based on invertedSpear's suggestion this is what I have come up with on how to change the actual data:

public static function makeXMLListOverTime(xmlList:XMLList,property:String):XMLList
{
    /** property can be either xmlList."nodeName" or xmlList."@attributeName" */

    xmlList = xmlList.copy();

    var value:Number = 0;

    for(var i:uint = 0; i<xmlList[property].length(); i++)
    {
        var curVal:Number = Number(xmlList[property][i]);
        value += curVal;
        xmlList[property][i] = value;
    }

    return xmlList;
}
John Isaacks