1 package com.calipso.reportgenerator.userinterface; 2 3 import org.jfree.chart.JFreeChart; 4 import org.jfree.chart.ChartFactory; 5 import org.jfree.chart.ChartPanel; 6 import org.jfree.chart.axis.*; 7 import org.jfree.chart.plot.CategoryPlot; 8 import org.jfree.ui.RectangleAnchor; 9 import org.jfree.ui.TextAnchor; 10 import org.jfree.text.TextBlockAnchor; 11 import org.jfree.data.category.CategoryDataset; 12 13 14 import javax.swing.*; 15 import java.awt.*; 16 17 import com.calipso.reportgenerator.common.LanguageTraslator; 18 19 22 23 public class VerticalBarChart extends Charts{ 24 25 26 34 public VerticalBarChart(CategoryDataset dataset, String tittle, Color color, boolean legend, boolean toolTips, Dimension size, boolean multipleAxis) { 35 super(dataset, tittle, color, legend, toolTips, size, multipleAxis); 36 previewVerticalhart(); 37 this.setVisible(true); 38 } 39 40 44 void previewVerticalhart(){ 45 JFreeChart chart = ChartFactory.createBarChart( 47 tittle, LanguageTraslator.traslate("336"), LanguageTraslator.traslate("337"), dataset, org.jfree.chart.plot.PlotOrientation.VERTICAL, 52 legend, toolTips, 54 false 55 ); 56 57 59 chart.setBackgroundPaint(color); 61 62 CategoryPlot plot = chart.getCategoryPlot(); 64 65 CategoryAxis domainAxis = plot.getDomainAxis(); 67 CategoryLabelPosition position = new CategoryLabelPosition( 68 RectangleAnchor.TOP, TextBlockAnchor.TOP_RIGHT, TextAnchor.TOP_RIGHT,-70, CategoryLabelWidthType.RANGE,70); 69 domainAxis.setCategoryLabelPositions(new CategoryLabelPositions(position,position,position,position)); 70 71 NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); 73 rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 74 75 77 ChartPanel chartPanel = new ChartPanel(chart); 79 chartPanel.setPreferredSize(getSize()); 80 add(chartPanel); 81 82 } 83 } 84 85 | Popular Tags |