List of usage examples for org.jfree.chart.axis ValueAxis setTickLabelsVisible
public void setTickLabelsVisible(boolean flag)
From source file:wattsup.jsdk.ui.ChartPanelSupport.java
/** * Clean the values of the chart./*from w w w . j av a 2 s .c o m*/ * * @see #createChart() */ public void cleanChart() { this.chart_.removeLegend(); this.chartPanel_.setBorder(null); cleanLabels(); DateAxis localDateAxis = (DateAxis) ((XYPlot) this.chart_.getPlot()).getDomainAxis(); localDateAxis.setTickLabelsVisible(false); localDateAxis.setTickMarksVisible(false); localDateAxis.setAxisLineVisible(false); ValueAxis localValueAxis = ((XYPlot) this.chart_.getPlot()).getRangeAxis(); localValueAxis.setTickLabelsVisible(false); localValueAxis.setTickMarksVisible(false); localValueAxis.setAxisLineVisible(false); XYPlot localXYPlot = (XYPlot) this.chart_.getPlot(); localXYPlot.setDomainGridlineStroke(this.defaultLineStroke_); localXYPlot.setDomainGridlinesVisible(true); localXYPlot.setRangeGridlineStroke(this.defaultLineStroke_); localXYPlot.setRangeGridlinesVisible(true); localXYPlot.setAxisOffset(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D)); localXYPlot.setInsets(new RectangleInsets(0.0D, 0.0D, 0.0D, 0.0D), true); }
From source file:de.citec.csra.allocation.vis.MovingChart.java
/** * Creates a sample chart.// w w w.j av a 2 s . c o m * * @param dataset the dataset. * * @return A sample chart. */ private JFreeChart createChart(final XYDataset dataset) { final JFreeChart result = ChartFactory.createTimeSeriesChart(null, "Time", "Resource", dataset, false, true, false); final XYPlot plot = result.getXYPlot(); plot.addDomainMarker(this.marker); plot.setBackgroundPaint(new Color(0xf8f8ed)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.lightGray); ValueAxis xaxis = plot.getDomainAxis(); xaxis.setAutoRange(true); xaxis.setTickLabelsVisible(false); //Domain axis would show data of 60 seconds for a time xaxis.setFixedAutoRange(this.past + this.future); // 60 seconds xaxis.setVerticalTickLabels(true); ValueAxis yaxis = plot.getRangeAxis(); yaxis.setAutoRangeMinimumSize(1.8); yaxis.setAutoRange(true); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setTickUnit(new NumberTickUnit(1)); range.setNumberFormatOverride(new NumberFormat() { @Override public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) { return format((long) number, toAppendTo, pos); } private String getID(long number) { return values.entrySet().stream().filter(e -> e.equals(number)).findFirst().get().getKey(); } @Override public StringBuffer format(long number, StringBuffer ap, FieldPosition pos) { String id = "N/A"; if (number == 0) { id = "(Time)"; } if (values.containsValue(number)) { for (Map.Entry<String, Long> entry : values.entrySet()) { if (entry.getValue() == number) { id = entry.getKey(); break; } } } id = id.replaceFirst("/$", ""); ap.append(id); if (id.length() > 32) { ap.replace(15, ap.length() - 15, ".."); } return ap; } @Override public Number parse(String source, ParsePosition parsePosition) { return null; } }); // this.chart.getXYPlot().getRenderer(1).set // XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) this.chart.getXYPlot().getRendererForDataset(dataset); return result; }
From source file:org.jivesoftware.openfire.reporting.graph.GraphEngine.java
/** * Generates a Sparkline Bar Graph./*from ww w .j av a 2s . co m*/ * * @param def the key of the statistic object. * @return the generated chart. */ public JFreeChart generateSparklineBarGraph(String key, String color, Statistic[] def, long startTime, long endTime, int dataPoints) { Color backgroundColor = getBackgroundColor(); IntervalXYDataset dataset = (IntervalXYDataset) populateData(key, def, startTime, endTime, dataPoints); JFreeChart chart = ChartFactory.createXYBarChart(null, // chart title null, // domain axis label true, null, // range axis label dataset, // data PlotOrientation.VERTICAL, false, // include legend false, // tooltips? false // URLs? ); chart.setBackgroundPaint(backgroundColor); chart.setBorderVisible(false); chart.setBorderPaint(null); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainGridlinesVisible(false); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); plot.setBackgroundPaint(backgroundColor); plot.setRangeGridlinesVisible(false); GraphDefinition graphDef = GraphDefinition.getDefinition(color); Color plotColor = graphDef.getInlineColor(0); plot.getRenderer().setSeriesPaint(0, plotColor); plot.getRenderer().setBaseItemLabelsVisible(false); plot.getRenderer().setBaseOutlinePaint(backgroundColor); plot.setOutlineStroke(null); plot.setDomainGridlinePaint(null); ValueAxis xAxis = chart.getXYPlot().getDomainAxis(); xAxis.setLabel(null); xAxis.setTickLabelsVisible(true); xAxis.setTickMarksVisible(true); xAxis.setAxisLineVisible(false); xAxis.setNegativeArrowVisible(false); xAxis.setPositiveArrowVisible(false); xAxis.setVisible(false); ValueAxis yAxis = chart.getXYPlot().getRangeAxis(); yAxis.setTickLabelsVisible(false); yAxis.setTickMarksVisible(false); yAxis.setAxisLineVisible(false); yAxis.setNegativeArrowVisible(false); yAxis.setPositiveArrowVisible(false); yAxis.setVisible(false); return chart; }
From source file:replicatorg.app.ui.panels.ControlPanel.java
private ChartPanel makeChart() { JFreeChart chart = ChartFactory.createXYLineChart(null, null, null, t0MeasuredDataset, PlotOrientation.VERTICAL, false, false, false); chart.setBorderVisible(false);/* ww w. jav a 2 s. com*/ chart.setBackgroundPaint(null); XYPlot plot = chart.getXYPlot(); ValueAxis axis = plot.getDomainAxis(); axis.setLowerMargin(0); axis.setFixedAutoRange(3L * 60L * 1000L); // auto range to three minutes TickUnits unitSource = new TickUnits(); unitSource.add(new NumberTickUnit(60L * 1000L)); // minutes unitSource.add(new NumberTickUnit(1L * 1000L)); // seconds axis.setStandardTickUnits(unitSource); axis.setTickLabelsVisible(false); // We don't need to see the millisecond count axis = plot.getRangeAxis(); axis.setRange(0, 300); // set temperature range from 0 to 300 degrees C so you can see overshoots XYStepRenderer renderer = new XYStepRenderer(); plot.setDataset(1, t0TargetDataset); plot.setRenderer(1, renderer); plot.getRenderer(1).setSeriesPaint(0, t0TargetColor); plot.getRenderer(0).setSeriesPaint(0, t0MeasuredColor); plot.setDataset(2, pMeasuredDataset); plot.setRenderer(2, new XYLineAndShapeRenderer(true, false)); plot.getRenderer(2).setSeriesPaint(0, pMeasuredColor); plot.setDataset(3, pTargetDataset); plot.setRenderer(3, new XYStepRenderer()); plot.getRenderer(3).setSeriesPaint(0, pTargetColor); plot.setDatasetRenderingOrder(DatasetRenderingOrder.REVERSE); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(400, 160)); chartPanel.setOpaque(false); return chartPanel; }