1
我爲Android使用了FreeFhart。原因是我在開始使用JFreeChart之前意識到這與Android不兼容。使用Android AFreeChart將折線圖保存爲png或jpeg文件
我找了一個aFreeChart替代下面的JFreeChart方法:
ChartUtilities.saveChartAsJPEG(lineChart, lineChartObject, width, height);
我的線圖結構的代碼如下:
DefaultCategoryDataset line_chart = new DefaultCategoryDataset();
line_chart.addValue(load[23], "load profile", "0");
line_chart.addValue(load[0], "load profile", "1");
line_chart.addValue(load[1], "load profile", "2");
line_chart.addValue(load[2], "load profile", "3");
line_chart.addValue(load[3], "load profile", "4");
line_chart.addValue(load[4], "load profile", "5");
line_chart.addValue(load[5], "load profile", "6");
line_chart.addValue(load[6], "load profile", "7");
line_chart.addValue(load[7], "load profile", "8");
line_chart.addValue(load[8], "load profile", "9");
line_chart.addValue(load[9], "load profile", "10");
line_chart.addValue(load[10], "load profile", "11");
line_chart.addValue(load[11], "load profile", "12");
line_chart.addValue(load[12], "load profile", "13");
line_chart.addValue(load[13], "load profile", "14");
line_chart.addValue(load[14], "load profile", "15");
line_chart.addValue(load[15], "load profile", "16");
line_chart.addValue(load[16], "load profile", "17");
line_chart.addValue(load[17], "load profile", "18");
line_chart.addValue(load[18], "load profile", "19");
line_chart.addValue(load[19], "load profile", "20");
line_chart.addValue(load[20], "load profile", "21");
line_chart.addValue(load[21], "load profile", "22");
line_chart.addValue(load[22], "load profile", "23");
AFreeChart chart = ChartFactory.createLineChart(
"Load Profile over 24hrs", // Title
"Time (Hrs)", // x-axis Label
"Power (kVA)", // y-axis Label
line_chart, // Dataset
PlotOrientation.VERTICAL, // Plot Orientation
true, // Show Legend
true, // Use tooltips
false // Configure chart to generate URLs?
);
的如何將這個保存到任何想法一個jpg/jpeg/png文件將非常有幫助!我需要保存爲圖像文件,因爲我需要在稍後的階段將其嵌入到pdf中。
在此先感謝!