List of usage examples for org.jfree.chart.plot XYPlot setRangeGridlinePaint
public void setRangeGridlinePaint(Paint paint)
From source file:edu.memphis.ccrg.lida.framework.gui.panels.ActivationChartPanel.java
/** Creates new form JChartGuiPanel */ public ActivationChartPanel() { chart = ChartFactory.createXYLineChart("", "Tick", "Activation", dataset, PlotOrientation.VERTICAL, true, true, false);//w w w . jav a 2 s . c om chart.setBackgroundPaint(new Color(238, 233, 233)); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); initComponents(); }
From source file:eu.choreos.chart.XYChart.java
private JFreeChart createChart(XYDataset dataset, String chartTitle) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title "Execution size", // domain axis label "Range", // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/*from ww w . j a v a 2 s . c om*/ // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); domain.resizeRange(1.1); domain.setLowerBound(0.5); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); range.setUpperBound(range.getUpperBound() * 1.1); // render shapes and lines XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(true, true); plot.setRenderer(renderer); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // set the renderer's stroke Stroke stroke = new BasicStroke(3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); renderer.setBaseOutlineStroke(stroke); // label the points NumberFormat format = NumberFormat.getNumberInstance(); format.setMaximumFractionDigits(2); XYItemLabelGenerator generator = new StandardXYItemLabelGenerator( StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, format, format); renderer.setBaseItemLabelGenerator(generator); renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:flexflux.analyses.result.TDRFBAResult.java
public void plot() { JPanel panel = new JPanel(); JScrollPane sp = new JScrollPane(panel); panel.setLayout(new BoxLayout(panel, BoxLayout.PAGE_AXIS)); // one chart by entity Color[] colors = new Color[] { Color.RED, Color.GREEN, Color.BLUE }; int index = 0; for (String s : entities) { XYSeriesCollection dataset = new XYSeriesCollection(); XYSeries series = new XYSeries(s); for (Double time : times) { series.add(time, resultMap.get(time).get(s)); }/*from w w w.j a v a2 s .c o m*/ final JFreeChart chart = ChartFactory.createXYLineChart(s, // chart // title "Time (h)", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setRangeGridlinePaint(Color.GRAY); plot.setDomainGridlinePaint(Color.GRAY); plot.getRenderer().setSeriesPaint(0, colors[index % colors.length]); index++; ChartPanel chartPanel = new ChartPanel(chart); dataset.addSeries(series); panel.add(chartPanel); panel.add(new JSeparator()); } Dimension d = panel.getComponent(0).getPreferredSize(); d.height *= 2; sp.getViewport().setPreferredSize(d); JFrame frame = new JFrame("Time-dependant FBA results"); frame.add(sp); frame.pack(); RefineryUtilities.centerFrameOnScreen(frame); frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); frame.setVisible(true); }
From source file:fr.paris.lutece.plugins.form.utils.FormUtils.java
/** * create a JFreeChart Graph function of the statistic form submit * @param listStatistic the list of statistic of form submit * @param strLabelX the label of axis x/*from w ww . j a v a 2 s . c om*/ * @param strLableY the label of axis x * @param strTimesUnit the times unit of axis x(Day,Week,Month) * @return a JFreeChart Graph function of the statistic form submit */ public static JFreeChart createXYGraph(List<StatisticFormSubmit> listStatistic, String strLabelX, String strLableY, String strTimesUnit) { XYDataset xyDataset = createDataset(listStatistic, strTimesUnit); JFreeChart jfreechart = ChartFactory.createTimeSeriesChart(EMPTY_STRING, strLabelX, strLableY, xyDataset, false, false, false); jfreechart.setBackgroundPaint(Color.white); XYPlot xyplot = jfreechart.getXYPlot(); //xyplot.setBackgroundPaint(Color.gray); //xyplot.setRangeGridlinesVisible(true); xyplot.setBackgroundPaint(Color.white); xyplot.setBackgroundPaint(Color.lightGray); xyplot.setDomainGridlinePaint(Color.white); xyplot.setRangeGridlinePaint(Color.white); // DateAxis dateaxis = (DateAxis) xyplot.getDomainAxis( ); // dateaxis.setLowerMargin(0); // DateFormat formatter = new SimpleDateFormat("d-MMM-yyyy"); // dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY,7,formatter)); //dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY,7)); //dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.DAY,7)); //dateaxis.setMinimumDate((Date)listStatistic.get(0).getTimesUnit()); //dateaxis.setMaximumDate((Date)listStatistic.get(listStatistic.size()-1).getTimesUnit()); //dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH,1)); //dateaxis.setTickUnit(new DateTickUnit(1, 1, DateFormat.getDateInstance(DateFormat.SHORT, Locale.FRENCH))); //dateaxis.setTickUnit(new DateTickUnit(DateTickUnit.MONTH, 1, new SimpleDateFormat("MM/YY"))); //dateaxis.setVerticalTickLabels( true ); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setSeriesFillPaint(0, Color.RED); renderer.setUseFillPaint(true); // renderer.setToolTipGenerator( new StandardXYToolTipGenerator( "{0} {1} {2}", // DateFormat.getDateInstance( DateFormat.SHORT, Locale.FRENCH ), NumberFormat.getInstance( ) ) ); // // ChartRenderingInfo info = new ChartRenderingInfo( new StandardEntityCollection( ) ); return jfreechart; }
From source file:com.view.TimeSeriesChartView.java
public JFreeChart getVendorTimeSeriesChart(Excel theExcel, String vendor) { int vendorCode = Integer.parseInt(vendor); ArrayList<Receiving> theReceiving = theExcel.getSheetReceiving(); // HashMap<Month, Integer> item1Map = new HashMap<>(); // HashMap<Month, Integer> item2Map = new HashMap<>(); // HashMap<Month, Integer> item3Map = new HashMap<>(); Set vendorItem = new HashSet(); for (int i = 0; i < theReceiving.size(); i++) { vendorItem.add(theReceiving.get(i).getItem()); }//from ww w. ja v a 2 s. co m TimeSeries data[] = new TimeSeries[vendorItem.size()]; HashMap<Month, Integer> itemMap[] = new HashMap[vendorItem.size()]; for (int i = 0; i < vendorItem.size(); i++) { String itemName = "item" + i; data[i] = new TimeSeries(itemName); itemMap[i] = new HashMap<>(); } Calendar cal = Calendar.getInstance(); for (int i = 0; i < theReceiving.size(); i++) { cal.setTime(theReceiving.get(i).getDate()); int month = cal.get(Calendar.MONTH) + 1; int year = cal.get(Calendar.YEAR); int quantity = 0; if (theReceiving.get(i).getVendor() == vendorCode) { quantity = theReceiving.get(i).getQuantity(); Month theMonth = new Month(month, year); int itemNum = theReceiving.get(i).getItem() - 1; itemMap[itemNum].put(theMonth, updateItemMap(itemMap[itemNum], theMonth, quantity)); } } TimeSeriesCollection my_data_series = new TimeSeriesCollection(); for (int i = 0; i < vendorItem.size(); i++) { for (Map.Entry<Month, Integer> entry : itemMap[i].entrySet()) { data[i].add(entry.getKey(), entry.getValue()); } my_data_series.addSeries(data[i]); } JFreeChart chart = ChartFactory.createTimeSeriesChart("Receiving", "Month", "Quantity", my_data_series, true, true, false); chart.setBackgroundPaint(Color.YELLOW); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setDomainGridlinePaint(Color.GREEN); plot.setRangeGridlinePaint(Color.orange); plot.setAxisOffset(new RectangleInsets(50, 0, 20, 5)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MM.yyyy")); return chart; }
From source file:ruc.edu.window.DynamicDataDemo2.java
/** * Constructs a new demonstration application. * * @param title the frame title./*from ww w.j a va2 s. c o m*/ */ public DynamicDataDemo2(final String title) { super(title); this.series1 = new TimeSeries("Random 1"); this.series2 = new TimeSeries("Random 2"); final TimeSeriesCollection dataset1 = new TimeSeriesCollection(this.series1); final TimeSeriesCollection dataset2 = new TimeSeriesCollection(this.series2); final JFreeChart chart = ChartFactory.createTimeSeriesChart("Dynamic Data Demo 2", "Time", "Value", dataset1, true, true, false); chart.setBackgroundPaint(Color.white); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setDomainPannable(true); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 4, 4, 4, 4)); final ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); //axis.setAutoRangeMinimumSize(600000.0); axis.setFixedAutoRange(5000.0); // 60 seconds plot.setDataset(1, dataset2); //final NumberAxis rangeAxis2 = new NumberAxis("Range Axis 2"); /// rangeAxis2.setAutoRangeIncludesZero(false); plot.setRenderer(0, new DefaultXYItemRenderer()); plot.setRenderer(1, new DefaultXYItemRenderer()); //plot.setRangeAxis(1, rangeAxis2); plot.mapDatasetToRangeAxis(1, 0); plot.getRenderer().setSeriesPaint(0, new Color(91, 155, 213)); plot.getRenderer(1).setSeriesPaint(0, Color.BLUE); XYLineAndShapeRenderer render2 = new XYLineAndShapeRenderer() { Stroke soild = new BasicStroke(2.0f); Stroke dashed = new BasicStroke(10.0f, BasicStroke.CAP_BUTT, BasicStroke.JOIN_MITER, 10.0f, new float[] { 10.0f }, 0.0f); @Override public Stroke getItemStroke(int row, int column) { return dashed; } }; plot.setRenderer(1, render2); final JPanel content = new JPanel(new BorderLayout()); final ChartPanel chartPanel = new ChartPanel(chart); content.add(chartPanel); final JButton button1 = new JButton("Add To Series 1"); button1.setActionCommand("ADD_DATA_1"); button1.addActionListener(this); final JButton button2 = new JButton("Add To Series 2"); button2.setActionCommand("ADD_DATA_2"); button2.addActionListener(this); final JButton button3 = new JButton("Add To Both"); button3.setActionCommand("ADD_BOTH"); button3.addActionListener(this); final JPanel buttonPanel = new JPanel(new FlowLayout()); buttonPanel.add(button1); buttonPanel.add(button2); buttonPanel.add(button3); content.add(buttonPanel, BorderLayout.SOUTH); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(content); }
From source file:edu.ucla.stat.SOCR.chart.demo.XYAreaChartDemo1.java
/** * Creates a chart./* w w w.j av a 2 s .com*/ * * @param dataset the dataset. * * @return A chart. */ protected JFreeChart createChart(XYDataset dataset) { JFreeChart chart = ChartFactory.createXYAreaChart(chartTitle, "Domain (X)", "Range (Y)", dataset, PlotOrientation.VERTICAL, !legendPanelOn, // legend true, // tool tips false // URLs ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setForegroundAlpha(0.65f); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); ValueAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickMarkPaint(Color.black); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); ValueAxis rangeAxis = plot.getRangeAxis(); rangeAxis.setTickMarkPaint(Color.black); /* XYPointerAnnotation pointer = new XYPointerAnnotation( "Test", 5.0, -500.0, 3.0 * Math.PI / 4.0 ); pointer.setTipRadius(0.0); pointer.setBaseRadius(35.0); pointer.setFont(new Font("SansSerif", Font.PLAIN, 9)); pointer.setPaint(Color.blue); pointer.setTextAnchor(TextAnchor.HALF_ASCENT_RIGHT); plot.addAnnotation(pointer);*/ XYItemRenderer renderer = plot.getRenderer(); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); setXSummary(dataset); return chart; }
From source file:ui.FitnessGraph.java
/** * Creates a chart./*from w w w.j av a 2 s. c o m*/ * * @param dataset * the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createScatterPlot("Fitness v generation", // chart title "X", // x axis label "Y", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); // renderer.setSeriesShape(0, new Ellipse2D.Float(1.0f, 1.0f, 1.0f, // 1.0f)); renderer.setSeriesPaint(0, Color.RED); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesShapesVisible(0, false); // renderer.setSeriesStroke(1, new BasicStroke(0.01f)); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.CrosshairDemo3.java
protected JFreeChart createChart(XYDataset dataset) { JFreeChart c = ChartFactory.createTimeSeriesChart(chartTitle, // "Legal & General Unit Trust Prices", domainLabel, rangeLabel, // "Date", "Price Per Unit", dataset, !legendPanelOn, true, false); c.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) c.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 renderer = plot.getRenderer(); if (renderer instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer rr = (XYLineAndShapeRenderer) renderer; rr.setBaseShapesVisible(true);/*from w ww. ja va 2 s . c o m*/ rr.setBaseShapesFilled(true); } renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("MMM-yyyy")); //setXSummary(dataset) X is time; return c; }
From source file:domain.Grafica.java
public JFreeChart createChart(XYDataset dataset) { /*// w ww . jav a2s . c o m ///* NumberAxis numberaxis = new NumberAxis(""); numberaxis.setAutoRangeIncludesZero(false); DateAxis dateaxis = new DateAxis(""); NumberAxis numberaxis1 = new NumberAxis(""); numberaxis1.setAutoRangeIncludesZero(false); XYSplineRenderer xysplinerenderer = new XYSplineRenderer(); XYPlot xyplot = new XYPlot(dataset, dateaxis, numberaxis1, xysplinerenderer); // xyplot.setBackgroundPaint(new Color(238, 242, 250));// // xyplot.setDomainGridlinePaint(new Color(255, 255, 255)); // xyplot.setRangeGridlinePaint(new Color(238, 242, 250)); xyplot.getRenderer().setSeriesPaint(0, Color.RED); xyplot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) xyplot.getRenderer(); renderer.setSeriesShapesVisible(0, true);//FIXME Dots // xyplot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); JFreeChart jfreechart = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, xyplot, false); jfreechart.setBackgroundPaint(Color.white); DateAxis axis = (DateAxis) xyplot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy hh:mm:ss aa")); xyplot.getRangeAxis().setUpperBound(maxPeso * 1.25); xyplot.getRangeAxis().setLowerBound(minPeso * 0.75); cargarImagen(); // xyplot.setBackgroundImage(i); //jfreechart.setBackgroundImage(i); return jfreechart; */ JFreeChart chart = ChartFactory.createTimeSeriesChart("", // title "Fecha/Hora", // x-axis label "Pesos(Kg.)", // y-axis label dataset, // data false, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.GRAY); plot.setRangeGridlinePaint(Color.GRAY); /* plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); */ plot.setAxisOffset(new RectangleInsets(4D, 4D, 4D, 4D)); XYItemRenderer r = plot.getRenderer(); if (r instanceof XYLineAndShapeRenderer) { XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) r; renderer.setBaseShapesVisible(true); } NumberAxis range = (NumberAxis) plot.getRangeAxis(); // range.setAutoRangeIncludesZero(true); DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat("dd-MMM-yyyy hh:mm:ss")); plot.getRangeAxis().setUpperBound(maxPeso * 1.25); plot.getRangeAxis().setLowerBound(minPeso * 0.75); return chart; }