Example usage for org.jfree.chart.axis NumberAxis NumberAxis

List of usage examples for org.jfree.chart.axis NumberAxis NumberAxis

Introduction

In this page you can find the example usage for org.jfree.chart.axis NumberAxis NumberAxis.

Prototype

public NumberAxis(String label) 

Source Link

Document

Constructs a number axis, using default values where necessary.

Usage

From source file:edu.caltechUcla.sselCassel.projects.jMarkets.shared.interfaces.PriceChart.java

public void test() {
    XYSeries testSeries = new XYSeries("Test Series");
    testSeries.add(10, 10);/*from   w ww . j a v  a2  s . co m*/
    testSeries.add(20, 20);
    testSeries.add(30, 30);

    XYSeriesCollection collection = new XYSeriesCollection(testSeries);

    NumberAxis yAxis = new NumberAxis("Y Axis");
    NumberAxis xAxis = new NumberAxis("X Axis");

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

    XYPlot plot = new XYPlot(collection, xAxis, yAxis, renderer);

    JFreeChart chart = new JFreeChart("Price Chart", new Font("Arial", 0, 12), plot, true);
    ChartPanel chartPanel = new ChartPanel(chart, false, false, false, false, false);

    JFrame frame = new JFrame();
    frame.getContentPane().add(chartPanel);
    frame.setVisible(true);
    frame.pack();

}

From source file:org.jfree.chart.demo.DualAxisDemo6.java

private static JFreeChart createChart(CategoryDataset categorydataset, CategoryDataset categorydataset1) {
    CategoryAxis categoryaxis = new CategoryAxis("Category");
    NumberAxis numberaxis = new NumberAxis("Value");
    GroupedStackedBarRenderer groupedstackedbarrenderer = new GroupedStackedBarRenderer();
    KeyToGroupMap keytogroupmap = new KeyToGroupMap("G1");
    keytogroupmap.mapKeyToGroup("Series 1A", "G1");
    keytogroupmap.mapKeyToGroup("Series 1B", "G1");
    keytogroupmap.mapKeyToGroup("NOTHING", "G2");
    groupedstackedbarrenderer.setSeriesToGroupMap(keytogroupmap);
    CategoryPlot categoryplot = new CategoryPlot(categorydataset, categoryaxis, numberaxis,
            groupedstackedbarrenderer) {

        private static final long serialVersionUID = 1L;

        public LegendItemCollection getLegendItems() {
            LegendItemCollection legenditemcollection = new LegendItemCollection();
            legenditemcollection.addAll(getRenderer().getLegendItems());
            CategoryDataset categorydataset2 = getDataset(1);
            if (categorydataset2 != null) {
                CategoryItemRenderer categoryitemrenderer = getRenderer(1);
                if (categoryitemrenderer != null) {
                    org.jfree.chart.LegendItem legenditem = categoryitemrenderer.getLegendItem(1, 1);
                    legenditemcollection.add(legenditem);
                }/* w ww  . ja  v  a 2  s  .c o  m*/
            }
            return legenditemcollection;
        }

    };
    JFreeChart jfreechart = new JFreeChart("Dual Axis Bar Chart", categoryplot);
    categoryplot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_RIGHT);
    categoryplot.setDataset(1, categorydataset1);
    categoryplot.mapDatasetToRangeAxis(1, 1);
    NumberAxis numberaxis1 = new NumberAxis("Secondary");
    categoryplot.setRangeAxis(1, numberaxis1);
    categoryplot.setRangeAxisLocation(1, AxisLocation.BOTTOM_OR_RIGHT);
    BarRenderer barrenderer = new BarRenderer();
    categoryplot.setRenderer(1, barrenderer);
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

From source file:electroStaticUI.DrawElectricFieldLines.java

public DrawElectricFieldLines(CustomMapper cMapper) {
    mapper = cMapper;// w ww  . j  a  v a  2 s. c o  m
    sumTotalVector();
    createDataset();
    renderer = new VectorRenderer();
    graph = new XYPlot(dataSet, new NumberAxis("Axis X"), new NumberAxis("Axis Y"), renderer);
    eFieldChart = new JFreeChart(graph);
    eFieldChart.setTitle("Electric Field Vectors");
    graphChart = new ChartPanel(eFieldChart);
    graphChart.setVisible(true);
}

From source file:com.bdb.weather.display.windrose.WindRosePlot.java

/**
 * Constructor./* w w  w. ja v  a  2 s.  c o m*/
 */
public WindRosePlot() {
    super();

    NumberAxis axis = new NumberAxis("%");
    axis.setTickUnit(new NumberTickUnit(10.0));
    setAxis(axis);

    renderer = new CompassPolarItemRenderer();
    renderer.setBasePaint(Color.black);
    renderer.setShapesVisible(false);
    renderer.setDrawOutlineWhenFilled(false);
    renderer.setFillComposite(AlphaComposite.Src);
    setRenderer(renderer);
    setAngleGridlinesVisible(true);
    setAngleGridlinePaint(Color.black);
    setRadiusGridlinesVisible(true);
    setRadiusGridlinePaint(Color.BLACK);
}

From source file:net.sf.profiler4j.console.MemoryPlotPanel.java

public MemoryPlotPanel(int maxAge, String title) {
    super(new BorderLayout());

    totalSeries = new TimeSeries("Committed Memory", Millisecond.class);
    totalSeries.setMaximumItemAge(maxAge);
    usedSeries = new TimeSeries("Used Memory", Millisecond.class);
    usedSeries.setMaximumItemAge(maxAge);
    TimeSeriesCollection seriesCollection = new TimeSeriesCollection();
    seriesCollection.addSeries(totalSeries);
    seriesCollection.addSeries(usedSeries);

    NumberAxis numberAxis = new NumberAxis("Memory (KB)");
    numberAxis.setLabelFont(new Font("SansSerif", 0, 14));
    numberAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    DateAxis dateAxis = new DateAxis("Time");
    dateAxis.setTickLabelFont(new Font("SansSerif", 0, 12));
    dateAxis.setLabelFont(new Font("SansSerif", 0, 14));
    dateAxis.setAutoRange(true);//w w  w  .j  a v  a  2s .com
    dateAxis.setLowerMargin(0);
    dateAxis.setUpperMargin(0);
    dateAxis.setTickLabelsVisible(true);
    dateAxis.setDateFormatOverride(new SimpleDateFormat("HH:mm:ss"));

    XYLineAndShapeRenderer lineRenderer = new XYLineAndShapeRenderer(true, false);
    lineRenderer.setSeriesPaint(0, Color.RED);
    lineRenderer.setSeriesPaint(1, Color.GREEN.darker());
    lineRenderer.setStroke(new BasicStroke(2F, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND));

    XYPlot xyplot = new XYPlot(seriesCollection, dateAxis, numberAxis, lineRenderer);
    xyplot.setBackgroundPaint(Color.WHITE);
    xyplot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setRangeGridlinePaint(Color.LIGHT_GRAY);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));

    JFreeChart chart = new JFreeChart(title, new Font("SansSerif", Font.PLAIN, 14), xyplot, true);
    chart.setBackgroundPaint(Color.white);

    ChartPanel panel = new ChartPanel(chart);
    panel.setBorder(createCompoundBorder(createEmptyBorder(8, 8, 8, 8), createLineBorder(Color.LIGHT_GRAY)));
    add(panel);
    setBorder(createEmptyBorder(8, 8, 8, 8));
}

From source file:com.ivli.roim.controls.ChartView.java

protected void initChart() {
    if (null != iPlot) {
        ((XYSeriesCollection) iPlot.getDataset()).removeAllSeries();
    } else {/*from  www. j a  va2 s  .c  o m*/
        iPlot = new XYPlot();
        iPlot.setRenderer(new StandardXYItemRenderer());
        iPlot.setDomainAxis(new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
                .getString("ROI_CHART.TIME_SERIES_VALUES")));
        iPlot.setRangeAxis(0, new NumberAxis(java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle")
                .getString("ROI_CHART.ROI_INTDEN_VALUES")));
        iPlot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
        iPlot.setDomainAxisLocation(AxisLocation.BOTTOM_OR_LEFT);

        iJfc = new JFreeChart(
                java.util.ResourceBundle.getBundle("com/ivli/roim/Bundle").getString("ROI_CHART.CHART_TITLE"),
                iPlot);

        iChart = new ChartControl(iJfc);

        iPlot.setDataset(new XYSeriesCollection());

        iChart.setPreferredSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
        iChart.setMaximumSize(new Dimension(Short.MAX_VALUE, Short.MAX_VALUE));
        setLayout(new BorderLayout());

        this.add(iChart);
    }
    iChart.setMouseZoomable(false);
    iChart.setMouseWheelEnabled(true);
}

From source file:com.bdb.weather.display.summary.TemperatureBinSummaryPlot.java

public TemperatureBinSummaryPlot() {
    plot = new CombinedDomainCategoryPlot();
    JFreeChart chart = new JFreeChart(plot);
    setMaxHeight(10000);/*from  ww  w.  j  a  va2s  .c o  m*/
    setMaxWidth(10000);

    NumberAxis countAxis = new NumberAxis("Day Count");
    countAxis.setUpperMargin(.2);
    countPlot.setRangeAxis(countAxis);
    countPlot.setDataset(countDataset);

    BarRenderer r = new BarRenderer();
    r.setBaseItemLabelsVisible(true);
    r.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    r.setSeriesPaint(0, Color.BLUE);
    r.setBasePaint(Color.BLUE);
    countPlot.setRenderer(r);

    NumberAxis durationAxis = new NumberAxis("Duration (Hours)");
    durationAxis.setUpperMargin(.2);
    durationPlot.setRangeAxis(durationAxis);
    durationPlot.setDataset(durationDataset);
    r = new BarRenderer();
    r.setBaseItemLabelsVisible(true);
    NumberFormat format = DecimalFormat.getNumberInstance();
    format.setMaximumFractionDigits(1);
    format.setMinimumFractionDigits(1);
    r.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, format));
    r.setSeriesPaint(0, Color.RED);
    r.setBasePaint(Color.RED);
    durationPlot.setRenderer(r);

    plot.getDomainAxis().setCategoryLabelPositions(CategoryLabelPositions.DOWN_90);
    plot.add(countPlot);
    plot.add(durationPlot);

    chartViewer = new ChartViewer(chart);
    this.setCenter(chartViewer);
}

From source file:com.idealista.solrmeter.view.statistic.HistogramChartPanel.java

private Component createChartPanel() {
    XYBarDataset xyBarDataset = new XYBarDataset(xyDataset, BAR_WIDTH);
    NumberAxis xaxis = new NumberAxis(I18n.get("statistic.histogramChartPanel.time"));
    NumberAxis yaxis = new NumberAxis(I18n.get("statistic.histogramChartPanel.numberOfQueries"));

    xaxis.setStandardTickUnits(/*from w  w w  .  j  a  va2s  .c  om*/
            new ChartUtils.LowerBoundedTickUnitSource(xaxis.getStandardTickUnits(), LOWER_TICK_UNIT));

    XYPlot plot = new XYPlot(xyBarDataset, xaxis, yaxis, new XYBarRenderer());

    JFreeChart chart = new JFreeChart(I18n.get("statistic.histogramChartPanel.title"), null, plot, false);

    ChartPanel chartPanel = new ChartPanel(chart);

    chartPanel.setBorder(CHART_BORDER);
    chartPanel.setMinimumDrawHeight(0);
    chartPanel.setMinimumDrawWidth(0);
    chartPanel.setMaximumDrawHeight(Integer.MAX_VALUE);
    chartPanel.setMaximumDrawWidth(Integer.MAX_VALUE);

    return chartPanel;
}

From source file:br.prof.salesfilho.oci.image.GraphicBuilder.java

public void createCombinedChart(Map<String, double[]> mapSeries, String legendTitle) {
    XYSeriesCollection xds;/*from   ww w.  j  av a  2  s. c  o  m*/
    final CombinedDomainXYPlot plot = new CombinedDomainXYPlot(new NumberAxis(legendTitle));
    plot.setGap(10.0);
    for (Map.Entry<String, double[]> entrySet : mapSeries.entrySet()) {
        String serieName = entrySet.getKey();
        double[] values = entrySet.getValue();

        final XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();

        final XYSeries series = new XYSeries(serieName);
        for (int i = 0; i < values.length; i++) {
            series.add(i, Precision.round(values[i], 2));
            renderer.setSeriesVisible(i, true, true);
            renderer.setSeriesShapesVisible(i, true);
        }
        xds = new XYSeriesCollection();
        xds.addSeries(series);

        final NumberAxis rangeAxis = new NumberAxis(serieName);

        final XYPlot subplot = new XYPlot(xds, null, rangeAxis, renderer);
        subplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
        plot.add(subplot);

    }
    this.chart = new JFreeChart(this.title, JFreeChart.DEFAULT_TITLE_FONT, plot, true);
    chartPanel.setChart(chart);
}

From source file:de.fub.maps.project.plugins.tasks.eval.OverviewChart.java

/**
 * Creates new form OverviewChart//from ww  w  .j  ava2  s  .  c o m
 */
public OverviewChart() {
    initComponents();
    barchart1.getRangeAxis()
            .setLabel(NbBundle.getMessage(OverviewChart.class, "overview.chart1.rangeaxis1.name"));
    barchart1.getPlot().setRangeAxis(1,
            new NumberAxis(NbBundle.getMessage(OverviewChart.class, "overview.chart1.rangeaxis2.name")));
    barchart1.getPlot().getRangeAxis(1).setUpperMargin(.1);
    barchart1.getPlot().getRangeAxis(0).setUpperMargin(.1);
    barchart1.getPlot().getRenderer(0).setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    barchart1.getPlot().getRenderer(0).setBaseItemLabelsVisible(true);
    BarRenderer barRenderer = new BarRenderer();
    barRenderer.setBarPainter(new StandardBarPainter());
    barRenderer.setBaseToolTipGenerator(new StandardCategoryToolTipGenerator());
    barRenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator(
            StandardCategoryItemLabelGenerator.DEFAULT_LABEL_FORMAT_STRING, new CustomNumberFormat()));
    barRenderer.setBaseItemLabelsVisible(true);
    barRenderer.setAutoPopulateSeriesFillPaint(true);
    barRenderer.setAutoPopulateSeriesPaint(true);
    barRenderer.setShadowVisible(false);
    barchart1.getPlot().setRenderer(1, barRenderer);
    CategoryPlot plot = barchart1.getPlot();
    plot.setDataset(1, new DefaultCategoryDataset());
    plot.mapDatasetToRangeAxis(0, 0);
    plot.mapDatasetToRangeAxis(1, 1);
}