public JFreeChart createChart ( CategoryDataset ds ) { final JFreeChart chart = ChartFactory . createLineChart ( null , // chart title null , // unused null , // range axis label ds , // data PlotOrientation . VERTICAL , // orientation true , // include legend true , // tooltips false // urls ) ; chart . setBackgroundPaint ( Color . white ) ; final CategoryPlot plot = chart . getCategoryPlot ( ) ; plot . setBackgroundPaint ( Color . WHITE ) ; plot . setOutlinePaint ( null ) ; plot . setRangeGridlinesVisible ( true ) ; plot . setRangeGridlinePaint ( Color . black ) ; final LineAndShapeRenderer renderer = ( LineAndShapeRenderer ) plot . getRenderer ( ) ; renderer . setBaseStroke ( new BasicStroke ( 3 ) ) ; configureRenderer ( renderer ) ; final CategoryAxis domainAxis = new NoOverlapCategoryAxis ( null ) ; plot . setDomainAxis ( domainAxis ) ; domainAxis . setCategoryLabelPositions ( CategoryLabelPositions . UP_90 ) ; domainAxis . setLowerMargin ( 0.0 ) ; domainAxis . setUpperMargin ( 0.0 ) ; domainAxis . setCategoryMargin ( 0.0 ) ; final NumberAxis rangeAxis = ( NumberAxis ) plot . getRangeAxis ( ) ; rangeAxis . setStandardTickUnits ( NumberAxis . createIntegerTickUnits ( ) ) ; // crop extra space around the graph plot . setInsets ( new RectangleInsets ( 0 , 0 , 0 , 5.0 ) ) ; return chart ; }
Creates a trend chart .