List of usage examples for org.jfree.chart.axis CategoryAxis setMaximumCategoryLabelLines
public void setMaximumCategoryLabelLines(int lines)
From source file:com.att.aro.ui.view.overviewtab.TraceBenchmarkChartPanel.java
private JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createBarChart( ResourceBundleHelper.getMessageString("overview.traceoverview.title"), null, null, createDataset(), PlotOrientation.HORIZONTAL, false, true, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis valueRangeAxis = plot.getDomainAxis(); valueRangeAxis.setMaximumCategoryLabelWidthRatio(1.0f); valueRangeAxis.setMaximumCategoryLabelLines(2); valueRangeAxis.setLabelFont(AROUIManager.LABEL_FONT); valueRangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentile")); rangeAxis.setRange(0.0, 100.0);/* w w w. j a v a 2s .co m*/ rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String traceInfo = ""; switch (arg2) { case TRACE_AVERAGE: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.avg"); break; case TRACE_ENERGY: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.engy"); break; case TRACE_OVERHEAD: traceInfo = ResourceBundleHelper.getMessageString("tooltip.traceAnalysis.ovrhd"); break; default: break; } return traceInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); return chart; }
From source file:com.att.aro.ui.view.overviewtab.ConnectionStatisticsChartPanel.java
public JFreeChart initializeChart() { JFreeChart chart = ChartFactory.createBarChart( ResourceBundleHelper.getMessageString("overview.sessionoverview.title"), null, null, createDataset(), PlotOrientation.HORIZONTAL, false, false, false); chart.setBackgroundPaint(this.getBackground()); chart.getTitle().setFont(AROUIManager.HEADER_FONT); this.plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.white); plot.setDomainGridlinePaint(Color.gray); plot.setRangeGridlinePaint(Color.gray); plot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_RIGHT); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setMaximumCategoryLabelWidthRatio(1.0f); domainAxis.setMaximumCategoryLabelLines(2); domainAxis.setLabelFont(AROUIManager.LABEL_FONT); domainAxis.setTickLabelFont(AROUIManager.LABEL_FONT); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setLabel(ResourceBundleHelper.getMessageString("analysisresults.percentage")); rangeAxis.setRange(0.0, 100.0);/* www. j a v a2 s.c o m*/ rangeAxis.setTickUnit(new NumberTickUnit(10)); rangeAxis.setLabelFont(AROUIManager.LABEL_FONT); rangeAxis.setTickLabelFont(AROUIManager.LABEL_FONT); BarRenderer renderer = new StackedBarRenderer(); renderer.setBasePaint(AROUIManager.CHART_BAR_COLOR); renderer.setAutoPopulateSeriesPaint(false); renderer.setBaseItemLabelGenerator(new PercentLabelGenerator()); renderer.setBaseItemLabelsVisible(true); renderer.setBaseItemLabelPaint(Color.black); // Make second bar in stack invisible renderer.setSeriesItemLabelsVisible(1, false); renderer.setSeriesPaint(1, new Color(0, 0, 0, 0)); ItemLabelPosition insideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT); renderer.setBasePositiveItemLabelPosition(insideItemlabelposition); ItemLabelPosition outsideItemlabelposition = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE3, TextAnchor.CENTER_LEFT); renderer.setPositiveItemLabelPositionFallback(outsideItemlabelposition); renderer.setBarPainter(new StandardBarPainter()); renderer.setShadowVisible(false); renderer.setMaximumBarWidth(BAR_WIDTH_PERCENT); renderer.setBaseToolTipGenerator(new CategoryToolTipGenerator() { @Override public String generateToolTip(CategoryDataset arg0, int arg1, int arg2) { String sessionInfo = ""; switch (arg2) { case SESSION_TERMINATION: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTermination"); break; case SESSION_TIGHT_CONN: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionTightConn"); break; case SESSION_BURST: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionBurst"); break; case SESSION_LONG_BURST: sessionInfo = ResourceBundleHelper.getMessageString("tooltip.sessionLongBurst"); break; default: break; } return sessionInfo; } }); plot.setRenderer(renderer); plot.getDomainAxis().setMaximumCategoryLabelLines(2); return chart; }
From source file:dk.sdu.mmmi.featureous.views.featurecharacterization.FeatureViewChart.java
public FeatureViewChart(List<TraceModel> ftms, final boolean pkg) { this.pkg = pkg; data = new DefaultCategoryDataset(); chart = ChartFactory.createStackedBarChart("Feature characterization", "Feature", "Scattering", data, PlotOrientation.VERTICAL, true, false, false); plot = (CategoryPlot) chart.getPlot(); CategoryAxis xAxis = (CategoryAxis) plot.getDomainAxis(); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); xAxis.setMaximumCategoryLabelLines(2); // chart.getLegend().setPosition(RectangleEdge.RIGHT); // chart.getLegend().setVerticalAlignment(VerticalAlignment.TOP); // chart.getLegend().setHorizontalAlignment(HorizontalAlignment.LEFT); LegendItemCollection lic = new LegendItemCollection(); // lic.add(new LegendItem("Infrastructural unit", "", "", "", new Rectangle(10, 10), Color.GREEN)); // lic.add(new LegendItem("Group-feature unit", "", "", "", new Rectangle(10, 10), Color.BLUE)); // lic.add(new LegendItem("Single-feature unit", "", "", "", new Rectangle(10, 10), Color.RED)); plot.setFixedLegendItems(lic);/* w w w. j ava 2s . c o m*/ // chart.removeLegend(); panel = new ChartPanel(chart); chart.setBackgroundPaint(Color.white); this.ftms = ftms; scattering = new ArrayList<Result>( new StaticScattering(pkg).calculateAndReturnAll(new HashSet<TraceModel>(ftms), null)); Result.sortByName(scattering); for (Result r : scattering) { // OutputUtil.log(r.name + ";" +r.value); } panel.getPopupMenu().setEnabled(false);//add(SVGExporter.createExportAction(chart, panel)); StackedBarRenderer r2 = new StackedBarRenderer() { @Override public void drawItem(Graphics2D g2, CategoryItemRendererState state, Rectangle2D dataArea, CategoryPlot plot, CategoryAxis domainAxis, ValueAxis rangeAxis, CategoryDataset dataset, int row, int column, int pass) { super.drawItem(g2, state, dataArea, plot, domainAxis, rangeAxis, dataset, row, column, pass); double start = plot.getDomainAxis().getCategoryStart(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); double end = plot.getDomainAxis().getCategoryEnd(column, getColumnCount(), dataArea, plot.getDomainAxisEdge()); String compUnit = data.getRowKey(row).toString(); // Calculate y coeffs double posBase = getBase(); for (int i = 0; i < row; i++) { Number val = dataset.getValue(i, column); if (val != null) { posBase = posBase + val.doubleValue(); } } Number value = dataset.getValue(row, column); if (value == null) { return; } double val = value.doubleValue(); double translatedBase = plot.getRangeAxis().valueToJava2D(posBase, dataArea, plot.getRangeAxisEdge()); double translatedValue = plot.getRangeAxis().valueToJava2D(posBase + val, dataArea, plot.getRangeAxisEdge()); if (Controller.getInstance().getTraceSet().getSelectionManager().getSelectedClasses() .contains(compUnit) || Controller.getInstance().getTraceSet().getSelectionManager().getSelectedPkgs() .contains(compUnit)) { g2.setPaint(UIUtils.SELECTION_COLOR); g2.setStroke(new BasicStroke(3f)); Line2D l2d = new Line2D.Double(start, translatedBase, start, translatedValue); g2.draw(l2d); l2d = new Line2D.Double(end, translatedBase, end, translatedValue); g2.draw(l2d); l2d = new Line2D.Double(start, translatedBase, end, translatedBase); g2.draw(l2d); l2d = new Line2D.Double(start, translatedValue, end, translatedValue); g2.draw(l2d); } } }; plot.setRenderer(r2, true); StackedBarRenderer r = (StackedBarRenderer) plot.getRenderer(); r.setDrawBarOutline(true); plot.getRenderer().setOutlineStroke(new BasicStroke(0.1f)); Controller.getInstance().getTraceSet().getSelectionManager().addSelectionListener(this); }
From source file:desmoj.extensions.grafic.util.Plotter.java
/** * Build a JPanel with a histogram plot of a desmoJ histogramAccumulate dataset * In the case histogram.getShowTimeSpansInReport() the data values are interpreted as * a timespan in a appropriate time unit. * @param histogram desmoJ histogramAccumulate dataset * @return//from w w w.j ava 2 s. c o m */ private JPanel getHistogramAccumulatePlot(HistogramAccumulate histogram) { JFreeChart chart; NumberFormat formatter = NumberFormat.getInstance(locale); HistogramDataSetAdapter dataSet = new HistogramDataSetAdapter(histogram, locale); String title = histogram.getName(); if (histogram.getDescription() != null) title = histogram.getDescription(); String xLabel = dataSet.getCategoryAxisLabel(); String yLabel = dataSet.getObservationAxisLabel(); chart = ChartFactory.createBarChart(title, xLabel, yLabel, dataSet, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) chart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setBaseItemLabelsVisible(true); StandardCategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator("{2}", formatter); barrenderer.setBaseItemLabelGenerator(generator); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setMaximumCategoryLabelLines(4); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setNumberFormatOverride(formatter); return new ChartPanel(chart); }
From source file:org.ow2.clif.jenkins.ClifProjectAction.java
private JFreeChart createActionErrorGraph(ClifGraphParam params) { DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> errorsDS = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>(); List<AbstractBuild> builds = new ArrayList<AbstractBuild>(getProject().getBuilds()); Collections.sort(builds);//from w ww .j ava2 s . c o m for (Run<?, ?> currentBuild : builds) { Result buildResult = currentBuild.getResult(); if (buildResult != null && buildResult.isBetterOrEqualTo(Result.SUCCESS)) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(currentBuild); ClifBuildAction clifBuildAction = currentBuild.getAction(ClifBuildAction.class); if (clifBuildAction == null) { continue; } ClifReport clifReport = clifBuildAction.getReport(); if (clifReport == null) { continue; } TestPlan tp = clifReport.getTestplan(params.getTestPlan()); if (tp == null) { continue; } if (tp.getAggregatedMeasures() != null) { Measure m = tp.getAggregatedMeasure(params.getLabel()); if (m == null) { continue; } errorsDS.add(m.errorPercent() * 100, Messages.ProjectAction_Errors(), label); } } } final CategoryAxis xAxis = new CategoryAxis(Messages.ProjectAction_BuildAxis()); xAxis.setLowerMargin(0.01); xAxis.setUpperMargin(0.01); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); xAxis.setMaximumCategoryLabelLines(3); final ValueAxis errorsAxis = new NumberAxis(Messages.ProjectAction_ErrorAxis()); errorsAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); errorsAxis.setUpperMargin(0.1); final LineAndShapeRenderer errorRenderer = new LineAndShapeRenderer(); errorRenderer.setItemMargin(0.0); final CategoryPlot plot = new CategoryPlot(errorsDS.build(), xAxis, errorsAxis, errorRenderer); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); JFreeChart chart = new JFreeChart(Messages.ProjectAction_PercentageOfErrors(), plot); chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:netmason.support.graphics.GanttDisplay.java
public GanttDisplay(String title) { super(title); collection.add(s1);// w w w . j a va2 s . co m // create the chart... chart = ChartFactory.createGanttChart("Gantt Chart", // chart title "Agent", // domain axis label "Date", // range axis label collection, // data false, // include legend true, // tooltips false // urls ); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); plot.setDomainGridlinePosition(CategoryAnchor.START); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setTickLabelPaint(Color.blue); domainAxis.setAxisLineVisible(false); domainAxis.setCategoryLabelPositionOffset(0); domainAxis.setMaximumCategoryLabelLines(2); domainAxis.setMaximumCategoryLabelWidthRatio(0.3f); renderer.setSeriesPaint(0, Color.blue); // add the chart to a panel... ChartPanel chartPanel = new ChartPanel(chart); setContentPane(chartPanel); }
From source file:org.ow2.clif.jenkins.ClifProjectAction.java
private JFreeChart createActionGraph(ClifGraphParam params) { DefaultStatisticalCategoryDataset timeDS = new DefaultStatisticalCategoryDataset(); DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel> minmaxDS = new DataSetBuilder<String, ChartUtil.NumberOnlyBuildLabel>(); List<AbstractBuild> builds = new ArrayList<AbstractBuild>(getProject().getBuilds()); Collections.sort(builds);/* www .j a v a 2 s . com*/ for (Run<?, ?> currentBuild : builds) { Result buildResult = currentBuild.getResult(); if (buildResult != null && buildResult.isBetterOrEqualTo(Result.SUCCESS)) { ChartUtil.NumberOnlyBuildLabel label = new ChartUtil.NumberOnlyBuildLabel(currentBuild); ClifBuildAction clifBuildAction = currentBuild.getAction(ClifBuildAction.class); if (clifBuildAction == null) { continue; } ClifReport clifReport = clifBuildAction.getReport(); if (clifReport == null) { continue; } TestPlan tp = clifReport.getTestplan(params.getTestPlan()); if (tp == null) { continue; } if (tp.getAggregatedMeasures() != null) { Measure m = tp.getAggregatedMeasure(params.getLabel()); if (m == null) { continue; } timeDS.add(m.getAverage(), m.getStdDev(), Messages.ProjectAction_Mean(), label); minmaxDS.add(m.getMax(), Messages.ProjectAction_Max(), label); minmaxDS.add(m.getMin(), Messages.ProjectAction_Min(), label); } } } final CategoryAxis xAxis = new CategoryAxis(Messages.ProjectAction_BuildAxis()); xAxis.setLowerMargin(0.01); xAxis.setUpperMargin(0.01); xAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); xAxis.setMaximumCategoryLabelLines(3); final ValueAxis timeAxis = new NumberAxis(Messages.ProjectAction_TimeAxis()); timeAxis.setUpperMargin(0.1); // final ValueAxis minmaxTimeAxis = new NumberAxis("Time (ms)"); final BarRenderer timeRenderer = new StatisticalBarRenderer(); timeRenderer.setSeriesPaint(2, ColorPalette.RED); timeRenderer.setSeriesPaint(1, ColorPalette.YELLOW); timeRenderer.setSeriesPaint(0, ColorPalette.BLUE); timeRenderer.setItemMargin(0.0); final CategoryPlot plot = new CategoryPlot(timeDS, xAxis, timeAxis, timeRenderer); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); final CategoryItemRenderer minmaxRenderer = new LineAndShapeRenderer(); // plot.setRangeAxis(1, timeAxis); plot.setDataset(1, minmaxDS.build()); plot.mapDatasetToRangeAxis(1, 0); plot.setRenderer(1, minmaxRenderer); JFreeChart chart = new JFreeChart(params.getLabel(), plot); chart.setBackgroundPaint(Color.WHITE); return chart; }
From source file:com.xpn.xwiki.plugin.charts.ChartCustomizer.java
public static void customizeCategoryAxis(CategoryAxis axis, ChartParams params, String prefix) { customizeAxis(axis, params, prefix); if (params.get(prefix + ChartParams.CATEGORY_AXIS_CATEGORY_MARGIN_SUFFIX) != null) { axis.setCategoryMargin(/*w w w . ja va 2s . com*/ params.getDouble(prefix + ChartParams.CATEGORY_AXIS_CATEGORY_MARGIN_SUFFIX).doubleValue()); } if (params.get(prefix + ChartParams.CATEGORY_AXIS_LABEL_POSITIONS_SUFFIX) != null) { axis.setCategoryLabelPositions( params.getCategoryLabelPositions(prefix + ChartParams.CATEGORY_AXIS_LABEL_POSITIONS_SUFFIX)); } if (params.get(prefix + ChartParams.CATEGORY_AXIS_LABEL_POSITION_OFFSET_SUFFIX) != null) { axis.setCategoryLabelPositionOffset( params.getInteger(prefix + ChartParams.CATEGORY_AXIS_LABEL_POSITION_OFFSET_SUFFIX).intValue()); } if (params.get(prefix + ChartParams.CATEGORY_AXIS_MAXIMUM_LABEL_LINES_SUFFIX) != null) { axis.setMaximumCategoryLabelLines( params.getInteger(prefix + ChartParams.CATEGORY_AXIS_MAXIMUM_LABEL_LINES_SUFFIX).intValue()); } if (params.get(prefix + ChartParams.CATEGORY_AXIS_MAXIMUM_LABEL_WIDTH_RATIO_SUFFIX) != null) { axis.setMaximumCategoryLabelWidthRatio(params .getFloat(prefix + ChartParams.CATEGORY_AXIS_MAXIMUM_LABEL_WIDTH_RATIO_SUFFIX).floatValue()); } }
From source file:com.wicht.benchmark.utils.Benchs.java
/** * Generate the chart.// w w w. j a v a2 s. c o m * * @param title The title of the chart. * @param benchmarks The benchmarks to include in the chart. * @param sub A boolean tag indicating if we want to generate sub chart ({@code true}) or not ({@code * false}). * @param prefix The time prefix. */ private void generateChart(String title, Collection<NamedBenchmark> benchmarks, boolean sub, Prefix prefix) { String data = "Time (" + prefix.getSymbol() + "s)"; DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (NamedBenchmark benchmark : benchmarks) { dataset.addValue(getExactMean(benchmark.getMean(), prefix), "", benchmark.getTitle()); } JFreeChart chart = ChartFactory.createBarChart(title.replace("-sub", ""), "Methods", data, dataset, PlotOrientation.VERTICAL, false, false, false); final CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); domainAxis.setMaximumCategoryLabelLines(5); BufferedImage image = chart.createBufferedImage(width, height); try { ImageIO.write(image, "png", new File(folder + title + ".png")); } catch (IOException e) { e.printStackTrace(); } if (sub) { generateSubChart(title, benchmarks); } }
From source file:stockit.ClientFrame.java
private void createChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int row = StockInfoTable.getSelectedRow(); if (row != -1) { //dataset.setValue(, "", table.getValueAt(0,1).toString()); String selectedStock = StockInfoTable.getValueAt(row, 0).toString(); try {//from w w w. ja v a 2s .com DBConnection dbcon = new DBConnection(); dbcon.establishConnection(); Statement stmt = dbcon.con.createStatement(); ResultSet rs = stmt .executeQuery("Select stock_daily_performance.Closing_Price, stock_daily_performance.Date\n" + "FROM stock_daily_performance, stock\n" + "WHERE stock_daily_performance.StockID = stock.StockID AND stock.StockID = '" + selectedStock + "'" + "AND Date IN\n" + "( Select * from\n" + "(\n" + "SELECT Date \n" + "FROM stock_daily_performance \n" + "WHERE StockID = stockID \n" + "ORDER BY Date ASC\n" + ") temp_table)\n" + " "); while (rs.next()) { String formattedDate = rs.getString("Date"); int closing_price = rs.getInt("Closing_Price"); dataset.setValue(closing_price, "value", formattedDate); } dbcon.con.close(); } catch (Exception ex) { System.out.println(ex.toString()); } String stockName = StockInfoTable.getValueAt(row, 1).toString(); JFreeChart chart = ChartFactory.createBarChart3D(stockName + " Stock Performance", "Date", "Value", dataset, PlotOrientation.VERTICAL, false, false, false); Color c = new Color(240, 240, 240, 0); chart.setBackgroundPaint(c); CategoryPlot catPlot = chart.getCategoryPlot(); catPlot.setRangeGridlinePaint(Color.BLACK); //set interval of Y-axis ticks (tick every 5 units) NumberAxis yAxis = (NumberAxis) catPlot.getRangeAxis(); yAxis.setTickUnit(new NumberTickUnit(5)); //set y-axis labels as currency types ($) NumberFormat currency = NumberFormat.getCurrencyInstance(); yAxis.setNumberFormatOverride(currency); //setting number of lines an x-axis label is displayed on CategoryAxis categoryAxis = catPlot.getDomainAxis(); categoryAxis.setMaximumCategoryLabelLines(4); ChartContainer.setLayout(new java.awt.BorderLayout()); ChartPanel chartPanel = new ChartPanel(chart); ChartContainer.removeAll(); ChartContainer.add(chartPanel, BorderLayout.CENTER); ChartContainer.validate(); ChartContainer.repaint(); } }