属性“dataProvider”有多个初始值设定项。(注意:“dataProvider”是“mx.charts.BarChart”的默认属性)。
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了属性“dataProvider”有多个初始值设定项。(注意:“dataProvider”是“mx.charts.BarChart”的默认属性)。相关的知识,希望对你有一定的参考价值。
1、错误描写叙述
属性“dataProvider”有多个初始值设定项。(注意:“dataProvider”是“mx.charts.BarChart”的默认属性)。
2、错误原因
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" creationComplete="initHandler(event)"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.events.FlexEvent; [Bindable] private var chartArray:ArrayCollection = new ArrayCollection([ {week:"星期一",snake:"5459",cow:"7845"}, {week:"星期二",snake:"8956",cow:"7845"}, {week:"星期三",snake:"3562",cow:"7845"}, {week:"星期四",snake:"7856",cow:"7845"}, {week:"星期五",snake:"1245",cow:"7845"}, {week:"星期六",snake:"9656",cow:"7845"}, {week:"星期日",snake:"6784",cow:"7845"} ]); protected function initHandler(event:FlexEvent):void { } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(比如服务、值对象)放在此处 --> </fx:Declarations> <mx:VBox width="100%" height="100%" horizontalAlign="center" paddingBottom="10" paddingLeft="10" paddingRight="20" paddingTop="10"> <mx:BarChart id="barchart" width="100%" height="90%" showDataTips="true" dataProvider="{chartArray}"> <mx:verticalAxis> <mx:CategoryAxis categoryField="week" displayName="星期"/> </mx:verticalAxis> <mx:series> <mx:BarSeries displayName="蛇数量" xField="snake" yField="week"/> </mx:series> <fx:Array> </fx:Array> </mx:BarChart> <mx:Legend dataProvider="{barchart}"/> </mx:VBox> </s:Application>
3、解决的方法
<?xml version="1.0" encoding="utf-8"?> <s:Application xmlns:fx="http://ns.adobe.com/mxml/2009" xmlns:s="library://ns.adobe.com/flex/spark" xmlns:mx="library://ns.adobe.com/flex/mx" width="100%" height="100%" creationComplete="initHandler(event)"> <s:layout> <s:BasicLayout/> </s:layout> <fx:Script> <![CDATA[ import mx.collections.ArrayCollection; import mx.events.FlexEvent; [Bindable] private var chartArray:ArrayCollection = new ArrayCollection([ {week:"星期一",snake:"5459",cow:"7845"}, {week:"星期二",snake:"8956",cow:"7845"}, {week:"星期三",snake:"3562",cow:"7845"}, {week:"星期四",snake:"7856",cow:"7845"}, {week:"星期五",snake:"1245",cow:"7845"}, {week:"星期六",snake:"9656",cow:"7845"}, {week:"星期日",snake:"6784",cow:"7845"} ]); protected function initHandler(event:FlexEvent):void { cate.ticksBetweenLabels = false; } ]]> </fx:Script> <fx:Declarations> <!-- 将非可视元素(比如服务、值对象)放在此处 --> </fx:Declarations> <mx:VBox width="100%" height="100%" horizontalAlign="center" paddingBottom="10" paddingLeft="10" paddingRight="20" paddingTop="10"> <mx:BarChart id="barchart" width="100%" height="90%" showDataTips="true" dataProvider="{chartArray}"> <mx:verticalAxis> <mx:CategoryAxis id="cate" categoryField="week" displayName="星期" /> </mx:verticalAxis> <mx:series> <mx:BarSeries displayName="蛇数量" xField="snake" yField="week"/> </mx:series> <mx:secondVerticalAxis> <mx:CategoryAxis categoryField="week" displayName="星期"/> </mx:secondVerticalAxis> <mx:secondSeries> <mx:LineSeries displayName="牛" xField="cow" yField="week"/> </mx:secondSeries> </mx:BarChart> <mx:Legend dataProvider="{barchart}"/> </mx:VBox> </s:Application>
以上是关于属性“dataProvider”有多个初始值设定项。(注意:“dataProvider”是“mx.charts.BarChart”的默认属性)。的主要内容,如果未能解决你的问题,请参考以下文章
不能在属性初始值设定项中使用实例成员 '';属性初始化程序在 'self' 可用之前运行