生成Data.xml 文件


private void BuildXMLDoc(Map<String, List<WebGameIncome>> map) throws IOException, JDOMException {

// 创建根节点 chart;
Element root = new Element("chart");

root.setAttribute("animation", "1");
root.setAttribute("showvalues", "0");
root.setAttribute("caption", "");
root.setAttribute("subcaption", "");
root.setAttribute("numberprefix", "");
root.setAttribute("chartrightmargin", "15");
root.setAttribute("xaxisname", "");
root.setAttribute("yaxisname", "");
root.setAttribute("pyaxisname", "");
root.setAttribute("canvasborderalpha", "0");
root.setAttribute("bgcolor", "FFFFFF");
root.setAttribute("bgratio", "0");
root.setAttribute("bgalpha", "50");
root.setAttribute("showalternatehgridcolor", "0");
root.setAttribute("numdivlines", "0");
root.setAttribute("showyaxisvalues", "0");
root.setAttribute("showlegend", "0");
root.setAttribute("chartleftmargin", "35");
root.setAttribute("charttopmargin", "25");
root.setAttribute("chartbottommargin", "35");
root.setAttribute("drawanchors", "0");
root.setAttribute("bordercolor", "970000");
root.setAttribute("borderalpha", "31");
root.setAttribute("stack100percent", "0");
root.setAttribute("linethickness", "3");
root.setAttribute("basefontsize", "12");
root.setAttribute("themename", "Custom");

// 根节点添加到文档中;
Document Doc = new Document(root);

Element category = new Element("categories");
Element dateSet1 = new Element("dataset");
dateSet1.setAttribute("seriesName", "kxd");
dateSet1.setAttribute("color_cc", "CE0000");
dateSet1.setAttribute("color", "CE0000");
Element dateSet2 = new Element("dataset");
dateSet2.setAttribute("seriesName", "income");
dateSet2.setAttribute("color_cc", "7F7F7F");
dateSet2.setAttribute("color", "7F7F7F");

for (Entry<String, List<WebGameIncome>> entry : map.entrySet()) {
List<WebGameIncome> value = entry.getValue();
if ((value.get(0) != null) && (value.get(0).getKxd() != 0)) {
category.addContent(new Element("category").setAttribute("label", entry.getKey()));
dateSet1.addContent(new Element("set").setAttribute("value", String.valueOf(value.get(0).getKxd())));
dateSet2.addContent(new Element("set").setAttribute("value", String.valueOf(value.get(0).getIncome())));
}
}

root.addContent(category);
root.addContent(dateSet1);
root.addContent(dateSet2);


XMLOutputter XMLOut = new XMLOutputter();

// 输出 Data.xml 文件;
XMLOut.output(Doc, new FileOutputStream(FileUtil.getXMLDataBasePath() + "/xmldata/Data.xml"));
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值