View Full Version : Legend Error...
ishone
06-11-2009, 10:00 PM
Greetings,
I am having issues adding a Legend to a chart which is loaded through a custom component. I tried placing the Legend in each of the files, but keep getting an error "("Multiple initializers for property 'dataProvider'. (note: 'dataProvider' is the default property of 'mx.charts.LineChart')". Is there a way to create the Legend from scratch (i.e. an array)?
Thanks!
ishone
06-12-2009, 12:10 AM
maybe this will help, I can now see the Markers, but no Labels:
<?xml version="1.0" encoding="utf-8"?>
<PodContentBase
xmlns="com.esria.samples.dashboard.view.*"
xmlns:mx="http://www.adobe.com/2006/mxml"
paddingTop="3"
creationComplete="initApp()"
xmlns:local="com.esria.samples.dashboard.view.*" xmlns:view="view.*"
backgroundColor="#FFFFFF"
fontFamily="Arial"
fontSize="10"
fontWeight="bold"
color="#003399">
<mx:Script>
<![CDATA[
import mx.controls.Label;
import flash.net.navigateToURL;
import mx.collections.ArrayCollection;
import mx.events.ListEvent;
import mx.rpc.events.ResultEvent;
//Range imports
import mx.controls.sliderClasses.SliderThumb;
import mx.core.UIComponent;
import mx.collections.ArrayCollection;
import mx.rpc.events.*;
//AllRegions imports
import mx.controls.Button;
import mx.charts.HitData;
import mx.events.FlexEvent;
import mx.charts.chartClasses.ChartBase;
[Bindable]
private var dataProvider:ArrayCollection;
//Range vars
[Bindable]
public var slicedMonthData:ArrayCollection;
[Bindable]
public var slicedRegionData:ArrayCollection;
[Bindable]
private var monthData:Array;
[Bindable]
private var regionData:Array;
[Bindable]
private var periodToolTip:String = "";
[Bindable]
private var dashboardToolTip:String = "";
//AllRegions vars
[Bindable]
public var lcToolTip:String = "";
[Bindable]
public var revenueData:Array;
override protected function onResultHttpService(e:ResultEvent):void
{
var a:Array = xmlListToObjectArray(e.result.item);
dataProvider = new ArrayCollection(a);
}
//Range functions
private function initApp():void
{
srv.send();
slicedMonthData = new ArrayCollection();
slicedRegionData = new ArrayCollection();
}
private function resultHandler(event:ResultEvent):void
{
monthData = event.result.list.day.source as Array;
regionData = new Array(monthData.length);
slicedMonthData.source = monthData;
// regionBreakdown.month = monthData[0];
dateRange.monthData = this.monthData;
dateRange.regionData = this.regionData;
dateRange.slicedMonthData = this.slicedMonthData;
dateRange.slicedRegionData = this.slicedRegionData;
dateRange.sliderComp();
var monthTotal:Number;
dateRange.valueUpdate();
slicedRegionData.source = regionData.slice(dateRange.startValue, dateRange.endValue);
}
]]>
</mx:Script>
<mx:HTTPService id="srv" url="data/overview_range.xml" useProxy="false" result="resultHandler(event)"/>
<mx:SeriesInterpolate id="interpolate" elementOffset="10"/>
<mx:ApplicationControlBar width="100%" tabChildren="true" id="appControlBar" backgroundColor="#002563">
<mx:Spacer width="10"/>
<mx:Label text="Select Period:" color="#e2e2e2" id="selectPeriodLabel" />
<!-- creationComplete="labelsComp()" -->
<AccessibleDateRange id="dateRange" tabIndex="5"/>
</mx:ApplicationControlBar>
<mx:VBox width="100%" height="100%">
<mx:LineChart id="chart" dataProvider="{slicedMonthData.source}"
name="Chart data is available in grid view" showDataTips="true"
width="100%" height="100%" toolTip="{lcToolTip}"
>
<mx:horizontalAxis>
<mx:CategoryAxis dataProvider="{slicedMonthData.source}" categoryField="name"/>
</mx:horizontalAxis>
<mx:series>
<mx:LineSeries yField="visits" showDataEffect="{interpolate}">
</mx:LineSeries>
<mx:LineSeries yField="completed" showDataEffect="{interpolate}">
</mx:LineSeries>
<mx:LineSeries yField="answered" showDataEffect="{interpolate}">
</mx:LineSeries>
<mx:LineSeries yField="conversions" showDataEffect="{interpolate}">
</mx:LineSeries>
</mx:series>
<mx:backgroundElements>
<mx:Array>
<mx:GridLines direction="both">
</mx:GridLines>
</mx:Array>
</mx:backgroundElements>
</mx:LineChart>
<mx:Legend dataProvider="{chart}" direction="horizontal"/>
</mx:VBox>
</PodContentBase>
|
vBulletin® v3.8.4, Copyright ©2000-2009, Jelsoft Enterprises Ltd.