Search in sources :

Example 21 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project series-rest-api by 52North.

the class ChartIoHandler method createRangeAxis.

public ValueAxis createRangeAxis(DatasetOutput metadata) {
    NumberAxis axis = new NumberAxis(createRangeLabel(metadata));
    axis.setTickLabelFont(LabelConstants.FONT_LABEL);
    axis.setLabelFont(LabelConstants.FONT_LABEL);
    axis.setTickLabelPaint(LabelConstants.COLOR);
    axis.setLabelPaint(LabelConstants.COLOR);
    return axis;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis)

Example 22 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project cubrid-manager by CUBRID.

the class ChartCompositePart method createChart.

/**
	 * Create the chart
	 *
	 * @return the instance of JFreeChart
	 */
private JFreeChart createChart() {
    timeseriescollection = new TimeSeriesCollection();
    seriesMap = new TreeMap<String, TimeSeries>();
    xylineandshaperenderer = new XYLineAndShapeRenderer(true, false);
    int number = 0;
    for (Map.Entry<String, String> entry : valueMap.entrySet()) {
        String key = entry.getKey();
        TimeSeries series = new TimeSeries(key);
        seriesMap.put(key, series);
        if (settingMap.get(key).isChecked()) {
            timeseriescollection.addSeries(series);
            RGB seriesRgb = settingMap.get(key).getSeriesRgb();
            float width = settingMap.get(key).getWidth();
            Color color = new Color(seriesRgb.red, seriesRgb.green, seriesRgb.blue);
            xylineandshaperenderer.setSeriesPaint(number, color);
            xylineandshaperenderer.setSeriesStroke(number, new BasicStroke(width, 0, 2));
            number++;
        }
    }
    DateAxis dateaxis = new DateAxis("");
    NumberAxis numberaxis = new NumberAxis("");
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 10));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 7));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    RectangleInsets rectangleInsets = new RectangleInsets();
    xyplot.setAxisOffset(rectangleInsets);
    xyplot.setDomainGridlineStroke(new BasicStroke(0.4f));
    xyplot.setRangeGridlineStroke(new BasicStroke(0.4f));
    xyplot.setOutlineVisible(false);
    xyplot.setBackgroundPaint(Color.BLACK);
    xyplot.setDomainGridlinePaint(new Color(0, 128, 64));
    xyplot.setRangeGridlinePaint(new Color(0, 128, 64));
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    numberaxis.setLowerMargin(0.01D);
    numberaxis.setUpperMargin(0.01D);
    JFreeChart chart = new JFreeChart(chartTitle, new Font("SansSerif", 1, 15), xyplot, false);
    chart.setBorderVisible(false);
    chart.setBorderStroke(new BasicStroke(0.0f));
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) TimeSeries(org.jfree.data.time.TimeSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) CommonUITool.trimPaintColor(com.cubrid.common.ui.spi.util.CommonUITool.trimPaintColor) RGB(org.eclipse.swt.graphics.RGB) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) RectangleInsets(org.jfree.ui.RectangleInsets) Map(java.util.Map) TreeMap(java.util.TreeMap)

Example 23 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project cubrid-manager by CUBRID.

the class ReplicationMonitorViewPart method createChart.

/**
	 * Create chart unit
	 * 
	 * @return chart
	 */
private JFreeChart createChart() {
    //create data set
    replTimeSeries = new TimeSeries(Messages.msgDelayValue + "    ");
    replTimeSeries.setMaximumItemAge(2592000);
    TimeSeriesCollection timeseriescollection = new TimeSeriesCollection();
    timeseriescollection.addSeries(replTimeSeries);
    //create X axis
    DateAxis dateaxis = new DateAxis(Messages.msgSlaveTimes);
    dateaxis.setTickLabelFont(new Font("SansSerif", 0, 10));
    dateaxis.setLabelFont(new Font("SansSerif", 0, 7));
    dateaxis.setFixedAutoRange(300000d);
    dateaxis.setLowerMargin(0.0D);
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setTickLabelsVisible(true);
    //create Y axis
    NumberAxis numberaxis = new NumberAxis(Messages.msgDelayValue);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    //create display model
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(true, true);
    xylineandshaperenderer.setSeriesPaint(0, new Color(146, 208, 80));
    xylineandshaperenderer.setSeriesStroke(0, new BasicStroke(2F, 0, 2));
    XYPlot xyplot = new XYPlot(timeseriescollection, dateaxis, numberaxis, xylineandshaperenderer);
    //set backcolor of grid
    xyplot.setBackgroundPaint(Color.BLACK);
    //set vertical line color of grid
    xyplot.setDomainGridlinePaint(new Color(130, 130, 130));
    //set horizontal line color of grid
    xyplot.setRangeGridlinePaint(new Color(130, 130, 130));
    xyplot.setAxisOffset(new RectangleInsets(0D, 0D, 0D, 10D));
    JFreeChart chart = new JFreeChart(Messages.titlePerformancePart, new Font("SansSerif", 1, 15), xyplot, true);
    return chart;
}
Also used : BasicStroke(java.awt.BasicStroke) DateAxis(org.jfree.chart.axis.DateAxis) TimeSeries(org.jfree.data.time.TimeSeries) NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) TimeSeriesCollection(org.jfree.data.time.TimeSeriesCollection) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) Color(java.awt.Color) RectangleInsets(org.jfree.ui.RectangleInsets) Font(java.awt.Font) JFreeChart(org.jfree.chart.JFreeChart)

Example 24 with NumberAxis

use of org.jfree.chart.axis.NumberAxis in project bamboobsc by billchen198318.

the class CommonBarChartAction method fillChart.

private void fillChart(String title, String categoryLabel, String valueLabel, List<String> names, List<Float> values, List<String> colors, boolean horizontal) throws Exception {
    DefaultCategoryDataset data = new DefaultCategoryDataset();
    for (int ix = 0; ix < names.size(); ix++) {
        data.addValue(values.get(ix), "", names.get(ix));
    }
    this.chart = ChartFactory.createBarChart3D(// title
    title, categoryLabel, valueLabel, data, (horizontal ? PlotOrientation.HORIZONTAL : PlotOrientation.VERTICAL), false, false, false);
    CategoryPlot plot = (CategoryPlot) this.chart.getPlot();
    CategoryAxis categoryAxis = plot.getDomainAxis();
    categoryAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
    categoryAxis.setTickLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
    NumberAxis numberAxis = (NumberAxis) plot.getRangeAxis();
    numberAxis.setLabelFont(new Font("", Font.TRUETYPE_FONT, 9));
    this.setPlotColor(plot, names, colors);
    this.chart.setTitle(new TextTitle(title, new Font("", Font.TRUETYPE_FONT, 9)));
}
Also used : TextTitle(org.jfree.chart.title.TextTitle) NumberAxis(org.jfree.chart.axis.NumberAxis) CategoryAxis(org.jfree.chart.axis.CategoryAxis) DefaultCategoryDataset(org.jfree.data.category.DefaultCategoryDataset) Paint(java.awt.Paint) CategoryPlot(org.jfree.chart.plot.CategoryPlot) Font(java.awt.Font)

Example 25 with NumberAxis

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

the class SecuritiesHistoryDialog method createChart.

private static JFreeChart createChart(final SecurityNode node) {
    Objects.requireNonNull(node);
    final List<SecurityHistoryNode> hNodes = node.getHistoryNodes();
    final Date max = DateUtils.asDate(hNodes.get(hNodes.size() - 1).getLocalDate());
    final Date min = DateUtils.asDate(hNodes.get(0).getLocalDate());
    final DateAxis timeAxis = new DateAxis(null);
    timeAxis.setVisible(false);
    timeAxis.setAutoRange(false);
    timeAxis.setRange(min, max);
    final NumberAxis valueAxis = new NumberAxis(null);
    valueAxis.setAutoRangeIncludesZero(false);
    valueAxis.setVisible(false);
    final XYAreaRenderer renderer = new XYAreaRenderer();
    renderer.setBaseToolTipGenerator(new SecurityItemLabelGenerator(node));
    renderer.setOutline(true);
    renderer.setSeriesPaint(0, new Color(225, 247, 223));
    final XYPlot plot = new XYPlot(null, timeAxis, valueAxis, renderer);
    final List<List<SecurityHistoryNode>> groups = node.getHistoryNodeGroupsBySplits();
    for (int i = 0; i < groups.size(); i++) {
        int size = groups.get(i).size();
        Date[] date = new Date[size];
        double[] high = new double[size];
        double[] low = new double[size];
        double[] open = new double[size];
        double[] close = new double[size];
        double[] volume = new double[size];
        for (int j = 0; j < size; j++) {
            final SecurityHistoryNode hNode = groups.get(i).get(j);
            date[j] = DateUtils.asDate(hNode.getLocalDate());
            high[j] = hNode.getAdjustedHigh().doubleValue();
            low[j] = hNode.getAdjustedLow().doubleValue();
            open[j] = hNode.getAdjustedPrice().doubleValue();
            close[j] = hNode.getAdjustedPrice().doubleValue();
            volume[j] = hNode.getVolume();
        }
        final AbstractXYDataset data = new DefaultHighLowDataset(node.getDescription() + i, date, high, low, open, close, volume);
        plot.setDataset(i, data);
    }
    plot.setInsets(new RectangleInsets(1, 1, 1, 1));
    final JFreeChart chart = new JFreeChart(null, JFreeChart.DEFAULT_TITLE_FONT, plot, false);
    chart.setBackgroundPaint(null);
    return chart;
}
Also used : DateAxis(org.jfree.chart.axis.DateAxis) NumberAxis(org.jfree.chart.axis.NumberAxis) AbstractXYDataset(org.jfree.data.xy.AbstractXYDataset) DefaultHighLowDataset(org.jfree.data.xy.DefaultHighLowDataset) Color(java.awt.Color) Date(java.util.Date) LocalDate(java.time.LocalDate) JFreeChart(org.jfree.chart.JFreeChart) XYAreaRenderer(org.jfree.chart.renderer.xy.XYAreaRenderer) XYPlot(org.jfree.chart.plot.XYPlot) RectangleInsets(org.jfree.ui.RectangleInsets) SecurityHistoryNode(jgnash.engine.SecurityHistoryNode) List(java.util.List)

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