Example usage for org.jfree.chart.axis ValueAxis setVerticalTickLabels

List of usage examples for org.jfree.chart.axis ValueAxis setVerticalTickLabels

Introduction

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

Prototype

public void setVerticalTickLabels(boolean flag) 

Source Link

Document

Sets the flag that controls whether the tick labels are displayed vertically (that is, rotated 90 degrees from horizontal).

Usage

From source file:net.sf.jsfcomp.chartcreator.utils.ChartAxisUtils.java

public static void createXYSeriesAxis(JFreeChart chart, ChartAxisData chartAxisData, int axisIndex) {
    ValueAxis axis = null;
    if (chartAxisData.getType() != null) {
        if (chartAxisData.getType().equals("number"))
            axis = createNumberAxis(chart, chartAxisData);
        else if (chartAxisData.getType().equals("date"))
            axis = createDateAxis(chart, chartAxisData);

        if (chartAxisData.getTickLabelFontSize() > 0) {
            Font tickFont = CategoryAxis.DEFAULT_TICK_LABEL_FONT
                    .deriveFont(chartAxisData.getTickLabelFontSize());
            axis.setTickLabelFont(tickFont);
        }/*from www .  jav a2 s .  com*/

        axis.setTickLabelsVisible(chartAxisData.isTickLabels());
        axis.setTickMarksVisible(chartAxisData.isTickMarks());
        axis.setVerticalTickLabels(chartAxisData.isVerticalTickLabels());
    }

    XYPlot plot = chart.getXYPlot();
    if (chartAxisData.isDomain()) {
        plot.setDomainAxis(plot.getDomainAxisCount() - 1, axis);
    } else {
        plot.setRangeAxis(axisIndex, axis);
        XYDataset dataset = (XYDataset) chartAxisData.getDatasource();
        plot.setRenderer(axisIndex, new StandardXYItemRenderer());
        plot.setDataset(axisIndex, dataset);
        plot.mapDatasetToRangeAxis(axisIndex, axisIndex);
    }

    setXYSeriesAxisColors(chartAxisData, plot.getRenderer(axisIndex));
}

From source file:de.berlios.statcvs.xml.chart.AbstractCombinedChart.java

/**
 * @param settings/*  w ww . ja va 2 s  .co  m*/
 * @param defaultFilename
 * @param defaultSubtitle
 */
public AbstractCombinedChart(ReportSettings settings, String defaultFilename, String defaultSubtitle) {
    super(settings, defaultFilename, defaultSubtitle);

    ValueAxis domainAxis = new DateAxis(I18n.tr("Date"));
    domainAxis.setVerticalTickLabels(true);

    combinedPlot = new CombinedDomainXYPlot(domainAxis);
    combinedPlot.setGap(10);
    combinedPlot.setOrientation(PlotOrientation.VERTICAL);

    JFreeChart chart = new JFreeChart(settings.getProjectName(), JFreeChart.DEFAULT_TITLE_FONT, combinedPlot,
            false);
    setChart(chart);
}

From source file:net.sf.statcvs.output.xml.chart.TimeLineChart.java

/**
 * @param filename/*from   www.j  a  v a2s.  c o  m*/
 * @param title
 */
public TimeLineChart(String filename, String title) {
    super(filename, title);

    Paint[] colors = new Paint[1];
    colors[0] = Color.blue;

    tsc = new TimeSeriesCollection();
    //collection.addSeries(createTimeSeries(timeline));

    //String range = timeline.getRangeLabel();
    String domain = I18n.tr("Date");

    setChart(ChartFactory.createTimeSeriesChart(Settings.getProjectName(), I18n.tr("Date"), rangeLabel,
            (XYDataset) tsc, true, true, false));

    //getChart().getPlot().setSeriesPaint(colors);

    XYPlot plot = getChart().getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setVerticalTickLabels(true);
    plot.setRenderer(new XYStepRenderer());
}

From source file:subterranean.crimson.server.graphics.graphs.LineChart.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("", "", "", dataset, false, false, false);

    XYPlot plot = result.getXYPlot();//from  w ww. j  av  a  2 s.co m
    plot.setDataset(1, new TimeSeriesCollection(s2));

    plot.setBackgroundPaint(new Color(0x000000));
    plot.setDomainGridlinesVisible(false);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(false);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);

    xaxis.setFixedAutoRange(160000.0); // 160 seconds
    xaxis.setVerticalTickLabels(false);

    ValueAxis yaxis = plot.getRangeAxis();

    yaxis.setAutoRange(true);
    yaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());

    return result;
}

From source file:networkanalyzer.DynamicPing.java

public JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Ping Chart", //title
            "Time", //x-axis
            "Ping", //y-axis
            dataset, false, false, false);

    final XYPlot plot = result.getXYPlot();

    plot.setBackgroundPaint(Color.WHITE);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.LIGHT_GRAY);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.LIGHT_GRAY);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);//w w w .  j  a v a 2s  . co m

    xaxis.setFixedAutoRange(60000.0);
    xaxis.setVerticalTickLabels(true);

    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setAutoRange(true);

    return result;

}

From source file:de.berlios.statcvs.xml.chart.AbstractTimeSeriesChart.java

/**
 * @param filename//from   ww  w  .ja  v a 2s. co m
 * @param title
 */
public AbstractTimeSeriesChart(ReportSettings settings, String filename, String title, String rangeLabel) {
    super(settings, filename, title);

    tsc = new TimeSeriesCollection();

    setChart(ChartFactory.createTimeSeriesChart(settings.getProjectName(), I18n.tr("Date"), rangeLabel, tsc,
            true, true, false));

    //Paint[] colors = new Paint[1];
    //colors[0] = Color.blue;
    //getChart().getPlot().setSeriesPaint(colors);

    // setup axis
    XYPlot plot = getChart().getXYPlot();
    ValueAxis axis = plot.getDomainAxis();
    axis.setVerticalTickLabels(true);
    plot.setRenderer(new XYStepRenderer());

    // the 4th color is yellow which has almost no contrast to the white 
    // background color, therefore we use a different color
    plot.getRenderer().setSeriesPaint(0, Color.red);
    plot.getRenderer().setSeriesPaint(1, Color.blue);
    plot.getRenderer().setSeriesPaint(2, Color.green);
    plot.getRenderer().setSeriesPaint(3, Color.magenta);
    plot.getRenderer().setSeriesPaint(4, Color.orange);
    plot.getRenderer().setSeriesPaint(5, Color.cyan);
    plot.getRenderer().setSeriesPaint(6, Color.pink);
}

From source file:com.pureinfo.srm.reports.impl.CategoryChartBuilder.java

/**
 * @see com.pureinfo.srm.reports.IChartBuilder#buildChart(java.util.List,
 *      int, java.lang.String)/*from   ww  w .  j a  va 2s .  com*/
 */
public JFreeChart buildChart() {
    CategoryDataset dataset = createDataset();

    JFreeChart jfreechart = MyChartFactory.createBarChart3D(null, m_sXAxisName, m_sYXxisName, dataset,
            PlotOrientation.VERTICAL, false, false, false);

    CategoryPlot categoryplot = jfreechart.getCategoryPlot();
    jfreechart.setBackgroundPaint(Color.white);
    categoryplot.setDomainGridlinesVisible(false);
    categoryplot.setRangeGridlinesVisible(true);

    categoryplot.setForegroundAlpha(0.8f);
    categoryplot.setDrawingSupplier(new DefaultDrawingSupplier(MyPaintMgr.getPaints(),
            DefaultDrawingSupplier.DEFAULT_OUTLINE_PAINT_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_OUTLINE_STROKE_SEQUENCE,
            DefaultDrawingSupplier.DEFAULT_SHAPE_SEQUENCE));
    CategoryAxis categoryAxisX = categoryplot.getDomainAxis();
    categoryAxisX.setTickLabelsVisible(true);
    categoryAxisX.setLabel(null);
    categoryAxisX.setMaximumCategoryLabelWidthRatio(.8f);
    ValueAxis categoryAxisY = categoryplot.getRangeAxis();
    categoryAxisY.setVerticalTickLabels(false);

    //        categoryplot.setDrawSharedDomainAxis(false);
    categoryAxisX.setCategoryLabelPositions(
            CategoryLabelPositions.createUpRotationLabelPositions(0.39269908169872414D));

    BarRenderer3D barrenderer3d = (BarRenderer3D) categoryplot.getRenderer();
    barrenderer3d.setDrawBarOutline(false);
    barrenderer3d.setItemLabelsVisible(true);

    barrenderer3d.setBaseItemLabelsVisible(false);
    barrenderer3d.setSeriesVisible(Boolean.FALSE);

    //CategoryPlot categoryPlot = jfreechart.getCategoryPlot();
    //        categoryPlot.setBackgroundPaint(Color.lightGray);
    //        categoryPlot.setDomainGridlinePaint(Color.white);
    //        categoryPlot.setRangeGridlinePaint(Color.white);
    //
    //        BarRenderer barRenderer = (BarRenderer) categoryPlot.getRenderer();
    //        barRenderer.setDrawBarOutline(false);
    //        barRenderer.setMaxBarWidth(0.03);
    //        GradientPaint gradientPaint = new GradientPaint(0.0F, 0.0F,
    // Color.red, 0.0F, 0.0F, new Color(64, 0, 0));
    //        barRenderer.setSeriesPaint(0, gradientPaint);

    DecimalFormat format = null;
    if (m_dblMaxData > 1) {
        format = new DecimalFormat("#,###");
    } else {
        StringBuffer sb = new StringBuffer();
        sb.append("0.00#");
        for (double i = m_dblMaxData; i != 0 && i < 1; i *= 10f) {
            sb.append("#");
        }
        format = new DecimalFormat(sb.toString());
    }
    fillChartInfo(dataset, format);
    barrenderer3d.setMaxBarWidth(8.0 / m_ChartInfo.getChartSize().x);
    NumberAxis numberAxis = (NumberAxis) categoryplot.getRangeAxis(0);
    numberAxis.setUpperMargin(0.149999999999D);
    numberAxis.setNumberFormatOverride(format);

    categoryAxisX.setCategoryLabelPositions(CategoryLabelPositions.UP_45);

    NumberAxis dataNumberAxis = (NumberAxis) categoryplot.getRangeAxisForDataset(0);
    dataNumberAxis.setUpperMargin(0.149999999999D);
    dataNumberAxis.setNumberFormatOverride(format);

    //        CategoryItemRenderer renderer = categoryPlot.getRenderer();
    //        CategoryItemLabelGenerator generator = new StandardCategoryItemLabelGenerator("{2}", format);
    //        renderer.setItemLabelGenerator(generator);
    //        renderer.setItemLabelFont(new Font("Serif", 0, 9));
    //        renderer.setItemLabelsVisible(true);
    return jfreechart;
}

From source file:Views.GraphView.java

private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(graphTitle, "Time", "Price", dataset, true,
            true, false);/*from   w  w  w. j  a v a  2s  . c  o  m*/

    plot = result.getXYPlot();

    plot.setBackgroundPaint(new Color(0xffffe0));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);
    xaxis.setVisible(false);

    xaxis.setFixedAutoRange(16000.0); // 60 seconds
    xaxis.setVerticalTickLabels(true);

    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setRange(0, 100.0);

    xaxis2 = new NumberAxis("Volume");

    plot.setDataset(1, dataset2);

    plot.setRangeAxis(1, xaxis2);
    plot.mapDatasetToRangeAxis(1, 1);

    XYBarRenderer renderer2 = new XYBarRenderer(0.20);
    renderer2.setToolTipGenerator(
            new StandardXYToolTipGenerator(StandardXYToolTipGenerator.DEFAULT_TOOL_TIP_FORMAT,
                    new SimpleDateFormat("d-MMM-yyyy"), new DecimalFormat("0,000.00")));
    renderer2.setToolTipGenerator(StandardXYToolTipGenerator.getTimeSeriesInstance());

    plot.setRenderer(1, renderer2);

    plot.setDataset(2, dataset3);

    plot.mapDatasetToRangeAxis(2, 0);

    XYErrorRenderer renderer3 = new XYErrorRenderer();
    plot.setRenderer(2, renderer3);

    plot.setDataset(3, dataset4);
    plot.mapDatasetToRangeAxis(3, 1);
    XYBarRenderer renderer4 = new XYBarRenderer(0.20);

    plot.setRenderer(3, renderer4);

    return result;
}

From source file:arduinouno.TimeChartGenerator.java

/**
 * Creates a sample chart.//  ww  w  .j ava  2s.c o m
 *
 * @param dataset the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset, final XYDataset dataset0, final XYDataset dataset1,
        final XYDataset dataset2, final XYDataset dataset3, final XYDataset dataset4,
        final XYDataset dataset5) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart("Arduino Serial Reader", "Time", "Value",
            dataset, true, true, false);

    plot = result.getXYPlot();

    //Set Graph Parameters
    plot.setBackgroundPaint(new Color(0xffffe0));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);
    xaxis.setTickLabelsVisible(false);

    //Domain axis would show data of 30 seconds for a time
    xaxis.setFixedAutoRange(30000.0); // 30 seconds

    xaxis.setVerticalTickLabels(false);

    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setRange(0.0, 6.0);

    if (dataset0 != null) {
        plot.setDataset(1, dataset0);
        plot.setRenderer(1, new StandardXYItemRenderer());
    }
    if (dataset1 != null) {
        plot.setDataset(2, dataset1);
        plot.setRenderer(2, new StandardXYItemRenderer());
    }
    if (dataset2 != null) {
        plot.setDataset(3, dataset2);
        plot.setRenderer(3, new StandardXYItemRenderer());
    }
    if (dataset3 != null) {
        plot.setDataset(4, dataset3);
        plot.setRenderer(4, new StandardXYItemRenderer());
    }
    if (dataset4 != null) {
        plot.setDataset(5, dataset4);
        plot.setRenderer(5, new StandardXYItemRenderer());
    }
    if (dataset5 != null) {
        plot.setDataset(6, dataset5);
        plot.setRenderer(6, new StandardXYItemRenderer());
    }

    return result;
}

From source file:de.citec.csra.allocation.vis.MovingChart.java

/**
 * Creates a sample chart.//from  ww  w .j  av a2 s  .  c o m
 *
 * @param dataset the dataset.
 *
 * @return A sample chart.
 */
private JFreeChart createChart(final XYDataset dataset) {
    final JFreeChart result = ChartFactory.createTimeSeriesChart(null, "Time", "Resource", dataset, false, true,
            false);

    final XYPlot plot = result.getXYPlot();

    plot.addDomainMarker(this.marker);
    plot.setBackgroundPaint(new Color(0xf8f8ed));
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePaint(Color.lightGray);
    plot.setRangeGridlinesVisible(true);
    plot.setRangeGridlinePaint(Color.lightGray);

    ValueAxis xaxis = plot.getDomainAxis();
    xaxis.setAutoRange(true);
    xaxis.setTickLabelsVisible(false);
    //Domain axis would show data of 60 seconds for a time
    xaxis.setFixedAutoRange(this.past + this.future); // 60 seconds
    xaxis.setVerticalTickLabels(true);
    ValueAxis yaxis = plot.getRangeAxis();
    yaxis.setAutoRangeMinimumSize(1.8);
    yaxis.setAutoRange(true);

    NumberAxis range = (NumberAxis) plot.getRangeAxis();
    range.setTickUnit(new NumberTickUnit(1));
    range.setNumberFormatOverride(new NumberFormat() {
        @Override
        public StringBuffer format(double number, StringBuffer toAppendTo, FieldPosition pos) {
            return format((long) number, toAppendTo, pos);
        }

        private String getID(long number) {
            return values.entrySet().stream().filter(e -> e.equals(number)).findFirst().get().getKey();
        }

        @Override
        public StringBuffer format(long number, StringBuffer ap, FieldPosition pos) {
            String id = "N/A";
            if (number == 0) {
                id = "(Time)";
            }
            if (values.containsValue(number)) {
                for (Map.Entry<String, Long> entry : values.entrySet()) {
                    if (entry.getValue() == number) {
                        id = entry.getKey();
                        break;
                    }
                }
            }
            id = id.replaceFirst("/$", "");
            ap.append(id);
            if (id.length() > 32) {
                ap.replace(15, ap.length() - 15, "..");
            }
            return ap;
        }

        @Override
        public Number parse(String source, ParsePosition parsePosition) {
            return null;
        }
    });

    //      this.chart.getXYPlot().getRenderer(1).set
    //      XYLineAndShapeRenderer r = (XYLineAndShapeRenderer) this.chart.getXYPlot().getRendererForDataset(dataset);
    return result;
}