List of usage examples for org.jfree.chart.axis NumberAxis createIntegerTickUnits
public static TickUnitSource createIntegerTickUnits()
From source file:com.intel.stl.ui.configuration.view.LFTHistogramPanel.java
@Override public void initComponents() { dataset = new HistogramDataset(); JFreeChart chart = ComponentFactory.createHistogramChart(K0427_PORT_NUMBER.getValue(), K0390_NUM_LIDS.getValue(), dataset); XYPlot plot = (XYPlot) chart.getPlot(); plot.setDomainPannable(true);/* w w w .ja v a2 s . c o m*/ plot.setRangePannable(true); final String portLabel = "<html>" + K0427_PORT_NUMBER.getValue() + ": "; final String lidCountLabel = "<br>" + K0390_NUM_LIDS.getValue() + ": "; XYItemRenderer renderer = plot.getRenderer(); renderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int arg1, int arg2) { int portNum = (int) dataset.getXValue(arg1, arg2); int lidCount = (int) dataset.getYValue(arg1, arg2); return portLabel + portNum + lidCountLabel + lidCount + "</html>"; } }); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chartPanel = new ChartPanel(chart); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(PREFERRED_CHART_SIZE); propsPanel.add(chartPanel); }
From source file:org.hxzon.demo.jfreechart.CategoryDatasetDemo.java
private static JFreeChart createBarChart(CategoryDataset dataset) { JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo 1", // chart title "Category", // domain axis label "Value", // range axis label dataset, // data PlotOrientation.HORIZONTAL, // orientation true, // include legend true, // tooltips? false // URLs? );/*from www. jav a2 s . com*/ chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); // set the range axis to display integers only... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, new Color(0, 0, 64)); GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, new Color(0, 64, 0)); GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, new Color(64, 0, 0)); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:org.jfree.chart.demo.LegendManiaDemo.java
/** * Creates a sample chart./*from w w w . j av a 2s.c o m*/ * * @param dataset * the dataset. * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart(CHART_TITLE, // chart title "Activity", // domain axis label "Rate", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... // set the background color for the chart... chart.setBackgroundPaint(new Color(255, 255, 180)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(BACKGROUND_PAINT); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); final StandardLegend legend = (StandardLegend) chart.getLegend(); legend.setBackgroundPaint(Color.orange); legend.setOutlinePaint(Color.orange); // activate word wrapping when legend is vertical. legend.setPreferredWidth(125); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:co.udea.edu.proyectointegrador.gr11.parqueaderoapp.domain.stadistics.graphics.implement.Grafica.java
@Override public JFreeChart createXYLineChartToHoursOfDay(List<HoraDelDiaEstadistica> horasDelDia) { //Se obtiene el conjunto de datos XYDataset dataset = createDataForHoursOfDay(horasDelDia); JFreeChart chart = ChartFactory.createXYLineChart(TITLE_OF_XY_CHART, //Titulo del grafico DOMAIN_AXIS_LABEL_HOUR, //Nombre del Rango RANGE_AXIS_LABEL, //Nombre del dominio dataset, //conjunto de datos PlotOrientation.VERTICAL, //Orientacion del grafico true, //incluir leyendas true, false);//from www.j a v a 2s . com //Se pinta el fondo de blanco chart.setBackgroundPaint(Color.WHITE); //Se pintan el fondo del grafico de gris y las lineas de blanco XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.LIGHT_GRAY); plot.setDomainGridlinePaint(Color.WHITE); plot.setRangeGridlinePaint(Color.WHITE); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); plot.setRenderer(renderer); plot.setNoDataMessage(NO_DATA_TO_DISPLAY); //Se configura para que solo muestre nmeros enteros en el rango NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); //Se configura para que solo muestre nmeros enteros en el dominio NumberAxis domainAxis = (NumberAxis) plot.getDomainAxis(); domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); return chart; }
From source file:org.squale.squaleweb.util.graph.RepartitionMaker.java
/** * @return le diagramme JFreeChart/*from www . j a v a 2 s . c o m*/ */ public JFreeChart getChart() { JFreeChart retChart = super.getChart(); if (null == retChart) { retChart = ChartFactory.createBarChart3D(mTitle, mXLabel, mYLabel, mDataSet, PlotOrientation.VERTICAL, false, true, true); CategoryPlot plot = retChart.getCategoryPlot(); CategoryAxis xAxis = plot.getDomainAxis(); xAxis.setAxisLineVisible(true); xAxis.setVisible(true); ValueAxis yAxis = plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // On rajoute 5% pour avoir une meilleure lisibilit final double YAxisCoeff = 1.05; yAxis.setRange(PracticeResultBO.REFUSED_MIN, Math.max(mMaxValue * YAxisCoeff, 1)); // Positionne les couleurs et les liens mRenderer = (CategoryItemRenderer) plot.getRenderer(); RepartitionUrlGenerator generator = new RepartitionUrlGenerator(mProjectId, mCurrentAuditId, mPreviousAuditId, mPracticeId, mFactorParentId, NB_SERIES_FOR_FLOAT_GRAPH); mRenderer.setItemURLGenerator(generator); BarRenderer barRenderer = (BarRenderer) mRenderer; barRenderer.setBaseSeriesVisible(true); RepartitionToolTipGenerator toolTipGenerator = new RepartitionToolTipGenerator(); barRenderer.setToolTipGenerator(toolTipGenerator); manageColor(NB_SERIES_FOR_FLOAT_GRAPH); retChart.setBackgroundPaint(Color.WHITE); super.setChart(retChart); } return retChart; }
From source file:Chart.JFreeChartDemo.java
/** * Create a chart./* w ww . j a v a 2s .co m*/ * * @param dataset the dataset * @return the chart */ private JFreeChart createChart(XYDataset dataset) { // WHAT IS THIS LINE??? // JFreeChart chart = ChartFactory.createTimeSeriesChart(null, null, null, dataset, rootPaneCheckingEnabled, rootPaneCheckingEnabled, rootPaneCheckingEnabled) // create the chart... JFreeChart chart = ChartFactory.createXYLineChart("", // chart title "Time", // domain axis label "Range", // range axis label dataset, // initial series PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set chart background chart.setBackgroundPaint(Color.white); // set a few custom plot features XYPlot plot = (XYPlot) chart.getPlot(); plot.setBackgroundPaint(new Color(0xffffe0)); plot.setDomainGridlinesVisible(true); plot.setDomainGridlinePaint(Color.lightGray); plot.setRangeGridlinePaint(Color.lightGray); // set the plot's axes to display integers TickUnitSource ticks = NumberAxis.createIntegerTickUnits(); NumberAxis domain = (NumberAxis) plot.getDomainAxis(); domain.setStandardTickUnits(ticks); NumberAxis range = (NumberAxis) plot.getRangeAxis(); range.setStandardTickUnits(ticks); // render shapes and lines // XYLineAndShapeRenderer renderer = // new XYLineAndShapeRenderer(true, true); // plot.setRenderer(renderer); // renderer.setBaseShapesVisible(true); // renderer.setBaseShapesFilled(true); // // // set the renderer's stroke // Stroke stroke = new BasicStroke( // 3f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_BEVEL); // // renderer.setBaseOutlineStroke(stroke); // //Shape theshape = ShapeUtilities.createDiamond(1); //renderer.setSeriesShape(5, theshape); // label the points // NumberFormat format = NumberFormat.getNumberInstance(); // format.setMaximumFractionDigits(2); // XYItemLabelGenerator generator = // new StandardXYItemLabelGenerator( // StandardXYItemLabelGenerator.DEFAULT_ITEM_LABEL_FORMAT, // format, format); // renderer.setBaseItemLabelGenerator(generator); // renderer.setBaseItemLabelsVisible(true); return chart; }
From source file:hudson.plugins.codeviation.RepositoryView.java
private JFreeChart createChart(CategoryDataset dataset, int max) { final JFreeChart chart = ChartFactory.createLineChart(null, // chart title null, // unused "counts", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips false // urls );// w w w. ja va 2 s. c o m // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... final LegendTitle legend = chart.getLegend(); legend.setPosition(RectangleEdge.RIGHT); chart.setBackgroundPaint(Color.white); final CategoryPlot plot = chart.getCategoryPlot(); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setBackgroundPaint(Color.WHITE); plot.setOutlinePaint(null); plot.setRangeGridlinesVisible(true); plot.setRangeGridlinePaint(Color.black); CategoryAxis domainAxis = new ShiftedCategoryAxis(null); plot.setDomainAxis(domainAxis); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.UP_90); domainAxis.setLowerMargin(0.0); domainAxis.setUpperMargin(0.0); domainAxis.setCategoryMargin(0.0); final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setUpperBound(max * 1.2); rangeAxis.setLowerBound(0); final LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setStroke(new BasicStroke(4.0f)); // crop extra space around the graph plot.setInsets(new RectangleInsets(5.0, 0, 0, 5.0)); return chart; }
From source file:Client.Gui.BarChart.java
/** * Creates a sample chart./*from ww w.ja v a 2s . com*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Distribution of Trainging", // chart title "", // domain axis label "", // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation true, // include legend true, // tooltips? false // URLs? ); // set the background color for the chart... chart.setBackgroundPaint(Color.white); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); // set the range axis to display integers only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // disable bar outlines... final BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // set up gradient paints for series... final GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, Color.blue, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp1 = new GradientPaint(0.0f, 0.0f, Color.green, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp2 = new GradientPaint(0.0f, 0.0f, Color.red, 0.0f, 0.0f, Color.lightGray); final GradientPaint gp3 = new GradientPaint(0.0f, 0.0f, Color.magenta, 0.0f, 0.0f, Color.lightGray); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); renderer.setSeriesPaint(3, gp3); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); return chart; }
From source file:net.nosleep.superanalyzer.analysis.views.TimeView.java
private void createChart() { // create the chart... _chart = ChartFactory.createLineChart(Misc.getString("LISTENING_TIMES"), // chart // title Misc.getString("HOUR_OF_DAY"), // domain axis label Misc.getString("SONG_COUNT"), // range axis label _dataset, // data PlotOrientation.VERTICAL, // orientation false, // include legend true, // tooltips false // urls );/*from w ww . jav a 2s . c om*/ CategoryPlot plot = (CategoryPlot) _chart.getPlot(); plot.setRangePannable(true); plot.setRangeZeroBaselineVisible(false); CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45); _chart.addSubtitle(HomePanel.createSubtitle(Misc.getString("LISTENING_TIMES_TOOLTIP"))); ChartUtilities.applyCurrentTheme(_chart); // format the renderer after applying the theme LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setSeriesStroke(0, new BasicStroke(3.0f)); renderer.setSeriesOutlineStroke(0, new BasicStroke(2.0f)); renderer.setSeriesShape(0, new Ellipse2D.Double(-4.0, -4.0, 8.0, 8.0)); // get rid of the little line above/next to the axis // plot.setRangeZeroBaselinePaint(Color.white); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); Misc.formatChart(plot); renderer.setSeriesPaint(0, Theme.getColorSet()[1]); }
From source file:com.intel.stl.ui.configuration.view.MTUByVLBarChartPanel.java
@Override public void initComponents() { dataset = new XYSeriesCollection(); JFreeChart chart = ComponentFactory.createXYBarChart(K0342_PORT_VL_TITLE.getValue(), K1068_MTU.getValue(), dataset, (XYItemLabelGenerator) null); XYPlot plot = chart.getXYPlot();//from w ww. ja v a 2s.c o m plot.setDomainPannable(true); plot.setRangePannable(true); final String vlLabel = "<html>" + K0342_PORT_VL_TITLE.getValue() + ": "; final String mtuLabel = "<br>" + K1068_MTU.getValue() + ": "; XYBarRenderer renderer = (XYBarRenderer) plot.getRenderer(); renderer.setBarAlignmentFactor(0); renderer.setMargin(0.2); renderer.setSeriesToolTipGenerator(0, new XYToolTipGenerator() { @Override public String generateToolTip(XYDataset dataset, int arg1, int arg2) { int vlNum = (int) dataset.getXValue(arg1, arg2); int mtuCount = (int) dataset.getYValue(arg1, arg2); return vlLabel + vlNum + mtuLabel + mtuCount + "</html>"; } }); NumberAxis yAxis = (NumberAxis) plot.getRangeAxis(); yAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); NumberAxis xAxis = (NumberAxis) plot.getDomainAxis(); xAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); chartPanel = new ChartPanel(chart); chartPanel.setMouseWheelEnabled(true); chartPanel.setPreferredSize(PREFERRED_CHART_SIZE); propsPanel.add(chartPanel); }