Archive

Archive for August, 2009

Setting dataprovider for Axiis line graph

August 28th, 2009 1 comment

I am building a widget to show routes for Runningmap.com and thought I would give Axiis a try for the elevation graph. The examples show a couple techniques for connecting a cvs formatted or xml source file as the data source for the graph. Connecting my ArrayCollection of value objects stumped me however. Tom Gonzalez was kind enough to guide me to the solution which was to wrap the collection in just the right way so that Axiis could get at the data. The rest was, as I expected, magic.

Wrapping the collection looked like this:

Actionscript:
  1. protected function handleNewMapData(p_evt:Event):void{
  2. var wrapper:Object = new Object();
  3. wrapper.plots = model.routePoints;
  4. var dataCollection:ArrayCollection = new ArrayCollection();
  5. dataCollection.addItem(wrapper);
  6. dataProvider = dataCollection;
  7. dc.invalidateDisplayList();
  8. }

Then set the "plotCollection" and "dataField" properties in the LineSeriesGroup:

Actionscript:
  1. <axiis:DataCanvas
  2.     width="90%"
  3.     height="50"
  4.     y="15"
  5.     id="dc"
  6.     horizontalCenter="0">
  7.     <axiis:layouts>
  8.         <groupings:LineSeriesGroup
  9.             verticalScale="{vScale}"
  10.             id="myLineGroup"
  11.             x="0"
  12.             y="0"
  13.             height="{dc.height}"
  14.             width="{dc.width-10}"
  15.             plotCollection="plots"
  16.             dataProvider = "{dataProvider}"
  17.             dataField="elevation"
  18.             />
  19.     </axiis:layouts>
  20. </axiis:DataCanvas>

And here it is:

Map did not load
Categories: Flex development, Runningmap Tags: