大家帮忙看看这个java程序吧,柱状图可以实现,下面的两个饼状图实现不了,谢谢了 10
packagegui;importjava.util.Calendar;importjava.util.Vector;importorg.jfree.chart.Char...
package gui;
import java.util.Calendar;
import java.util.Vector;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
/**
*
* @author s
*/
class IWalletChartFactory {
public IWalletChartFactory() {
}
JFreeChart createChart(int selectedIndex) {
if (selectedIndex == 0)
{
return createMonthlyBarChart();
}
else if (selectedIndex == 1)
{
return createIncomePieChart();
}
else if (selectedIndex == 2)
{
return createOutgoPieChart();
}
else
return null;
}
private JFreeChart createIncomePieChart() {
PieDataset dataset = getIncomePieDataSet();
JFreeChart chart = ChartFactory.createPieChart3D(
"收入来源组成图", // chart title
dataset,// data
true,// include legend
true,
false
);
return chart;
}
private JFreeChart createOutgoPieChart() {
PieDataset dataset = getOutgoPieDataSet();
JFreeChart chart = ChartFactory.createPieChart3D(
"支出原因组成图", // chart title
dataset,// data
true,// include legend
true,
false
);
return chart;
}
private PieDataset getOutgoPieDataSet() {
DefaultPieDataset dataset = new DefaultPieDataset();
Vector<Double> typeOutgo =
IWalletApp.getApplication().getIChart().getTypeOutgo();
Vector<String> typeOutgoName =
IWalletApp.getApplication().getIChart().getTypeOutgoName();
int i = 0;
for (Double money : typeOutgo)
{
dataset.setValue(typeOutgoName.elementAt(i), money);
i++;
}
return dataset;
}
private PieDataset getIncomePieDataSet() {
DefaultPieDataset dataset = new DefaultPieDataset();
Vector<Double> typeIncome =
IWalletApp.getApplication().getIChart().getTypeIncome();
Vector<String> typeIncomeName =
IWalletApp.getApplication().getIChart().getTypeIncomeName();
int i = 0;
for (Double money : typeIncome)
{
dataset.setValue(typeIncomeName.elementAt(i), money);
i++;
}
return dataset;
}
} 展开
import java.util.Calendar;
import java.util.Vector;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.CategoryDataset;
import org.jfree.data.general.DatasetUtilities;
import org.jfree.data.general.DefaultPieDataset;
import org.jfree.data.general.PieDataset;
/**
*
* @author s
*/
class IWalletChartFactory {
public IWalletChartFactory() {
}
JFreeChart createChart(int selectedIndex) {
if (selectedIndex == 0)
{
return createMonthlyBarChart();
}
else if (selectedIndex == 1)
{
return createIncomePieChart();
}
else if (selectedIndex == 2)
{
return createOutgoPieChart();
}
else
return null;
}
private JFreeChart createIncomePieChart() {
PieDataset dataset = getIncomePieDataSet();
JFreeChart chart = ChartFactory.createPieChart3D(
"收入来源组成图", // chart title
dataset,// data
true,// include legend
true,
false
);
return chart;
}
private JFreeChart createOutgoPieChart() {
PieDataset dataset = getOutgoPieDataSet();
JFreeChart chart = ChartFactory.createPieChart3D(
"支出原因组成图", // chart title
dataset,// data
true,// include legend
true,
false
);
return chart;
}
private PieDataset getOutgoPieDataSet() {
DefaultPieDataset dataset = new DefaultPieDataset();
Vector<Double> typeOutgo =
IWalletApp.getApplication().getIChart().getTypeOutgo();
Vector<String> typeOutgoName =
IWalletApp.getApplication().getIChart().getTypeOutgoName();
int i = 0;
for (Double money : typeOutgo)
{
dataset.setValue(typeOutgoName.elementAt(i), money);
i++;
}
return dataset;
}
private PieDataset getIncomePieDataSet() {
DefaultPieDataset dataset = new DefaultPieDataset();
Vector<Double> typeIncome =
IWalletApp.getApplication().getIChart().getTypeIncome();
Vector<String> typeIncomeName =
IWalletApp.getApplication().getIChart().getTypeIncomeName();
int i = 0;
for (Double money : typeIncome)
{
dataset.setValue(typeIncomeName.elementAt(i), money);
i++;
}
return dataset;
}
} 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询