Example usage for org.jfree.chart.axis CategoryAnchor START

List of usage examples for org.jfree.chart.axis CategoryAnchor START

Introduction

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

Prototype

CategoryAnchor START

To view the source code for org.jfree.chart.axis CategoryAnchor START.

Click Source Link

Document

Start of period.

Usage

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart3D("Student Grades", "Students", "Grade",
            categorydataset, PlotOrientation.VERTICAL, false, true, false);
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    CustomBarRenderer3D custombarrenderer3d = new CustomBarRenderer3D();
    custombarrenderer3d.setBaseItemLabelGenerator(new StandardCategoryItemLabelGenerator());
    custombarrenderer3d.setBaseItemLabelsVisible(true);
    custombarrenderer3d.setItemLabelAnchorOffset(10D);
    custombarrenderer3d.setBasePositiveItemLabelPosition(
            new ItemLabelPosition(ItemLabelAnchor.OUTSIDE12, TextAnchor.BASELINE_LEFT));
    categoryplot.setRenderer(custombarrenderer3d);
    ValueMarker valuemarker = new ValueMarker(0.69999999999999996D, new Color(200, 200, 255),
            new BasicStroke(1.0F), new Color(200, 200, 255), new BasicStroke(1.0F), 1.0F);
    categoryplot.addRangeMarker(valuemarker, Layer.BACKGROUND);
    custombarrenderer3d.setBaseItemLabelsVisible(true);
    custombarrenderer3d.setMaximumBarWidth(0.050000000000000003D);
    CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("Minimum grade to pass",
            "Robert", 0.70999999999999996D);
    categorytextannotation.setCategoryAnchor(CategoryAnchor.START);
    categorytextannotation.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categoryplot.addAnnotation(categorytextannotation);
    NumberAxis numberaxis = (NumberAxis) categoryplot.getRangeAxis();
    numberaxis.setNumberFormatOverride(NumberFormat.getPercentInstance());
    numberaxis.setUpperMargin(0.10000000000000001D);
    return jfreechart;
}

From source file:netmason.support.graphics.GanttDisplay.java

public GanttDisplay(String title) {

    super(title);

    collection.add(s1);/* w  w  w .ja  va 2 s  .  c  om*/

    // create the chart...
    chart = ChartFactory.createGanttChart("Gantt Chart", // chart title
            "Agent", // domain axis label
            "Date", // range axis label
            collection, // data
            false, // include legend
            true, // tooltips
            false // urls
    );

    CategoryPlot plot = (CategoryPlot) chart.getPlot();

    CategoryItemRenderer renderer = plot.getRenderer();
    plot.setDomainGridlinePosition(CategoryAnchor.START);
    CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setTickLabelPaint(Color.blue);
    domainAxis.setAxisLineVisible(false);

    domainAxis.setCategoryLabelPositionOffset(0);
    domainAxis.setMaximumCategoryLabelLines(2);
    domainAxis.setMaximumCategoryLabelWidthRatio(0.3f);

    renderer.setSeriesPaint(0, Color.blue);

    // add the chart to a panel...
    ChartPanel chartPanel = new ChartPanel(chart);
    setContentPane(chartPanel);

}

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

private static JFreeChart createChart(CategoryDataset categorydataset) {
    JFreeChart jfreechart = ChartFactory.createBarChart(null, null, null, categorydataset,
            PlotOrientation.HORIZONTAL, false, true, false);
    jfreechart.setBackgroundPaint(Color.white);
    TextTitle texttitle = new TextTitle(
            "Figure 7 | I. Resources - The site offers users relevant, informative and educational resources");
    texttitle.setHorizontalAlignment(HorizontalAlignment.LEFT);
    texttitle.setBackgroundPaint(Color.red);
    texttitle.setPaint(Color.white);
    jfreechart.setTitle(texttitle);/* ww  w .  jav  a  2  s . c o m*/
    CategoryPlot categoryplot = (CategoryPlot) jfreechart.getPlot();
    categoryplot.setOutlinePaint(null);
    categoryplot.setDomainGridlinesVisible(true);
    categoryplot.setDomainGridlinePosition(CategoryAnchor.END);
    categoryplot.setDomainGridlineStroke(new BasicStroke(0.5F));
    categoryplot.setDomainGridlinePaint(Color.black);
    categoryplot.setRangeGridlinesVisible(false);
    categoryplot.clearRangeMarkers();
    CategoryAxis categoryaxis = categoryplot.getDomainAxis();
    categoryaxis.setVisible(false);
    categoryaxis.setCategoryMargin(0.5D);
    categoryplot.getRangeAxis().setVisible(false);
    BarRenderer barrenderer = (BarRenderer) categoryplot.getRenderer();
    barrenderer.setSeriesPaint(0, new Color(156, 164, 74));
    barrenderer.setDrawBarOutline(false);
    barrenderer.setBaseItemLabelsVisible(true);
    barrenderer.setBaseItemLabelFont(new Font("SansSerif", 1, 10));
    ItemLabelPosition itemlabelposition = new ItemLabelPosition(ItemLabelAnchor.INSIDE3,
            TextAnchor.CENTER_RIGHT);
    barrenderer.setBasePositiveItemLabelPosition(itemlabelposition);
    CategoryTextAnnotation categorytextannotation = new CategoryTextAnnotation("1. White papers are available.",
            "Category 1", 0.0D);
    categorytextannotation.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation);
    CategoryTextAnnotation categorytextannotation1 = new CategoryTextAnnotation(
            "2. White papers enhance users understanding of the firm and its expertise.", "Category 2", 0.0D);
    categorytextannotation1.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation1.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation1);
    CategoryTextAnnotation categorytextannotation2 = new CategoryTextAnnotation(
            "3. White papers are relevant to the firm's prospects and clients.", "Category 3", 0.0D);
    categorytextannotation2.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation2.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation2);
    CategoryTextAnnotation categorytextannotation3 = new CategoryTextAnnotation(
            "4. White papers are relevant to the firm's positioning.", "Category 4", 0.0D);
    categorytextannotation3.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation3.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation3);
    CategoryTextAnnotation categorytextannotation4 = new CategoryTextAnnotation(
            "5. Case studies are available.", "Category 5", 0.0D);
    categorytextannotation4.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation4.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation4);
    CategoryTextAnnotation categorytextannotation5 = new CategoryTextAnnotation(
            "6. Case studies enhance users understanding of the firm and its expertise.", "Category 6", 0.0D);
    categorytextannotation5.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation5.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation5.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation5);
    CategoryTextAnnotation categorytextannotation6 = new CategoryTextAnnotation(
            "7. Case studies are relevant to the firm's prospects and clients.", "Category 7", 0.0D);
    categorytextannotation6.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation6.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation6.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation6);
    CategoryTextAnnotation categorytextannotation7 = new CategoryTextAnnotation(
            "8. White papers are relevant to the firm's positioning.", "Category 8", 0.0D);
    categorytextannotation7.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation7.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation7.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation7);
    CategoryTextAnnotation categorytextannotation8 = new CategoryTextAnnotation(
            "9. Case studies are available.", "Category 9", 0.0D);
    categorytextannotation8.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation8.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation8.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation8);
    CategoryTextAnnotation categorytextannotation9 = new CategoryTextAnnotation(
            "10. Case studies enhance users understanding of the firm and its expertise.", "Category 10", 0.0D);
    categorytextannotation9.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation9.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation9.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation9);
    CategoryTextAnnotation categorytextannotation10 = new CategoryTextAnnotation(
            "11. Case studies are relevant to the firm's prospects and clients.", "Category 11", 0.0D);
    categorytextannotation10.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation10.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation10.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation10);
    CategoryTextAnnotation categorytextannotation11 = new CategoryTextAnnotation(
            "12. White papers are relevant to the firm's positioning.", "Category 12", 0.0D);
    categorytextannotation11.setFont(new Font("SansSerif", 0, 12));
    categorytextannotation11.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation11.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation11);
    CategoryTextAnnotation categorytextannotation12 = new CategoryTextAnnotation(
            "13. Users can easily access resources based on viewer interest.", "Category 13", 0.0D);
    categorytextannotation12.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation12.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation12.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation12);
    CategoryTextAnnotation categorytextannotation13 = new CategoryTextAnnotation(
            "14. Access to additional hyperlinks enhances users's ability to find relevant information.",
            "Category 14", 0.0D);
    categorytextannotation13.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation13.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation13.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation13);
    CategoryTextAnnotation categorytextannotation14 = new CategoryTextAnnotation("15. OVERALL EFFECTIVENESS.",
            "Overall", 0.0D);
    categorytextannotation14.setFont(new Font("SansSerif", 1, 12));
    categorytextannotation14.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    categorytextannotation14.setCategoryAnchor(CategoryAnchor.START);
    categoryplot.addAnnotation(categorytextannotation14);
    return jfreechart;
}

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

/**
 * Creates a chart.//from  w w  w  .  j  av  a2 s.c o  m
 * 
 * @param dataset  the dataset.
 * 
 * @return The chart.
 */
private JFreeChart createChart(final CategoryDataset dataset) {

    final JFreeChart chart = ChartFactory.createBarChart(null, // chart title
            null, // domain axis label
            null, // range axis label
            dataset, // data
            PlotOrientation.HORIZONTAL, // orientation
            false, // include legend
            true, false);

    chart.setBackgroundPaint(Color.white);

    final TextTitle title = new TextTitle("Figure 7 | I. Resources - The site offers users relevant, "
            + "informative and educational resources");
    title.setHorizontalAlignment(HorizontalAlignment.LEFT);
    title.setBackgroundPaint(Color.red);
    title.setPaint(Color.white);

    chart.setTitle(title);
    final CategoryPlot plot = (CategoryPlot) chart.getPlot();
    plot.setOutlinePaint(null);
    plot.setDomainGridlinesVisible(true);
    plot.setDomainGridlinePosition(CategoryAnchor.END);
    plot.setDomainGridlineStroke(new BasicStroke(0.5f));
    plot.setDomainGridlinePaint(Color.black);

    plot.setRangeGridlinesVisible(false);
    plot.clearRangeMarkers();

    final CategoryAxis domainAxis = plot.getDomainAxis();
    domainAxis.setVisible(false);
    domainAxis.setCategoryMargin(0.50);

    plot.getRangeAxis().setVisible(false);

    final CategoryItemRenderer renderer = plot.getRenderer();
    renderer.setSeriesPaint(0, new Color(0x9C, 0xA4, 0x4A));
    renderer.setOutlineStroke(null);
    renderer.setBaseOutlineStroke(null);

    renderer.setItemLabelsVisible(true);
    renderer.setItemLabelFont(new Font("SansSerif", Font.BOLD, 10));
    final ItemLabelPosition position = new ItemLabelPosition(ItemLabelAnchor.INSIDE3, TextAnchor.CENTER_RIGHT);
    renderer.setPositiveItemLabelPosition(position);

    final CategoryTextAnnotation a1 = new CategoryTextAnnotation("1. White papers are available.", "Category 1",
            0.0);
    a1.setFont(new Font("SansSerif", Font.BOLD, 12));
    a1.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a1.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a1);

    final CategoryTextAnnotation a2 = new CategoryTextAnnotation(
            "2. White papers enhance users " + "understanding of the firm and its expertise.", "Category 2",
            0.0);
    a2.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a2.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a2.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a2);

    final CategoryTextAnnotation a3 = new CategoryTextAnnotation(
            "3. White papers are relevant to " + "the firm's prospects and clients.", "Category 3", 0.0);
    a3.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a3.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a3.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a3);

    final CategoryTextAnnotation a4 = new CategoryTextAnnotation(
            "4. White papers are relevant to " + "the firm's positioning.", "Category 4", 0.0);
    a4.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a4.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a4.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a4);

    final CategoryTextAnnotation a5 = new CategoryTextAnnotation("5. Case studies are available.", "Category 5",
            0.0);
    a5.setFont(new Font("SansSerif", Font.BOLD, 12));
    a5.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a5.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a5);

    final CategoryTextAnnotation a6 = new CategoryTextAnnotation(
            "6. Case studies enhance users " + "understanding of the firm and its expertise.", "Category 6",
            0.0);
    a6.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a6.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a6.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a6);

    final CategoryTextAnnotation a7 = new CategoryTextAnnotation(
            "7. Case studies are relevant to " + "the firm's prospects and clients.", "Category 7", 0.0);
    a7.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a7.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a7.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a7);

    final CategoryTextAnnotation a8 = new CategoryTextAnnotation(
            "8. White papers are relevant to the firm's positioning.", "Category 8", 0.0);
    a8.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a8.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a8.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a8);

    final CategoryTextAnnotation a9 = new CategoryTextAnnotation("9. Case studies are available.", "Category 9",
            0.0);
    a9.setFont(new Font("SansSerif", Font.BOLD, 12));
    a9.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a9.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a9);

    final CategoryTextAnnotation a10 = new CategoryTextAnnotation(
            "10. Case studies enhance users " + "understanding of the firm and its expertise.", "Category 10",
            0.0);
    a10.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a10.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a10.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a10);

    final CategoryTextAnnotation a11 = new CategoryTextAnnotation(
            "11. Case studies are relevant " + "to the firm's prospects and clients.", "Category 11", 0.0);
    a11.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a11.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a11.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a11);

    final CategoryTextAnnotation a12 = new CategoryTextAnnotation(
            "12. White papers are relevant to the firm's positioning.", "Category 12", 0.0);
    a12.setFont(new Font("SansSerif", Font.PLAIN, 12));
    a12.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a12.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a12);

    final CategoryTextAnnotation a13 = new CategoryTextAnnotation(
            "13. Users can easily access " + "resources based on viewer interest.", "Category 13", 0.0);
    a13.setFont(new Font("SansSerif", Font.BOLD, 12));
    a13.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a13.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a13);

    final CategoryTextAnnotation a14 = new CategoryTextAnnotation(
            "14. Access to additional hyperlinks enhances users's ability to find relevant " + "information.",
            "Category 14", 0.0);
    a14.setFont(new Font("SansSerif", Font.BOLD, 12));
    a14.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a14.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a14);

    final CategoryTextAnnotation a15 = new CategoryTextAnnotation("15. OVERALL EFFECTIVENESS.", "Overall", 0.0);
    a15.setFont(new Font("SansSerif", Font.BOLD, 12));
    a15.setTextAnchor(TextAnchor.BOTTOM_LEFT);
    a15.setCategoryAnchor(CategoryAnchor.START);
    plot.addAnnotation(a15);

    return chart;

}