问题描述
- FusionCharts 用 Java代码实现多条曲线
-
// category集合 BaseChart chart = ChartFactory.getDefaultSYChart(" 预警指示图" + "2015年1月" + "至" + "2015年12月", "", "", ""); Categories categories = new Categories(); // chart.cgOtherProperties().put("useRoundEdges", "1");// // 除IE外其他浏览器不鸟这个东西 Background background = new Background(); background.setBgColor("FFFFFF"); chart.setBackground(background); Border border = new Border(); border.setShowBorder("0"); chart.setBorder(border); Canvas canvas = new Canvas(); canvas.setCanvasBorderThickness("0"); canvas.setCanvasBorderAlpha("30"); chart.setCanvas(canvas); chart.cgOtherProperties().put("useRoundEdges", "0");// firefox chart.cgOtherProperties().put("plotGradientColor", " "); if ("true".equals(shouye)) { Font font = new Font(); font.setBaseFontSize("12"); chart.setFont(font); } Collection allCategory = new ArrayList(); String label[] = new String[8]; label[0] = "1周"; label[1] = "3周"; label[2] = "5周"; label[3] = "7周"; label[4] = "9周"; label[5] = "11周"; label[6] = "13周"; label[7] = "15周"; for (int i = 0; i < 8; i++) { Category category = new Category(); category.setLabel(label[1]); allCategory.add(category); } categories.setAllCategory(allCategory); chart.setCategories(categories); String value[] = new String[8]; value[0] = "36"; value[1] = "16"; value[2] = "32"; value[3] = "16"; value[4] = "36"; value[5] = "16"; value[6] = "32"; value[7] = "16"; String value1[] = new String[8]; value1[0] = "26"; value1[1] = "16"; value1[2] = "32"; value1[3] = "38"; value1[4] = "36"; value1[5] = "16"; value1[6] = "32"; value1[7] = "16"; Collection<Set> tjSets = new ArrayList<Set>(); for (int j = 0; j < 8; j++) { Set set = new Set(); set.setLabel(label[j]); set.setValue(value[j]); tjSets.add(set); } Collection<Set> tjSets1 = new ArrayList<Set>(); for (int j = 0; j < 8; j++) { Set set = new Set(); set.setLabel(label[j]); set.setValue(value1[j]); tjSets1.add(set); } DataSet dataSet = new DataSet(); dataSet.setAllSet(tjSets); chart.cgAllSet().addAll(tjSets); DataSet dataSet1 = new DataSet(); dataSet.setAllSet(tjSets1); chart.cgAllSet().addAll(tjSets1); System.out.println(chart.generateXML()); request.setAttribute("xml", chart.generateXML()); request.setAttribute("swf", "Line"); request.setAttribute("isClientExp", "0"); request.setAttribute("method", "Execute2"); return mapping.findForward("view");
时间: 2024-10-24 19:04:22