Flex 条形图不起作用
要绘制的 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>
XML Data to plot:
<?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>
The above data I need to plot to a Bar chart, which I tried with code below and not working
I need to plot "Langid" on y-axis and bar length based on the value in speakers tag.
<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>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以尝试使用 E4X 语法:
You can try using E4X syntax:
将 mx:BarChart 更改为下面的内容对我有用:
Changing mx:BarChart to below, worked for me: