List of usage examples for org.jfree.chart.plot XYPlot setRangeCrosshairVisible
public void setRangeCrosshairVisible(boolean flag)
From source file:com.ace.capitalflows.ui.frame.chart.NianYdChart.java
/** * Creates a chart.//from w w w . j a v a2 s.co m * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("ZhongGuoGuoJiShouZhiPingHeBiao(NianDuCeSuan)", // title "NianYd", // x-axis label "YiMeiYuan", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM")); return chart; }
From source file:com.ace.capitalflows.ui.frame.chart.NianJdChart.java
/** * Creates a chart./*from w ww. j a v a2 s .c o m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(final XYDataset dataset) { final JFreeChart chart = ChartFactory.createTimeSeriesChart("ZhongGuoGuoJiShouZhiPingHeBiao(NianDuCeSuan)", // title "NianJd", // x-axis label "YiMeiYuan", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); final XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { final XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } final DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("yyyy-MM")); return chart; }
From source file:bullioneconomy.bullionchart.java
/** * Creates a chart./*from ww w . j a v a2 s .c o m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Gold Price in Recent Years", // title "Date", // x-axis label "Price Per 10g", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; //renderer.setDefaultShapesVisible(true); //renderer.setDefaultShapesFilled(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:st.jigasoft.dbutil.util.ReportTheme.java
public static void crescentTheme(JFreeChart chart, String... lineNames) { XYPlot plot = (XYPlot) chart.getPlot(); chart.setBackgroundPaint(Color.white); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; //renderer.setBaseShapesVisible(true); renderer.setStroke(new BasicStroke(3)); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); }/* w w w .j av a 2 s.c o m*/ DateAxis axis = (DateAxis) plot.getDomainAxis(); /* chart.setBackgroundPaint(new GradientPaint(new Point(0, 0), Color.decode("#121E31"), new Point(400, 200), Color.DARK_GRAY)); plot.setBackgroundPaint(null); //plot.setInteriorGap(0.04); plot.setOutlineVisible(false); int iCount = 0; // use gradients and white borders for the section colours for(Object s : lineNames) { // plot.setDomainGridlinePaint(new PrintColorUIResource(25, Color.CYAN)));//s.toString(), createGradientPaint(new Color(200, 200, 255), colorItems(iCount ++))); if(iCount == MAX_COLUNS_COLOR) iCount = 0; } // // add a subtitle giving the data source TextTitle source = new TextTitle("Source: http://www.bbc.co.uk/news/business-15489523", new Font("Courier New", Font.PLAIN, 12)); source.setPaint(Color.WHITE); source.setPosition(RectangleEdge.BOTTOM); source.setHorizontalAlignment(HorizontalAlignment.RIGHT); chart.addSubtitle(source); */ }
From source file:TimeSeriesChartDemo1.java
/** * Creates a chart./*from w ww . j a v a 2 s.c om*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("Legal & General Unit Trust Prices", // title "Date", // x-axis label "Price Per Unit", // y-axis label dataset, // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); } DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); return chart; }
From source file:eu.kprod.gui.chart.MwChartFactory.java
public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) { final JFreeChart chart; chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true); chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); chart.setBorderVisible(false);//from ww w . ja va 2s . c o m final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS")); axis.setAxisLineVisible(false); axis.setTickLabelsVisible(false); axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // force integer display final ValueAxis va = plot.getRangeAxis(); va.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // va.setRange(-280,280); // va.setFixedAutoRange(560); // va.setLowerBound(-280); // va.setUpperBound(280); // va.setAutoRange(false); va.setRangeWithMargins(-280, 280); final MwChartPanel chartPanel = new MwChartPanel(chart, conf); chartPanel.setMouseWheelEnabled(false); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); return chartPanel; }
From source file:org.multiwii.swingui.gui.chart.MwChartFactory.java
public static MwChartPanel createChart(MwConfiguration conf, final XYDataset xyDataset) { final JFreeChart chart; chart = ChartFactory.createTimeSeriesChart(null, null, null, xyDataset, false, true, true); chart.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); chart.setBorderVisible(false);//from w w w . j a va2 s . co m final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(conf.color.getColor(MwColor.BACKGROUND_COLOR)); plot.setDomainGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setRangeGridlinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); final DateAxis axis = (DateAxis) plot.getDomainAxis(); // axis.setDateFormatOverride(new SimpleDateFormat("mm''ss''''SSS")); axis.setAxisLineVisible(false); axis.setTickLabelsVisible(false); axis.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // force integer display final ValueAxis va = plot.getRangeAxis(); va.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); va.setLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setAxisLinePaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); va.setTickLabelPaint(conf.color.getColor(MwColor.FORGROUND_COLOR)); // va.setRange(-280,280); // va.setFixedAutoRange(560); // va.setLowerBound(-280); // va.setUpperBound(280); // va.setAutoRange(false); va.setRangeWithMargins(-280, 280); final MwChartPanel chartPanel = new MwChartPanel(chart, conf); chartPanel.setMouseWheelEnabled(false); chartPanel.setDomainZoomable(false); chartPanel.setRangeZoomable(false); return chartPanel; }
From source file:org.hxzon.demo.jfreechart.DatasetVisibleDemo.java
private static JFreeChart createTimeSeriesChart(XYDataset dataset) { //DomainAxis//w w w . j a v a2 s. co m DateAxis timeAxis = new DateAxis(""); timeAxis.setLowerMargin(0.02); // reduce the default margins timeAxis.setUpperMargin(0.02); timeAxis.setDateFormatOverride(new SimpleDateFormat("MM-yyyy")); //RangeAxis NumberAxis valueAxis = new NumberAxis(""); valueAxis.setAutoRangeIncludesZero(false); // override default // valueAxis.setAutoRange(false); // valueAxis.setDefaultAutoRange(new Range(100, 1150)); //Renderer XYToolTipGenerator toolTipGenerator = StandardXYToolTipGenerator.getTimeSeriesInstance(); XYURLGenerator urlGenerator = null; // urlGenerator = new StandardXYURLGenerator(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, false); renderer.setBaseToolTipGenerator(toolTipGenerator); renderer.setURLGenerator(urlGenerator); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); renderer.setDrawSeriesLineAsPath(true); //Plot XYPlot plot = new XYPlot(dataset, timeAxis, valueAxis, null); plot.setRenderer(renderer); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); // plot.setRangePannable(true); //chart JFreeChart chart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); chart.setBackgroundPaint(Color.white); return chart; }
From source file:com.orsonpdf.demo.PDFTimeSeriesChartDemo1.java
/** * Creates a chart./*from ww w .java 2s . c om*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", null, "US cents/lb", dataset, true, false, false); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setRangeGridlinePaint(Color.red); plot.setDomainGridlinePaint(Color.red); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setBaseStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }
From source file:org.jfree.graphics2d.demo.SVGTimeSeriesChartDemo1.java
/** * Creates a chart./*from w ww . j a v a2 s .c o m*/ * * @param dataset a dataset. * * @return A chart. */ private static JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createTimeSeriesChart("International Coffee Organisation : Coffee Prices", null, "US cents/lb", dataset); String fontName = "Palatino"; chart.getTitle().setFont(new Font(fontName, Font.BOLD, 18)); chart.addSubtitle(new TextTitle("Source: http://www.ico.org/historical/2010-19/PDF/HIST-PRICES.pdf", new Font(fontName, Font.PLAIN, 14))); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true); plot.setRangePannable(false); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getDomainAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.getRangeAxis().setLabelFont(new Font(fontName, Font.BOLD, 14)); plot.getRangeAxis().setTickLabelFont(new Font(fontName, Font.PLAIN, 12)); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); chart.getLegend().setItemFont(new Font(fontName, Font.PLAIN, 14)); chart.getLegend().setFrame(BlockBorder.NONE); chart.getLegend().setHorizontalAlignment(HorizontalAlignment.CENTER); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(false); renderer.setDrawSeriesLineAsPath(true); // set the default stroke for all series renderer.setAutoPopulateSeriesStroke(false); renderer.setDefaultStroke(new BasicStroke(3.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL), false); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesPaint(1, new Color(24, 123, 58)); renderer.setSeriesPaint(2, new Color(149, 201, 136)); renderer.setSeriesPaint(3, new Color(1, 62, 29)); renderer.setSeriesPaint(4, new Color(81, 176, 86)); renderer.setSeriesPaint(5, new Color(0, 55, 122)); renderer.setSeriesPaint(6, new Color(0, 92, 165)); } return chart; }