1 package com.calipso.reportgenerator.userinterface; 2 3 4 import org.jfree.chart.ChartFactory; 5 import org.jfree.chart.JFreeChart; 6 import org.jfree.chart.ChartPanel; 7 import org.jfree.chart.axis.NumberAxis; 8 import org.jfree.chart.plot.CategoryPlot; 9 import org.jfree.data.category.CategoryDataset; 10 11 import java.awt.*; 12 13 import javax.swing.*; 14 15 import com.calipso.reportgenerator.common.LanguageTraslator; 16 17 20 21 public class HorizontalBarChart extends Charts{ 22 23 24 29 public HorizontalBarChart(CategoryDataset dataset, String tittle, Color color, boolean legend, boolean toolTips, Dimension size, boolean multipleAxis) { 30 super(dataset, tittle, color, legend, toolTips, size, multipleAxis); 31 previewHorizontalBarChart(); 32 this.setVisible(true); 33 } 34 35 39 private void previewHorizontalBarChart() { 40 41 42 43 JFreeChart chart = ChartFactory.createBarChart( 44 tittle, LanguageTraslator.traslate("337"), LanguageTraslator.traslate("336"), dataset, org.jfree.chart.plot.PlotOrientation.HORIZONTAL, 49 legend, toolTips, 51 false 52 ); 53 54 56 chart.setBackgroundPaint(color); 58 59 CategoryPlot plot = chart.getCategoryPlot(); 61 62 NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); 64 rangeAxis.setAutoRangeIncludesZero(true); 65 rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); 66 67 ChartPanel chartPanel = new ChartPanel(chart); 68 chartPanel.setPreferredSize(getSize()); 69 add(chartPanel); 70 71 } 72 73 } 74 75 | Popular Tags |