要绘制的XML数据:
<?xml version="1.0" encoding="utf-8" ?>
<spearkerslist>
<speakers langid="afb" countryid="SA" countryalpha3id="SAU">200000</speakers>
<speakers langid="acw" countryid="SA" countryalpha3id="SAU">6000000</speakers>
<speakers langid="ars" countryid="SA" countryalpha3id="SAU">8000000</speakers>
<speakers langid="arb" countryid="SA" countryalpha3id="SAU">206000000</speakers>
</spearkerslist>
我需要将上述数据绘制成条形图,我尝试使用下面的代码并且无法正常工作 我需要根据扬声器标签中的值在y轴和条形长度上绘制“Langid”。
<mx:Script>
<![CDATA[
private var languagelist:XML = new XML(); //Variable where the XML is stored.
]]>
</mx:Script>
<mx:Panel>
<mx:BarChart id="chrtLangugeVsPopulation" dataProvider="{languagelist.speakers}" showAllDataTips="true">
<mx:verticalAxis>
<mx:CategoryAxis
dataProvider="{languagelist.speakers.@langid}"
categoryField="Language"
/>
</mx:verticalAxis>
<mx:series>
<mx:BarSeries
yField="Language"
xField="Speakers"
displayName="Speakers"
/>
</mx:series>
</mx:BarChart>
</mx:Panel>
答案 0 :(得分:0)
您可以尝试使用E4X语法:
dataProvider="{languagelist..speakers}"
答案 1 :(得分:0)
将mx:BarChart更改为以下,为我工作:
<mx:BarChart id="chrtLangugeVsPopulation" dataProvider="{languagelist.speakers}" showDataTips="true">
<mx:verticalAxis>
<mx:CategoryAxis
dataProvider="{languagelist.speakers}"
categoryField="@langid"
/>
</mx:verticalAxis>
<mx:series>
<mx:BarSeries
yField="@langid"
xField=""
displayName="Speakers"
click="barseries1_clickHandler(event)"
/>
</mx:series>
</mx:BarChart>