Search in sources :

Example 1 with NumberAxis3D

use of org.jfree.chart.axis.NumberAxis3D in project sonar-scanner-jenkins by SonarSource.

the class BarChart3D method configureRangeAxis.

private void configureRangeAxis(CategoryPlot plot, String valueLabelSuffix, Font font) {
    NumberAxis3D numberAxis = new NumberAxis3D();
    numberAxis.setUpperMargin(0.3);
    numberAxis.setTickLabelFont(font);
    numberAxis.setTickLabelPaint(OUTLINE_COLOR);
    String suffix = "";
    if (valueLabelSuffix != null && !"".equals(valueLabelSuffix)) {
        suffix = new StringBuilder().append("'").append(valueLabelSuffix).append("'").toString();
    }
    numberAxis.setNumberFormatOverride(new DecimalFormat("0" + suffix));
    numberAxis.setStandardTickUnits(NumberAxis.createIntegerTickUnits());
    plot.setRangeAxis(numberAxis);
}
Also used : DecimalFormat(java.text.DecimalFormat) NumberAxis3D(org.jfree.chart.axis.NumberAxis3D)

Example 2 with NumberAxis3D

use of org.jfree.chart.axis.NumberAxis3D in project pentaho-platform by pentaho.

the class JFreeChartEngine method createXYSeriesCollectionChart.

private static JFreeChart createXYSeriesCollectionChart(final XYSeriesCollectionChartDefinition chartDefinition) {
    JFreeChart chart = null;
    // TODO Make the following accessible from the chartDefinition
    String domainAxisLabel = null;
    String rangeAxisLabel = null;
    boolean tooltips = true;
    boolean urls = true;
    // -----------------------------------------------------------
    String title = chartDefinition.getTitle();
    boolean legend = chartDefinition.isLegendIncluded();
    NumberAxis domainAxis = chartDefinition.isThreeD() ? new NumberAxis3D(domainAxisLabel) : new NumberAxis(domainAxisLabel);
    domainAxis.setAutoRangeIncludesZero(chartDefinition.isDomainIncludesZero());
    domainAxis.setAutoRangeStickyZero(chartDefinition.isDomainStickyZero());
    ValueAxis rangeAxis = new NumberAxis(rangeAxisLabel);
    AbstractXYItemRenderer renderer = null;
    switch(chartDefinition.getChartType()) {
        case LINE_CHART_TYPE:
            renderer = chartDefinition.isThreeD() ? new XYLine3DRenderer() : new XYLineAndShapeRenderer(true, false);
            ((XYLineAndShapeRenderer) renderer).setShapesVisible(chartDefinition.isMarkersVisible());
            ((XYLineAndShapeRenderer) renderer).setBaseShapesFilled(chartDefinition.isMarkersVisible());
            break;
        case AREA_CHART_TYPE:
            renderer = new XYAreaRenderer();
            break;
        case STEP_CHART_TYPE:
            renderer = new XYStepRenderer();
            break;
        case STEP_AREA_CHART_TYPE:
            renderer = new XYStepAreaRenderer();
            break;
        case DIFFERENCE_CHART_TYPE:
            renderer = new XYDifferenceRenderer();
            break;
        case DOT_CHART_TYPE:
            renderer = new XYDotRenderer();
            ((XYDotRenderer) renderer).setDotHeight(chartDefinition.getDotHeight());
            ((XYDotRenderer) renderer).setDotWidth(chartDefinition.getDotWidth());
            break;
        default:
            // should log an error if invalid chart type passed in - at least return null for no renderer
            return null;
    }
    if (renderer != null && legend) {
        renderer.setLegendItemURLGenerator(new StandardXYSeriesLabelGenerator());
    }
    if (tooltips) {
        XYToolTipGenerator generator = new StandardXYToolTipGenerator(chartDefinition.getTooltipContent(), new DecimalFormat(chartDefinition.getTooltipXFormat()), new DecimalFormat(chartDefinition.getTooltipYFormat()));
        renderer.setToolTipGenerator(generator);
    }
    if (urls) {
        renderer.setURLGenerator(new StandardXYURLGenerator());
    }
    renderer.setStroke(JFreeChartEngine.getLineStyleStroke(chartDefinition.getLineStyle(), chartDefinition.getLineWidth()));
    XYPlot plot = new XYPlot(chartDefinition, domainAxis, rangeAxis, renderer);
    JFreeChartEngine.updatePlot(plot, chartDefinition);
    chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) AbstractXYItemRenderer(org.jfree.chart.renderer.xy.AbstractXYItemRenderer) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) StandardXYSeriesLabelGenerator(org.jfree.chart.labels.StandardXYSeriesLabelGenerator) DecimalFormat(java.text.DecimalFormat) NumberAxis3D(org.jfree.chart.axis.NumberAxis3D) XYStepAreaRenderer(org.jfree.chart.renderer.xy.XYStepAreaRenderer) XYDotRenderer(org.jfree.chart.renderer.xy.XYDotRenderer) XYDifferenceRenderer(org.jfree.chart.renderer.xy.XYDifferenceRenderer) JFreeChart(org.jfree.chart.JFreeChart) XYAreaRenderer(org.jfree.chart.renderer.xy.XYAreaRenderer) XYLine3DRenderer(org.jfree.chart.renderer.xy.XYLine3DRenderer) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) XYStepRenderer(org.jfree.chart.renderer.xy.XYStepRenderer) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator)

Example 3 with NumberAxis3D

use of org.jfree.chart.axis.NumberAxis3D in project pentaho-platform by pentaho.

the class JFreeChartEngine method createXYZSeriesCollectionChart.

/*
   * New char types based on the XYZSeriesCollectionChartDefinition
   */
private static JFreeChart createXYZSeriesCollectionChart(final XYZSeriesCollectionChartDefinition chartDefinition) {
    JFreeChart chart = null;
    // TODO Make the following accessible from the chartDefinition
    String domainAxisLabel = null;
    String rangeAxisLabel = null;
    boolean tooltips = true;
    boolean urls = true;
    // -----------------------------------------------------------
    String title = chartDefinition.getTitle();
    boolean legend = chartDefinition.isLegendIncluded();
    NumberAxis domainAxis = chartDefinition.isThreeD() ? new NumberAxis3D(domainAxisLabel) : new NumberAxis(domainAxisLabel);
    domainAxis.setAutoRangeIncludesZero(chartDefinition.isDomainIncludesZero());
    domainAxis.setAutoRangeStickyZero(chartDefinition.isDomainStickyZero());
    NumberAxis rangeAxis = new NumberAxis(rangeAxisLabel);
    rangeAxis.setAutoRangeIncludesZero(chartDefinition.isRangeIncludesZero());
    rangeAxis.setAutoRangeStickyZero(chartDefinition.isRangeStickyZero());
    BubbleRenderer renderer = null;
    // So far only Bubble charts are supported
    switch(chartDefinition.getChartType()) {
        case BUBBLE_CHART_TYPE:
            renderer = new BubbleRenderer();
            break;
        default:
            // should log an error if invalid chart type passed in - at least return null for no renderer
            return null;
    }
    if (tooltips) {
        // creating the label definition
        renderer.setToolTipGenerator(new StandardXYZToolTipGenerator(chartDefinition.getBubbleLabelContent(), chartDefinition.getXFormat(), chartDefinition.getYFormat(), chartDefinition.getZFormat()));
    }
    if (urls) {
        renderer.setURLGenerator(new StandardBubbleURLGenerator());
    }
    renderer.setMaxSize(chartDefinition.getMaxBubbleSize());
    renderer.setMaxZ(chartDefinition.getMaxZValue());
    XYPlot plot = new XYPlot(chartDefinition, domainAxis, rangeAxis, renderer);
    JFreeChartEngine.updatePlot(plot, chartDefinition);
    chart = new JFreeChart(title, JFreeChart.DEFAULT_TITLE_FONT, plot, legend);
    return chart;
}
Also used : NumberAxis(org.jfree.chart.axis.NumberAxis) XYPlot(org.jfree.chart.plot.XYPlot) NumberAxis3D(org.jfree.chart.axis.NumberAxis3D) JFreeChart(org.jfree.chart.JFreeChart) StandardXYZToolTipGenerator(org.jfree.chart.labels.StandardXYZToolTipGenerator)

Aggregations

NumberAxis3D (org.jfree.chart.axis.NumberAxis3D)3 DecimalFormat (java.text.DecimalFormat)2 JFreeChart (org.jfree.chart.JFreeChart)2 NumberAxis (org.jfree.chart.axis.NumberAxis)2 XYPlot (org.jfree.chart.plot.XYPlot)2 ValueAxis (org.jfree.chart.axis.ValueAxis)1 StandardXYSeriesLabelGenerator (org.jfree.chart.labels.StandardXYSeriesLabelGenerator)1 StandardXYToolTipGenerator (org.jfree.chart.labels.StandardXYToolTipGenerator)1 StandardXYZToolTipGenerator (org.jfree.chart.labels.StandardXYZToolTipGenerator)1 XYToolTipGenerator (org.jfree.chart.labels.XYToolTipGenerator)1 AbstractXYItemRenderer (org.jfree.chart.renderer.xy.AbstractXYItemRenderer)1 XYAreaRenderer (org.jfree.chart.renderer.xy.XYAreaRenderer)1 XYDifferenceRenderer (org.jfree.chart.renderer.xy.XYDifferenceRenderer)1 XYDotRenderer (org.jfree.chart.renderer.xy.XYDotRenderer)1 XYLine3DRenderer (org.jfree.chart.renderer.xy.XYLine3DRenderer)1 XYLineAndShapeRenderer (org.jfree.chart.renderer.xy.XYLineAndShapeRenderer)1 XYStepAreaRenderer (org.jfree.chart.renderer.xy.XYStepAreaRenderer)1 XYStepRenderer (org.jfree.chart.renderer.xy.XYStepRenderer)1 StandardXYURLGenerator (org.jfree.chart.urls.StandardXYURLGenerator)1