加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

SunshineCharts部署教程(最简单的flex Charts)

发布时间:2020-12-15 05:11:14 所属栏目:百科 来源:网络整理
导读:? 近来因为公司项目需要,并且因为开源的报表控件太多bug了,无法使用。所以简单封装了一个flexchart,使用更加简单,基本3分钟就可以上手使用,并且扩展性是好。该报表控件全开源欢迎有兴趣的朋友下载使用。? ? ? ?首先请下载sunshinecharts的包: ? ? ??ht
? 近来因为公司项目需要,并且因为开源的报表控件太多bug了,无法使用。所以简单封装了一个flexchart,使用更加简单,基本3分钟就可以上手使用,并且扩展性是好。该报表控件全开源欢迎有兴趣的朋友下载使用。? ? ? ?首先请下载sunshinecharts的包:

? ? ??http://ken-javaframeword.googlecode.com/files/SunshineCharts.war

? ?下载2.5.2的javaframework:

? ? ??http://ken-javaframeword.googlecode.com/files/javaFramework2_5_2.jar

? ??

? ??SunshineCharts.swf 报表的核心swf文件;

? ?chartsTag.tld 报表标签文件

? ??

? ?

? ? ?第一步:加入标签

? ? 在web.xml加入

? ?

[html] view plain copy print ?
  1. <jsp-config>??
  2. ????????<taglib>??
  3. ????????????<taglib-uri>/WEB-INF/chartsTagLib</taglib-uri>??
  4. ????????????<taglib-location>/WEB-INF/tag/chartsTag.tld</taglib-location>??
  5. ????????</taglib>??
  6. ????</jsp-config>??
? ?其中
[html] view plain copy print ?
  1. /WEB-INF/tag/chartsTag.tld??

?问tld存放的路径;


? ?第二步:加入报表

? ? 在jsp头部加入

? ??

[html] view plain copy print ?
  1. <%@taglib?uri="/WEB-INF/chartsTagLib"?prefix="chart"%>??
? ?然后在jsp的body加入

?

[html] view plain copy print ?
  1. <chart:flashTag??id="lineChart"?type="lineChart"??
  2. ????????????dataUrl="xml/LineChartData.xml"?flashUrl="SunshineCharts.swf"??
  3. ????????????cleanCache="off"?width="100%"?height="100%"?/>??
? ?id:报表的id

? type:lineChart/pieChart/columnChart

? flashUrl:SunshineCharts.swf的路径

? dataUrl:数据源url的路径,数据源为xml

? cleanCache:是否自动清除缓存


? ??第三步:构造数据源

? ?我们在dataUrl传入一个一个LineChartData.xml

[html] view plain copy print ?
  1. <?xml?version="1.0"?encoding="UTF-8"?>??
  2. ??
  3. <data?title=""?autoRefreshPolicy="on"?autoRefreshTime="180"?debug="off"??
  4. ????backGroudColor="0xffffff"?verticalTitle="price"?horizontalTitle="date"??
  5. ????form="curve"?showDataTips="true"?showAllDataTips="false"??
  6. ????savePicturePolicy="on"?savePicturePolicyName="test.jpg"?legend="true">??
  7. ????<lines>??
  8. ????????<line?value="line1"?label="线1"?color="ox000000"?/>??
  9. ????</lines>??
  10. ????<node?label="1"?line1="100"?/>??
  11. ????<node?label="2"?line1="0"?/>??
  12. ????<node?label="3"?line1="100"?/>??
  13. </data>??

? ? xml解析:

? ?title:标题

? ?autoRefreshPolicy:是否自动刷新

? ?autoRefreshTime:自动刷新时间

? ?debug:是否显示debug

? ??backGroudColor:底色

? ??verticalTitle:纵轴标签

? ?horizontalTitle:横轴标签

? ?form:线的样式

? ?showDataTips:是否交互显示

? ?showAllDataTips:显示所有标签

? ?savePicturePolicy:是否可以右键保存图片

? ?savePicturePolicyName:右键保存图片的名称

? ?legend:是否需要图例

? ?color:线的颜色

?效果图:


? ? ?另外的xml:

? ? ?

[html] view plain copy print ?
  1. <?xml?version="1.0"?encoding="UTF-8"?>??
  2. ??
  3. <data?title=""?autoRefreshPolicy="on"?autoRefreshTime="180"?debug="off"??
  4. ????backGroudColor="0xffffff"?verticalTitle="price"?horizontalTitle="date"??
  5. ????form="curve"?showDataTips="true"?showAllDataTips="false"?legend="true">??
  6. ????<lines>??
  7. ????????<line?value="line1"?label="线1"?color="0x00ffff"?/>??
  8. ????????<line?value="line2"?label="线2"?color="0xffff00"?/>??
  9. ????</lines>??
  10. ????<node?label="1"?line1="100"?line2="100"?/>??
  11. ????<node?label="2"?line1="0"?line2="300"?/>??
  12. ????<node?label="3"?line1="100"?line2="100"?/>??
  13. </data>??

? ?结果图:

??


? ? 通过java代码构造xml:

? ? ?构造线图xml

? ??

[java] view plain copy print ?
  1. package?com.shine.framework.Charts.cofferCharts.LineCharts;??
  2. ??
  3. public?class?LineChartsExample?{??
  4. ??
  5. ????/**?
  6. ?????*?生成线图例子?
  7. ?????*??
  8. ?????*?@param?args?
  9. ?????*/??
  10. ????public?static?void?main(String[]?args)?{??
  11. ????????Line?line1?=?new?Line("line1",?"线1",?"0x000000");??
  12. ????????line1.put("1",?100);??
  13. ????????line1.put("3",?100);??
  14. ??
  15. ????????LineChartsHelper?helper?=?new?LineChartsHelper();??
  16. ????????helper.addAix("1",?"2",?"3");??
  17. ????????helper.addLine(line1);??
  18. ??
  19. ????????System.out.println(helper.getDataXml());??
  20. ????}??
  21. ??
  22. }??

? ?构造饼图xml

[java] view plain copy print ?
  1. package?com.shine.framework.Charts.cofferCharts.PieCharts;??
  2. ??
  3. public?class?PieChartExample?{??
  4. ??
  5. ????/**?
  6. ?????*?饼图使用例子?
  7. ?????*??
  8. ?????*?@param?args?
  9. ?????*/??
  10. ????public?static?void?main(String[]?args)?{??
  11. ????????PieChartsHelper?helper?=?new?PieChartsHelper();??
  12. ????????helper.addPieChart("p1",?10,?"0xffff00",?"饼1");??
  13. ????????helper.addPieChart("p2",?"0xff00ff",?"饼2");??
  14. ????????helper.addPieChart("p3",?"0x00ffff",?"饼3");??
  15. ??
  16. ????????System.out.println(helper.getDataXml());??
  17. ????}??
  18. }??

? 构造柱图的xml

[java] view plain copy print ?
  1. package?com.shine.framework.Charts.cofferCharts.ColumnsCharts;??
  2. ??
  3. import?com.shine.framework.Charts.cofferCharts.LineCharts.Line;??
  4. import?com.shine.framework.Charts.cofferCharts.LineCharts.LineChartsHelper;??
  5. ??
  6. public?class?ColumnsChartsExample?{??
  7. ??
  8. ????/**?
  9. ?????*?柱图例子?
  10. ?????*??
  11. ?????*?@param?args?
  12. ?????*/??
  13. ????public?static?void?main(String[]?args)?{??
  14. ????????Colunms?colunms?=?new?Colunms("colunms1",?"0x00ffff");??
  15. ????????colunms.put("1",?100);??
  16. ????????colunms.put("2",?300);??
  17. ????????colunms.put("3",?100);??
  18. ??
  19. ????????Colunms?colunms1?=?new?Colunms("colunms2",?"0xffff00");??
  20. ????????colunms1.put("1",?200);??
  21. ????????colunms1.put("3",?500);??
  22. ??
  23. ????????ColumnsChartsHelper?helper?=?new?ColumnsChartsHelper();??
  24. ????????helper.addAix("1",?"3");??
  25. ????????helper.addColunms(colunms);??
  26. ????????helper.addColunms(colunms1);??
  27. ??
  28. ????????System.out.println(helper.getDataXml());??
  29. ??
  30. ????}??
  31. ??
  32. }??

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读