private static JFreeChart createChart(XYDataset xydataset) { JFreeChart jfreechart = ChartFactory.createTimeSeriesChart( "Legal & General Unit Trust Prices", "Date", "Price Per Unit", xydataset, true, true, false); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); org.jfree.chart.renderer.xy.XYItemRenderer xyitemrenderer = xyplot.getRenderer(); if (xyitemrenderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer xylineandshaperenderer = (XYLineAndShapeRenderer) xyitemrenderer; xylineandshaperenderer.setBaseShapesVisible(true); xylineandshaperenderer.setBaseShapesFilled(true); xylineandshaperenderer.setBaseItemLabelsVisible(true); } PeriodAxis periodaxis = new PeriodAxis("Date"); periodaxis.setTimeZone(TimeZone.getTimeZone("Pacific/Auckland")); periodaxis.setAutoRangeTimePeriodClass(org.jfree.data.time.Day.class); PeriodAxisLabelInfo aperiodaxislabelinfo[] = new PeriodAxisLabelInfo[3]; aperiodaxislabelinfo[0] = new PeriodAxisLabelInfo(org.jfree.data.time.Day.class, new SimpleDateFormat("d")); aperiodaxislabelinfo[1] = new PeriodAxisLabelInfo( org.jfree.data.time.Month.class, new SimpleDateFormat("MMM"), new RectangleInsets(2D, 2D, 2D, 2D), new Font("SansSerif", 1, 10), Color.blue, false, new BasicStroke(0.0F), Color.lightGray); aperiodaxislabelinfo[2] = new PeriodAxisLabelInfo(org.jfree.data.time.Year.class, new SimpleDateFormat("yyyy")); periodaxis.setLabelInfo(aperiodaxislabelinfo); xyplot.setDomainAxis(periodaxis); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
private static JFreeChart createChart(IntervalXYDataset paramIntervalXYDataset) { JFreeChart localJFreeChart = ChartFactory.createXYBarChart( "Maximum Temperature", "Day", true, "Temperature", paramIntervalXYDataset, PlotOrientation.VERTICAL, true, true, false); XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot(); localXYPlot.setDomainCrosshairVisible(true); localXYPlot.setRangeCrosshairVisible(true); PeriodAxis localPeriodAxis = new PeriodAxis("Day"); localPeriodAxis.setAutoRangeTimePeriodClass(Day.class); PeriodAxisLabelInfo[] arrayOfPeriodAxisLabelInfo = new PeriodAxisLabelInfo[3]; arrayOfPeriodAxisLabelInfo[0] = new PeriodAxisLabelInfo(Day.class, new SimpleDateFormat("d")); arrayOfPeriodAxisLabelInfo[1] = new PeriodAxisLabelInfo( Day.class, new SimpleDateFormat("E"), new RectangleInsets(2.0D, 2.0D, 2.0D, 2.0D), new Font("SansSerif", 1, 10), Color.blue, false, new BasicStroke(0.0F), Color.lightGray); arrayOfPeriodAxisLabelInfo[2] = new PeriodAxisLabelInfo(Month.class, new SimpleDateFormat("MMM")); localPeriodAxis.setLabelInfo(arrayOfPeriodAxisLabelInfo); localXYPlot.setDomainAxis(localPeriodAxis); ChartUtilities.applyCurrentTheme(localJFreeChart); return localJFreeChart; }