List of usage examples for org.jfree.chart.axis NumberAxis setStandardTickUnits
public void setStandardTickUnits(TickUnitSource source)
From source file:com.intel.stl.ui.configuration.view.SC2SLMTBarChartPanel.java
@Override public void initComponents() { dataset = new XYSeriesCollection(); JFreeChart chart = ComponentFactory.createXYBarChart(K1105_SC.getValue(), K1106_SL.getValue(), dataset, (XYItemLabelGenerator) null); XYPlot plot = chart.getXYPlot();/*from w w w .j a v a2 s . c o m*/ plot.setDomainPannable(true); plot.setRangePannable(true); final String scLabel = "<html>" + K1105_SC.getValue() + ": "; final String slLabel = "<br>" + K1106_SL.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 scNum = (int) dataset.getXValue(arg1, arg2); int slCount = (int) dataset.getYValue(arg1, arg2); return scLabel + scNum + slLabel + slCount + "</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:com.intel.stl.ui.configuration.view.SC2VLTMTBarChartPanel.java
@Override public void initComponents() { dataset = new XYSeriesCollection(); JFreeChart chart = ComponentFactory.createXYBarChart(K1105_SC.getValue(), K1109_VLT.getValue(), dataset, (XYItemLabelGenerator) null); XYPlot plot = chart.getXYPlot();//from w w w . j ava 2 s .co m plot.setDomainPannable(true); plot.setRangePannable(true); final String scLabel = "<html>" + K1105_SC.getValue() + ": "; final String vltLabel = "<br>" + K1109_VLT.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 scNum = (int) dataset.getXValue(arg1, arg2); int vltCount = (int) dataset.getYValue(arg1, arg2); return scLabel + scNum + vltLabel + vltCount + "</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:edu.ucla.stat.SOCR.chart.demo.StatisticalBarChartDemo2.java
/** * Creates a sample chart.// w w w .j a v a2 s . c o m * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); rangeAxis.setAutoRangeIncludesZero(true); // customise the renderer... StatisticalBarRenderer renderer = new StatisticalBarRenderer(); renderer.setErrorIndicatorPaint(Color.black); renderer.setLegendItemLabelGenerator( new SOCRCategoryCellLabelGenerator(dataset, values_storage, SERIES_COUNT, CATEGORY_COUNT)); plot.setRenderer(renderer); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:edu.ucla.stat.SOCR.chart.demo.LineChartDemo1a.java
/** * Creates a sample chart.//from w w w . j a v a 2 s. c o m * * @param dataset a dataset. * * @return The chart. */ protected JFreeChart createChart(CategoryDataset dataset) { // create the chart... JFreeChart chart = ChartFactory.createLineChart(chartTitle, // chart title domainLabel, // domain axis label rangeLabel, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation !legendPanelOn, // include legend true, // tooltips false // urls ); chart.setBackgroundPaint(Color.white); CategoryPlot plot = (CategoryPlot) chart.getPlot(); plot.setBackgroundPaint(Color.lightGray); plot.setRangeGridlinePaint(Color.white); // customise the range axis... NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // customise the renderer... LineAndShapeRenderer renderer = (LineAndShapeRenderer) plot.getRenderer(); renderer.setBaseShapesVisible(true); renderer.setDrawOutlines(true); renderer.setUseFillPaint(true); renderer.setBaseFillPaint(Color.white); renderer.setLegendItemLabelGenerator(new SOCRCategorySeriesLabelGenerator()); setCategorySummary(dataset); return chart; }
From source file:j2se.jfreechart.barchart.BarChartDemo4.java
/** * Creates a sample chart.//from w ww . ja v a 2 s . c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", // 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(new Color(0xBBBBDD)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); // 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); renderer.setMaximumBarWidth(0.10); // 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); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:no.ntnu.mmfplanner.ui.graph.SaNpvChart.java
/** * Creates the chart// w ww .jav a2s . co m */ private void createChart() { JFreeChart chart = ChartFactory.createXYLineChart(null, // chart title "Period", // x axis label "Discounted Cash", // y axis label null, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); XYPlot plot = (XYPlot) chart.getPlot(); plot.getDomainAxis().setLowerMargin(0.0); plot.getDomainAxis().setUpperMargin(0.0); plot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_LEFT); // change the auto tick unit selection to integer units only... NumberAxis rangeAxis = (NumberAxis) plot.getDomainAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); setChart(chart); setMouseZoomable(false); XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setLegendLine(new Rectangle2D.Double(0.0, 0.0, 6.0, 0.0)); renderer.setUseFillPaint(true); // the x=0 line renderer.setSeriesPaint(0, Color.GRAY); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesVisibleInLegend(0, new Boolean(false)); plot.setRenderer(renderer); }
From source file:org.jfree.chart.demo.BarChartDemo4.java
/** * Creates a sample chart./*from w w w .j ava 2 s . c o m*/ * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Bar Chart Demo", // 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(new Color(0xBBBBDD)); // get a reference to the plot for further customisation... final CategoryPlot plot = chart.getCategoryPlot(); // 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); renderer.setMaxBarWidth(0.10); // 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); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:com.cs572.assignments.Project2.view.LineChartPanel.java
/** * Creates a chart./* w w w . j a v a2 s . c om*/ * * @param dataset the data for the chart. * * @return a chart. */ private JFreeChart createChart(final XYDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createXYLineChart("Expression Tree", // chart title "DataPoints", // x axis label "Output", // y axis label dataset, // data PlotOrientation.VERTICAL, true, // include legend true, // tooltips false // urls ); // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART... chart.setBackgroundPaint(Color.white); // final StandardLegend legend = (StandardLegend) chart.getLegend(); // legend.setDisplaySeriesShapes(true); // get a reference to the plot for further customisation... final XYPlot plot = chart.getXYPlot(); plot.setBackgroundPaint(Color.lightGray); // plot.setAxisOffset(new Spacer(Spacer.ABSOLUTE, 5.0, 5.0, 5.0, 5.0)); plot.setDomainGridlinePaint(Color.white); plot.setRangeGridlinePaint(Color.white); final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer(); renderer.setSeriesLinesVisible(0, true); renderer.setSeriesLinesVisible(1, true); renderer.setSeriesShapesVisible(0, false); renderer.setSeriesShapesVisible(1, false); plot.setRenderer(renderer); // change the auto tick unit selection to integer units only... final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }
From source file:Graphic.camion.java
private void initialiser() { DefaultCategoryDataset dataset = new DefaultCategoryDataset(); int k = 0;/* www. j a v a 2s .co m*/ for (int j = 0; j < categories.size(); j++) { for (int i = 0; i < series.size(); i++) { dataset.addValue(valeurs.get(k), series.get(i), categories.get(j)); k++; } } JFreeChart chart = ChartFactory.createBarChart(titre, // chart title abscisse, // domain axis label ordonnee, // range axis label dataset, // data PlotOrientation.VERTICAL, // orientation legende, // include legend true, // tooltips false // URL ); // definition de la couleur de fond //chart.setBackgroundPaint(couleurFond); CategoryPlot plot = (CategoryPlot) chart.getPlot(); //valeur comprise entre 0 et 1 transparence de la zone graphique plot.setBackgroundAlpha(0.9f); NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis(); rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits()); BarRenderer renderer = (BarRenderer) plot.getRenderer(); renderer.setDrawBarOutline(false); // pour la couleur des barres pour chaque serie for (int s = 0; s < series.size(); s++) { GradientPaint gp0 = new GradientPaint(0.0f, 0.0f, couleursBarres[s], 0.0f, 0.0f, new Color(0, 40, 70)); renderer.setSeriesPaint(s, gp0); } ChartPanel chartPanel = new ChartPanel(chart); chartPanel.setFillZoomRectangle(true); chartPanel.setMouseWheelEnabled(true); add(chartPanel); }
From source file:graphs.LimitsGraphs.java
/** * Creates a sample chart.//from w w w . j a v a2 s . c o m * * @param dataset the dataset. * * @return The chart. */ private JFreeChart createChart(final CategoryDataset dataset) { // create the chart... final JFreeChart chart = ChartFactory.createBarChart("Limits ..", // chart title "Metric", // domain axis label "Value", // 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(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); renderer.setSeriesPaint(0, gp0); renderer.setSeriesPaint(1, gp1); renderer.setSeriesPaint(2, gp2); final CategoryAxis domainAxis = plot.getDomainAxis(); domainAxis.setCategoryLabelPositions(CategoryLabelPositions.createUpRotationLabelPositions(Math.PI / 6.0)); // OPTIONAL CUSTOMISATION COMPLETED. return chart; }