List of usage examples for org.jfree.chart.axis DateTickMarkPosition MIDDLE
DateTickMarkPosition MIDDLE
To view the source code for org.jfree.chart.axis DateTickMarkPosition MIDDLE.
Click Source Link
From source file:org.jfree.chart.demo.HighLowChartDemo1.java
private static JFreeChart createChart(OHLCDataset ohlcdataset) { JFreeChart jfreechart = ChartFactory.createHighLowChart("High-Low-Open-Close Demo", "Time", "Value", ohlcdataset, true);// w w w . j ava 2 s. c om XYPlot xyplot = (XYPlot) jfreechart.getPlot(); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); return jfreechart; }
From source file:org.jfree.chart.demo.OverlaidXYPlotDemo1.java
private static JFreeChart createChart() { IntervalXYDataset dataset1 = createDataset1(); XYBarRenderer renderer1 = new XYBarRenderer(0.20000000000000001D); renderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); DateAxis domainAxis = new DateAxis("Date"); domainAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); NumberAxis valueAxis = new NumberAxis("Value"); XYPlot plot = new XYPlot(dataset1, domainAxis, valueAxis, renderer1); XYDataset dataset2 = createDataset2(); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0}: ({1}, {2})", new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0.00"))); plot.setDataset(1, dataset2);/*from w w w. j a v a2 s .com*/ plot.setRenderer(1, renderer2); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); return new JFreeChart("Overlaid XYPlot Demo 1", JFreeChart.DEFAULT_TITLE_FONT, plot, true); }
From source file:org.jfree.chart.demo.CompareToPreviousYearDemo.java
private static JFreeChart createChart() { XYDataset xydataset = createDataset2006(); XYDataset xydataset1 = createDataset2007(); DateAxis dateaxis = new DateAxis("Date"); Month month = new Month(1, 2007); Month month1 = new Month(12, 2007); dateaxis.setRange(month.getFirstMillisecond(), month1.getLastMillisecond()); dateaxis.setDateFormatOverride(new SimpleDateFormat("MMM")); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(); xylineandshaperenderer.setUseFillPaint(true); xylineandshaperenderer.setBaseFillPaint(Color.white); xylineandshaperenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{1}: {2}", new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.00"))); XYPlot xyplot = new XYPlot(xydataset1, dateaxis, new NumberAxis("Sales"), xylineandshaperenderer); xyplot.setDomainPannable(true);//from www . j av a2s. c o m xyplot.setRangePannable(true); DateAxis dateaxis1 = new DateAxis(); dateaxis1.setVisible(false); xyplot.setDomainAxis(1, dateaxis1); xyplot.setDataset(1, xydataset); xyplot.mapDatasetToDomainAxis(1, 1); XYLineAndShapeRenderer xylineandshaperenderer1 = new XYLineAndShapeRenderer(); xylineandshaperenderer1.setSeriesPaint(0, Color.blue); xylineandshaperenderer1.setUseFillPaint(true); xylineandshaperenderer1.setBaseFillPaint(Color.white); xylineandshaperenderer1.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{1}: {2}", new SimpleDateFormat("MMM-yyyy"), new DecimalFormat("0.00"))); xyplot.setRenderer(1, xylineandshaperenderer1); JFreeChart jfreechart = new JFreeChart("Sales Comparison Chart", xyplot); xyplot.setDomainCrosshairVisible(true); xyplot.setRangeCrosshairVisible(true); DateAxis dateaxis2 = (DateAxis) xyplot.getDomainAxis(); dateaxis2.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:org.jfree.chart.demo.StackedXYBarChartDemo3.java
private static JFreeChart createChart(TableXYDataset tablexydataset) { DateAxis dateaxis = new DateAxis("Year"); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D);//from w ww.ja v a 2 s.c o m dateaxis.setUpperMargin(0.01D); NumberAxis numberaxis = new NumberAxis("Tonnes"); numberaxis.setNumberFormatOverride(new DecimalFormat("0.0%")); StackedXYBarRenderer stackedxybarrenderer = new StackedXYBarRenderer(0.29999999999999999D); stackedxybarrenderer.setRenderAsPercentages(true); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, new Color(64, 0, 0), 0.0F, 0.0F, Color.red); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, new Color(0, 64, 0), 0.0F, 0.0F, Color.green); stackedxybarrenderer.setSeriesPaint(0, gradientpaint); stackedxybarrenderer.setSeriesPaint(1, gradientpaint1); stackedxybarrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.HORIZONTAL)); stackedxybarrenderer.setDrawBarOutline(false); stackedxybarrenderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator("{0} : {1} = {2} tonnes", new SimpleDateFormat("yyyy"), new DecimalFormat("#,##0"))); XYPlot xyplot = new XYPlot(tablexydataset, dateaxis, numberaxis, stackedxybarrenderer); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); JFreeChart jfreechart = new JFreeChart("Waste Management", xyplot); jfreechart.setBackgroundPaint(Color.white); jfreechart.addSubtitle(new TextTitle("St Albans City and District Council")); return jfreechart; }
From source file:org.jfree.chart.demo.XYBarChartDemo1.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("State Executions - USA", "Year", true, "Number of People", intervalxydataset, PlotOrientation.VERTICAL, true, false, false); jfreechart.addSubtitle(new TextTitle("Source: http://www.amnestyusa.org/abolish/listbyyear.do", new Font("Dialog", 2, 10))); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); xyitemrenderer.setBaseToolTipGenerator(standardxytooltipgenerator); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D);/*from w w w . j a v a2 s .co m*/ dateaxis.setUpperMargin(0.01D); return jfreechart; }
From source file:com.xpn.xwiki.plugin.charts.params.DateTickMarkPositionChartParam.java
@Override protected void init() { addChoice("start", DateTickMarkPosition.START); addChoice("middle", DateTickMarkPosition.MIDDLE); addChoice("end", DateTickMarkPosition.END); }
From source file:org.jfree.chart.demo.XYBarChartDemo5.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("US Budget Deficit", "Year", true, "$ Billion", intervalxydataset, PlotOrientation.VERTICAL, false, false, false); TextTitle texttitle = new TextTitle("Source: http://www.cbo.gov/showdoc.cfm?index=1821&sequence=0#table12"); texttitle.setFont(new Font("Dialog", 0, 8)); texttitle.setPosition(RectangleEdge.BOTTOM); texttitle.setHorizontalAlignment(HorizontalAlignment.RIGHT); jfreechart.addSubtitle(texttitle);//ww w. jav a2 s . c om jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = (XYPlot) jfreechart.getPlot(); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); xyitemrenderer.setBaseToolTipGenerator(standardxytooltipgenerator); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D); dateaxis.setUpperMargin(0.01D); return jfreechart; }
From source file:Operacional.Janela2.java
private static JFreeChart createChart(IntervalXYDataset intervalxydataset) { JFreeChart jfreechart = ChartFactory.createXYBarChart("Dados Parquimetro", "Mes", true, "Dados", intervalxydataset, PlotOrientation.VERTICAL, true, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = jfreechart.getXYPlot(); XYItemRenderer xyitemrenderer = xyplot.getRenderer(); StandardXYToolTipGenerator standardxytooltipgenerator = new StandardXYToolTipGenerator("{1} = {2}", new SimpleDateFormat("yyyy"), new DecimalFormat("0")); //xyitemrenderer.setToolTipGenerator(standardxytooltipgenerator); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setRangeGridlinePaint(Color.white); DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis(); dateaxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); dateaxis.setLowerMargin(0.01D);//from w w w .j a v a2 s . c o m dateaxis.setUpperMargin(0.01D); return jfreechart; }
From source file:jamel.gui.charts.TimeChart.java
/** * Returns a new time plot.//from w w w . ja v a 2s . co m * @param timeSeries the time series. * @param valueAxisLabel the value axis label. * @return a new time plot. */ private static Plot newTimePlot(TimeSeries[] timeSeries, String valueAxisLabel) { final TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.setXPosition(TimePeriodAnchor.MIDDLE); for (int i = 0; i < timeSeries.length; i++) { TimeSeries series = timeSeries[i]; if (series == null) throw new RuntimeException(); dataset.addSeries(series); } final XYPlot plot = new XYPlot(dataset, new DateAxis(), new NumberAxis(valueAxisLabel), new XYLineAndShapeRenderer(true, false)); ((DateAxis) plot.getDomainAxis()).setAutoRange(false); ((DateAxis) plot.getDomainAxis()).setTickMarkPosition(DateTickMarkPosition.MIDDLE); plot.setDomainGridlinesVisible(false); return plot; }
From source file:com.charts.IntradayChart.java
public IntradayChart(YStockQuote currentStock) { TimeSeries series = new TimeSeries(currentStock.get_name()); ArrayList<String> fiveDayData = currentStock.get_one_day_data(); int length = fiveDayData.size(); for (int i = 17; i < length; i++) { String[] data = fiveDayData.get(i).split(","); Date time = new Date((long) Integer.parseInt(data[0]) * 1000); DateFormat df = new SimpleDateFormat("MM-dd-yyyy-h-m"); series.addOrUpdate(new Minute(time), Double.parseDouble(data[1])); }//from w w w. j a va2s . c o m TimeSeriesCollection dataset = new TimeSeriesCollection(); dataset.addSeries(series); JFreeChart chart = ChartFactory.createTimeSeriesChart( currentStock.get_name() + "(" + currentStock.get_symbol() + ")" + " Intraday", "Date", "Price", dataset, true, true, false); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); ValueAxis yAxis = (ValueAxis) plot.getRangeAxis(); DateAxis xAxis = (DateAxis) plot.getDomainAxis(); xAxis.setTimeline(SegmentedTimeline.newMondayThroughFridayTimeline()); xAxis.setDateFormatOverride(new SimpleDateFormat("h:m a")); xAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE); //xAxis.setVerticalTickLabels(true); chartPanel = new ChartPanel(chart); chart.setBackgroundPaint(chartPanel.getBackground()); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); chartPanel.setVisible(true); chartPanel.revalidate(); chartPanel.repaint(); }