3
我使用以下代碼創建了使用jfree.chart.ChartFactory
的條形圖。我需要將Y軸的範圍設置爲0 - 100.如何設置最大值。如何設置使用ChartFactory.createBarChart創建的BarGraph的Y軸範圍
import java.io.File;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartUtilities;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.data.category.DefaultCategoryDataset;
public class BarGraph
{
public static void main(String[ ] args)throws Exception
{
final DefaultCategoryDataset dataset = new DefaultCategoryDataset();
dataset.addValue(10 , "FIAT" , "Speed");
dataset.addValue(30 , "AUDI", "Speed");
dataset.addValue(20 , "FORD", "Speed");
dataset.addValue(50 , "BMW", "Speed");
JFreeChart barChart = ChartFactory.createBarChart3D(
"CAR USAGE STATISTICS",
"Category", "Score",
dataset,PlotOrientation.VERTICAL,
true, true, false);
int width = 380; /* Width of the image 480*/
int height = 280; /* Height of the image 360*/
File BarChart = new File("../ELec/WebContent/img/BarChart.jpeg");
ChartUtilities.saveChartAsJPEG(BarChart , barChart , width , height );
}
}
這是我得到的輸出。我需要設置Y軸最大值爲100:對劇情的範圍軸
Thanku非常感謝它的工作:D – Nikhilesh