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

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

Introduction

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

Prototype

public SymbolAxis(String label, String[] sv) 

Source Link

Document

Constructs a symbol axis, using default attribute values where necessary.

Usage

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

private static JFreeChart createChart(XYDataset xydataset) {
    SymbolAxis symbolaxis = new SymbolAxis("Domain", new String[] { "A", "B", "C", "D" });
    SymbolAxis symbolaxis1 = new SymbolAxis("Range", new String[] { "V", "X", "Y", "Z" });
    symbolaxis1.setUpperMargin(0.0D);//from   www .j a v a  2  s.c  om
    XYLineAndShapeRenderer xylineandshaperenderer = new XYLineAndShapeRenderer(false, true);
    XYPlot xyplot = new XYPlot(xydataset, symbolaxis, symbolaxis1, xylineandshaperenderer);
    JFreeChart jfreechart = new JFreeChart("SymbolicAxis Demo 1", xyplot);
    return jfreechart;
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("XYBarChartDemo7", "Date", true, "Y",
            intervalxydataset, PlotOrientation.VERTICAL, true, false, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setDomainAxis(new DateAxis("Date"));
    SymbolAxis symbolaxis = new SymbolAxis("Series", new String[] { "S1", "S2", "S3" });
    symbolaxis.setGridBandsVisible(false);
    xyplot.setRangeAxis(symbolaxis);//w  w w  . j a v a2  s.c  o  m
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setUseYInterval(true);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    return jfreechart;
}

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

private static JFreeChart createChart(IntervalXYDataset intervalxydataset) {
    JFreeChart jfreechart = ChartFactory.createXYBarChart("XYTaskDatasetDemo1", "Resource", false, "Timing",
            intervalxydataset, PlotOrientation.HORIZONTAL, true, false, false);
    jfreechart.setBackgroundPaint(Color.white);
    XYPlot xyplot = (XYPlot) jfreechart.getPlot();
    xyplot.setRangePannable(true);/*from   w  w w .j a v a2 s.c o m*/
    SymbolAxis symbolaxis = new SymbolAxis("Series", new String[] { "Team A", "Team B", "Team C", "Team D" });
    symbolaxis.setGridBandsVisible(false);
    xyplot.setDomainAxis(symbolaxis);
    XYBarRenderer xybarrenderer = (XYBarRenderer) xyplot.getRenderer();
    xybarrenderer.setUseYInterval(true);
    xyplot.setRangeAxis(new DateAxis("Timing"));
    ChartUtilities.applyCurrentTheme(jfreechart);
    return jfreechart;
}

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

private static XYPlot createSubplot2(IntervalXYDataset intervalxydataset) {
    DateAxis dateaxis = new DateAxis("Date/Time");
    SymbolAxis symbolaxis = new SymbolAxis("Resources",
            new String[] { "Team A", "Team B", "Team C", "Team D", "Team E" });
    symbolaxis.setGridBandsVisible(false);
    XYBarRenderer xybarrenderer = new XYBarRenderer();
    xybarrenderer.setUseYInterval(true);
    XYPlot xyplot = new XYPlot(intervalxydataset, dateaxis, symbolaxis, xybarrenderer);
    return xyplot;
}

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    NumberAxis numberaxis = new NumberAxis("X");
    numberaxis.setLowerMargin(0.0D);//from   w  w w .  j a va  2 s .c o m
    numberaxis.setUpperMargin(0.0D);
    NumberAxis numberaxis1 = new NumberAxis("Y");
    numberaxis1.setAutoRangeIncludesZero(false);
    numberaxis1.setInverted(true);
    numberaxis1.setLowerMargin(0.0D);
    numberaxis1.setUpperMargin(0.0D);
    numberaxis1.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 3.5D, Color.black);
    lookuppaintscale.add(0.5D, Color.green);
    lookuppaintscale.add(1.5D, Color.orange);
    lookuppaintscale.add(2.5D, Color.red);
    xyblockrenderer.setPaintScale(lookuppaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, numberaxis, numberaxis1, xyblockrenderer);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setDomainGridlinePaint(Color.white);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setForegroundAlpha(0.66F);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo3", xyplot);
    jfreechart.removeLegend();
    jfreechart.setBackgroundPaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis(null, new String[] { "", "OK", "Uncertain", "Bad" });
    symbolaxis.setRange(0.5D, 3.5D);
    symbolaxis.setPlot(new PiePlot());
    symbolaxis.setGridBandsVisible(false);
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis);
    paintscalelegend.setAxisOffset(5D);
    paintscalelegend.setPosition(RectangleEdge.BOTTOM);
    paintscalelegend.setMargin(new RectangleInsets(5D, 5D, 5D, 5D));
    jfreechart.addSubtitle(paintscalelegend);
    return jfreechart;
}

From source file:osproject.Drawer.java

private static JFreeChart createChart(IntervalXYDataset paramIntervalXYDataset) {
    JFreeChart localJFreeChart = ChartFactory.createXYBarChart("Procssing schadual", "Resource", false,
            "Timing", paramIntervalXYDataset, PlotOrientation.HORIZONTAL, true, false, false);
    localJFreeChart.setBackgroundPaint(Color.BLACK);
    XYPlot localXYPlot = (XYPlot) localJFreeChart.getPlot();

    SymbolAxis localSymbolAxis = new SymbolAxis("Process", arr);
    localSymbolAxis.setGridBandsVisible(false);
    localXYPlot.setDomainAxis(localSymbolAxis);
    XYBarRenderer localXYBarRenderer = (XYBarRenderer) localXYPlot.getRenderer();
    localXYBarRenderer.setUseYInterval(true);
    localXYPlot.setRangeAxis(new DateAxis("Timing"));
    ChartUtilities.applyCurrentTheme(localJFreeChart);
    return localJFreeChart;
}

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

private static JFreeChart createChart(XYZDataset xyzdataset) {
    DateAxis dateaxis = new DateAxis("Date");
    dateaxis.setLowerMargin(0.0D);//from w ww. ja  v a 2  s .c o m
    dateaxis.setUpperMargin(0.0D);
    dateaxis.setInverted(true);
    NumberAxis numberaxis = new NumberAxis("Hour");
    numberaxis.setUpperMargin(0.0D);
    numberaxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    XYBlockRenderer xyblockrenderer = new XYBlockRenderer();
    xyblockrenderer.setBlockWidth(86400000D);
    xyblockrenderer.setBlockAnchor(RectangleAnchor.BOTTOM_LEFT);
    LookupPaintScale lookuppaintscale = new LookupPaintScale(0.5D, 4.5D, Color.white);
    lookuppaintscale.add(0.5D, Color.red);
    lookuppaintscale.add(1.5D, Color.green);
    lookuppaintscale.add(2.5D, Color.blue);
    lookuppaintscale.add(3.5D, Color.yellow);
    xyblockrenderer.setPaintScale(lookuppaintscale);
    XYPlot xyplot = new XYPlot(xyzdataset, dateaxis, numberaxis, xyblockrenderer);
    xyplot.setOrientation(PlotOrientation.HORIZONTAL);
    xyplot.setBackgroundPaint(Color.lightGray);
    xyplot.setRangeGridlinePaint(Color.white);
    xyplot.setAxisOffset(new RectangleInsets(5D, 5D, 5D, 5D));
    JFreeChart jfreechart = new JFreeChart("XYBlockChartDemo2", xyplot);
    jfreechart.removeLegend();
    jfreechart.setBackgroundPaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis(null,
            new String[] { "", "Unavailable", "Free", "Group 1", "Group 2" });
    symbolaxis.setRange(0.5D, 4.5D);
    symbolaxis.setPlot(new PiePlot());
    symbolaxis.setGridBandsVisible(false);
    PaintScaleLegend paintscalelegend = new PaintScaleLegend(lookuppaintscale, symbolaxis);
    paintscalelegend.setMargin(new RectangleInsets(3D, 10D, 3D, 10D));
    paintscalelegend.setPosition(RectangleEdge.BOTTOM);
    paintscalelegend.setAxisOffset(5D);
    jfreechart.addSubtitle(paintscalelegend);
    return jfreechart;
}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createLineChart("Line Chart Demo 8", "Category", "Count",
            categorydataset, PlotOrientation.VERTICAL, true, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setBackgroundPaint(Color.lightGray);
    categoryplot.setRangeGridlinePaint(Color.white);
    SymbolAxis symbolaxis = new SymbolAxis("Group", new String[] { "A", "B", "C", "D", "E", "F" });
    categoryplot.setRangeAxis(symbolaxis);
    LineAndShapeRenderer lineandshaperenderer = (LineAndShapeRenderer) categoryplot.getRenderer();
    lineandshaperenderer.setSeriesShapesVisible(0, true);
    lineandshaperenderer.setSeriesShapesVisible(1, false);
    lineandshaperenderer.setSeriesShapesVisible(2, true);
    lineandshaperenderer.setSeriesLinesVisible(2, false);
    lineandshaperenderer.setSeriesShape(2, ShapeUtilities.createDiamond(4F));
    lineandshaperenderer.setDrawOutlines(true);
    lineandshaperenderer.setUseFillPaint(true);
    lineandshaperenderer.setBaseFillPaint(Color.white);
    return jfreechart;
}

From source file:lu.lippmann.cdb.common.gui.ts.TimeSeriesChartUtil.java

public static ChartPanel buildChartPanelForNominalAttribute(final Instances ds, final Attribute attr,
        final int dateIdx) {
    final TaskSeriesCollection localTaskSeriesCollection = new TaskSeriesCollection();
    final java.util.List<String> names = new ArrayList<String>();

    final Set<String> present = WekaDataStatsUtil.getPresentValuesForNominalAttribute(ds, attr.index());
    for (final String pr : present) {
        names.add(pr);/* ww w . ja  va2s  . c  o  m*/
        localTaskSeriesCollection.add(new TaskSeries(pr));
    }

    final Calendar cal = Calendar.getInstance();
    try {
        for (final double[] dd : WekaTimeSeriesUtil.split(ds, attr.index())) {
            cal.setTimeInMillis((long) dd[0]);
            final Date start = cal.getTime();
            cal.setTimeInMillis((long) dd[1]);
            final Date end = cal.getTime();
            final String sd = ds.instance((int) dd[2]).stringValue(attr);
            localTaskSeriesCollection.getSeries(sd).add(new Task("T", start, end));
        }
    } catch (Exception e) {
        e.printStackTrace();
    }

    final XYTaskDataset localXYTaskDataset = new XYTaskDataset(localTaskSeriesCollection);
    localXYTaskDataset.setTransposed(true);
    localXYTaskDataset.setSeriesWidth(0.6D);

    final DateAxis localDateAxis = new DateAxis(DATE_TIME_LABEL);
    final SymbolAxis localSymbolAxis = new SymbolAxis("", names.toArray(new String[names.size()]));
    localSymbolAxis.setGridBandsVisible(false);
    final XYBarRenderer localXYBarRenderer = new XYBarRenderer();
    localXYBarRenderer.setUseYInterval(true);
    localXYBarRenderer.setShadowVisible(false);
    final XYPlot localXYPlot = new XYPlot(localXYTaskDataset, localDateAxis, localSymbolAxis,
            localXYBarRenderer);

    final CombinedDomainXYPlot localCombinedDomainXYPlot = new CombinedDomainXYPlot(
            new DateAxis(DATE_TIME_LABEL));
    localCombinedDomainXYPlot.add(localXYPlot);
    final JFreeChart localJFreeChart = new JFreeChart("", localCombinedDomainXYPlot);
    localJFreeChart.setBackgroundPaint(Color.white);

    final ChartPanel cp = new ChartPanel(localJFreeChart, true);
    cp.setBorder(new TitledBorder(attr.name()));
    return cp;
}

From source file:org.matsim.contrib.dvrp.util.chart.ScheduleChartUtils.java

public static <T extends Task> JFreeChart chartSchedule(List<? extends Vehicle> vehicles,
        DescriptionCreator<T> descriptionCreator, PaintSelector<T> paintSelector) {
    // data/*from w  w  w .  ja va 2  s .  c om*/
    TaskSeriesCollection dataset = createScheduleDataset(vehicles, descriptionCreator);
    XYTaskDataset xyTaskDataset = new XYTaskDataset(dataset);

    // chart
    JFreeChart chart = ChartFactory.createXYBarChart("Schedules", "Time", false, "Vehicles", xyTaskDataset,
            PlotOrientation.HORIZONTAL, false, true, false);
    XYPlot plot = (XYPlot) chart.getPlot();

    // Y axis
    String[] series = new String[vehicles.size()];
    for (int i = 0; i < series.length; i++) {
        series[i] = vehicles.get(i).getId().toString();
    }

    SymbolAxis symbolAxis = new SymbolAxis("Vehicles", series);
    symbolAxis.setGridBandsVisible(false);
    plot.setDomainAxis(symbolAxis);

    // X axis
    plot.setRangeAxis(new DateAxis("Time", TimeZone.getTimeZone("GMT"), Locale.getDefault()));

    // Renderer
    XYBarRenderer xyBarRenderer = new ChartTaskRenderer<T>(dataset, paintSelector);
    xyBarRenderer.setUseYInterval(true);
    plot.setRenderer(xyBarRenderer);

    return chart;
}