List of usage examples for org.jfree.chart ChartFactory createStackedXYAreaChart
public static JFreeChart createStackedXYAreaChart(String title, String xAxisLabel, String yAxisLabel, TableXYDataset dataset)
From source file:cachedataanalysis.FlowCache.java
public XYSeries exportReportChart() throws IOException { File outputHitRate = new File("report/" + name + "_" + policy + "_hitrate.txt"); FileWriter fw = new FileWriter(outputHitRate); XYSeries hitRateCount = new XYSeries(name + "(" + size + " entries)"); for (int i = 0; i < hitRateRecord.size(); i++) { hitRateCount.add(i, hitRateRecord.get(i)); fw.write(i + "," + hitRateRecord.get(i) + "\n"); fw.flush();//from w w w .j a va 2s . co m } fw.close(); XYSeriesCollection HitRateData = new XYSeriesCollection(); HitRateData.addSeries(hitRateCount); JFreeChart hitRateStat = ChartFactory.createXYLineChart( "Hit Rate variatoion throughout recording in " + name, "Seconds", "HitRate", HitRateData, PlotOrientation.VERTICAL, true, true, false); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitRate" + size + ".jpg"), hitRateStat, 1500, 900); //------------------------------- if (!fullReport) { return hitRateCount; } DefaultPieDataset hitProtoData = new DefaultPieDataset(); DefaultPieDataset missProtoData = new DefaultPieDataset(); CategoryTableXYDataset hitProtoDataRec = new CategoryTableXYDataset(); for (int i = 0; i < hitProtoRec.size(); i++) { if (i % 120 != 0) { continue; } HashMap<String, Integer> _map = hitProtoRec.get(i); for (String _str : _map.keySet()) { hitProtoDataRec.add(i, _map.get(_str), _str); } } CategoryTableXYDataset missProtoDataRec = new CategoryTableXYDataset(); for (int i = 0; i < missProtoRec.size(); i++) { if (i % 120 != 0) { continue; } HashMap<String, Integer> _map = missProtoRec.get(i); for (String _str : _map.keySet()) { missProtoDataRec.add(i, _map.get(_str), _str); } } XYSeries hitCountData = new XYSeries("Hit"); XYSeries allCountData = new XYSeries("All"); for (int i = 0; i < hitCount.size(); i++) { hitCountData.add(i, hitCount.get(i)); //hitRateCount.add(i,(float)hitCount.get(i)/(hitCount.get(i)+allCount.get(i))); } for (int i = 0; i < allCount.size(); i++) { allCountData.add(i, allCount.get(i)); } XYSeriesCollection CountStatData = new XYSeriesCollection(); CountStatData.addSeries(hitCountData); CountStatData.addSeries(allCountData); for (String protocol : hitProto.keySet()) { hitProtoData.setValue(protocol, hitProto.get(protocol)); } for (String protocol : missProto.keySet()) { missProtoData.setValue(protocol, missProto.get(protocol)); } JFreeChart hitStatRec = ChartFactory.createStackedXYAreaChart( "Hit Protocol Fraction throughout record in " + name, "Seconds", "Count", hitProtoDataRec); JFreeChart missStatRec = ChartFactory.createStackedXYAreaChart( "Miss Protocol Fraction throughout record in " + name, "Seconds", "Count", missProtoDataRec); JFreeChart hitStat = ChartFactory.createPieChart3D("Protocal Fraction of Hit Flows in " + name, hitProtoData, true, true, false); JFreeChart missStat = ChartFactory.createPieChart3D("Protocal Fraction of Miss Flows in " + name, missProtoData, true, true, false); JFreeChart countStat = ChartFactory.createXYAreaChart("Hit Count to All Packet lookup in " + name, "Seconds", "Count", CountStatData, PlotOrientation.VERTICAL, true, true, false); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitProto" + size + ".jpg"), hitStat, 1500, 900); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_missProto" + size + ".jpg"), missStat, 1500, 900); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitCount" + size + ".jpg"), countStat, 1500, 900); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_hitProtoRecord" + size + ".jpg"), hitStatRec, 1500, 900); ChartUtilities.saveChartAsJPEG(new File("report/" + name + "_missProtoRecord" + size + ".jpg"), missStatRec, 1500, 900); return hitRateCount; }