Search in sources :

Example 6 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project jgnash by ccavanaugh.

the class MonthlyAccountBalanceChart method createVerticalXYBarChart.

private JFreeChart createVerticalXYBarChart(Account a) {
    DateFormat df = new SimpleDateFormat("MM/yy");
    TimeSeriesCollection data = createTimeSeriesCollection(a);
    DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
    dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
    dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    // if (a.getTransactionCount() > 0) {
    Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate()));
    Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()));
    dateAxis.setRange(start, end);
    // }
    NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance"));
    StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
    XYBarRenderer renderer = new XYBarRenderer(0.2);
    renderer.setBaseToolTipGenerator(tooltipGenerator);
    XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
    String title = rb.getString("Title.AccountBalance") + " - " + a.getPathName();
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(null);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) DateTickUnit(org.jfree.chart.axis.DateTickUnit) XYPlot(org.jfree.chart.plot.XYPlot) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LocalDate(java.time.LocalDate) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 7 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project jgnash by ccavanaugh.

the class MonthlyAccountBalanceChartCompare method createVerticalXYBarChart.

private JFreeChart createVerticalXYBarChart(final Account a, final Account a2) {
    DateFormat df = new SimpleDateFormat("MM/yy");
    TimeSeriesCollection data = createTimeSeriesCollection(a, a2);
    DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
    dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
    dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    // if (a.getTransactionCount() > 0) {
    Date start = DateUtils.asDate(DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate()));
    Date end = DateUtils.asDate(DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate()));
    dateAxis.setRange(start, end);
    // }
    NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance") + "-" + a.getCurrencyNode().getSymbol());
    StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
    ClusteredXYBarRenderer renderer = new ClusteredXYBarRenderer(0.2, false);
    renderer.setBaseToolTipGenerator(tooltipGenerator);
    XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
    String title;
    if (jcb_compare.isSelected()) {
        title = a.getPathName() + " vs " + a2.getPathName();
    } else {
        title = rb.getString("Title.AccountBalance") + " - " + a.getPathName();
    }
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(null);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) DateTickUnit(org.jfree.chart.axis.DateTickUnit) XYPlot(org.jfree.chart.plot.XYPlot) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) ClusteredXYBarRenderer(org.jfree.chart.renderer.xy.ClusteredXYBarRenderer) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) LocalDate(java.time.LocalDate) JFreeChart(org.jfree.chart.JFreeChart)

Example 8 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project jgnash by ccavanaugh.

the class RunningAccountBalanceChart method createVerticalXYBarChart.

private JFreeChart createVerticalXYBarChart(Account a) {
    DateFormat df = new SimpleDateFormat("MM/yy");
    TimeSeriesCollection data = createTimeSeriesCollection(a);
    DateAxis dateAxis = new DateAxis(rb.getString("Column.Date"));
    dateAxis.setTickUnit(new DateTickUnit(DateTickUnitType.MONTH, 1, df));
    dateAxis.setTickMarkPosition(DateTickMarkPosition.MIDDLE);
    LocalDate start = DateUtils.getFirstDayOfTheMonth(startDateField.getLocalDate());
    LocalDate end = DateUtils.getLastDayOfTheMonth(endDateField.getLocalDate());
    dateAxis.setRange(DateUtils.asDate(start), DateUtils.asDate(end));
    NumberAxis valueAxis = new NumberAxis(rb.getString("Column.Balance"));
    StandardXYToolTipGenerator tooltipGenerator = new StandardXYToolTipGenerator("{1}, {2}", df, NumberFormat.getNumberInstance());
    XYBarRenderer renderer = new XYBarRenderer(0.2);
    renderer.setBaseToolTipGenerator(tooltipGenerator);
    XYPlot plot = new XYPlot(data, dateAxis, valueAxis, renderer);
    String title = rb.getString("Title.EndMonthBalance") + " - " + a.getPathName();
    JFreeChart chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(null);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) DateTickUnit(org.jfree.chart.axis.DateTickUnit) XYPlot(org.jfree.chart.plot.XYPlot) SimpleDateFormat(java.text.SimpleDateFormat) DateFormat(java.text.DateFormat) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) SimpleDateFormat(java.text.SimpleDateFormat) LocalDate(java.time.LocalDate) XYBarRenderer(org.jfree.chart.renderer.xy.XYBarRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 9 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project jgnash by ccavanaugh.

the class SecurityHighLowChart method createHighLowChart.

private static JFreeChart createHighLowChart(String title, String timeAxisLabel, String valueAxisLabel, AbstractXYDataset data, boolean legend) {
    ValueAxis timeAxis = new DateAxis(timeAxisLabel);
    NumberAxis valueAxis = new NumberAxis(valueAxisLabel);
    valueAxis.setAutoRangeIncludesZero(false);
    HighLowRenderer renderer = new HighLowRenderer();
    renderer.setBaseToolTipGenerator(new HighLowItemLabelGenerator());
    XYPlot plot = new XYPlot(data, timeAxis, valueAxis, renderer);
    return new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) HighLowItemLabelGenerator(org.jfree.chart.labels.HighLowItemLabelGenerator) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) HighLowRenderer(org.jfree.chart.renderer.xy.HighLowRenderer) JFreeChart(org.jfree.chart.JFreeChart)

Example 10 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project processdash by dtuma.

the class EstErrorScatterChart method truncAxis.

private TruncatedNumberAxis truncAxis(ValueAxis va, double maxValue) {
    NumberAxis axis = (NumberAxis) va;
    double upper = Math.max(100, Math.min(maxValue, axis.getUpperBound()));
    return new TruncatedNumberAxis(va.getLabel(), upper);
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis)

Aggregations

NumberAxis (org.jfree.chart.axis.NumberAxis)26 JFreeChart (org.jfree.chart.JFreeChart)21 CategoryAxis (org.jfree.chart.axis.CategoryAxis)12 CategoryPlot (org.jfree.chart.plot.CategoryPlot)11 XYPlot (org.jfree.chart.plot.XYPlot)10 RectangleInsets (org.jfree.ui.RectangleInsets)10 DateAxis (org.jfree.chart.axis.DateAxis)9 Color (java.awt.Color)6 DefaultCategoryDataset (org.jfree.data.category.DefaultCategoryDataset)6 TimeSeriesCollection (org.jfree.data.time.TimeSeriesCollection)6 Paint (java.awt.Paint)5 CategoryDataset (org.jfree.data.category.CategoryDataset)5 BasicStroke (java.awt.BasicStroke)4 Font (java.awt.Font)4 LocalDate (java.time.LocalDate)4 StackedAreaRenderer (org.jfree.chart.renderer.category.StackedAreaRenderer)4 ShiftedCategoryAxis (hudson.util.ShiftedCategoryAxis)3 DateFormat (java.text.DateFormat)3 SimpleDateFormat (java.text.SimpleDateFormat)3 ArrayList (java.util.ArrayList)3