List of usage examples for org.jfree.chart.labels StandardCategoryToolTipGenerator StandardCategoryToolTipGenerator
public StandardCategoryToolTipGenerator()
From source file:org.jfree.chart.demo.ImageMapDemo4.java
/** * Starting point for the demo./*from w ww . ja v a2s . c om*/ * * @param args ignored. */ public static void main(final String[] args) { // create a chart final double[][] data = new double[][] { { 56.0, -12.0, 34.0, 76.0, 56.0, 100.0, 67.0, 45.0 }, { 37.0, 45.0, 67.0, 25.0, 34.0, 34.0, 100.0, 53.0 }, { 43.0, 54.0, 34.0, 34.0, 87.0, 64.0, 73.0, 12.0 } }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data); JFreeChart chart = null; final boolean drilldown = true; if (drilldown) { final CategoryAxis3D categoryAxis = new CategoryAxis3D("Category"); final ValueAxis valueAxis = new NumberAxis3D("Value"); final BarRenderer3D renderer = new BarRenderer3D(); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setItemURLGenerator(new StandardCategoryURLGenerator("bar_chart_detail.jsp")); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { chart = ChartFactory.createBarChart3D("Bar Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); } chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * 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 are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("barchart101.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("barchart101.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"barchart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:org.jfree.chart.demo.ImageMapDemo1.java
/** * Starting point for the demo.//from w ww. j a va 2 s. c o m * * @param args ignored. */ public static void main(final String[] args) { // create a chart final double[][] data = new double[][] { { 56.0, -12.0, 34.0, 76.0, 56.0, 100.0, 67.0, 45.0 }, { 37.0, 45.0, 67.0, 25.0, 34.0, 34.0, 100.0, 53.0 }, { 43.0, 54.0, 34.0, 34.0, 87.0, 64.0, 73.0, 12.0 } }; final CategoryDataset dataset = DatasetUtilities.createCategoryDataset("Series ", "Type ", data); JFreeChart chart = null; final boolean drilldown = true; if (drilldown) { final CategoryAxis categoryAxis = new CategoryAxis("Category"); final ValueAxis valueAxis = new NumberAxis("Value"); final BarRenderer renderer = new BarRenderer(); renderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setItemURLGenerator(new StandardCategoryURLGenerator("bar_chart_detail.jsp")); final CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(PlotOrientation.VERTICAL); chart = new JFreeChart("Bar Chart", JFreeChart.DEFAULT_TITLE_FONT, plot, true); } else { chart = ChartFactory.createBarChart("Vertical Bar Chart", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, false); } chart.setBackgroundPaint(java.awt.Color.white); // **************************************************************************** // * 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 are used to provide funding for the JFreeChart project - please * // * support us so that we can continue developing free software. * // **************************************************************************** // save it to an image try { final ChartRenderingInfo info = new ChartRenderingInfo(new StandardEntityCollection()); final File file1 = new File("barchart100.png"); ChartUtilities.saveChartAsPNG(file1, chart, 600, 400, info); // write an HTML page incorporating the image with an image map final File file2 = new File("barchart100.html"); final OutputStream out = new BufferedOutputStream(new FileOutputStream(file2)); final PrintWriter writer = new PrintWriter(out); writer.println("<HTML>"); writer.println("<HEAD><TITLE>JFreeChart Image Map Demo</TITLE></HEAD>"); writer.println("<BODY>"); // ChartUtilities.writeImageMap(writer, "chart", info); writer.println("<IMG SRC=\"barchart100.png\" " + "WIDTH=\"600\" HEIGHT=\"400\" BORDER=\"0\" USEMAP=\"#chart\">"); writer.println("</BODY>"); writer.println("</HTML>"); writer.close(); } catch (IOException e) { System.out.println(e.toString()); } }
From source file:org.jfree.chart.demo.CategoryStepChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { CategoryStepRenderer categorysteprenderer = new CategoryStepRenderer(true); categorysteprenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); CategoryAxis categoryaxis = new CategoryAxis("Category"); NumberAxis numberaxis = new NumberAxis("Value"); CategoryPlot categoryplot = new CategoryPlot(categorydataset, categoryaxis, numberaxis, categorysteprenderer);// w w w . ja v a2 s . com JFreeChart jfreechart = new JFreeChart("Category Step Chart", categoryplot); jfreechart.setBackgroundPaint(Color.white); categoryplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D)); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setDomainGridlinesVisible(true); categoryplot.setDomainGridlinePaint(Color.white); categoryplot.setRangeGridlinesVisible(true); categoryplot.setRangeGridlinePaint(Color.white); categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.UP_45); categoryaxis.setLowerMargin(0.0D); categoryaxis.setUpperMargin(0.0D); categoryaxis.addCategoryLabelToolTip("Type 1", "The first type."); categoryaxis.addCategoryLabelToolTip("Type 2", "The second type."); categoryaxis.addCategoryLabelToolTip("Type 3", "The third type."); numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); numberaxis.setLabelAngle(0.0D); return jfreechart; }
From source file:com.pureinfo.srm.reports.impl.MyChartFactory.java
public static JFreeChart createBarChart3D(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset dataset, PlotOrientation orientation, boolean legend, boolean tooltips, boolean urls) { if (orientation == null) { throw new IllegalArgumentException("Null 'orientation' argument."); }//from w ww . j a v a 2s. c o m CategoryAxis categoryAxis = new CategoryAxis3D(categoryAxisLabel); ValueAxis valueAxis = new NumberAxis3D(valueAxisLabel); BarRenderer3D renderer = new BarRenderer3D() { /** * @see org.jfree.chart.renderer.AbstractRenderer#getItemPaint(int, int) */ public Paint getItemPaint(int _nRow, int _nColumn) { return getSeriesPaint(_nColumn); } }; if (tooltips) { renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); } if (urls) { renderer.setBaseItemURLGenerator(new StandardCategoryURLGenerator()); } CategoryPlot plot = new CategoryPlot(dataset, categoryAxis, valueAxis, renderer); plot.setOrientation(orientation); if (orientation == PlotOrientation.HORIZONTAL) { // change rendering order to ensure that bar overlapping is the // right way around plot.setRowRenderingOrder(SortOrder.DESCENDING); plot.setColumnRenderingOrder(SortOrder.DESCENDING); } plot.setForegroundAlpha(0.75f); JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend); return chart; }
From source file:org.jfree.chart.demo.SpiderWebChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { SpiderWebPlot plot = new SpiderWebPlot(categorydataset); plot.setStartAngle(54D);/*from w w w.j ava 2 s . c o m*/ plot.setInteriorGap(0.40000000000000002D); plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); JFreeChart chart = new JFreeChart("Spider Web Chart Demo 1", TextTitle.DEFAULT_FONT, plot, false); LegendTitle legendtitle = new LegendTitle(plot); legendtitle.setPosition(RectangleEdge.BOTTOM); chart.addSubtitle(legendtitle); return chart; }
From source file:soap.ui.stats.OverLaidBarChartFactory.java
public static JFreeChart createDualBarAndLineDiagram(String title, String categoryAxisLabel, String valueAxisLabel, CategoryDataset barDiagramDataset, LinkedList lineDiagramDatasets) { CategoryPlot plot = new CategoryPlot(); int inc = 0;/*from ww w .j a v a 2 s. co m*/ BarRenderer barRenderer = null; if (barDiagramDataset != null) { plot.setDataset(barDiagramDataset); barRenderer = new BarRenderer3D(); barRenderer.setToolTipGenerator(new StandardCategoryToolTipGenerator()); plot.setRenderer(barRenderer); inc = 1; plot.setDomainAxis(new CategoryAxis3D(categoryAxisLabel)); plot.setRangeAxis(new NumberAxis3D(valueAxisLabel)); } else { plot.setDomainAxis(new CategoryAxis(categoryAxisLabel)); plot.setRangeAxis(new NumberAxis(valueAxisLabel)); } plot.mapDatasetToRangeAxis(0, 0); plot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT); plot.setRangeAxisLocation(AxisLocation.TOP_OR_LEFT); CategoryItemRenderer renderers[] = new LineAndShapeRenderer[lineDiagramDatasets.size()]; for (int i = 0; i < lineDiagramDatasets.size(); i++) { CategoryDataset lineDiagramDataset = (CategoryDataset) lineDiagramDatasets.get(i); plot.setDataset(i + inc, lineDiagramDataset); plot.mapDatasetToRangeAxis(i + inc, 0); if (barDiagramDataset != null && i < barDiagramDataset.getRowCount()) { renderers[i] = new LineAndShapeRendererMapToBar(barRenderer, i); } else { renderers[i] = new LineAndShapeRenderer(); } renderers[i].setToolTipGenerator(new StandardCategoryToolTipGenerator()); renderers[i].setSeriesStroke(0, new BasicStroke(1.5f)); renderers[i].setSeriesStroke(1, new BasicStroke(1.5f)); plot.setRenderer(i + inc, renderers[i]); } CategoryDataset dataset; if (lineDiagramDatasets.size() > 0) dataset = (CategoryDataset) lineDiagramDatasets.get(0); else dataset = barDiagramDataset; for (int i = 0; i < dataset.getColumnCount(); i++) plot.getDomainAxis().addCategoryLabelToolTip(dataset.getColumnKey(i), (String) dataset.getColumnKey(i)); plot.setRangeGridlinePaint(Color.black); plot.setDatasetRenderingOrder(DatasetRenderingOrder.FORWARD); JFreeChart chart = new JFreeChart(plot); chart.setTitle(title); chart.setLegend(new StandardLegend()); return chart; }
From source file:scheduler.benchmarker.manager.CustomBarRenderer.java
public CustomBarRenderer(PluginColors colors) { //super();// www.j a v a2s.co m pluginColors = colors; setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator()); setBaseItemLabelsVisible(true); setBasePositiveItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); setBaseNegativeItemLabelPosition(new ItemLabelPosition(ItemLabelAnchor.CENTER, TextAnchor.CENTER)); setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); }
From source file:org.jfree.chart.demo.CylinderChartDemo1.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart3D("Cylinder Chart Demo 1", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); Paint apaint[] = createPaint(); CustomCylinderRenderer customcylinderrenderer = new CustomCylinderRenderer(apaint); customcylinderrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_HORIZONTAL)); customcylinderrenderer.setBaseOutlinePaint(Color.gray); customcylinderrenderer.setBaseOutlineStroke(new BasicStroke(0.3F)); customcylinderrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); categoryplot.setRenderer(customcylinderrenderer); return jfreechart; }
From source file:org.operamasks.faces.render.graph.RadarChartRenderer.java
protected JFreeChart createChart(UIChart comp) { Dataset dataset = createDataset(comp); JFreeChart chart = null;/*from w ww .j a v a 2 s. c om*/ if (dataset instanceof CategoryDataset) { SpiderWebPlot plot = new SpiderWebPlot((CategoryDataset) dataset); plot.setWebFilled(false); Object startAngle = comp.getAttributes().get("startAngle"); if (startAngle != null) { plot.setStartAngle(Coercion.coerceToDouble(startAngle)); } if (comp.isShowItemTips()) { plot.setToolTipGenerator(new StandardCategoryToolTipGenerator()); } chart = new JFreeChart(null, null, plot, false); } return chart; }
From source file:org.jfree.chart.demo.CylinderChartDemo2.java
private static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart3D("Cylinder Chart Demo 2", "Category", "Value", categorydataset, PlotOrientation.HORIZONTAL, false, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); Paint apaint[] = createPaint(); CustomCylinderRenderer customcylinderrenderer = new CustomCylinderRenderer(apaint); customcylinderrenderer.setGradientPaintTransformer( new StandardGradientPaintTransformer(GradientPaintTransformType.CENTER_VERTICAL)); customcylinderrenderer.setBaseOutlinePaint(Color.gray); customcylinderrenderer.setBaseOutlineStroke(new BasicStroke(0.3F)); customcylinderrenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); categoryplot.setRenderer(customcylinderrenderer); return jfreechart; }