Search in sources :

Example 1 with StandardXYURLGenerator

use of org.jfree.chart.urls.StandardXYURLGenerator in project pentaho-platform by pentaho.

the class JFreeChartEngine method createTimeSeriesCollectionChart.

private static JFreeChart createTimeSeriesCollectionChart(final TimeSeriesCollectionChartDefinition 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();
    DateAxis domainAxis = new DateAxis(domainAxisLabel, TimeZone.getDefault());
    ValueAxis rangeAxis = new NumberAxis(rangeAxisLabel);
    XYItemRenderer 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 (tooltips) {
        XYToolTipGenerator generator = new StandardXYToolTipGenerator(chartDefinition.getTooltipContent(), new SimpleDateFormat(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 : DateAxis(org.jfree.chart.axis.DateAxis) NumberAxis(org.jfree.chart.axis.NumberAxis) XYLineAndShapeRenderer(org.jfree.chart.renderer.xy.XYLineAndShapeRenderer) DecimalFormat(java.text.DecimalFormat) 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) AbstractXYItemRenderer(org.jfree.chart.renderer.xy.AbstractXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) SimpleDateFormat(java.text.SimpleDateFormat)

Example 2 with StandardXYURLGenerator

use of org.jfree.chart.urls.StandardXYURLGenerator 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 StandardXYURLGenerator

use of org.jfree.chart.urls.StandardXYURLGenerator in project pentaho-platform by pentaho.

the class JFreeChartEngine method createStackedTimeSeriesChart.

/*
   * The only type of chart this method will produce is a stacked XY area chart with a time series dimension. This
   * is because the dataset that jFreeChart expects is different than the regular TimeSeriesCOllection. More
   * lipstick on this homely pig.
   */
private static JFreeChart createStackedTimeSeriesChart(final TimeTableXYDatasetChartDefinition 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();
    DateAxis domainAxis = new DateAxis(domainAxisLabel, TimeZone.getDefault());
    ValueAxis rangeAxis = new NumberAxis(rangeAxisLabel);
    XYItemRenderer renderer = null;
    switch(chartDefinition.getChartType()) {
        case AREA_CHART_TYPE:
            renderer = chartDefinition.isStacked() ? new StackedXYAreaRenderer2() : new XYAreaRenderer();
            break;
        default:
            // should log an error if invalid chart type passed in - at least return null for no renderer
            return null;
    }
    if (tooltips) {
        XYToolTipGenerator generator = new StandardXYToolTipGenerator(chartDefinition.getTooltipContent(), new SimpleDateFormat(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 : DateAxis(org.jfree.chart.axis.DateAxis) NumberAxis(org.jfree.chart.axis.NumberAxis) DecimalFormat(java.text.DecimalFormat) JFreeChart(org.jfree.chart.JFreeChart) XYAreaRenderer(org.jfree.chart.renderer.xy.XYAreaRenderer) StackedXYAreaRenderer2(org.jfree.chart.renderer.xy.StackedXYAreaRenderer2) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYPlot(org.jfree.chart.plot.XYPlot) ValueAxis(org.jfree.chart.axis.ValueAxis) StandardXYURLGenerator(org.jfree.chart.urls.StandardXYURLGenerator) AbstractXYItemRenderer(org.jfree.chart.renderer.xy.AbstractXYItemRenderer) XYItemRenderer(org.jfree.chart.renderer.xy.XYItemRenderer) StandardXYToolTipGenerator(org.jfree.chart.labels.StandardXYToolTipGenerator) XYToolTipGenerator(org.jfree.chart.labels.XYToolTipGenerator) SimpleDateFormat(java.text.SimpleDateFormat)

Aggregations

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