1 year ago
#374713
Manish
Error compiling ChartUtilities.saveChartAsJPEG()
I get this error:
ChartUtilities.saveChartAsJPEG(new File(path), chart, 300, 300);
The method saveChartAsJPEG(java.io.File, org.jfree.chart.JFreeChart, int, int) in the type ChartUtilities is not applicable for the arguments (org.apache.tomcat.jni.File, org.jfree.chart.JFreeChart, int, int)
Here is my code:
package com.manish.location.util;
import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import org.apache.tomcat.jni.File;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
public class ReportUtilImpl implements ReportUtil {
@SuppressWarnings("deprecation")
@Override
public void generatePieChart(String path, List<Object[]> data) {
DefaultPieDataset dataset= new DefaultPieDataset();
for(Object[] object:data) {
dataset.setValue(object[0].toString(), new Double(object[1].toString()));
}
JFreeChart chart = ChartFactory.createPieChart3D("Location Type Report", dataset);
try {
ChartUtilities.saveChartAsJPEG(new File(path), chart, 300, 300);
}
catch(IOException e) {
e.printStackTrace();
}
}
}
I am getting above error. Please fix it; it's about report utility program. I am using jfreechart API.
spring-boot
jfreechart
jfreereport
0 Answers
Your Answer