List of usage examples for org.jfree.chart.axis NumberAxis setTickUnit
public void setTickUnit(NumberTickUnit unit)
From source file:logica_controladores.controlador_estadistica.java
private static void configurarRangeAxis(NumberAxis rangeAxis, double min, double max) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setTickUnit(new NumberTickUnit(500)); rangeAxis.setRange(min, max);//from w w w . ja v a2s . c om }
From source file:logica_controladores.controlador_estadistica.java
private static void configurarDomainAxis(NumberAxis domainAxis, Inventario inventario) { domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setTickUnit(new NumberTickUnit(20)); domainAxis.setRange(inventario.getOrden_min(), inventario.getOrden_max()); }
From source file:classpackage.ChartGalaxy.java
private static JFreeChart createChart(final XYDataset dataset) { JFreeChart jfreechart = ChartFactory.createScatterPlot("MDS Galaxy", "X", "Y", createDataset(), PlotOrientation.VERTICAL, true, true, false); XYPlot xyPlot = (XYPlot) jfreechart.getPlot(); XYItemRenderer renderer = xyPlot.getRenderer(); renderer.setBaseItemLabelGenerator(new LabelGenerator()); renderer.setBaseItemLabelPaint(Color.WHITE);//label renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); renderer.setBaseItemLabelFont(renderer.getBaseItemLabelFont().deriveFont(15f)); renderer.setBaseItemLabelsVisible(true); renderer.setBaseToolTipGenerator(new StandardXYToolTipGenerator()); //set false para linhas no grafico xyPlot.setDomainGridlinesVisible(false); xyPlot.setRangeGridlinesVisible(false); xyPlot.setRangeMinorGridlinesVisible(false); xyPlot.setRangeCrosshairVisible(false); xyPlot.setRangeCrosshairLockedOnData(false); xyPlot.setRangeZeroBaselineVisible(false); xyPlot.setBackgroundPaint(Color.BLACK); double size = 40.0; double delta = size / 2.0; Shape shape = new Rectangle2D.Double(-delta, -delta, size, size); renderer.setSeriesShape(0, shape);//from ww w . ja v a 2 s .c om renderer.setSeriesPaint(0, transparent); NumberAxis domain = (NumberAxis) xyPlot.getDomainAxis(); domain.setRange(-0.1, 0.1); domain.setTickUnit(new NumberTickUnit(0.1)); domain.setVerticalTickLabels(true); NumberAxis range = (NumberAxis) xyPlot.getRangeAxis(); range.setRange(-0.1, 0.1); range.setTickUnit(new NumberTickUnit(0.1)); return jfreechart; }
From source file:playground.thibautd.utils.charts.XYChartUtils.java
/** * Sets the X axis of an XYPlot chart to a {@link NumberAxis} * with integer values.// www . j a v a 2 s . co m */ public static void integerYAxis(final JFreeChart chart) { ValueAxis axis = (chart.getXYPlot()).getRangeAxis(); NumberAxis numberAxis; if (axis instanceof NumberAxis) { numberAxis = (NumberAxis) axis; } else { numberAxis = new NumberAxis(); (chart.getXYPlot()).setRangeAxis(numberAxis); } numberAxis.setTickUnit((NumberTickUnit) NumberAxis.createIntegerTickUnits().getCeilingTickUnit(1d)); numberAxis.setAutoRangeIncludesZero(false); }
From source file:playground.thibautd.utils.charts.XYChartUtils.java
/** * Sets the X axis of an XYPlot chart to a {@link NumberAxis} * with integer values.//from w ww . j a va 2 s .co m */ public static void integerXAxis(final JFreeChart chart) { ValueAxis axis = (chart.getXYPlot()).getDomainAxis(); NumberAxis numberAxis; if (axis instanceof NumberAxis) { numberAxis = (NumberAxis) axis; } else { numberAxis = new NumberAxis(); (chart.getXYPlot()).setDomainAxis(numberAxis); } numberAxis.setTickUnit((NumberTickUnit) NumberAxis.createIntegerTickUnits().getCeilingTickUnit(1d)); numberAxis.setAutoRangeIncludesZero(false); }
From source file:org.openfaces.component.chart.impl.helpers.AxisUtil.java
public static void setupAxisPresentation(String label, Axis axis, FakeAxisStyle axisStyle) { StyleObjectModel model = axisStyle.getStyleObjectModel(); StyleBorderModel border = model.getBorder(); if (border != null) { if (border.getColor() != null) { axis.setAxisLinePaint(border.getColor()); }/*from ww w . ja v a 2 s . c om*/ if (!border.isNone()) { axis.setAxisLineVisible(true); axis.setAxisLineStroke(PropertiesConverter.toStroke(border)); axis.setTickMarkPaint(border.getColor()); axis.setTickMarksVisible(true); if (!axis.isTickMarksVisible()) axis.setTickMarksVisible(false); } if (border.getStyle().equalsIgnoreCase("none")) { axis.setAxisLineVisible(false); axis.setTickMarksVisible(false); if (axis.isTickMarksVisible()) axis.setTickMarksVisible(true); } } axis.setTickLabelsVisible(axisStyle.isTickLabelsVisible()); if (axisStyle.isLabelVisible() && label != null) { axis.setLabel(label); axis.setLabelPaint(model.getColor()); axis.setLabelFont(CSSUtil.getFont(model)); } if (axisStyle.isTickLabelsVisible()) { axis.setTickLabelsVisible(true); axis.setTickLabelPaint(model.getColor()); axis.setTickLabelFont(CSSUtil.getFont(model)); } else { axis.setTickLabelsVisible(false); } Double tickInterval = axisStyle.getTickInterval(); if (tickInterval != null && tickInterval != 0 && axis instanceof NumberAxis) { NumberAxis numberAxis = (NumberAxis) axis; if (tickInterval > 0) { NumberTickUnit tickUnit = new NumberTickUnit(tickInterval); numberAxis.setTickUnit(tickUnit); } else if (tickInterval == -1) { TickUnitSource tickUnits = NumberAxis.createIntegerTickUnits(); numberAxis.setStandardTickUnits(tickUnits); } else { throw new FacesException("tickInterval must be a positive number for a fixed tick interval, " + "or -1 for automatic integer tick selection: " + tickInterval); } numberAxis.setMinorTickMarksVisible(true); numberAxis.setMinorTickCount(2); numberAxis.setMinorTickMarkOutsideLength(3); numberAxis.setMinorTickMarkInsideLength(3); numberAxis.setTickMarkInsideLength(5); numberAxis.setTickMarkOutsideLength(5); } axis.setTickMarkInsideLength(axisStyle.getTickInsideLength()); axis.setTickMarkOutsideLength(axisStyle.getTickOutsideLength()); if (axisStyle.getMinorTicksVisible()) { axis.setMinorTickMarksVisible(true); if (axis instanceof ValueAxis) ((ValueAxis) axis).setMinorTickCount(axisStyle.getMinorTickCount() + 1); axis.setMinorTickMarkInsideLength(axisStyle.getMinorTickInsideLength()); axis.setMinorTickMarkOutsideLength(axisStyle.getMinorTickOutsideLength()); } else { axis.setMinorTickMarksVisible(false); } }
From source file:no.met.jtimeseries.marinogram.MarinogramWrapper.java
public static JFreeChart createEmptyChart(ChartPlottingInfo cpi) { ChartPlotter cp = new ChartPlotter(); cp.setHeight(cpi.getHeight());//from w w w .j av a 2 s. c o m cp.setWidth(cpi.getWidth()); cp.setPlotDefaultProperties("", ""); ValueAxis dateAxis = new DateAxis(); dateAxis.setTickLabelsVisible(false); cp.setDomainAxis(dateAxis); NumberAxis numberAxis = new NumberAxis(); numberAxis.setRange(0, 10); numberAxis.setTickUnit(new NumberTickUnit(1.0d)); numberAxis.setTickLabelsVisible(false); cp.setRangeAxis(numberAxis); return createJFreeChart("", cp.getPlot(), cpi.getWidth()); }
From source file:org.cyberoam.iview.charts.XYLine.java
/** * This method generates JFreeChart instance for XYLine chart with iView customization. * @param reportID specifies that for which report Chart is being prepared. * @param rsw specifies data set which would be used for the Chart * @param requeest used for Hyperlink generation from URL. * @return jfreechart instance with iView Customization. *///from w ww .jav a 2 s .co m public static JFreeChart getChart(int reportID, ResultSetWrapper rsw, HttpServletRequest request) { ReportBean reportBean = ReportBean.getRecordbyPrimarykey(reportID); JFreeChart chart = null; try { ReportColumnBean reportColumnBean = null; GraphBean graphBean = null; DataLinkBean dataLinkBean = null; XYDataset dataset = null; XYSeriesCollection seriesCollection = new XYSeriesCollection(); XYSeries series = new XYSeries(reportBean.getTitle()); graphBean = GraphBean.getRecordbyPrimarykey(reportBean.getGraphId());//Getting GraphBean reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getXColumnId());//getting ReportColumnBean For X Axis String xColumnDBname = reportColumnBean.getDbColumnName(); String xColumnName = reportColumnBean.getColumnName(); //Wheather DataLink is Given For X Axis column if (reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getYColumnId()); String yColumnDBname = reportColumnBean.getDbColumnName(); String yColumnName = reportColumnBean.getColumnName(); //if DataLink is not Given For X Axis column then Check of Y Axis Column if (dataLinkBean == null && reportColumnBean.getDataLinkId() != -1) { dataLinkBean = DataLinkBean.getRecordbyPrimarykey(reportColumnBean.getDataLinkId()); } reportColumnBean = ReportColumnBean.getRecordByPrimaryKey(reportBean.getReportId(), graphBean.getZColumnId()); String zColumnDbname = reportColumnBean.getDbColumnName(); //Preparing DataSet String data = ""; rsw.beforeFirst(); while (rsw.next()) { data = rsw.getString(xColumnDBname); series.add(Long.parseLong((data).substring(data.length() - 2)), new Long(rsw.getLong(yColumnDBname)).longValue()); } seriesCollection.addSeries(series); dataset = seriesCollection; // create the chart... chart = ChartFactory.createXYLineChart("", // chart title "", // domain axis label "", seriesCollection, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips? false // URLs? ); /* * Additional iView Customization. */ //Set the background color for the chart... chart.setBackgroundPaint(Color.white); //Get a reference to the plot for further customisation... XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(new Color(245, 245, 245)); plot.setDomainGridlinePaint(Color.LIGHT_GRAY); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.LIGHT_GRAY); plot.setForegroundAlpha(0.7f); //Set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); if (reportColumnBean.getColumnFormat() == TabularReportConstants.BYTE_FORMATTING) { rangeAxis.setTickUnit(new ByteTickUnit(rangeAxis.getUpperBound() / 4)); } rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); rangeAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); rangeAxis.setTickLabelsVisible(true); rangeAxis.setTickMarksVisible(false); rangeAxis.setAxisLineVisible(false); Axis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelFont(new Font("Vandara", Font.CENTER_BASELINE, 10)); domainAxis.setTickMarksVisible(false); domainAxis.setAxisLineVisible(false); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setSeriesPaint(0, Color.DARK_GRAY); renderer.setSeriesStroke(0, new BasicStroke(1)); } catch (Exception e) { e.printStackTrace(); } return chart; }
From source file:org.gwaspi.reports.PlinkReportLoader.java
private static void appendToCombinedRangePlot(CombinedRangeXYPlot combinedPlot, String chromosome, XYSeriesCollection seriesCol) {//from ww w .java2 s . com XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(false, true); renderer.setSeriesPaint(0, Color.blue); JFreeChart subchart = ChartFactory.createScatterPlot("", "Chr " + chromosome, "", seriesCol, PlotOrientation.VERTICAL, true, false, false); XYPlot subplot = (XYPlot) subchart.getPlot(); subplot.setRenderer(renderer); subplot.setBackgroundPaint(null); subplot.setDomainGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setDomainGridlinePaint(Color.blue); subplot.setRangeGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeMinorGridlineStroke(new BasicStroke(0.0f)); subplot.setRangeGridlinePaint(Color.blue); NumberAxis chrAxis = (NumberAxis) subplot.getDomainAxis(); chrAxis.setAxisLineVisible(true); chrAxis.setTickLabelsVisible(true); chrAxis.setTickMarksVisible(true); chrAxis.setTickUnit(new NumberTickUnit(10000)); chrAxis.setAutoRangeIncludesZero(false); NumberAxis log10Axis = (NumberAxis) subplot.getRangeAxis(); log10Axis.setTickMarkInsideLength(2.0f); log10Axis.setTickMarkOutsideLength(2.0f); log10Axis.setMinorTickCount(2); log10Axis.setMinorTickMarksVisible(true); log10Axis.setAxisLineVisible(true); log10Axis.setAutoRangeIncludesZero(false); XYItemRenderer lblRenderer = subplot.getRenderer(); MySeriesItemLabelGenerator lblGenerator = new MySeriesItemLabelGenerator(4.0d, chromosome); lblRenderer.setSeriesItemLabelGenerator(0, lblGenerator); lblRenderer.setSeriesItemLabelGenerator(1, lblGenerator); lblRenderer.setSeriesItemLabelFont(0, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesItemLabelFont(1, new Font("Serif", Font.PLAIN, 12)); lblRenderer.setSeriesPositiveItemLabelPosition(0, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesPositiveItemLabelPosition(1, new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.BOTTOM_LEFT, TextAnchor.TOP_LEFT, -Math.PI / 4.0)); lblRenderer.setSeriesItemLabelsVisible(0, true); lblRenderer.setSeriesItemLabelsVisible(1, true); combinedPlot.add(subplot, 1); }
From source file:ec.ui.view.DistributionView.java
private static JFreeChart createDistributionViewChart() { XYPlot plot = new XYPlot(); XYLineAndShapeRenderer dRenderer = new XYSplineRenderer(); dRenderer.setBaseShapesVisible(false); dRenderer.setAutoPopulateSeriesPaint(false); dRenderer.setAutoPopulateSeriesStroke(false); dRenderer.setBaseStroke(TsCharts.getStrongStroke(LinesThickness.Thin)); dRenderer.setDrawSeriesLineAsPath(true); // not sure if useful plot.setDataset(DISTRIBUTION_INDEX, Charts.emptyXYDataset()); plot.setRenderer(DISTRIBUTION_INDEX, dRenderer); XYBarRenderer hRenderer = new XYBarRenderer(); hRenderer.setShadowVisible(false);/* w w w .j ava2 s . co m*/ hRenderer.setDrawBarOutline(true); hRenderer.setAutoPopulateSeriesPaint(false); hRenderer.setAutoPopulateSeriesOutlinePaint(false); hRenderer.setBaseSeriesVisibleInLegend(false); plot.setDataset(HISTOGRAM_INDEX, Charts.emptyXYDataset()); plot.setRenderer(HISTOGRAM_INDEX, hRenderer); NumberAxis domainAxis = new NumberAxis(); domainAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); plot.setDomainAxis(domainAxis); plot.setDomainGridlinesVisible(false); NumberAxis rangeAxis = new NumberAxis(); rangeAxis.setTickLabelPaint(TsCharts.CHART_TICK_LABEL_COLOR); rangeAxis.setTickUnit(new NumberTickUnit(0.05)); rangeAxis.setNumberFormatOverride(new DecimalFormat("0.###")); plot.setRangeAxis(rangeAxis); plot.mapDatasetToDomainAxis(0, 0); plot.mapDatasetToRangeAxis(0, 0); plot.mapDatasetToDomainAxis(1, 0); plot.mapDatasetToRangeAxis(1, 0); JFreeChart result = new JFreeChart("", JFreeChart.DEFAULT_TITLE_FONT, plot, true); result.setPadding(TsCharts.CHART_PADDING); result.getTitle().setFont(TsCharts.CHART_TITLE_FONT); result.getLegend().setFrame(BlockBorder.NONE); result.getLegend().setBackgroundPaint(null); return result; }