List of usage examples for org.jfree.chart.axis NumberAxis setUpperMargin
public void setUpperMargin(double margin)
From source file:edu.ucla.stat.SOCR.chart.demo.PowerTransformXYScatterChart.java
/** * Creates a chart./*from w ww. j a v a 2 s . c o m*/ * * @param dataset the data for the chart. * * @return a chart. */ protected JFreeChart createChart(XYDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, //"Power Transformed XYScatter Chart", // chart title domainLabel, // x axis label rangeLabel, // 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); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setBaseShapesFilled(true); // renderer.setLinesVisible(false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, true); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0); // OPTIONAL CUSTOMISATION COMPLETED. setXSummary(dataset); return chart; }
From source file:net.nosleep.superanalyzer.analysis.views.PlayCountView.java
private void createChart() { _chart = ChartFactory.createXYBarChart(Misc.getString("PLAY_COUNT"), Misc.getString("PLAY_COUNT"), false, Misc.getString("NUMBER_OF_SONGS"), _dataset, PlotOrientation.VERTICAL, false, true, false); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("PLAY_COUNT_SUBTITLE"))); // then customise it a little... XYPlot plot = (XYPlot) _chart.getPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); plot.setForegroundAlpha(0.75f);/*from w w w. ja v a 2 s . c o m*/ ChartUtilities.applyCurrentTheme(_chart); renderer.setBarPainter(new StandardXYBarPainter()); renderer.setShadowVisible(false); plot.setDomainGridlinesVisible(false); plot.setRangeGridlinesVisible(false); domainAxis.setLowerMargin(0); domainAxis.setUpperMargin(0); // domainAxis.setLowerBound(0); // domainAxis.setAutoRangeIncludesZero(true); // domainAxis.setAutoRangeStickyZero(true); Misc.formatChart(plot); renderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:umontreal.iro.lecuyer.charts.Axis.java
/** * Create a new <TT>Axis</TT> instance from an existing <TT>NumberAxis</TT> * instance with vertical (<SPAN CLASS="MATH"><I>y</I></SPAN>-axis) or horizontal (<SPAN CLASS="MATH"><I>x</I></SPAN>-axis) orientation. * //from w ww. j a va 2 s . c o m * @param inAxis NumberAxis instance associated to the new variable. * * @param orientation axis direction, horizontal or vertical * */ public Axis(NumberAxis inAxis, boolean orientation) { this.axis = inAxis; this.orientation = orientation; this.labelsFlag = false; this.labelsValue = null; this.labelsName = null; inAxis.setAutoRangeIncludesZero(false); inAxis.setLowerMargin(0); inAxis.setUpperMargin(0); axis.setTickUnit(new NumberTickUnit(computeAutoTickValue())); }
From source file:adapters.AxisAdapter.java
/** * Create a new <TT>AxisAdapter</TT> instance from an existing <TT>NumberAxis</TT> * instance with vertical (<SPAN CLASS="MATH"><I>y</I></SPAN>-axis) or horizontal (<SPAN CLASS="MATH"><I>x</I></SPAN>-axis) orientation. * * @param inAxis NumberAxis instance associated to the new variable. * * @param orientation axis direction, horizontal or vertical * *//*from www . ja va2 s . c om*/ public AxisAdapter(NumberAxis inAxis, boolean orientation) { this.axis = inAxis; this.orientation = orientation; this.labelsFlag = false; this.labelsValue = null; this.labelsName = null; inAxis.setAutoRangeIncludesZero(false); inAxis.setLowerMargin(0); inAxis.setUpperMargin(0); axis.setTickUnit(new NumberTickUnit(computeAutoTickValue())); }
From source file:net.sf.mzmine.modules.visualization.tic.TICPlot.java
public TICPlot(final ActionListener listener) { super(null, true); // Initialize. visualizer = listener;//w w w .j a va2s. co m labelsVisible = 1; havePeakLabels = false; numOfDataSets = 0; numOfPeaks = 0; showSpectrumRequest = false; // Set cursor. setCursor(Cursor.getPredefinedCursor(Cursor.CROSSHAIR_CURSOR)); // Y-axis label. final String yAxisLabel; if (listener instanceof TICVisualizerWindow) { yAxisLabel = ((TICVisualizerWindow) listener).getPlotType() == PlotType.BASEPEAK ? "Base peak intensity" : "Total ion intensity"; } else { yAxisLabel = "Base peak intensity"; } // Initialize the chart by default time series chart from factory. final JFreeChart chart = ChartFactory.createXYLineChart("", // title "Retention time", // x-axis label yAxisLabel, // y-axis label null, // data set PlotOrientation.VERTICAL, // orientation true, // create legend? true, // generate tooltips? false // generate URLs? ); chart.setBackgroundPaint(Color.white); setChart(chart); // Title. chartTitle = chart.getTitle(); chartTitle.setFont(TITLE_FONT); chartTitle.setMargin(TITLE_TOP_MARGIN, 0.0, 0.0, 0.0); // Subtitle. chartSubTitle = new TextTitle(); chartSubTitle.setFont(SUBTITLE_FONT); chartSubTitle.setMargin(TITLE_TOP_MARGIN, 0.0, 0.0, 0.0); chart.addSubtitle(chartSubTitle); // Disable maximum size (we don't want scaling). setMaximumDrawWidth(Integer.MAX_VALUE); setMaximumDrawHeight(Integer.MAX_VALUE); // Legend constructed by ChartFactory. final LegendTitle legend = chart.getLegend(); legend.setItemFont(LEGEND_FONT); legend.setFrame(BlockBorder.NONE); // Set the plot properties. plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(AXIS_OFFSET); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); // Set grid properties. plot.setDomainGridlinePaint(GRID_COLOR); plot.setRangeGridlinePaint(GRID_COLOR); // Set cross-hair (selection) properties. if (listener instanceof TICVisualizerWindow) { plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); plot.setDomainCrosshairPaint(CROSS_HAIR_COLOR); plot.setRangeCrosshairPaint(CROSS_HAIR_COLOR); plot.setDomainCrosshairStroke(CROSS_HAIR_STROKE); plot.setRangeCrosshairStroke(CROSS_HAIR_STROKE); } // Set the x-axis (retention time) properties. final NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setNumberFormatOverride(MZmineCore.getConfiguration().getRTFormat()); xAxis.setUpperMargin(AXIS_MARGINS); xAxis.setLowerMargin(AXIS_MARGINS); // Set the y-axis (intensity) properties. final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setNumberFormatOverride(MZmineCore.getConfiguration().getIntensityFormat()); // Set default renderer properties. defaultRenderer = new TICPlotRenderer(); defaultRenderer.setBaseShapesFilled(true); defaultRenderer.setDrawOutlines(false); defaultRenderer.setUseFillPaint(true); defaultRenderer.setBaseItemLabelPaint(LABEL_COLOR); // Set label generator final XYItemLabelGenerator labelGenerator = new TICItemLabelGenerator(this); defaultRenderer.setBaseItemLabelGenerator(labelGenerator); defaultRenderer.setBaseItemLabelsVisible(true); // Set toolTipGenerator final XYToolTipGenerator toolTipGenerator = new TICToolTipGenerator(); defaultRenderer.setBaseToolTipGenerator(toolTipGenerator); // Set focus state to receive key events. setFocusable(true); // Register key handlers. GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("LEFT"), listener, "MOVE_CURSOR_LEFT"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("RIGHT"), listener, "MOVE_CURSOR_RIGHT"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke("SPACE"), listener, "SHOW_SPECTRUM"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('+'), this, "ZOOM_IN"); GUIUtils.registerKeyHandler(this, KeyStroke.getKeyStroke('-'), this, "ZOOM_OUT"); // Add items to popup menu. final JPopupMenu popupMenu = getPopupMenu(); popupMenu.addSeparator(); if (listener instanceof TICVisualizerWindow) { popupMenu.add(new ExportPopUpMenu((TICVisualizerWindow) listener)); popupMenu.addSeparator(); popupMenu.add(new AddFilePopupMenu((TICVisualizerWindow) listener)); popupMenu.add(new RemoveFilePopupMenu((TICVisualizerWindow) listener)); popupMenu.add(new ExportPopUpMenu((TICVisualizerWindow) listener)); popupMenu.addSeparator(); } GUIUtils.addMenuItem(popupMenu, "Toggle showing peak values", this, "SHOW_ANNOTATIONS"); GUIUtils.addMenuItem(popupMenu, "Toggle showing data points", this, "SHOW_DATA_POINTS"); if (listener instanceof TICVisualizerWindow) { popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Show spectrum of selected scan", listener, "SHOW_SPECTRUM"); } popupMenu.addSeparator(); GUIUtils.addMenuItem(popupMenu, "Set axes range", this, "SETUP_AXES"); if (listener instanceof TICVisualizerWindow) { GUIUtils.addMenuItem(popupMenu, "Set same range to all windows", this, "SET_SAME_RANGE"); } }
From source file:edu.ucla.stat.SOCR.analyses.gui.Chart.java
protected JFreeChart createQQChart(String title, String xLabel, String yLabel, XYDataset dataset, String other) {//from w w w . j a v a 2s . c om // create the chart... JFreeChart chart = ChartFactory.createXYLineChart(title, // chart title xLabel, // x axis label yLabel, // 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); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer(); // renderer.setShapesVisible(true); renderer.setBaseShapesFilled(true); // renderer.setLinesVisible(false); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(1, false); renderer.setSeriesLinesVisible(0, false); renderer.setSeriesShapesVisible(0, true); //renderer.setLegendItemLabelGenerator(new SOCRXYSeriesLabelGenerator()); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setAutoRangeIncludesZero(false); rangeAxis.setUpperMargin(0.02); rangeAxis.setLowerMargin(0.02); // rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0.02); domainAxis.setLowerMargin(0.02); // domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. //setQQSummary(dataset); // very confusing return chart; }
From source file:org.csa.rstb.dat.toolviews.HaAlphaPlotPanel.java
private void createUI() { plot = new XYImagePlot(); plot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); domainAxis.setAutoRangeIncludesZero(false); rangeAxis.setAutoRangeIncludesZero(false); domainAxis.setUpperMargin(0); domainAxis.setLowerMargin(0);/*from w ww .ja v a2 s .c om*/ rangeAxis.setUpperMargin(0); rangeAxis.setLowerMargin(0); plot.setNoDataMessage(NO_DATA_MESSAGE); plot.getRenderer().setBaseToolTipGenerator(new XYPlotToolTipGenerator()); JFreeChart chart = new JFreeChart(CHART_TITLE, plot); ChartFactory.getChartTheme().apply(chart); chart.removeLegend(); createUI(createChartPanel(chart), createOptionsPanel(), bindingContext); updateUIState(); }
From source file:com.googlecode.logVisualizer.chart.HorizontalBarChartBuilder.java
private JFreeChart createChart(final CategoryDataset dataset) { final JFreeChart chart = ChartFactory.createBarChart(getTitle(), xLable, yLable, dataset, PlotOrientation.HORIZONTAL, isIncludeLegend(), true, false); final CategoryPlot plot = (CategoryPlot) chart.getPlot(); final BarRenderer renderer = (BarRenderer) plot.getRenderer(); final CategoryAxis categoryAxis = plot.getDomainAxis(); final NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis(); plot.setNoDataMessage("No data available"); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); setBarShadowVisible(chart, false);/*from w w w . j a v a2s . com*/ renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); renderer.setBaseToolTipGenerator( new StandardCategoryToolTipGenerator("{1}, {2}", NumberFormat.getInstance())); categoryAxis.setCategoryMargin(0.02); categoryAxis.setUpperMargin(0.02); categoryAxis.setLowerMargin(0.02); numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberAxis.setUpperMargin(0.1); return chart; }
From source file:it.eng.spagobi.engines.chart.bo.charttypes.barcharts.SimpleBar.java
public JFreeChart createChart(DatasetMap datasets) { logger.debug("IN"); CategoryDataset dataset = (CategoryDataset) datasets.getDatasets().get("1"); PlotOrientation plotOrientation = PlotOrientation.VERTICAL; if (horizontalView) { plotOrientation = PlotOrientation.HORIZONTAL; }//from w w w. j a v a 2s . c o m JFreeChart chart = ChartFactory.createBarChart(name, // chart title categoryLabel, // domain axis label valueLabel, // range axis label dataset, // data plotOrientation, // orientation false, // include legend true, // tooltips? false // URLs? ); TextTitle title = setStyleTitle(name, styleTitle); chart.setTitle(title); if (subName != null && !subName.equals("")) { TextTitle subTitle = setStyleTitle(subName, styleSubTitle); chart.addSubtitle(subTitle); } // set the background color for the chart... chart.setBackgroundPaint(color); // get a reference to the plot for further customisation... CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.white); NumberFormat nf = NumberFormat.getNumberInstance(locale); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setLabelPaint(styleXaxesLabels.getColor()); rangeAxis .setTickLabelFont(new Font(styleXaxesLabels.getFontName(), Font.PLAIN, styleXaxesLabels.getSize())); rangeAxis.setTickLabelPaint(styleXaxesLabels.getColor()); rangeAxis.setUpperMargin(0.10); rangeAxis.setNumberFormatOverride(nf); if (firstAxisLB != null && firstAxisUB != null) { rangeAxis.setLowerBound(firstAxisLB); rangeAxis.setUpperBound(firstAxisUB); } if (rangeIntegerValues == true) { rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); } else rangeAxis.setStandardTickUnits(NumberAxis.createStandardTickUnits()); if (rangeAxisLocation != null) { if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_LEFT); } else if (rangeAxisLocation.equalsIgnoreCase("BOTTOM_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.BOTTOM_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_RIGHT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_RIGHT); } else if (rangeAxisLocation.equalsIgnoreCase("TOP_OR_LEFT")) { plot.setRangeAxisLocation(0, AxisLocation.TOP_OR_LEFT); } } // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // add CategorySeriesLabelGenerator generator = new StandardCategorySeriesLabelGenerator("{0}"); renderer.setLegendItemLabelGenerator(generator); if (maxBarWidth != null) { renderer.setMaximumBarWidth(maxBarWidth.doubleValue()); } if (showValueLabels) { renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelGenerator(new FilterZeroStandardCategoryItemLabelGenerator()); renderer.setBaseItemLabelFont( new Font(styleValueLabels.getFontName(), Font.PLAIN, styleValueLabels.getSize())); renderer.setBaseItemLabelPaint(styleValueLabels.getColor()); // if(valueLabelsPosition.equalsIgnoreCase("inside")){ // renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); // renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.CENTER, TextAnchor.BASELINE_LEFT)); // } else { // renderer.setBasePositiveItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT)); // renderer.setBaseNegativeItemLabelPosition(new ItemLabelPosition( // ItemLabelAnchor.OUTSIDE3, TextAnchor.BASELINE_LEFT)); // } } // PROVA LEGENDA if (legend == true) { drawLegend(chart); /*BlockContainer wrapper = new BlockContainer(new BorderArrangement()); wrapper.setFrame(new BlockBorder(1.0, 1.0, 1.0, 1.0)); LabelBlock titleBlock = new LabelBlock("Legend Items:", new Font("SansSerif", Font.BOLD, 12)); title.setPadding(5, 5, 5, 5); wrapper.add(titleBlock, RectangleEdge.TOP); LegendTitle legend = new LegendTitle(chart.getPlot()); BlockContainer items = legend.getItemContainer(); items.setPadding(2, 10, 5, 2); wrapper.add(items); legend.setWrapper(wrapper); if(legendPosition.equalsIgnoreCase("bottom")) legend.setPosition(RectangleEdge.BOTTOM); else if(legendPosition.equalsIgnoreCase("left")) legend.setPosition(RectangleEdge.LEFT); else if(legendPosition.equalsIgnoreCase("right")) legend.setPosition(RectangleEdge.RIGHT); else if(legendPosition.equalsIgnoreCase("top")) legend.setPosition(RectangleEdge.TOP); else legend.setPosition(RectangleEdge.BOTTOM); legend.setHorizontalAlignment(HorizontalAlignment.LEFT); chart.addSubtitle(legend);*/ } int seriesN = dataset.getRowCount(); // the order color vedctor overrides the color map!! if (orderColorVector != null && orderColorVector.size() > 0) { logger.debug("color serie by SERIES_ORDER_COLORS template specification"); for (int i = 0; i < seriesN; i++) { if (orderColorVector.get(i) != null) { Color color = orderColorVector.get(i); renderer.setSeriesPaint(i, color); } } } else if (colorMap != null) { logger.debug("color serie by SERIES_COLORS template specification"); for (int i = 0; i < seriesN; i++) { String serieName = (String) dataset.getRowKey(i); String labelName = ""; int index = -1; if (seriesCaptions != null && seriesCaptions.size() > 0) { labelName = serieName; serieName = (String) seriesCaptions.get(serieName); index = dataset.getRowIndex(labelName); } else index = dataset.getRowIndex(serieName); Color color = (Color) colorMap.get(serieName); if (color != null) { //renderer.setSeriesPaint(i, color); renderer.setSeriesPaint(index, color); renderer.setSeriesItemLabelFont(i, new Font(defaultLabelsStyle.getFontName(), Font.PLAIN, defaultLabelsStyle.getSize())); renderer.setSeriesItemLabelPaint(i, defaultLabelsStyle.getColor()); } } } CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); domainAxis.setLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setLabelPaint(styleYaxesLabels.getColor()); domainAxis .setTickLabelFont(new Font(styleYaxesLabels.getFontName(), Font.PLAIN, styleYaxesLabels.getSize())); domainAxis.setTickLabelPaint(styleYaxesLabels.getColor()); domainAxis.setUpperMargin(0.10); logger.debug("OUT"); return chart; }
From source file:com.googlecode.logVisualizer.chart.VerticalXYBarChartBuilder.java
private JFreeChart createChart(final IntervalXYDataset dataset) { final JFreeChart chart = ChartFactory.createXYBarChart(getTitle(), xLable, false, yLable, dataset, PlotOrientation.VERTICAL, isIncludeLegend(), true, false); final XYPlot plot = (XYPlot) chart.getPlot(); final NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); double lastXValue = 0; if (dataset.getSeriesCount() > 0) lastXValue = dataset.getXValue(0, dataset.getItemCount(0) - 1); plot.setDomainAxis(new FixedZoomNumberAxis(lastXValue)); plot.setNoDataMessage("No data available"); plot.setBackgroundPaint(Color.white); plot.setRangeGridlinePaint(Color.black); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); setBarShadowVisible(chart, false);/* ww w .j ava 2 s. co m*/ plot.getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits()); if (dataset.getSeriesCount() > 0) plot.getDomainAxis().setUpperBound(lastXValue); plot.getDomainAxis().setLowerBound(0); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); yAxis.setUpperMargin(0.1); return chart; }