List of usage examples for org.jfree.chart.renderer.category MinMaxCategoryRenderer MinMaxCategoryRenderer
public MinMaxCategoryRenderer()
From source file:org.jfree.chart.demo.MinMaxCategoryPlotDemo1.java
public static JFreeChart createChart(CategoryDataset categorydataset) { JFreeChart jfreechart = ChartFactory.createBarChart("Min/Max Category Plot", "Category", "Value", categorydataset, PlotOrientation.VERTICAL, true, true, false); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setRangePannable(true); MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer(); minmaxcategoryrenderer.setDrawLines(false); categoryplot.setRenderer(minmaxcategoryrenderer); ChartUtilities.applyCurrentTheme(jfreechart); return jfreechart; }
From source file:com.googlecode.jchav.chart.MinMeanMaxChart.java
/** * Construct a new chart to display the given data. * * @param title The page id, used for the title of the chart. * @param data the data to plot./* w w w. ja v a 2s . c o m*/ */ public MinMeanMaxChart(final String title, final SortedSet<Measurement> data) { // The renderer that does all the real work here: final MinMaxCategoryRenderer minMaxRenderer = new MinMaxCategoryRenderer(); minMaxRenderer.setObjectIcon(new FilledCircle()); // Munge the data into form JFreeChart can use: DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (Measurement m : data) { // This ordering gives max=red, min=green, mean=blue dataset.addValue(m.getMaximumTime(), "max", m.getBuildId().getBuildName()); dataset.addValue(m.getAverageTime(), "mean", m.getBuildId().getBuildName()); dataset.addValue(m.getMinimumTime(), "min", m.getBuildId().getBuildName()); } // Create the plot area: final CategoryPlot plot = new CategoryPlot(); plot.setDataset(dataset); plot.setRenderer(minMaxRenderer); plot.setDomainAxis(new CategoryAxis("Build")); // TO DO: i18n plot.setRangeAxis(new NumberAxis("RT")); // Build labels running diagonally under the bars of the chart. plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.UP_45); plot.setOrientation(PlotOrientation.VERTICAL); plot.setRangeGridlinesVisible(true); plot.setDomainGridlinesVisible(false); // the legend here would be the "min", "max", "mean" strings used when created int category data set. boolean showLegend = true; // Render the chart: JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, showLegend); chart.setTitle(title); chart.setBackgroundPaint(Color.WHITE); chart.setBorderVisible(false); if (showLegend) { chart.getLegend().setBorder(BlockBorder.NONE); } this.setChart(chart); }
From source file:net.sf.maltcms.common.charts.ui.CategoryChartComponentOpenAction.java
@Override public void actionPerformed(ActionEvent e) { Task t = RequestProcessor.getDefault().create(new Runnable() { @Override/*from w w w . j a v a 2 s .c om*/ public void run() { final ACategoryDataset<List<Double>, Double> dataset = createCategoryDataset(); final CategoryChartBuilder builder = new CategoryChartBuilder(); MinMaxCategoryRenderer renderer = new MinMaxCategoryRenderer(); renderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator()); renderer.setBaseItemLabelsVisible(true); CategoryAxis domain = new CategoryAxis("Categories"); builder.categories(dataset).renderer(renderer).domainAxis(domain).minimumDrawSize(400, 300) .preferredDrawSize(800, 600).maximumDrawSize(1280, 1024).plot().chart("Sample plot") .createLegend(true); invokeLater(new Runnable() { @Override public void run() { TopComponent tc = WindowManager.getDefault().findTopComponent("navigatorTC"); if (tc != null) { tc.open(); } } }); invokeLater(new Runnable() { @Override public void run() { CategoryChartTopComponent<Double> xytc = new CategoryChartTopComponent<>(Double.class, dataset, builder); xytc.open(); xytc.requestActive(); } }); } }); RequestProcessor.getDefault().post(t); }
From source file:agentlogfileanalyzer.gui.ComparisonFrame.java
/** * Creates a chart frame for comparing a selected classifier to a set of * other classifiers.//ww w. j a v a 2 s . c o m * * @param firstTitle * the first line of the chart title * @param secondTitle * the second line of the chart title * @param compDataForColumns * the data the will be displayed in the chart */ public ComparisonFrame(String firstTitle, String secondTitle, Vector<ComparisonDataSet> compDataForColumns) { super("Classifier comparison"); DefaultCategoryDataset dataset = new DefaultCategoryDataset(); for (int i = 0; i < compDataForColumns.size(); i++) { ComparisonDataSet mms = compDataForColumns.get(i); dataset.addValue(mms.getMax(), "max", mms.getColumnName()); dataset.addValue(mms.getMin(), "min", mms.getColumnName()); dataset.addValue(mms.getSelected(), "selected", mms.getColumnName()); } JFreeChart jfreechart = ChartFactory.createBarChart("", // title "", // x-axis title "", // y-axis title dataset, PlotOrientation.VERTICAL, true, true, false); TextTitle subtitle1 = new TextTitle(firstTitle, new Font("SansSerif", Font.BOLD, 12)); TextTitle subtitle2 = new TextTitle(secondTitle, new Font("SansSerif", Font.BOLD, 12)); jfreechart.addSubtitle(0, subtitle1); jfreechart.addSubtitle(1, subtitle2); jfreechart.setBackgroundPaint(Color.white); CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot(); categoryplot.setBackgroundPaint(Color.lightGray); categoryplot.setRangeGridlinePaint(Color.white); MinMaxCategoryRenderer minmaxcategoryrenderer = new MinMaxCategoryRenderer(); categoryplot.setRenderer(minmaxcategoryrenderer); ChartPanel chartpanel = new ChartPanel(jfreechart); chartpanel.setPreferredSize(new Dimension(500, 270)); setContentPane(chartpanel); }
From source file:org.jfree.chart.demo.MinMaxCategoryPlotDemo.java
/** * Creates a new demo.//from w ww . j a v a 2s . co m * * @param title the frame title. */ public MinMaxCategoryPlotDemo(final String title) { super(title); // create a dataset... final DefaultCategoryDataset dataset = new DefaultCategoryDataset(); dataset.addValue(1.0, "First", "Category 1"); dataset.addValue(4.0, "First", "Category 2"); dataset.addValue(3.0, "First", "Category 3"); dataset.addValue(5.0, "First", "Category 4"); dataset.addValue(5.0, "First", "Category 5"); dataset.addValue(7.0, "First", "Category 6"); dataset.addValue(7.0, "First", "Category 7"); dataset.addValue(8.0, "First", "Category 8"); dataset.addValue(5.0, "Second", "Category 1"); dataset.addValue(7.0, "Second", "Category 2"); dataset.addValue(6.0, "Second", "Category 3"); dataset.addValue(8.0, "Second", "Category 4"); dataset.addValue(4.0, "Second", "Category 5"); dataset.addValue(4.0, "Second", "Category 6"); dataset.addValue(2.0, "Second", "Category 7"); dataset.addValue(1.0, "Second", "Category 8"); dataset.addValue(4.0, "Third", "Category 1"); dataset.addValue(3.0, "Third", "Category 2"); dataset.addValue(2.0, "Third", "Category 3"); dataset.addValue(3.0, "Third", "Category 4"); dataset.addValue(6.0, "Third", "Category 5"); dataset.addValue(3.0, "Third", "Category 6"); dataset.addValue(4.0, "Third", "Category 7"); dataset.addValue(3.0, "Third", "Category 8"); // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Min/Max Category Plot", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(Color.yellow); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setRenderer(new MinMaxCategoryRenderer()); // OPTIONAL CUSTOMISATION COMPLETED. // add the chart to a panel... final ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new java.awt.Dimension(500, 270)); setContentPane(chartPanel); }