/** * Creates a histogram chart. This chart is constructed with an * {@link XYPlot} using an {@link XYBarRenderer}. The domain and range * axes are {@link NumberAxis} instances. * * @param title the chart title ({@code null} permitted). * @param xAxisLabel the x axis label ({@code null} permitted). * @param yAxisLabel the y axis label ({@code null} permitted). * @param dataset the dataset ({@code null} permitted). * @return A chart. * * @since 1.0.20 */ public static JFreeChart createHistogram(String title, String xAxisLabel, String yAxisLabel, IntervalXYDataset dataset) { return createHistogram(title, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, true, true, false); }
public ChartHelper generateChart() { boolean legend = false; boolean tooltips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram(null, null, yLabel, dataset, PlotOrientation.VERTICAL, legend, tooltips, urls); setHistogramChartDefaults(chart, i18nBean); chart.setBorderVisible(false); return new ChartHelper(chart); }
/** Return the JFreeChart with this histogram, and as a side effect, show it in a JFrame * that provides the means to edit the dimensions and also the plot properties via a popup menu. */ public JFreeChart asChart(final boolean show) { double[] d = new double[this.size()]; int i = 0; for (Number num : this.values()) d[i++] = num.doubleValue(); HistogramDataset hd = new HistogramDataset(); hd.setType(HistogramType.RELATIVE_FREQUENCY); String title = "Histogram"; hd.addSeries(title, d, d.length); JFreeChart chart = ChartFactory.createHistogram(title, "", "", hd, PlotOrientation.VERTICAL, false, false, false); setTheme(chart); if (show) { JFrame frame = new JFrame(title); frame.getContentPane().add(new ChartPanel(chart)); frame.pack(); frame.setVisible(true); } return chart; }
public Chart(Model model, AccuracyRadioButtons accuracyRadioButtons, AutoScaleRadioButtons autoScaleRadioButtons, ProbesCheckboxes probesCheckboxes) { this.model = model; this.accuracyRadioButtons = accuracyRadioButtons; this.autoScaleRadioButtons = autoScaleRadioButtons; this.probesCheckboxes = probesCheckboxes; setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); setLayout(new BorderLayout()); initSliders(); JPanel horizontalSlidersPanel = new JPanel(); horizontalSlidersPanel.setLayout(new BoxLayout(horizontalSlidersPanel, BoxLayout.Y_AXIS)); horizontalSlidersPanel.add(mainHorizontalSlider); horizontalSlidersPanel.add(fineHorizontalSlider); JFreeChart chart = ChartFactory.createHistogram("Latency Distribution", "Latency (µs)", "Operations", null, PlotOrientation.VERTICAL, true, true, true); plot = chart.getXYPlot(); plot.setForegroundAlpha(ALPHA); ChartPanel chartPanel = new ChartPanel(null); chartPanel.setChart(chart); add(horizontalSlidersPanel, BorderLayout.SOUTH); add(verticalSlider, BorderLayout.EAST); add(chartPanel, BorderLayout.CENTER); initSliderChangeListener(); }
public Chart(Model model, AccuracyRadioButtons accuracyRadioButtons, AutoScaleRadioButtons autoScaleRadioButtons, ProbesCheckboxes probesCheckboxes) { this.model = model; this.accuracyRadioButtons = accuracyRadioButtons; this.autoScaleRadioButtons = autoScaleRadioButtons; this.probesCheckboxes = probesCheckboxes; setMaximumSize(new Dimension(Integer.MAX_VALUE, Integer.MAX_VALUE)); setLayout(new BorderLayout()); initSliders(); JPanel horizontalSlidersPanel = new JPanel(); horizontalSlidersPanel.setLayout(new BoxLayout(horizontalSlidersPanel, BoxLayout.Y_AXIS)); horizontalSlidersPanel.add(mainHorizontalSlider); horizontalSlidersPanel.add(fineHorizontalSlider); JFreeChart chart = ChartFactory.createHistogram("Latency Distribution", "Latency (µs)", "Operations", null, PlotOrientation.VERTICAL, true, true, true); plot = chart.getXYPlot(); plot.setForegroundAlpha(ALPHA); ChartPanel chartPanel = new ChartPanel(null); chartPanel.setChart(chart); add(horizontalSlidersPanel, BorderLayout.SOUTH); add(verticalSlider, BorderLayout.EAST); add(chartPanel, BorderLayout.CENTER); initSliderChangeListener(); }
private static JFreeChart createHistogram(List<Double> samples) { double[] data = new double[samples.size()]; for (int i = 0; i < samples.size(); i++) { data[i] = samples.get(i); } // int number = data.length; HistogramDataset dataset = new HistogramDataset(); dataset.setType(HistogramType.RELATIVE_FREQUENCY); dataset.addSeries("Hist", data, 200); String plotTitle = ""; String xAxis = "Value"; String yAxis = "Frequency"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram(plotTitle, xAxis, yAxis, dataset, orientation, show, toolTips, urls); chart.setBackgroundPaint(Color.white); return chart; }
JFreeChart chart = ChartFactory.createHistogram( bundle.getString( "chronos.label.histogram" ), bundle.getString( "chronos.label.histogram.x" ), bundle.getString( "chronos.label.histogram.y" ),
/** * Creates a chart. * * @param dataset * a dataset. * @return A chart. */ private JFreeChart createChart(SimpleHistogramDataset dataset) { String label = "Value"; if (targetAttributeName != null) { label = targetAttributeName.getFullname(); if (label == null || label.trim().length() == 0) label = targetAttributeName.getId(); } chart = ChartFactory.createHistogram(null, label, "Histogram", dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.getRenderer().setSeriesPaint(0, new Color(0x7f9f51)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(true); plot.setRangeCrosshairVisible(true); return chart; }
public JFreeChart createChart(Chart chart) { ChartModel model = (ChartModel) chart.getModel(); if (!(model instanceof XYModel)) { throw new UiException("model must be a org.zkoss.zul.XYModel"); } return ChartFactory.createHistogram( chart.getTitle(), chart.getXAxis(), chart.getYAxis(), (IntervalXYDataset)XYModelToXYDataset((XYModel)model), getOrientation(chart.getOrient()), chart.isShowLegend(), chart.isShowTooltiptext(), true); } }
chart = ChartFactory.createHistogram( null, null, null, dataset, PlotOrientation.VERTICAL, false, false, false );
/** * Creates a chart. * * @param dataset * a dataset. * * @return A chart. */ private JFreeChart createChart(SimpleHistogramDataset dataset) { chart = ChartFactory.createHistogram(null, engl("Value"), engl("Histogram"), dataset, PlotOrientation.VERTICAL, false, true, false); chart.setBackgroundPaint(Color.white); XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(Color.white); plot.getRenderer().setSeriesPaint(0, new Color(0x7f9f51)); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0)); plot.setDomainCrosshairVisible(false); plot.setRangeCrosshairVisible(false); return chart; }
chart = ChartFactory.createHistogram( null, null, null, dataset, PlotOrientation.VERTICAL, false, false, false );
public void createChart(String pngFileName){ HistogramDataset dataset = new HistogramDataset(); dataset.setType(HistogramType.FREQUENCY); double [] values = getValuesBetween(getMinScore(), getMaxScore()); dataset.addSeries(getTitle(), values,getNumberOfBars(),getMinScore(),getMaxScore()); String plotTitle = getTitle(); String xaxis = "Score"; String yaxis = "Number of interactions"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram( plotTitle, xaxis, yaxis, dataset, orientation, show, toolTips, urls); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setAutoRange(true); try { ChartUtilities.saveChartAsPNG(new File(pngFileName), chart, getWidth(), getHeight()); } catch (IOException e) { e.printStackTrace(); } }
public void createRelativeChart(String pngFileName){ HistogramDataset dataset = new HistogramDataset(); dataset.setType(HistogramType.RELATIVE_FREQUENCY); double [] values = getValuesBetween(getMinScore(), getMaxScore()); dataset.addSeries(getTitle(), values,getNumberOfBars(),getMinScore(),getMaxScore()); String plotTitle = getTitle(); String xaxis = "Score"; String yaxis = "% of interactions"; PlotOrientation orientation = PlotOrientation.VERTICAL; boolean show = false; boolean toolTips = false; boolean urls = false; JFreeChart chart = ChartFactory.createHistogram( plotTitle, xaxis, yaxis, dataset, orientation, show, toolTips, urls); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.getRangeAxis().setAutoRange(true); try { ChartUtilities.saveChartAsPNG(new File(pngFileName), chart, getWidth(), getHeight()); } catch (IOException e) { e.printStackTrace(); } }
private static ChartPanel getHistogramPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel, String yAxisLabel, Color color) { JFreeChart chart = ChartFactory.createHistogram( null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, // Legend? true, // tooltips false // url ); final XYPlot xyPlot = chart.getXYPlot(); //xyPlot.setForegroundAlpha(0.85f); xyPlot.setNoDataMessage("No data"); xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setSeriesPaint(0, color); StandardXYBarPainter painter = new StandardXYBarPainter(); renderer.setBarPainter(painter); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(300, 200)); // chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem()); return chartPanel; }
private static ChartPanel getHistogramPlotPanel(XIntervalSeriesCollection dataset, String xAxisLabel, String yAxisLabel, Color color) { JFreeChart chart = ChartFactory.createHistogram( null, xAxisLabel, yAxisLabel, dataset, PlotOrientation.VERTICAL, false, // Legend? true, // tooltips false // url ); final XYPlot xyPlot = chart.getXYPlot(); //xyPlot.setForegroundAlpha(0.85f); xyPlot.setNoDataMessage("No data"); xyPlot.setAxisOffset(new RectangleInsets(5, 5, 5, 5)); final XYBarRenderer renderer = (XYBarRenderer) xyPlot.getRenderer(); renderer.setDrawBarOutline(false); renderer.setShadowVisible(false); renderer.setSeriesPaint(0, color); StandardXYBarPainter painter = new StandardXYBarPainter(); renderer.setBarPainter(painter); ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setPreferredSize(new Dimension(300, 200)); // chartPanel.getPopupMenu().add(createCopyDataToClipboardMenuItem()); return chartPanel; }
private void createUI() { dataset = new XIntervalSeriesCollection(); chart = ChartFactory.createHistogram( CHART_TITLE, "Values",
private void createUI() { dataset = new XIntervalSeriesCollection(); chart = ChartFactory.createHistogram( CHART_TITLE, "Values",
/** * Creates a histogram chart that displays the given integer histogram data. * * @param aHistogram * Complex parameter that stores the data to be visualized. * @param aSettings * Settings group for integer histogram. * @return Newly created chart control. */ public static JFreeChart createHistogram(IntHistogram aHistogram, IntHistogramGroup aSettings) { XYSeriesCollection collection = fromIntHistogram(aHistogram); JFreeChart chart = ChartFactory.createHistogram(null, // title convertLabel(aSettings.axes.getDomainAxisLabel()), // label of X axis convertLabel(aSettings.axes.getRangeAxisLabel()), // label of Y axis collection, // dataset PlotOrientation.VERTICAL, // orientation false, // create legend false, // display tooltips false); // generate urls XYPlot plot = chart.getXYPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); updateGeneral(plot, aSettings.general); updateAxes(chart, aSettings.axes, aSettings.grid); updateBars(plot, aSettings.bars); chart.setBackgroundPaint(null); return chart; }
/** * Creates a histogram chart that displays the given long histogram data. * * @param aHistogram * Complex parameter that stores the data to be visualized. * @param aSettings * Settings group for long histogram. * @return Newly created chart control. */ public static JFreeChart createHistogram(LongHistogram aHistogram, LongHistogramGroup aSettings) { XYSeriesCollection collection = fromLongHistogram(aHistogram); JFreeChart chart = ChartFactory.createHistogram(null, // title convertLabel(aSettings.axes.getDomainAxisLabel()), // label of X axis convertLabel(aSettings.axes.getRangeAxisLabel()), // label of Y axis collection, // dataset PlotOrientation.VERTICAL, // orientation false, // create legend false, // display tooltips false); // generate urls XYPlot plot = chart.getXYPlot(); NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); updateGeneral(plot, aSettings.general); updateAxes(chart, aSettings.axes, aSettings.grid); updateBars(plot, aSettings.bars); chart.setBackgroundPaint(null); return chart; }