/** * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param axis the axis ({@code null} permitted). */ public void setRangeAxis(ValueAxis axis) { setRangeAxis(0, axis); }
/** * Sets a range axis and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param index the axis index. * @param axis the axis. */ public void setRangeAxis(int index, ValueAxis axis) { setRangeAxis(index, axis, true); }
/** * Sets a range axis and sends a {@link PlotChangeEvent} to all registered * listeners. * * @param index the axis index. * @param axis the axis. */ public void setRangeAxis(int index, ValueAxis axis) { setRangeAxis(index, axis, true); }
/** * Sets the range axis for the plot and sends a {@link PlotChangeEvent} to * all registered listeners. * * @param axis the axis (<code>null</code> permitted). */ public void setRangeAxis(ValueAxis axis) { setRangeAxis(0, axis); }
/** * Sets the range axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes ({@code null} not permitted). * * @see #setDomainAxes(CategoryAxis[]) */ public void setRangeAxes(ValueAxis[] axes) { for (int i = 0; i < axes.length; i++) { setRangeAxis(i, axes[i], false); } fireChangeEvent(); }
/** * Sets the range axes for this plot and sends a {@link PlotChangeEvent} * to all registered listeners. * * @param axes the axes (<code>null</code> not permitted). * * @see #setDomainAxes(CategoryAxis[]) */ public void setRangeAxes(ValueAxis[] axes) { for (int i = 0; i < axes.length; i++) { setRangeAxis(i, axes[i], false); } fireChangeEvent(); }
private void configureRangeAxis(CategoryPlot plot, String valueLabelSuffix, Font font) { NumberAxis numberAxis = new NumberAxis(); numberAxis.setUpperMargin(0.3); numberAxis.setTickLabelFont(font); numberAxis.setTickLabelPaint(OUTLINE_COLOR); String suffix = ""; if (valueLabelSuffix != null && !"".equals(valueLabelSuffix)) { suffix = new StringBuilder().append("'").append(valueLabelSuffix).append("'").toString(); } numberAxis.setNumberFormatOverride(new DecimalFormat("0" + suffix)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setRangeAxis(numberAxis); } }
private void configureRangeAxis(CategoryPlot plot, String valueLabelSuffix, Font font) { NumberAxis3D numberAxis = new NumberAxis3D(); numberAxis.setUpperMargin(0.3); numberAxis.setTickLabelFont(font); numberAxis.setTickLabelPaint(OUTLINE_COLOR); String suffix = ""; if (valueLabelSuffix != null && !"".equals(valueLabelSuffix)) { suffix = new StringBuilder().append("'").append(valueLabelSuffix).append("'").toString(); } numberAxis.setNumberFormatOverride(new DecimalFormat("0" + suffix)); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setRangeAxis(numberAxis); } }
CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setSeriesPaint(0, Color.blue); NumberAxis xAxis = new NumberAxis(); DecimalFormat format = (DecimalFormat)DecimalFormat.getNumberInstance(Locale.ENGLISH); format.applyPattern("#"); xAxis.setNumberFormatOverride(format); xAxis.setLabel("Cycles"); plot.setRangeAxis(xAxis); renderer.setBaseToolTipGenerator(new IntervalCategoryToolTipGenerator("{3} - {4}", format));
public class Example1 { public static void main(String args[]) { DefaultKeyedValues data = new DefaultKeyedValues(); data.addValue("8/4/2012", new Day(8, 4, 2012).getFirstMillisecond()); data.addValue("19/04/2012", new Day(19, 4, 2012).getFirstMillisecond()); CategoryDataset dataset = DatasetUtilities .createCategoryDataset("Population", data); JFreeChart chart = ChartFactory.createLineChart("Population", "Date", "Population", dataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot plot = (CategoryPlot) chart.getPlot(); LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseLinesVisible(false); DateAxis range = new DateAxis("Date"); range.setDateFormatOverride(new SimpleDateFormat("dd/MM/yyyy")); plot.setRangeAxis(range); ChartFrame frame = new ChartFrame("Test", chart); frame.pack(); frame.setVisible(true); } }
NumberAxis rangeAxis = new NumberAxis("Value"); plot.setDomainAxis(0, domainAxis); plot.setRangeAxis(rangeAxis); JFreeChart chart = new JFreeChart(plot); ChartPanel chartPanel = new ChartPanel(chart);
protected CategoryPlot drawChart4FOI(String featureID, String timeString, ObservedValueTuple tuple) { BarRenderer3D barRenderer = new BarRenderer3D(); CategoryPlot plot = new CategoryPlot(); plot.setDomainAxis(new CategoryAxis(featureID)); for (int i = 0; i < observedProperties.length; i++) { plot.setDataset(i, createDataset(i, timeString, tuple)); plot.setRangeAxis(i, new NumberAxis(tuple.getPhenomenonNames()[i].split(":")[tuple.getPhenomenonNames()[i].split(":").length - 1])); plot.setRenderer(i, barRenderer); plot.mapDatasetToRangeAxis(i, i); } return plot; }
subplot.setWeight(weight); subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); subplot.setRangeAxis(null); subplot.setOrientation(getOrientation()); subplot.addChangeListener(this);
@Override protected JFreeChart createGraph() { CategoryDataset dataset = createDataset(); JFreeChart chart = ChartFactory.createBarChart(graphTitle, "", "Number of failures", dataset, PlotOrientation.HORIZONTAL, false, false, false); NumberAxis domainAxis = new NumberAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); CategoryPlot plot = (CategoryPlot)chart.getPlot(); plot.setRangeAxis(domainAxis); BarRenderer renderer = (BarRenderer)plot.getRenderer(); renderer.setMaximumBarWidth(MAX_BAR_WIDTH); return chart; }
/** * Adds a subplot and sends a {@link PlotChangeEvent} to all registered * listeners. * <br><br> * You must ensure that the subplot has a non-null domain axis. The range * axis for the subplot will be set to {@code null}. * * @param subplot the subplot ({@code null} not permitted). * @param weight the weight (must be >= 1). */ public void add(CategoryPlot subplot, int weight) { Args.nullNotPermitted(subplot, "subplot"); if (weight <= 0) { throw new IllegalArgumentException("Require weight >= 1."); } // store the plot and its weight subplot.setParent(this); subplot.setWeight(weight); subplot.setInsets(new RectangleInsets(0.0, 0.0, 0.0, 0.0)); subplot.setRangeAxis(null); subplot.setOrientation(getOrientation()); subplot.addChangeListener(this); this.subplots.add(subplot); // configure the range axis... ValueAxis axis = getRangeAxis(); if (axis != null) { axis.configure(); } fireChangeEvent(); }
//Mock data DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int[] times = new int[]{1,2,3,4,5,6,7,8,9}; for ( int i = 0; i < times.length; i++ ){ dataset.addValue(times[i], "Time", "Hour" + String.valueOf(i+1)); } //create the plot CategoryPlot plot = new CategoryPlot(); //add the first dataset, and render as bar values CategoryItemRenderer renderer = new BarRenderer(); plot.setDataset(0,dataset); plot.setRenderer(0,renderer); //add the second dataset, render as lines CategoryItemRenderer renderer2 = new LineAndShapeRenderer(); plot.setDataset(1, dataset); plot.setRenderer(1, renderer2); //set axis plot.setDomainAxis(new CategoryAxis("Time")); plot.setRangeAxis(new NumberAxis("Value"));
final ValueAxis axis2 = new NumberAxis("# executions"); axis2.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); plot.setRangeAxis(1, axis2);
plot.setRangeAxis(i, dimension.getRangeAxis()); plot.setRenderer(i, dimension.getRenderer()); plot.setDataset(i, dimension.getDatasetBuilder().build());
plot.setRangeAxis(1, axis2);
plot.setRangeAxis(rangeAxis2);