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

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

Introduction

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

Prototype

public static TickUnitSource createIntegerTickUnits() 

Source Link

Document

Returns a collection of tick units for integer values.

Usage

From source file:be.ugent.maf.cellmissy.gui.controller.analysis.singlecell.PlateHeatMapController.java

/**
 * Plot the z-scores: simple scatterplot
 *///from   w  w  w  . j  a  v  a 2 s  . c  o m
private void plotZScores() {
    XYSeriesCollection xySeriesCollection = new XYSeriesCollection();
    Map<Well, Double> map = computeZScoresForMap();

    List<PlateCondition> plateConditionList = trackCoordinatesController.getPlateConditionList();

    for (int i = 0; i < plateConditionList.size(); i++) {
        // current condition
        PlateCondition condition = plateConditionList.get(i);
        XYSeries series = new XYSeries(i + "-" + condition);
        for (int j = 0; j < condition.getSingleCellAnalyzedWells().size(); j++) {
            // current well
            Well well = condition.getSingleCellAnalyzedWells().get(j);
            series.add(i + 1, map.get(well));
        }
        xySeriesCollection.addSeries(series);
    }

    JFreeChart jfreechart = ChartFactory.createScatterPlot("z*-score", "condition number", "z*-score",
            xySeriesCollection, PlotOrientation.VERTICAL, false, true, false);
    JFreeChartUtils.setupXYPlot(jfreechart.getXYPlot());
    jfreechart.getXYPlot().getDomainAxis().setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // line for the median speed
    ValueMarker marker = new ValueMarker(0);
    marker.setPaint(Color.GRAY);
    Stroke dashedStroke = new BasicStroke(2.0f, BasicStroke.CAP_ROUND, BasicStroke.JOIN_ROUND, 1.0f,
            new float[] { 1.0f, 3.0f }, 0.0f);
    marker.setStroke(dashedStroke);
    jfreechart.getXYPlot().addRangeMarker(marker);

    marker = new ValueMarker(3);
    marker.setPaint(Color.GRAY);
    marker.setStroke(dashedStroke);
    jfreechart.getXYPlot().addRangeMarker(marker);

    marker = new ValueMarker(-3);
    marker.setPaint(Color.GRAY);
    marker.setStroke(dashedStroke);
    jfreechart.getXYPlot().addRangeMarker(marker);

    XYItemRenderer renderer = jfreechart.getXYPlot().getRenderer();
    for (int i = 0; i < xySeriesCollection.getSeriesCount(); i++) {
        // plot lines according to conditions indexes
        int colorIndex = i % GuiUtils.getAvailableColors().length;
        Color color = GuiUtils.getAvailableColors()[colorIndex];
        color = new Color(color.getRed(), color.getGreen(), color.getBlue(), 127);
        renderer.setSeriesPaint(i, color);
        renderer.setSeriesShape(i, new Ellipse2D.Double(0, 0, 10, 10));
    }
    zScoreChartPanel.setChart(jfreechart);
}

From source file:com.hmsinc.epicenter.webapp.remoting.AnalysisService.java

/**
 * Builds a timeseries for the given criteria.
 * //from w  ww.  j ava 2 s .  co  m
 * @param classifierId
 * @param classifierCategory
 * @param start
 * @param end
 * @param geoType
 * @param geoId
 * @return
 */
@Secured("ROLE_USER")
@Transactional(readOnly = true)
@RemoteMethod
public String getTimeSeriesChart(final AnalysisParametersDTO paramsDTO) {

    final AnalysisParameters params = convertParameters(paramsDTO);
    final Properties analyzerProperties = paramsDTO.getAlgorithmProperties();

    // Set the period based on the date range:
    params.setPeriod(deltaDays(params.getStartDate(), params.getEndDate()) > 0 ? TimeSeriesPeriod.DAY
            : TimeSeriesPeriod.HOUR);

    TimeSeries ts = queryService.queryForTimeSeries(params, paramsDTO.getAlgorithmName(), analyzerProperties);
    TimeSeriesChart chart = new TimeSeriesChart();
    final List<XYAnnotation> events = new ArrayList<XYAnnotation>();

    if (ts != null) {

        chart.setYLabel(params.getDataRepresentation().getDisplayName());

        final String label = getAttributeLabel(params);
        if (!DataConditioning.NONE.equals(params.getDataConditioning())) {

            chart.add(label + " (Conditioned)", ts, ChartColor.VALUE.getColor(), LineStyle.SOLID);
            chart.add("Actual Value", ts, ResultType.RAW, ChartColor.VALUE.getColor(), LineStyle.DASHED);

        } else {

            chart.add(label, ts, ChartColor.VALUE.getColor(), LineStyle.SOLID);
            if (DataRepresentation.ACTUAL.equals(params.getDataRepresentation())) {
                chart.setRangeTickUnits(NumberAxis.createIntegerTickUnits());
            }
        }

        if (paramsDTO.getAlgorithmName() != null) {
            chart.add(paramsDTO.getAlgorithmName(), ts, ResultType.THRESHOLD, ChartColor.THRESHOLD.getColor(),
                    LineStyle.SOLID);

            /*
             * for (TimeSeriesEntry entry : ts) { if (entry.getValue() >=
             * entry.getDoubleProperty(ResultType.THRESHOLD) &&
             * entry.getValue() > 10) { final String value =
             * String.valueOf(FormatUtils.round(entry.getValue(), 1)); final
             * XYPointerAnnotation annotation = new
             * XYPointerAnnotation(value, entry.getTime().getMillis(),
             * entry.getValue(), 3.0 * Math.PI / 4.0 );
             * annotation.setPaint(ChartColor.THRESHOLD.getColor());
             * events.add(annotation); } }
             */
        }
    }

    return chartService.getChartURL(chart, events);
}

From source file:edu.ucla.stat.SOCR.chart.ChartGenerator.java

private JFreeChart createBoxAndWhiskerChart(String title, String xLabel, String yLabel,
        BoxAndWhiskerCategoryDataset dataset) {

    CategoryAxis domainAxis = new CategoryAxis(xLabel);
    NumberAxis rangeAxis = new NumberAxis(yLabel);

    // CategoryItemRenderer renderer = new BoxAndWhiskerRenderer();
    BoxAndWhiskerRenderer renderer = new BoxAndWhiskerRenderer();
    CategoryPlot plot = new CategoryPlot(dataset, domainAxis, rangeAxis, renderer);
    JFreeChart chart = new JFreeChart(title, plot);

    chart.setBackgroundPaint(Color.white);

    plot.setBackgroundPaint(Color.lightGray);
    plot.setDomainGridlinePaint(Color.white);
    plot.setDomainGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.white);

    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    //columnCount -- category count
    //RowCount -- serie count
    if (dataset.getColumnCount() * dataset.getRowCount() < 5) {

        domainAxis.setLowerMargin(0.2);/*from   w  w  w .j  a  v  a  2 s . com*/
        domainAxis.setUpperMargin(0.2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(0.5);
        //   domainAxis.setCategoryMargin(domainAxis.getCategoryMargin()*2);

        /*   System.out.println("lowerMargin="+domainAxis.getLowerMargin());
           System.out.println("ItemMargin="+renderer.getItemMargin());
           System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());*/
    }

    else if (dataset.getColumnCount() * dataset.getRowCount() < 10) {
        domainAxis.setLowerMargin(domainAxis.getLowerMargin() * 2);
        domainAxis.setUpperMargin(domainAxis.getUpperMargin() * 2);
        if (dataset.getColumnCount() == 1)
            renderer.setItemMargin(renderer.getItemMargin() * 2);
        else
            domainAxis.setCategoryMargin(domainAxis.getCategoryMargin() * 2);
        /*System.out.println("lowerMargin="+domainAxis.getLowerMargin());
         System.out.println("ItemMargin="+renderer.getItemMargin());
         System.out.println("CategoryMargin="+domainAxis.getCategoryMargin());
        */
    }

    return chart;
}

From source file:org.objectweb.proactive.extensions.timitspmd.util.charts.MatrixChart.java

private void buildLegendChart(int nbValues) {
    this.legendValues = new int[nbValues + 1];
    this.legendValues[0] = 0;
    int offset = 255 / nbValues;
    int step = offset;

    if (this.scaleMode == Chart.Scale.LOGARITHMIC) {
        double logStep = (Math.log(this.maxValue) / Math.log(2)) / nbValues;
        for (int i = 1; i < (nbValues + 1); i++) {
            this.legendValues[i] = (int) Math.pow(2, logStep * i);
        }//w w  w .j  a v  a 2 s. co m
    } else { // Linear scale mode
        for (int i = 1; i < (nbValues + 1); i++) {
            this.legendValues[i] = (step * this.maxValue) / 255;
            step += offset;
        }
    }

    final MatrixSeriesCollection dataset = new MatrixSeriesCollection(this.createLegendDataSet());

    final JFreeChart chart = ChartFactory.createBubbleChart("", "", "", dataset, PlotOrientation.VERTICAL, true,
            true, false);

    chart.setBackgroundPaint(new GradientPaint(0, 0, Color.white, 0, 1000, Color.WHITE));
    chart.removeLegend();

    // Perform customizations starts here ...
    final XYPlot plot1 = chart.getXYPlot();

    plot1.setDomainGridlinesVisible(false);
    plot1.setRangeGridlinesVisible(false);
    plot1.setForegroundAlpha(0.5f);
    plot1.setDomainAxis(new CustomAxis(plot1.getDomainAxis().getLabel()));
    plot1.setRangeAxis(new CustomAxis(plot1.getRangeAxis().getLabel()));

    // Custumize the domain axis ( x )
    final NumberAxis domainAxis = (NumberAxis) plot1.getDomainAxis();
    domainAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    domainAxis.setRange(-1, 1);
    domainAxis.setVisible(false);

    // Custumize the range axis ( y )
    final NumberAxis rangeAxis = (NumberAxis) plot1.getRangeAxis();
    rangeAxis.setTickUnit(new CustomTickUnit(rangeAxis.getTickUnit().getSize()));
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setRange(-1, this.legendValues.length);
    rangeAxis.setTickLabelsVisible(true);
    rangeAxis.setTickMarkInsideLength(4);

    // Create custom renderer
    StandardXYItemRenderer ren = new CustomRenderer(true);
    ren.setSeriesItemLabelPaint(0, Color.BLUE);
    plot1.setRenderer(ren);
    plot1.setRangeAxisLocation(AxisLocation.TOP_OR_RIGHT);

    this.legendChart = chart;
}

From source file:edu.ucla.stat.SOCR.chart.SuperDotChart.java

/**
 * Creates a chart./*from ww  w  . j av a 2 s. c  o  m*/
 * 
 * @param dataset  the dataset.
 * 
 * @return a chart.
 */
protected JFreeChart createChart1(XYDataset dataset) {
    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart(chartTitle, // chart title
            domainLabel, // x axis label
            rangeLabel, // y axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, !legendPanelOn, // include legend
            true, // tooltips
            false // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    XYPlot plot = (XYPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.lightGray);
    plot.setAxisOffset(new RectangleInsets(5.0, 5.0, 5.0, 5.0));
    plot.setDomainGridlinePaint(Color.white);
    plot.setRangeGridlinePaint(Color.white);

    XYLineAndShapeRenderer renderer = (XYLineAndShapeRenderer) plot.getRenderer();
    renderer.setBaseShapesVisible(true);
    renderer.setBaseShapesFilled(true);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:com.mothsoft.alexis.web.ChartServlet.java

private void doLineGraph(final HttpServletRequest request, final HttpServletResponse response,
        final String title, final String[] dataSetIds, final Integer width, final Integer height,
        final Integer numberOfSamples) throws ServletException, IOException {

    final DataSetService dataSetService = WebApplicationContextUtils
            .getWebApplicationContext(this.getServletContext()).getBean(DataSetService.class);

    final OutputStream out = response.getOutputStream();
    response.setContentType("image/png");
    response.setHeader("Cache-Control", "max-age: 5; must-revalidate");

    final XYSeriesCollection seriesCollection = new XYSeriesCollection();

    final DateAxis dateAxis = new DateAxis(title != null ? title : "Time");
    final DateTickUnit unit = new DateTickUnit(DateTickUnit.HOUR, 1);
    final DateFormat chartFormatter = new SimpleDateFormat("ha");
    dateAxis.setDateFormatOverride(chartFormatter);
    dateAxis.setTickUnit(unit);//from  w w  w . j ava  2s  .  c  o  m
    dateAxis.setLabelFont(DEFAULT_FONT);
    dateAxis.setTickLabelFont(DEFAULT_FONT);

    if (numberOfSamples > 12) {
        dateAxis.setTickLabelFont(
                new Font(DEFAULT_FONT.getFamily(), Font.PLAIN, (int) (DEFAULT_FONT.getSize() * .8)));
    }

    final NumberAxis yAxis = new NumberAxis("Activity");

    final StandardXYItemRenderer renderer = new StandardXYItemRenderer(StandardXYItemRenderer.SHAPES_AND_LINES);

    int colorCounter = 0;

    if (dataSetIds != null) {
        for (final String dataSetIdString : dataSetIds) {
            final Long dataSetId = Long.valueOf(dataSetIdString);
            final DataSet dataSet = dataSetService.get(dataSetId);

            // go back for numberOfSamples, but include current hour
            final Calendar calendar = new GregorianCalendar();
            calendar.add(Calendar.HOUR_OF_DAY, -1 * (numberOfSamples - 1));
            calendar.set(Calendar.MINUTE, 0);
            calendar.set(Calendar.SECOND, 0);
            calendar.set(Calendar.MILLISECOND, 0);
            final Timestamp startDate = new Timestamp(calendar.getTimeInMillis());

            calendar.add(Calendar.HOUR_OF_DAY, numberOfSamples);
            calendar.set(Calendar.MINUTE, 59);
            calendar.set(Calendar.SECOND, 59);
            calendar.set(Calendar.MILLISECOND, 999);
            final Timestamp endDate = new Timestamp(calendar.getTimeInMillis());

            logger.debug(String.format("Generating chart for period: %s to %s", startDate.toString(),
                    endDate.toString()));

            final List<DataSetPoint> dataSetPoints = dataSetService
                    .findAndAggregatePointsGroupedByUnit(dataSetId, startDate, endDate, TimeUnits.HOUR);

            final boolean hasData = addSeries(seriesCollection, dataSet.getName(), dataSetPoints, startDate,
                    numberOfSamples, renderer);

            if (dataSet.isAggregate()) {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.BLACK);
            } else if (hasData) {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1,
                        PAINTS[colorCounter++ % PAINTS.length]);
            } else {
                renderer.setSeriesPaint(seriesCollection.getSeriesCount() - 1, Color.LIGHT_GRAY);
            }
        }
    }

    final XYPlot plot = new XYPlot(seriesCollection, dateAxis, yAxis, renderer);

    // create the chart...
    final JFreeChart chart = new JFreeChart(plot);

    // set the background color for the chart...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    plot.setBackgroundPaint(new Color(253, 253, 253));
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    // set the range axis to display integers only...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setLabelFont(DEFAULT_FONT);
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setLowerBound(0.00d);

    ChartUtilities.writeChartAsPNG(out, chart, width, height);
}

From source file:PhysicDrawing.PhysicGraph.java

/**
 * Creates a chart./* ww w  .j a va2  s .  c  o  m*/
 * 
 * @param dataset  the data for the chart.
 * 
 * @return a chart.
 */
private JFreeChart createDisplacementChart(XYDataset dataset) {

    // create the chart...
    JFreeChart chart = ChartFactory.createXYLineChart("Displacement", // chart title
            "X - Time (s)", // x axis label
            "Y - S (px)", // y axis label
            dataset, // data
            PlotOrientation.VERTICAL, true, // include legend
            true, // tooltips
            true // urls
    );

    // NOW DO SOME OPTIONAL CUSTOMISATION OF THE CHART...
    chart.setBackgroundPaint(Color.white);

    // get a reference to the plot for further customisation...
    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); // vertical line 
    plot.setRangeGridlinePaint(Color.white); // horizontal line 

    XYLineAndShapeRenderer renderer = new XYLineAndShapeRenderer();
    renderer.setSeriesLinesVisible(0, true); // (index , value)
    renderer.setSeriesLinesVisible(1, true);
    // renderer.setSeriesShapesVisible(1, true);
    // renderer.setSeriesFillPaint(2, Color.black);
    renderer.setSeriesPaint(0, Color.RED, true);
    renderer.setSeriesPaint(1, Color.black, true);
    renderer.setSeriesPaint(2, Color.white, true);
    renderer.setSeriesShape(0, new Rectangle(1, 1));
    renderer.setSeriesShape(1, new Rectangle(1, 1));

    plot.setRenderer(renderer);

    // change the auto tick unit selection to integer units only...
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    // OPTIONAL CUSTOMISATION COMPLETED.

    return chart;

}

From source file:edu.ku.brc.specify.toycode.BugParse.java

/**
 * @param lines//from  www .  j a  v a2 s  . co m
 */
protected void createChart(final List<String> lines, final String engineer) {

    int[] mins = new int[lines.size() - 1];
    for (int index = 1; index < lines.size(); index++) {
        String line = lines.get(index);
        String[] values = StringUtils.splitPreserveAllTokens(line, ",");
        int inx = 0;
        while (inx < values.length && values[inx].equals("0")) {
            inx++;
        }
        mins[index - 1] = inx < values.length ? inx : Integer.MAX_VALUE;
        System.err.println(mins[index - 1]);
    }

    int startInx = Integer.MAX_VALUE;
    for (int min : mins) {
        startInx = Math.min(startInx, min);
        System.out.println(min + "  " + startInx);
    }

    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    String[] headers = StringUtils.split(lines.get(0), ",");
    int len = headers.length - startInx;
    System.out.println(headers.length + "  " + len);
    List<double[]> valArray = new Vector<double[]>();

    for (int i = 1; i < lines.size(); i++) {
        String[] values = StringUtils.splitPreserveAllTokens(lines.get(i), ",");
        double[] vals = new double[len];
        int inx = 0;
        double prev = -1;
        for (int j = startInx; j < headers.length; j++) {
            if (StringUtils.isNotEmpty(values[j])) {
                prev = Double.parseDouble(values[j]);
                vals[inx++] = prev;
            } else {
                vals[inx++] = 0.0;
            }
        }
        valArray.add(vals);
    }

    double[] vals = valArray.get(0);
    for (int i = 0; i < vals.length; i++) {
        dataset.addValue(vals[i], "Bugs", headers[i + startInx]);
    }
    vals = valArray.get(1);
    for (int i = 0; i < vals.length; i++) {
        dataset.addValue(vals[i], "Resolved", headers[i + startInx]);
    }

    vals = valArray.get(2);
    for (int i = 0; i < vals.length; i++) {
        dataset.addValue(vals[i], "Open", headers[i + startInx]);
    }

    JFreeChart chart = ChartFactory.createLineChart("Bugs - " + engineer, "Time", "Bugs", dataset,
            PlotOrientation.VERTICAL, true, true, false);
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    //plot.setBackgroundPaint(Color.lightGray);
    //plot.setRangeGridlinePaint(Color.white);

    // customise the range axis...
    final NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    rangeAxis.setAutoRangeIncludesZero(false);
    rangeAxis.setAxisLineVisible(true);

    CategoryAxis catAxis = plot.getDomainAxis();
    catAxis.setAxisLineVisible(true);
    catAxis.setTickMarksVisible(true);

    ChartFrame frame = new ChartFrame("", chart, false);
    frame.setBackground(Color.WHITE);
    frame.setSize(500, 500);
    frame.setVisible(true);
}

From source file:eu.delving.stats.ChartHelper.java

private static JFreeChart finishBarChart(JFreeChart chart, Color... colors) {
    CategoryPlot categoryplot = (CategoryPlot) chart.getPlot();
    categoryplot.setRangeAxisLocation(AxisLocation.BOTTOM_OR_LEFT);
    categoryplot.setRangePannable(true);
    if (colors.length > 0)
        categoryplot.setRenderer(new CustomRenderer(colors));
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setItemLabelAnchorOffset(9D);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    barrenderer.setMaximumBarWidth(0.05);
    barrenderer.setItemMargin(0.03D);/*from www  . j a  v a 2s.co m*/
    ItemLabelPosition itemlabelposition = new ItemLabelPosition(INSIDE12, CENTER_RIGHT, CENTER_RIGHT,
            -1.5707963267948966D);
    barrenderer.setBasePositiveItemLabelPosition(itemlabelposition);
    ItemLabelPosition itemlabelposition1 = new ItemLabelPosition(OUTSIDE12, CENTER_LEFT, CENTER_LEFT,
            -1.5707963267948966D);
    barrenderer.setPositiveItemLabelPositionFallback(itemlabelposition1);
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setCategoryLabelPositions(CategoryLabelPositions.DOWN_45);
    categoryaxis.setCategoryMargin(0.25D);
    categoryaxis.setUpperMargin(0.02D);
    categoryaxis.setLowerMargin(0.02D);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setUpperMargin(0.10000000000000001D);
    ChartUtilities.applyCurrentTheme(chart);
    return chart;
}

From source file:gg.view.overview.IncomeExpensesTopComponent.java

/** Displays the total income vs expenses for the current month */
public void displayData() {
    log.info("Income vs Expenses graph computed and displayed");

    // Display hourglass cursor
    Utilities.changeCursorWaitStatus(true);

    // Create a dataset (the dataset will contain the plotted values)
    DefaultCategoryDataset dataset = new DefaultCategoryDataset();

    // Create an empty chart
    JFreeChart chart = ChartFactory.createBarChart("", // chart title
            "", // x axis label
            NbBundle.getMessage(IncomeExpensesTopComponent.class, "IncomeExpensesTopComponent.Amount"), // y axis label
            dataset, // data displayed in the chart
            PlotOrientation.VERTICAL, false, // include legend
            true, // tooltips
            false // urls
    );/*  www  . jav a 2 s  . com*/

    // Update the chart color
    chart.setBackgroundPaint(jPanelIncomeExpenses.getBackground());
    CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setBackgroundPaint(Color.WHITE);

    // Set the orientation of the categories on the domain axis (X axis)
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setCategoryLabelPositions(CategoryLabelPositions.STANDARD);

    // Set the range axis (Y axis) to display integers only
    NumberAxis rangeAxis = (NumberAxis) plot.getRangeAxis();
    rangeAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    // Set the bar renderer
    BarRenderer renderer = (BarRenderer) plot.getRenderer();
    renderer.setDrawBarOutline(false);
    renderer.setMaximumBarWidth(0.1);

    GradientPaint gradientPaint = new GradientPaint(0.0f, 0.0f, new Color(49, 106, 196), 0.0f, 0.0f,
            Color.LIGHT_GRAY);
    renderer.setSeriesPaint(0, gradientPaint);

    // Create a period for the current month
    LocalDate today = new LocalDate();
    Period currentMonth = new Period(Periods.getAdjustedStartDate(today, PeriodType.MONTH),
            Periods.getAdjustedEndDate(today, PeriodType.MONTH), PeriodType.MONTH);

    // Fill the dataset
    List<Currency> currencies = Wallet.getInstance().getActiveCurrencies();
    for (Currency currency : currencies) {
        // Filter on the currency and on the current month
        SearchCriteria searchCriteria = new SearchCriteria(currency, null, currentMonth, null, null, null,
                false);

        // Get income
        BigDecimal currencyIncome = Datamodel.getIncome(searchCriteria);
        currencyIncome = currencyIncome.setScale(2, RoundingMode.HALF_EVEN);

        // Get expenses
        BigDecimal currencyExpenses = Datamodel.getExpenses(searchCriteria).abs();
        currencyExpenses = currencyExpenses.setScale(2, RoundingMode.HALF_EVEN);

        // Plot income and expenses for the current month and for the current currency on the chart
        dataset.addValue(currencyIncome, currency.getName(),
                NbBundle.getMessage(IncomeExpensesTopComponent.class, "IncomeExpensesTopComponent.Income",
                        new Object[] { currency }));

        dataset.addValue(currencyExpenses, currency.getName(),
                NbBundle.getMessage(IncomeExpensesTopComponent.class, "IncomeExpensesTopComponent.Expenses",
                        new Object[] { currency }));
    }

    // Create the chart panel that contains the chart
    ChartPanel chartPanel = new ChartPanel(chart);

    // Display the chart
    jPanelIncomeExpenses.removeAll();
    jPanelIncomeExpenses.add(chartPanel, BorderLayout.CENTER);

    // Display the normal cursor
    Utilities.changeCursorWaitStatus(false);
}