您的位置:首页 > 其它

AnyChart使用指南三:生成动态图像

2012-11-21 14:59 423 查看
AnyChart主要工作原理是有一个.swf文件作为对象,数据和设置存放在.xml文件中,然后在.html文件里通过JS来调用,生成动态图像。

由于想使用到struts中去,xml文件自动生成,有个叫jdom的包能够实现这样的功能,于是在网上找jdom的使用教程,终于写好了第一个生成xml的java文件,示例代码如下:

生成的xml文件如下:

<?xml version="1.0" encoding="gb2312"?>
<root>
<type>
<system>
<refresh enabled="yes" />
</system>
<workspace>  //整个工作区
<background enabled="yes" type="gradient" gradient_type="linear">
<colors>
<color>0xFFFFFF</color>
<color>0xF4E1C4</color>
</colors>
<alphas>
<alpha>100</alpha>
<alpha>100</alpha>
</alphas>
<ratios>
<ratio>0</ratio>
<ratio>0xFF</ratio>
</ratios>
<matrix r="1.7" />
</background>
<chart_area width="400" height="240" x="20" y="30" enabled="no" />
<base_area enabled="no" />
</workspace>
<chart type="3DPie">  //输出图形部分
<animation enabled="yes" speed="10" type="step" />
<names show="no" />
<values show="no" postfix="%" />
<pie_chart radius="100" x="340" y="150" rotation="360">
<border enabled="yes" color="0xF4E1C4" />
</pie_chart>
<hints width="170">
<border color="0xB54001" />
<background background="0xF4E1C4" />
</hints>
</chart>
<legend enabled="yes" x="22" y="60">  //输出文字部分
<background enabled="no" />
<border enabled="no" />
<scroller enabled="no" />
<names width="120" />
<values width="40" />
<header values="%" names="Name" />
</legend>
</type>
<data>
<block>
<set name="column 0" value="4" color="0xAFD8F8" />
<set name="column 1" value="17" color="0xAFD8F8" />
</block>
</data>
<objects>
<text text="sillyPieChart" auto_size="yes" x="20" y="380" url="./pieChart.xml">
<font size="12" align="center" type="Verdana" />
<border enabled="no" />
</text>
</objects>
</root>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: