List of usage examples for org.jfree.chart.plot XYPlot setRangeAxis
public void setRangeAxis(int index, ValueAxis axis)
From source file:se.six.jmeter.visualizer.statagg.StatAggVisualizer.java
private JFreeChart createChart() { setupDatasets();//ww w. ja va 2s .c o m final JFreeChart chart = ChartFactory.createTimeSeriesChart(null, "Time", "ThroughPut", _dataSet1, true, true, false); final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); ValueAxis axis = plot.getDomainAxis(); axis.setAutoRange(true); //axis.setFixedAutoRange(12 * 3600 * 1000); // 12 Hours XYItemRenderer renderer1 = plot.getRenderer(); renderer1.setSeriesPaint(0, Color.BLACK); final NumberAxis axis2 = new NumberAxis("Response Time"); axis2.setAutoRangeIncludesZero(false); plot.setRangeAxis(1, axis2); plot.setDataset(1, _dataSet2); plot.mapDatasetToRangeAxis(1, 1); StandardXYItemRenderer renderer2 = new StandardXYItemRenderer(); renderer2.setSeriesPaint(0, new Color(0, 153, 255)); plot.setRenderer(1, renderer2); chart.setBackgroundPaint(Color.white); return chart; }
From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
private void addSeries(Series<?> series) { Unit unit = series.getUnit();/*from w w w .j a v a 2 s . co m*/ XYPlot plot = chart.getXYPlot(); Integer datasetIndex = datasetMapping.get(unit); TimeSeriesCollection col; if (datasetIndex == null) { col = new TimeSeriesCollection(); int nextIndex = getNextDatasetIndex(plot); datasetMapping.put(unit, nextIndex); plot.setDataset(nextIndex, col); plot.setRenderer(nextIndex, new XYLineAndShapeRenderer(true, false)); NumberAxis axis = new AutoNumberAxis(unit); plot.setRangeAxis(nextIndex, axis); plot.mapDatasetToRangeAxis(nextIndex, nextIndex); seriesMapping.put(unit, new ArrayList<String>()); } else { col = (TimeSeriesCollection) plot.getDataset(datasetIndex); } TimeSeries ts = new SeriesWrapper(series, sampler); seriesMapping.get(unit).add(series.getKey()); col.addSeries(ts); setColor(series.getKey(), palette.allocate()); }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getDailyIntegratedStats(Session s) throws CloneNotSupportedException { JFreeChart chart;/*from ww w . jav a 2 s. co m*/ List<DailyStatsModel> stats = (new SafeHibList<DailyStatsModel>( s.createQuery("select ds from DailyStatsModel as ds where day<? and day>=? order by day desc") .setDate(0, new Date()).setDate(1, GraphServlet.getStartDate()))).list(); TimeSeriesCollection theData = new TimeSeriesCollection(); TimeSeriesCollection theData2 = new TimeSeriesCollection(); TimeSeries users = new TimeSeries("Total Users", Day.class); theData.addSeries(users); TimeSeries regulars = new TimeSeries("Regular Members", Day.class); theData2.addSeries(regulars); int numUsers = Helpers.getGroup("Org").getNumMembers(); int numReg = Helpers.getGroup("Regular").getNumMembers(); for (DailyStatsModel ds : stats) { Day theDay = new Day(ds.getDay()); users.add(theDay, numUsers); regulars.add(theDay, numReg); numUsers -= (ds.getMailinglistsignups() + ds.getSignups() - ds.getDeletions()); numReg -= (ds.getRegupgrades() - ds.getRegdowngrades()); } chart = ChartFactory.createTimeSeriesChart("Membership", "Day", "Users", theData, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis2 = new NumberAxis("Regular Members"); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, MovingAverage.createMovingAverage(theData2, "", 14, 0)); plot.mapDatasetToRangeAxis(1, 1); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(0); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer = (XYLineAndShapeRenderer) renderer.clone(); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); plot.setRenderer(1, renderer); return chart; }
From source file:ca.myewb.frame.servlet.GraphServlet.java
private JFreeChart getLastLogin(Session s) throws CloneNotSupportedException { Integer numCurrentLogins = ((Long) s .createQuery("select count(*) from UserModel " + "where currentLogin is not null and currentLogin >= :date") .setDate("date", getStartDate()).uniqueResult()).intValue(); List currentStats = s/*from w w w . j a v a 2 s .c o m*/ .createSQLQuery("SELECT DATE(currentLogin) as date, count( * ) as lastLogins " + "FROM users where currentLogin is not null and currentLogin >= :date " + "GROUP BY DATE( currentLogin )") .addScalar("date", Hibernate.DATE).addScalar("lastLogins", Hibernate.INTEGER) .setDate("date", getStartDate()).list(); TimeSeriesCollection theData = new TimeSeriesCollection(); TimeSeriesCollection theData2 = new TimeSeriesCollection(); TimeSeries current = new TimeSeries("Num Latest Sign-ins", Day.class); theData.addSeries(current); TimeSeries current2 = new TimeSeries("Signed-in Users Since", Day.class); theData2.addSeries(current2); for (Object ds : currentStats) { Date date = (Date) ((Object[]) ds)[0]; Day day = new Day(date); Integer integer = (Integer) ((Object[]) ds)[1]; current.add(day, integer); numCurrentLogins -= integer.intValue(); current2.add(day, numCurrentLogins); } JFreeChart chart = ChartFactory.createTimeSeriesChart("Sign-in Recency", "Day", "Sign-ins", theData, true, true, true); XYPlot plot = (XYPlot) chart.getPlot(); NumberAxis axis2 = new NumberAxis("Users"); plot.setRangeAxis(1, axis2); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT); plot.setDataset(1, theData2); plot.mapDatasetToRangeAxis(1, 1); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(0); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); renderer = (XYLineAndShapeRenderer) renderer.clone(); renderer.setSeriesStroke(0, new BasicStroke(2.0f)); renderer.setSeriesStroke(1, new BasicStroke(2.0f)); plot.setRenderer(1, renderer); return chart; }
From source file:com.android.ddmuilib.log.event.DisplayGraph.java
/** * Returns a {@link TimeSeriesCollection} for a specific {@link com.android.ddmlib.log.EventValueDescription.ValueType}. * If the data set is not yet created, it is first allocated and set up into the * {@link org.jfree.chart.JFreeChart} object. * @param type the {@link com.android.ddmlib.log.EventValueDescription.ValueType} of the data set. * @param accumulateValues//from ww w .ja v a2s. c om */ private TimeSeriesCollection getValueDataset(EventValueDescription.ValueType type, boolean accumulateValues) { TimeSeriesCollection dataset = mValueTypeDataSetMap.get(type); if (dataset == null) { // create the data set and store it in the map dataset = new TimeSeriesCollection(); mValueTypeDataSetMap.put(type, dataset); // create the renderer and configure it depending on the ValueType AbstractXYItemRenderer renderer; if (type == EventValueDescription.ValueType.PERCENT && accumulateValues) { renderer = new XYAreaRenderer(); } else { XYLineAndShapeRenderer r = new XYLineAndShapeRenderer(); r.setBaseShapesVisible(type != EventValueDescription.ValueType.PERCENT); renderer = r; } // set both the dataset and the renderer in the plot object. XYPlot xyPlot = mChart.getXYPlot(); xyPlot.setDataset(mDataSetCount, dataset); xyPlot.setRenderer(mDataSetCount, renderer); // put a new axis label, and configure it. NumberAxis axis = new NumberAxis(type.toString()); if (type == EventValueDescription.ValueType.PERCENT) { // force percent range to be (0,100) fixed. axis.setAutoRange(false); axis.setRange(0., 100.); } // for the index, we ignore the occurrence dataset int count = mDataSetCount; if (mOccurrenceDataSet != null) { count--; } xyPlot.setRangeAxis(count, axis); if ((count % 2) == 0) { xyPlot.setRangeAxisLocation(count, AxisLocation.BOTTOM_OR_LEFT); } else { xyPlot.setRangeAxisLocation(count, AxisLocation.TOP_OR_RIGHT); } // now we link the dataset and the axis xyPlot.mapDatasetToRangeAxis(mDataSetCount, count); mDataSetCount++; } return dataset; }
From source file:org.n52.oxf.render.sos.TimeSeriesChartRenderer4xPhenomenons.java
public JFreeChart renderChart(OXFFeatureCollection observationCollection, ParameterContainer paramCon) { // which observedProperty has been used?: ParameterShell observedPropertyPS = paramCon.getParameterShellWithServiceSidedName("observedProperty"); if (observedPropertyPS.hasMultipleSpecifiedValues()) { observedProperties = observedPropertyPS.getSpecifiedTypedValueArray(String[].class); } else if (observedPropertyPS.hasSingleSpecifiedValue()) { observedProperties = new String[] { (String) observedPropertyPS.getSpecifiedValue() }; } else {//w w w . java 2 s.c o m throw new IllegalArgumentException("no observedProperties found."); } String[] foiIdArray; ParameterShell foiParamShell = paramCon.getParameterShellWithServiceSidedName("featureOfInterest"); if (foiParamShell.hasMultipleSpecifiedValues()) { foiIdArray = foiParamShell.getSpecifiedTypedValueArray(String[].class); } else { foiIdArray = new String[] { (String) foiParamShell.getSpecifiedValue() }; } ObservationSeriesCollection tuples4FOI = new ObservationSeriesCollection(observationCollection, foiIdArray, observedProperties, false); JFreeChart chart = ChartFactory.createTimeSeriesChart(null, // title "Date", // x-axis label observedProperties[0], // y-axis label createDataset(foiIdArray, tuples4FOI, 0), // data true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(2.0, 2.0, 2.0, 2.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // add additional datasets: DateAxis axis = (DateAxis) plot.getDomainAxis(); axis.setDateFormatOverride(new SimpleDateFormat()); for (int i = 1; i < observedProperties.length; i++) { XYDataset additionalDataset = createDataset(foiIdArray, tuples4FOI, i); plot.setDataset(i, additionalDataset); plot.setRangeAxis(i, new NumberAxis(observedProperties[i])); plot.getRangeAxis(i).setRange((Double) tuples4FOI.getMinimum(i), (Double) tuples4FOI.getMaximum(i)); plot.mapDatasetToRangeAxis(i, i); } return chart; }
From source file:com.vgi.mafscaling.VECalc.java
protected void createChart(JPanel plotPanel, String xAxisName, String yAxisName) { JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);/* ww w . ja va 2s . c o m*/ chart.setBorderVisible(true); chartPanel = new ChartPanel(chart, true, true, true, true, true); chartPanel.setAutoscrolls(true); chartPanel.setMouseZoomable(false); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.CENTER; gbl_chartPanel.insets = new Insets(3, 3, 3, 3); gbl_chartPanel.weightx = 1.0; gbl_chartPanel.weighty = 1.0; gbl_chartPanel.fill = GridBagConstraints.BOTH; gbl_chartPanel.gridx = 0; gbl_chartPanel.gridy = 1; plotPanel.add(chartPanel, gbl_chartPanel); XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(); lineRenderer.setUseFillPaint(true); lineRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); lineRenderer.setSeriesStroke(0, stroke); lineRenderer.setSeriesPaint(0, Color.RED); lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5)); lineRenderer.setLegendItemLabelGenerator(new StandardXYSeriesLabelGenerator() { private static final long serialVersionUID = 7593430826693873496L; public String generateLabel(XYDataset dataset, int series) { XYSeries xys = ((XYSeriesCollection) dataset).getSeries(series); return xys.getDescription(); } }); NumberAxis xAxis = new NumberAxis(xAxisName); xAxis.setAutoRangeIncludesZero(false); NumberAxis yAxis = new NumberAxis(yAxisName); yAxis.setAutoRangeIncludesZero(false); XYSeriesCollection lineDataset = new XYSeriesCollection(); XYPlot plot = chart.getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setDataset(0, lineDataset); plot.setRenderer(0, lineRenderer); plot.setDomainAxis(0, xAxis); plot.setRangeAxis(0, yAxis); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); chart.addLegend(legend); }
From source file:com.hazelcast.monitor.server.MChartGenerator.java
@Override protected void afterPlot(List<? super InstanceStatistics> list, JFreeChart chart, XYPlot plot) { NumberAxis sizeAxis = (NumberAxis) plot.getRangeAxis(0); Font labelFont = sizeAxis.getLabelFont(); Paint labelPaint = sizeAxis.getLabelPaint(); TimeSeries tm = new TimeSeries("memory"); for (int i = 0; i < list.size(); i++) { double memory = 0; MapStatistics mapStatistics = (MapStatistics) list.get(i); for (MapStatistics.LocalMapStatistics localMapStatistics : mapStatistics.getListOfLocalStats()) { memory = memory + localMapStatistics.ownedEntryMemoryCost + localMapStatistics.backupEntryMemoryCost + localMapStatistics.markedAsRemovedMemoryCost; }/*from w w w .j a v a2s .c om*/ double mem = new Double(memory / (double) (1024 * 1024)); tm.addOrUpdate(new Second(((MapStatistics) list.get(i)).getCreatedDate()), mem); } NumberAxis memoryAxis = new NumberAxis("memory (MB)"); memoryAxis.setAutoRange(true); memoryAxis.setAutoRangeIncludesZero(false); plot.setDataset(1, new TimeSeriesCollection(tm)); plot.setRangeAxis(1, memoryAxis); plot.mapDatasetToRangeAxis(1, 1); plot.setRenderer(1, new StandardXYItemRenderer()); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); increaseRange(memoryAxis); memoryAxis.setLabelFont(labelFont); memoryAxis.setLabelPaint(labelPaint); }
From source file:org.griphyn.vdl.karajan.monitor.monitors.swing.GraphPanel.java
protected void removeSeries(JFreeChart chart, int seriesIndex) { Color color = (Color) chart.getPlot().getLegendItems().get(seriesIndex).getLinePaint(); palette.release(color);/*from ww w.ja v a 2s . com*/ String key = enabled.remove(seriesIndex); XYPlot plot = chart.getXYPlot(); Series<?> series = sampler.getSeries(key); Unit unit = series.getUnit(); Integer datasetIndex = datasetMapping.get(unit); TimeSeriesCollection col = (TimeSeriesCollection) plot.getDataset(datasetIndex); List<String> colIndices = seriesMapping.get(unit); int colIndex = colIndices.indexOf(key); colIndices.remove(key); col.removeSeries(colIndex); if (col.getSeriesCount() == 0) { plot.setDataset(datasetIndex, null); plot.setRangeAxis(datasetIndex, null); seriesMapping.remove(unit); datasetMapping.remove(unit); } rebuildLegend(); repaint(); gp.saveLayout(); }
From source file:com.vgi.mafscaling.Rescale.java
private void createGraghPanel(JPanel dataPanel) { JFreeChart chart = ChartFactory.createScatterPlot(null, null, null, null, PlotOrientation.VERTICAL, false, true, false);/* ww w. jav a 2 s. c om*/ chart.setBorderVisible(true); mafChartPanel = new MafChartPanel(chart, this); GridBagConstraints gbl_chartPanel = new GridBagConstraints(); gbl_chartPanel.anchor = GridBagConstraints.PAGE_START; gbl_chartPanel.insets = insets0; gbl_chartPanel.fill = GridBagConstraints.BOTH; gbl_chartPanel.weightx = 1.0; gbl_chartPanel.weighty = 1.0; gbl_chartPanel.gridx = 0; gbl_chartPanel.gridy = 2; dataPanel.add(mafChartPanel.getChartPanel(), gbl_chartPanel); XYSplineRenderer lineRenderer = new XYSplineRenderer(3); lineRenderer.setUseFillPaint(true); lineRenderer.setBaseToolTipGenerator( new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT, new DecimalFormat("0.00"), new DecimalFormat("0.00"))); Stroke stroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f, null, 0.0f); lineRenderer.setSeriesStroke(0, stroke); lineRenderer.setSeriesStroke(1, stroke); lineRenderer.setSeriesPaint(0, new Color(201, 0, 0)); lineRenderer.setSeriesPaint(1, new Color(0, 0, 255)); lineRenderer.setSeriesShape(0, ShapeUtilities.createDiamond((float) 2.5)); lineRenderer.setSeriesShape(1, ShapeUtilities.createUpTriangle((float) 2.5)); ValueAxis mafvDomain = new NumberAxis(XAxisName); ValueAxis mafgsRange = new NumberAxis(YAxisName); XYSeriesCollection lineDataset = new XYSeriesCollection(); lineDataset.addSeries(currMafData); lineDataset.addSeries(corrMafData); XYPlot plot = chart.getXYPlot(); plot.setRangePannable(true); plot.setDomainPannable(true); plot.setDomainGridlinePaint(Color.DARK_GRAY); plot.setRangeGridlinePaint(Color.DARK_GRAY); plot.setBackgroundPaint(new Color(224, 224, 224)); plot.setSeriesRenderingOrder(SeriesRenderingOrder.FORWARD); plot.setDataset(0, lineDataset); plot.setRenderer(0, lineRenderer); plot.setDomainAxis(0, mafvDomain); plot.setRangeAxis(0, mafgsRange); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); LegendTitle legend = new LegendTitle(plot.getRenderer()); legend.setItemFont(new Font("Arial", 0, 10)); legend.setPosition(RectangleEdge.TOP); chart.addLegend(legend); }