List of usage examples for org.jfree.chart JFreeChart getCategoryPlot
public CategoryPlot getCategoryPlot()
From source file:hudson.plugins.codeviation.MetricsAction.java
private JFreeChart createChart(CategoryDataset dataset, int maxVal) { final JFreeChart chart = ChartFactory.createLineChart(null, // chart title null, // unused "count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );/*w w w. j av a2s . c om*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperBound(maxVal); rangeAxis.setLowerBound(0); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setStroke(new BasicStroke(4.0f)); // crop extra space around the graph plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:BarChartDemo.java
/** * Creates a sample chart./* w ww . j av a2 s . c o m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customization... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:gui.BarChart.java
/** * Zusammenbauen des Diagrammes.//from www . j av a2s.c o m * * @return diagramm */ private JFreeChart createChart() { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("", // berschrift label_x_axis, // x label label_y_axis, // y label dataset, // datenstze PlotOrientation.VERTICAL, // vertikale balken true, // mit legende true, // mit tooltips false // URLs??? ); // Layoutanpassungen im Folgende: // allg. Hintergrundfarbe chart.setBackgroundPaint(Color.white); // Referenz auf Zeichnung: final CategoryPlot plot = chart.getCategoryPlot(); plot.setNoDataMessage("NO DATA!"); // aussehen des eigentlichen diagrammes: plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); plot.setDomainGridlinesVisible(true); // skaleneinteilung: final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperMargin(0.1); // kategorien renderer einstellungen verndern: final CategoryItemRenderer categories = plot.getRenderer(); // casten in bar renderer: final BarRenderer bars = (BarRenderer) categories; // werte im diagramm anzeigen: categories.setLabelGenerator(new StandardCategoryLabelGenerator()); categories.setItemLabelsVisible(true); final ItemLabelPosition p = new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.CENTER, TextAnchor.CENTER, -Math.PI / 6); categories.setPositiveItemLabelPosition(p); categories.setNegativeItemLabelPosition(p); plot.setRenderer(categories); // farbverlauf der serien 1 und 2 final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, new Color(127, 127, 255), 0.0f, 0.0f, new Color(127, 127, 127)); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, new Color(255, 127, 127), 0.0f, 0.0f, new Color(127, 127, 127)); bars.setSeriesPaint(0, gp0); bars.setSeriesPaint(1, gp1); // keine umrandung der balken bars.setDrawBarOutline(false); // abstand der zahlen vom balken bars.setItemLabelAnchorOffset(13); // x achsenbeschriftung final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.BarChartDemo1.java
protected JFreeChart createLegend(CategoryDataset dataset) { domainLabel = "Category"; rangeLabel = "Value"; // JFreeChart chart = ChartFactory.createAreaChart( JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );/*from www. jav a 2s. c o m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); BarRenderer renderer = (BarRenderer) plot.getRenderer(); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); // renderer.setDrawOutlines(true); // renderer.setUseFillPaint(true); // renderer.setFillPaint(Color.white); renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); return chart; }
From source file:ds.monte.carlo.Application.java
private void createLengthGraph(HashMap<Integer, Integer> probability) { DefaultCategoryDataset pDataset = new DefaultCategoryDataset(); for (Integer key : probability.keySet()) { pDataset.setValue(probability.get(key), "", "" + key); }// w w w .j av a 2s .c o m JFreeChart growChart = ChartFactory.createLineChart("Simulated annealing", "", "", pDataset, PlotOrientation.VERTICAL, false, false, false); growChart.setBackgroundPaint(Color.WHITE); CategoryPlot catPlot = growChart.getCategoryPlot(); catPlot.setRangeGridlinePaint(new Color(92, 184, 92)); ValueAxis vAxis = catPlot.getRangeAxis(); CategoryAxis cAxis = catPlot.getDomainAxis(); cAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); cAxis.setTickLabelsVisible(false); Font font = new Font("SansSerif", Font.PLAIN, 12); Font fontTitle = new Font("SansSerif", Font.PLAIN, 14); vAxis.setTickLabelFont(font); growChart.getTitle().setFont(fontTitle); LineAndShapeRenderer renderer = (LineAndShapeRenderer) catPlot.getRenderer(); Color bootstrapGreen = new Color(92, 184, 92); renderer.setSeriesPaint(0, bootstrapGreen); ChartPanel chartPanel = new ChartPanel(growChart); jPanel9.removeAll(); jPanel9.add(chartPanel, BorderLayout.CENTER); jPanel9.validate(); }
From source file:com.google.gwt.benchmarks.viewer.server.ReportImageServer.java
private JFreeChart createChart(String testName, Result result, String title, List<Result> comparativeResults) { // Find the maximum values across both axes for all of the results // (this chart's own results, plus all comparative results). //// w w w. ja v a 2 s . com // This is a stop-gap solution that helps us compare different charts for // the same benchmark method (usually with different user agents) until we // get real comparative functionality in version two. double maxTime = 0; for (Result r : comparativeResults) { for (Trial t : r.getTrials()) { maxTime = Math.max(maxTime, t.getRunTimeMillis()); } } // Determine the number of variables in this benchmark method List<Trial> trials = result.getTrials(); Trial firstTrial = new Trial(); int numVariables = 0; if (trials.size() > 0) { firstTrial = trials.get(0); numVariables = firstTrial.getVariables().size(); } // Display the trial data. // // First, pick the domain and series variables for our graph. // Right now we only handle up to two "user" variables. // We set the domain variable to the be the one containing the most unique // values. // This might be easier if the results had meta information telling us // how many total variables there are, what types they are of, etc.... String domainVariable = null; String seriesVariable = null; Map<String, Set<String>> variableValues = null; if (numVariables == 1) { domainVariable = firstTrial.getVariables().keySet().iterator().next(); } else { // TODO(tobyr): Do something smarter, like allow the user to specify which // variables are domain and series, along with the variables which are // held constant. variableValues = new HashMap<String, Set<String>>(); for (int i = 0; i < trials.size(); ++i) { Trial trial = trials.get(i); Map<String, String> variables = trial.getVariables(); for (Map.Entry<String, String> entry : variables.entrySet()) { String variable = entry.getKey(); Set<String> set = variableValues.get(variable); if (set == null) { set = new TreeSet<String>(); variableValues.put(variable, set); } set.add(entry.getValue()); } } TreeMap<Integer, List<String>> numValuesMap = new TreeMap<Integer, List<String>>(); for (Map.Entry<String, Set<String>> entry : variableValues.entrySet()) { Integer numValues = new Integer(entry.getValue().size()); List<String> variables = numValuesMap.get(numValues); if (variables == null) { variables = new ArrayList<String>(); numValuesMap.put(numValues, variables); } variables.add(entry.getKey()); } if (numValuesMap.values().size() > 0) { domainVariable = numValuesMap.get(numValuesMap.lastKey()).get(0); seriesVariable = numValuesMap.get(numValuesMap.firstKey()).get(0); } } String valueTitle = "time (ms)"; // This axis is time across all charts. if (numVariables == 0) { // Show a bar graph, with a single centered simple bar // 0 variables means there is only 1 trial DefaultCategoryDataset data = new DefaultCategoryDataset(); data.addValue(firstTrial.getRunTimeMillis(), "result", "result"); JFreeChart chart = ChartFactory.createBarChart(title, testName, valueTitle, data, PlotOrientation.VERTICAL, false, false, false); CategoryPlot p = chart.getCategoryPlot(); ValueAxis axis = p.getRangeAxis(); axis.setUpperBound(maxTime + maxTime * 0.1); return chart; } else if (numVariables == 1) { // Show a line graph with only 1 series // Or.... choose between a line graph and a bar graph depending upon // whether the type of the domain is numeric. XYSeriesCollection data = new XYSeriesCollection(); XYSeries series = new XYSeries(domainVariable); for (Trial trial : trials) { double time = trial.getRunTimeMillis(); String domainValue = trial.getVariables().get(domainVariable); series.add(Double.parseDouble(domainValue), time); } data.addSeries(series); JFreeChart chart = ChartFactory.createXYLineChart(title, domainVariable, valueTitle, data, PlotOrientation.VERTICAL, false, false, false); XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setUpperBound(maxTime + maxTime * 0.1); double maxDomainValue = getMaxValue(comparativeResults, domainVariable); plot.getDomainAxis().setUpperBound(maxDomainValue + maxDomainValue * 0.1); return chart; } else if (numVariables == 2) { // Show a line graph with two series XYSeriesCollection data = new XYSeriesCollection(); Set<String> seriesValues = variableValues.get(seriesVariable); for (String seriesValue : seriesValues) { XYSeries series = new XYSeries(seriesValue); for (Trial trial : trials) { Map<String, String> variables = trial.getVariables(); if (variables.get(seriesVariable).equals(seriesValue)) { double time = trial.getRunTimeMillis(); String domainValue = trial.getVariables().get(domainVariable); series.add(Double.parseDouble(domainValue), time); } } data.addSeries(series); } // TODO(tobyr) - Handle graphs above 2 variables JFreeChart chart = ChartFactory.createXYLineChart(title, domainVariable, valueTitle, data, PlotOrientation.VERTICAL, true, true, false); XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setUpperBound(maxTime + maxTime * 0.1); double maxDomainValue = getMaxValue(comparativeResults, domainVariable); plot.getDomainAxis().setUpperBound(maxDomainValue + maxDomainValue * 0.1); return chart; } throw new RuntimeException("The ReportImageServer is not yet able to " + "create charts for benchmarks with more than two variables."); // Sample JFreeChart code for creating certain charts: // Leaving this around until we can handle multivariate charts in dimensions // greater than two. // Code for creating a category data set - probably better with a bar chart // instead of line chart /* * DefaultCategoryDataset data = new DefaultCategoryDataset(); String series * = domainVariable; * * for ( Iterator it = trials.iterator(); it.hasNext(); ) { Trial trial = * (Trial) it.next(); double time = trial.getRunTimeMillis(); String * domainValue = (String) trial.getVariables().get( domainVariable ); * data.addValue( time, series, domainValue ); } * * String title = ""; String categoryTitle = domainVariable; PlotOrientation * orientation = PlotOrientation.VERTICAL; * * chart = ChartFactory.createLineChart( title, categoryTitle, valueTitle, * data, orientation, true, true, false ); */ /* * DefaultCategoryDataset data = new DefaultCategoryDataset(); String * series1 = "firefox"; String series2 = "ie"; * * data.addValue( 1.0, series1, "1024"); data.addValue( 2.0, series1, * "2048"); data.addValue( 4.0, series1, "4096"); data.addValue( 8.0, * series1, "8192"); * * data.addValue( 2.0, series2, "1024"); data.addValue( 4.0, series2, * "2048"); data.addValue( 8.0, series2, "4096"); data.addValue( 16.0, * series2,"8192"); * * String title = ""; String categoryTitle = "size"; PlotOrientation * orientation = PlotOrientation.VERTICAL; * * chart = ChartFactory.createLineChart( title, categoryTitle, valueTitle, * data, orientation, true, true, false ); */ }
From source file:graphs.LimitsGraphs.java
/** * Creates a sample chart.// w w w. jav a 2s. c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Limits ..", // chart title "Metric", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:researchbehaviour.MainOutput.java
private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed try {/*from ww w . j a v a 2 s .com*/ FileReader reader = new FileReader("xml.txt"); BufferedReader br = new BufferedReader(reader); String line; line = br.readLine(); String[] strArray = line.split(" "); String[] FName = strArray[0].split(">"); String applicantName = FName[1] + " " + strArray[1]; jLabel20.setText(applicantName); double agr = 0; double con = 0; double ext = 0; double emo = 0; double ope = 0; double edu = 0; try { // agr = be.agreeablenessPersentage(); // con = be.conscientiousPersentage(); // ext = be.extraversionPersentage(); // emo = be.emotional_stabilityPersentage(); // ope = be.opennessPersentage(); // edu = be.educationPersentage(); // agr = pv.agrvalue(); con = pv.convalue(); ext = pv.extvalue(); emo = pv.emovalue(); ope = pv.opevalue(); edu = pv.eduvalue(); } catch (IOException ex) { Logger.getLogger(MainOutput.class.getName()).log(Level.SEVERE, null, ex); } DefaultCategoryDataset barChartData = new DefaultCategoryDataset(); barChartData.setValue(agr, "Personality Factor", "A"); barChartData.setValue(con, "Personality Factor", "C"); barChartData.setValue(ext, "Personality Factor", "E"); barChartData.setValue(emo, "Personality Factor", "N"); barChartData.setValue(ope, "Personality Factor", "O"); barChartData.setValue(edu - 20, "Personality Factor", "Education"); // barChartData.setValue(81.12, "Personality Factor", "A"); // barChartData.setValue(70.01, "Personality Factor", "C"); // barChartData.setValue(34.34, "Personality Factor", "E"); // barChartData.setValue(44.67,"Personality Factor", "N"); // barChartData.setValue(55.87, "Personality Factor", "O"); // barChartData.setValue(77.34, "Personality Factor", "Education"); JFreeChart barChart = ChartFactory.createBarChart("Applicant Statues", "Personality Factor", "Persentage", barChartData, PlotOrientation.VERTICAL, false, true, false); CategoryPlot barchart = barChart.getCategoryPlot(); barchart.setRangeGridlinePaint(Color.BLUE); // Plot plot = bar.getPlot(); BarRenderer barRenderer = (BarRenderer) barchart.getRenderer(); barRenderer.setSeriesPaint(0, Color.white); ChartPanel barPanel = new ChartPanel(barChart); panelChart.removeAll(); panelChart.add(barPanel, BorderLayout.CENTER); panelChart.validate(); // panelChart.repaint(); ChangeValues cvv = new ChangeValues(); ArrayList<Double> updateVal2 = new ArrayList<Double>(); updateVal2 = cvv.changedCutOff(); if (agr > updateVal2.get(0)) { jTextArea1.append( " The person has good Agreeableness,altruistic, sympathetic to others and eager to help them, and in return believes that others will be " + "\n" + " equally helpful." + "\n"); } else jTextArea1.append( " Low agreeableness, egocentric, sceptical of other's intentions, and competitive rather than co-operative." + "\n"); if (ope > updateVal2.get(2)) { jTextArea1.append( " Have active imagination, aesthetic sensitivity, attentiveness to inner feelings, a preference for variety, intellectual curiosity " + "\n" + " and independence of judgement " + "\n"); } else jTextArea1.append(" Not having enough openness to experience value." + "\n"); if (emo > updateVal2.get(3)) { jTextArea1.append( " Calm,even-tempered, relaxed and able to face stressful situations without becoming upset." + "\n"); } else { jTextArea1.append( " Not having good emotional stability.not calm,hot tempered ,not able to face stressfull situations sucessfully." + "\n"); } if (ext > updateVal2.get(1)) { jTextArea1.append( " Have good extraversion.social,active , talkative,energetic and optimistic person. " + "\n"); } else { jTextArea1.append( " Not having good extraversion.reserved rather than unfriendly, independent rather than followers, even-paced " + "\n" + "rather than sluggish." + "\n"); } if (con > updateVal2.get(4)) { jTextArea1.append(" Conscientious person,purposeful, strong-willed and determined." + "\n"); } else { jTextArea1.append(" Not having enough Conscientious." + "\n"); } } catch (IOException ex) { Logger.getLogger(MainOutput.class.getName()).log(Level.SEVERE, null, ex); } }
From source file:Client.Gui.TeamBarChart.java
/** * Creates a sample chart.//ww w. j a v a 2 s . com * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Distribution of Trainging", // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:com.mentor.questa.ucdb.jenkins.QuestaCoverageAction.java
private JFreeChart createBarChart(final StaplerRequest req, final CategoryDataset dataset, final String title) { JFreeChart chart = ChartFactory.createBarChart(title, //title null, //categoryaxislabel, null, //valueaxislabel dataset, //dataset PlotOrientation.HORIZONTAL, //orientation false, //legend true, //tooltips false //urls );/*from w w w . ja v a2 s . co m*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setForegroundAlpha(0.8f); final BarRenderer cir = new BarRenderer() { private final Paint[] colors = { Color.red, Color.blue, Color.green, Color.yellow, Color.orange, Color.cyan, Color.magenta, Color.blue }; /** * Returns the paint for an item. Overrides the default behavior * inherited from AbstractSeriesRenderer. * * @param row the series. * @param column the category. * * @return The item color. */ @Override public Paint getItemPaint(final int row, final int column) { return colors[column % colors.length]; } }; cir.setMaximumBarWidth(0.35); plot.setRenderer(cir); // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }