import org.jfree.chart.ChartFactory; import org.jfree.chart.ChartPanel; import org.jfree.chart.JFreeChart; import org.jfree.chart.axis.CategoryAxis; import org.jfree.chart.axis.CategoryLabelPosition; import org.jfree.chart.axis.CategoryLabelPositions; import org.jfree.chart.axis.CategoryLabelWidthType; import org.jfree.chart.plot.CategoryPlot; import org.jfree.chart.plot.PlotOrientation; import org.jfree.data. category.CategoryDataset; import org.jfree.data.category.DefaultCategoryDataset; import org.jfree.text.TextBlockAnchor; import org.jfree.ui.ApplicationFrame; import org.jfree.ui.RectangleAnchor; import org.jfree.ui.RefineryUtilities ; import org.jfree.ui.TextAnchor; import org.jfree.util.Log; import org.jfree.util.PrintStreamLogTarget; / ** * A simple demonstration application showing how to create a horizontal 3D bar chart using data * from a {@
Link categoryDataSet}. * / public class barchart3ddemo2 extends ApplicationFrame {// *********************************************************** ************************************************** / / * JFreeChart Developer Guide * // * The JFreeChart Developer Guide, written by David Gilbert, is available * // * to purchase from Object Refinery Limited: * // * * // * http://www.object-refinery.com/jfreechart/guide.html * // * * // * Sales area Used to provide Funding for the jfreechart project - please * // * Support us SOTWARE. * // ************* *********************************************************** ************ / ** * Creates a new demo. * * @Param Title the frame title. * / public BarChart3DDemo2 (final String title) {super (title); // create the chart ... final DefaultCategoryDataset dataset = new DefaultCategoryDataset (); dataset.addValue (23.0, "Series 1", "London"); dataset.addValue ( 14.0, "Series 1", "New York"); Dataset.AddValue (14.0, "Series 1", "Istanbul"); Dataset.AddValue (14.0, "Series 1", "Cairo"); Dataset.AddValue (13.0 , "Series 2", "London"); DataSet.addValue (19.0, "Series 2", "New York"); Dataset.AddValue (19.0, "Series 2", "Istanbul"); Dataset.AddValue (19.0, "Series 2", "cairo");
Dataset.addValue (7.0, "Series 3", "London"); Dataset.addValue (9.0, "Series 3", "New York"); Dataset.AddValue (9.0, "Series 3", "Istanbul"); Dataset .addValue (9.0, "Series 3", "Cairo"); Final Jfreechart Chart = Createchart (Dataset); // Add The Chart To a Panel ... Final ChartPanel ChartPanel = New ChartPanel (chart); ChartPanel.SetPreferredSize (New java.awt.Dimension (500, 270)); setContentPane (chartPanel);...} / ** * Creates a chart * * @param dataset the dataset * * @return The chart * / private JFreeChart createChart (final CategoryDataset dataset ) {Final Jfreechart Chart = ChartFactory.createBarchart3d ("3D Bar Chart Demo 2", // Chart title "category", // Domain Axis Label "Value", // Range Axis Label Dataset, // Data Plotorientation.horzontal, / / / Orientation Tru e, // include legend true, // Tooltips false // URLS); Final CategoryPlot Plot = chart.getcategoryPlot (); Plot.SetForeGRoundalpha (1.0f); // Left align the category labels ... final categoryaxis axis = plot .getdomainaxis (); final categorylabelpositions p = axis.getcategorylabelpositions (); final categorylabelposition left =