List of usage examples for org.jfree.chart.axis CategoryLabelPositions createUpRotationLabelPositions
public static CategoryLabelPositions createUpRotationLabelPositions(double angle)
From source file:fuel.gui.stats.BarChartPanel.java
public BarChartPanel(DefaultCategoryDataset barDataset, String message, boolean stacked) { JFreeChart barChart;/*from w w w . j a v a 2 s . c o m*/ if (stacked) { barChart = ChartFactory.createStackedBarChart3D("", // chart title "", // domain axis label "", // range axis label barDataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips? true // URLs? ); } else { barChart = ChartFactory.createBarChart3D("", // chart title "", // domain axis label "", // range axis label barDataset, // data PlotOrientation.VERTICAL, false, // include legend true, // tooltips? true // URLs? ); } CategoryPlot plot = barChart.getCategoryPlot(); BarRenderer3D renderer = (BarRenderer3D) plot.getRenderer(); renderer.setDrawBarOutline(false); final CategoryAxis domainAxis = plot.getDomainAxis(); double count = barDataset.getColumnCount(); double extra = 16 / count; domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / (2 + extra))); ChartPanel barChartPanel = new ChartPanel(barChart); barChartPanel.getChartRenderingInfo().setEntityCollection(null); barChartPanel.setBorder(BorderFactory.createTitledBorder(message)); int wider = barDataset.getColumnCount() * 12; barChartPanel.setPreferredSize(new java.awt.Dimension(192 + wider, 240)); barChartPanel.setLayout(new BorderLayout()); setLayout(new BorderLayout()); add(barChartPanel); }
From source file:userInterface.StateAdminRole.DecisionCartJPanel2.java
private static JFreeChart createChart1(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Order Statistics", "Hospital", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.blue); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:com.crunchify.jsp.servlet.ChartServlet.java
public JFreeChart getChart() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(25.0, "Series 1", "Category 1"); dataset.addValue(34.0, "Series 1", "Category 2"); dataset.addValue(19.0, "Series 2", "Category 1"); dataset.addValue(29.0, "Series 2", "Category 2"); dataset.addValue(41.0, "Series 3", "Category 1"); dataset.addValue(33.0, "Series 3", "Category 2"); JFreeChart chart = ChartFactory.createBarChart3D("3D 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 );/*from ww w.java 2 s . com*/ CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0)); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setItemLabelsVisible(true); BarRenderer r = (BarRenderer) renderer; r.setMaximumBarWidth(0.05); return chart; }
From source file:ws.moor.bt.gui.charts.DownloadRatePerPeer.java
private JFreeChart createChart() { JFreeChart chart = ChartFactory.createBarChart("Top 20 Download Rates", "Remote IP", "KB/s", createDataset(), PlotOrientation.VERTICAL, false, false, false); chart.setBackgroundPaint(Color.white); CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 2.0)); return chart; }
From source file:Controlador.ChartServlet.java
public JFreeChart getChart() throws URISyntaxException { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); Equipos eq = new Equipos(); Equipo e = eq.buscar(1);/*from ww w . j a va 2 s .c om*/ dataset.addValue(e.getNumSerie(), String.copyValueOf(e.getNombre()), " 1"); JFreeChart chart = ChartFactory.createBarChart3D("3D Bar Chart Demo", // chart title "equipo", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls ); CategoryPlot plot = chart.getCategoryPlot(); CategoryAxis axis = plot.getDomainAxis(); axis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 8.0)); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setItemLabelsVisible(true); BarRenderer r = (BarRenderer) renderer; r.setMaximumBarWidth(0.05); return chart; }
From source file:gchisto.gui.panels.gcstats.BreakdownChartPanelMulti.java
/** * It creates a chart for the given dataset and adds the chart to the panel. * * @param dataset The dataset that will provide the values for the chart. *//*w w w. j a v a2 s . c o m*/ private void addChart() { JFreeChart chart = ChartFactory.createStackedBarChart3D(getTitle(), null, "Breakdown" + unitSuffix(), dataset, PlotOrientation.VERTICAL, true, true, false); CategoryAxis domainAxis = chart.getCategoryPlot().getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); chart.addProgressListener(locker); CategoryPlot plot = (CategoryPlot) chart.getPlot(); CategoryItemRenderer renderer = plot.getRenderer(); renderer.setToolTipGenerator(dataset); mainPanel().add(BorderLayout.CENTER, new ChartPanel(chart)); }
From source file:org.jfree.chart.demo.BarChartDemo10.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Bar Chart Demo", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeGridlinePaint(Color.white); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:gui.MainForm.java
private static JFreeChart create_AMS_DATA_Chart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("AMS??", "", "??", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.blue); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.blue, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }
From source file:gov.nih.nci.ispy.ui.graphing.chart.plot.ISPYCategoricalCorrelationPlot.java
private void createChart() { String title = "Categorical Plot"; CategoryDataset chartData = createChartData(); CategoryAxis domainAxis = new CategoryAxis(null); NumberAxis rangeAxis = new NumberAxis(yLabel); //BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer(); BoxAndWhiskerCoinPlotRenderer renderer = new BoxAndWhiskerCoinPlotRenderer(); renderer.setDisplayAllOutliers(true); CategoryPlot plot = new CategoryPlot(chartData, domainAxis, rangeAxis, renderer); domainAxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(45.0 * Math.PI / 180.0)); catCorrChart = new JFreeChart(title, plot); catCorrChart.removeLegend();/*from w w w. j av a 2 s. c o m*/ //renderer.setFillBox(false); String cat = (String) chartData.getColumnKey(0); //renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setToolTipGenerator(new CategoryToolTipGenerator() { public String generateToolTip(CategoryDataset dataset, int series, int item) { String tt = ""; NumberFormat formatter = new DecimalFormat(".####"); String key = ""; //String s = formatter.format(-1234.567); // -001235 if (dataset instanceof DefaultBoxAndWhiskerCategoryDataset) { DefaultBoxAndWhiskerCategoryDataset ds = (DefaultBoxAndWhiskerCategoryDataset) dataset; try { String med = formatter.format(ds.getMedianValue(series, item)); tt += "Median: " + med + "<br/>"; tt += "Mean: " + formatter.format(ds.getMeanValue(series, item)) + "<br/>"; tt += "Q1: " + formatter.format(ds.getQ1Value(series, item)) + "<br/>"; tt += "Q3: " + formatter.format(ds.getQ3Value(series, item)) + "<br/>"; tt += "Max: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMaxFaroutOutlier(ds, series, item)) + "<br/>"; tt += "Min: " + formatter.format( FaroutOutlierBoxAndWhiskerCalculator.getMinFaroutOutlier(ds, series, item)) + "<br/>"; //tt += "<br/><br/>Please click on the box and whisker to view a plot for this reporter.<br/>"; //tt += "X: " + ds.getValue(series, item).toString()+"<br/>"; //tt += "<br/><a href=\\\'#\\\' id=\\\'"+ds.getRowKeys().get(series)+"\\\' onclick=\\\'alert(this.id);return false;\\\'>"+ds.getRowKeys().get(series)+" plot</a><br/><br/>"; key = ds.getRowKeys().get(series).toString(); } catch (Exception e) { } } return tt; } }); // renderer.setToolTipGenerator(new CategoryToolTipGenerator() { // // public String generateToolTip(CategoryDataset dataset,int series, int item) { // String tt=""; // NumberFormat formatter = new DecimalFormat(".####"); // String key = ""; // //String s = formatter.format(-1234.567); // -001235 // StringBuffer sb = new StringBuffer(); // if(dataset instanceof DefaultBoxAndWhiskerCategoryDataset){ // DefaultBoxAndWhiskerCategoryDataset ds = (DefaultBoxAndWhiskerCategoryDataset)dataset; // try { // // String str; // str = (String) ds.getColumnKey(item); // sb.append(str).append(" N="); // BoxAndWhiskerItem bwitem = ds.getItem(series,item); // // str = formatter.format(ds.getMedianValue(series, item)); // sb.append("Median: ").append(str); // str = formatter.format(ds.getMeanValue(series, item)); // sb.append(" Mean: ").append(str); // str = formatter.format(ds.getMinRegularValue(series, item)); // sb.append(" Min: ").append(str); // str = formatter.format(ds.getMaxRegularValue(series, item)); // sb.append(" Max: ").append(str); // str = formatter.format(ds.getQ1Value(series, item)); // sb.append(" Q1: ").append(str); // str = formatter.format(ds.getQ3Value(series, item)); // sb.append(" Q3: ").append(str); // // } // catch(Exception e) {} // } // // return sb.toString(); // // } // // }); plot.setNoDataMessage(null); }
From source file:userInterface.cdcRole.OverviewJPanel.java
private static JFreeChart createChart1(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Distribution of Vaccines", "Vaccine", "Quantity", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setDomainGridlinesVisible(true); categoryplot.setRangeCrosshairVisible(true); categoryplot.setRangeCrosshairPaint(Color.green); NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis(); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer(); barrenderer.setDrawBarOutline(false); GradientPaint gradientpaint = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 0, 64)); GradientPaint gradientpaint1 = new GradientPaint(0.0F, 0.0F, Color.green, 0.0F, 0.0F, new Color(0, 64, 0)); GradientPaint gradientpaint2 = new GradientPaint(0.0F, 0.0F, Color.red, 0.0F, 0.0F, new Color(64, 0, 0)); barrenderer.setSeriesPaint(0, gradientpaint); barrenderer.setSeriesPaint(1, gradientpaint1); barrenderer.setSeriesPaint(2, gradientpaint2); barrenderer.setLegendItemToolTipGenerator(new StandardCategorySeriesLabelGenerator("Tooltip: {0}")); CategoryAxis categoryaxis = categoryplot.getDomainAxis(); categoryaxis.setCategoryLabelPositions( CategoryLabelPositions.createUpRotationLabelPositions(0.52359877559829882D)); return jfreechart; }