List of usage examples for org.jfree.chart.axis NumberAxis setStandardTickUnits
public void setStandardTickUnits(TickUnitSource source)
From source file:de.mpg.mpdl.inge.pubman.web.statistic_charts.StatisticChartServlet.java
/** * Creates the statistic chart.//from w ww. ja v a2 s . com * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(CategoryDataset dataset) { // create the chart JFreeChart chart = ChartFactory.createStackedBarChart(null, // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips? false // URLs? ); // set the background color for the chart chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xf5, 0xf5, 0xf5)); plot.setDomainGridlinePaint(Color.gray); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.gray); // set the range axis to display integers only final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0); // disable bar outlines... StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setDrawBarOutline(false); // 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.red, 0.0f, 0.0f, new Color(64, * 0, 0)); */ Color series1Color = new Color(0xfa, 0x80, 0x72); Color series2Color = new Color(0x64, 0x95, 0xed); renderer.setSeriesPaint(1, series1Color); renderer.setSeriesPaint(0, series2Color); // remove shadow renderer.setShadowVisible(false); // // Labels in bars /* * renderer.setSeriesItemLabelsVisible(0, true); renderer.setSeriesItemLabelGenerator(0, new * StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(0, Color.white); * renderer.setSeriesItemLabelsVisible(1, true); renderer.setSeriesItemLabelGenerator(1, new * StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(1, Color.white); */ // setCategorySummary(dataset); // rotate labels on x-axis CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:com.intel.stl.ui.performance.PerformanceChartsCreator.java
protected JFreeChart getBwHistogramChart(Dataset dataset) { JFreeChart chart = ComponentFactory.createXYBarChart(STLConstants.K0053_CAPABILITY.getValue(), STLConstants.K0044_NUM_PORTS.getValue(), (IntervalXYDataset) dataset, (XYItemLabelGenerator) null); NumberAxis axis = (NumberAxis) chart.getXYPlot().getDomainAxis(); axis.setTickUnit(new NumberTickUnit(0.2, UIConstants.PERCENTAGE)); axis = (NumberAxis) chart.getXYPlot().getRangeAxis(); axis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:com.cwctravel.hudson.plugins.suitegroupedtests.TrendGraph.java
@Override protected JFreeChart createGraph() { final CategoryDataset dataset = createDataSet().build(); final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart // title null, // unused yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls );/*from ww w. j ava2 s. c o m*/ 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.setForegroundAlpha(0.8f); // plot.setDomainGridlinesVisible(true); // plot.setDomainGridlinePaint(Color.white); 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(); ChartUtil.adjustChebyshev(dataset, rangeAxis); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); StackedAreaRenderer ar = new StackedAreaRenderer2() { private static final long serialVersionUID = 7962375662395944968L; @Override public Paint getItemPaint(int row, int column) { ChartLabel key = (ChartLabel) dataset.getColumnKey(column); if (key.getColor() != null) return key.getColor(); return super.getItemPaint(row, column); } @Override public String generateURL(CategoryDataset dataset, int row, int column) { ChartLabel label = (ChartLabel) dataset.getColumnKey(column); return label.getURL() + relativeUrl; } @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { ChartLabel label = (ChartLabel) dataset.getColumnKey(column); return label.getToolTipText(); } }; plot.setRenderer(ar); ar.setSeriesPaint(0, ColorPalette.RED); // Skips. ar.setSeriesPaint(1, ColorPalette.YELLOW); // Failures. ar.setSeriesPaint(2, ColorPalette.BLUE); // Total. // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }
From source file:com.indicator_engine.controller.GraphController.java
private JFreeChart createBarChart(final CategoryDataset dataset, final String chartTitle) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart(chartTitle, // chart title "Indicators", // domain axis label "Count", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? );/* ww w .j a v a 2s.com*/ // 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)); return chart; }
From source file:userInterface.SystemAdmin.PovertyAnalysisJPanel.java
private JFreeChart createChart(DefaultCategoryDataset crimeDataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Poverty Rate vs Crime Chart", "Network Values", "Value", crimeDataset, PlotOrientation.HORIZONTAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangePannable(true); categoryplot.setRangeZeroBaselineVisible(true); categoryplot.configureRangeAxes();/* w w w.ja v a 2 s . c o m*/ NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); LayeredBarRenderer layeredbarrenderer = new LayeredBarRenderer(); layeredbarrenderer.setDrawBarOutline(false); categoryplot.setRenderer(layeredbarrenderer); return jfreechart; }
From source file:sentimentanalyzer.ChartController.java
public void postTheTimeSeriesChartOnTheGUI_words(JPanel timeSeriesChart, XYSeriesCollection dataset, String title, String y, String x, int row) { this.wordCountsChart = ChartFactory.createXYLineChart(title, x, y, dataset, PlotOrientation.VERTICAL, true, true, false);/*from www .ja v a 2 s . c o m*/ this.wordIndexesOnGraph.add(row); this.plot_counter = this.wordCountsChart.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); //CHECK THIS renderer.setBaseShapesVisible(true); this.plot_counter.setRenderer(renderer); this.plot_counter.setOutlinePaint(Color.orange); NumberAxis rangeAxis = (NumberAxis) this.plot_counter.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) this.plot_counter.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.wordCountsChart.setBackgroundPaint(Color.white); this.wordCountsChart.setBorderPaint(Color.orange); ChartPanel CP = new ChartPanel(this.wordCountsChart); timeSeriesChart.setLayout(new java.awt.BorderLayout()); timeSeriesChart.add(CP, BorderLayout.CENTER); timeSeriesChart.revalidate(); }
From source file:com.cwctravel.hudson.plugins.multimoduletests.TrendGraph.java
@Override protected JFreeChart createGraph() { final CategoryDataset dataset = createDataSet().build(); final JFreeChart chart = ChartFactory.createStackedAreaChart(null, // chart // title null, // unused yLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls );/*w w w. j a v a2 s .c om*/ 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.setForegroundAlpha(0.8f); // plot.setDomainGridlinesVisible(true); // plot.setDomainGridlinePaint(Color.white); 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(); ChartUtil.adjustChebyshev(dataset, rangeAxis); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRange(true); StackedAreaRenderer ar = new StackedAreaRenderer2() { private static final long serialVersionUID = 7962375662395944968L; @Override public Paint getItemPaint(int row, int column) { ChartLabel key = (ChartLabel) dataset.getColumnKey(column); if (key.getColor() != null) return key.getColor(); return super.getItemPaint(row, column); } @Override public String generateURL(CategoryDataset dataset, int row, int column) { ChartLabel label = (ChartLabel) dataset.getColumnKey(column); return prefixUrl + label.getURL() + suffixUrl; } @Override public String generateToolTip(CategoryDataset dataset, int row, int column) { ChartLabel label = (ChartLabel) dataset.getColumnKey(column); return label.getToolTipText(); } }; plot.setRenderer(ar); ar.setSeriesPaint(0, ColorPalette.RED); // Skips. ar.setSeriesPaint(1, ColorPalette.YELLOW); // Failures. ar.setSeriesPaint(2, ColorPalette.BLUE); // Total. // crop extra space around the graph plot.setInsets(new RectangleInsets(0, 0, 0, 5.0)); return chart; }
From source file:de.mpg.escidoc.pubman.statistic_charts.StatisticChartServlet.java
/** * Creates the statistic chart./*from w w w . java2s. c om*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(CategoryDataset dataset) { // create the chart JFreeChart chart = ChartFactory.createStackedBarChart(null, // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend false, // tooltips? false // URLs? ); // set the background color for the chart chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xf5, 0xf5, 0xf5)); plot.setDomainGridlinePaint(Color.gray); plot.setDomainGridlinesVisible(true); plot.setRangeGridlinePaint(Color.gray); // set the range axis to display integers only final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setLowerBound(0); // disable bar outlines... StackedBarRenderer renderer = (StackedBarRenderer) plot.getRenderer(); renderer.setBarPainter(new StandardBarPainter()); renderer.setDrawBarOutline(false); // 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.red, 0.0f, 0.0f, new Color(64, 0, 0)); */ Color series1Color = new Color(0xfa, 0x80, 0x72); Color series2Color = new Color(0x64, 0x95, 0xed); renderer.setSeriesPaint(1, series1Color); renderer.setSeriesPaint(0, series2Color); //remove shadow renderer.setShadowVisible(false); // //Labels in bars /* renderer.setSeriesItemLabelsVisible(0, true); renderer.setSeriesItemLabelGenerator(0, new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(0, Color.white); renderer.setSeriesItemLabelsVisible(1, true); renderer.setSeriesItemLabelGenerator(1, new StandardCategoryItemLabelGenerator()); renderer.setSeriesItemLabelPaint(1, Color.white); */ //setCategorySummary(dataset); //rotate labels on x-axis CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:sentimentanalyzer.ChartController.java
public void postTheTimeSeriesChartOnTheGUI_sentiment(JPanel timeSeriesChart, XYSeriesCollection dataset, String title, String y, String x, int row) { this.wordSentimentScore = ChartFactory.createXYLineChart(title, y, x, dataset, PlotOrientation.VERTICAL, true, true, false);/*ww w .j ava2 s.co m*/ this.wordIndexesOnGraph.add(row); this.plot_sentiment = this.wordSentimentScore.getXYPlot(); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); //CHECK THIS renderer.setBaseShapesVisible(true); this.plot_sentiment.setRenderer(renderer); this.plot_sentiment.setOutlinePaint(Color.orange); NumberAxis rangeAxis = (NumberAxis) this.plot_sentiment.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis domainAxis = (NumberAxis) this.plot_sentiment.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); this.wordSentimentScore.setBackgroundPaint(Color.white); this.wordSentimentScore.setBorderPaint(Color.ORANGE); ChartPanel CP = new ChartPanel(this.wordSentimentScore); timeSeriesChart.setLayout(new java.awt.BorderLayout()); timeSeriesChart.add(CP, BorderLayout.CENTER); timeSeriesChart.revalidate(); }
From source file:br.usp.icmc.gazetteer.SemanticSearchTest.Grafico.java
public ChartPanel interpolado(int index) { // create the chart... JFreeChart graf = ChartFactory.createXYLineChart("Interpolado", // chart title "Recall", // x axis label "Precision", // y axis label createDatasetInterpoled(index), // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls );/* ww w .jav a2s . c om*/ // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... graf.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... XYPlot plot = (XYPlot) graf.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.setShapesVisible(false); XYLineAndShapeRenderer renderer2 = new XYLineAndShapeRenderer(true, false); plot.setRenderer(1, renderer2); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. ChartPanel myChartPanel = new ChartPanel(graf, true); return myChartPanel; }