/**
     *
     */
    override public void afterReportInit()
    {
        try
        {
            AreaChartProperties areaChartProperties = new AreaChartProperties();

            double[][] data = new double[][] { new double[] { 10, 15, 30, 53 },
                                               new double[] { 6, 30, 10, 21 }, new double[] { 20, 25, 20, 8 } };
            Paint[]          paints           = { new Color(0, 255, 0, 100), new Color(255, 0, 0, 100), new Color(0, 0, 255, 100) };
            string[]         legendLabels     = { "Games", "Events", "Players" };
            AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.AREA, areaChartProperties);

            string[]   axisLabels = { "January", "March", "May", "June" };
            DataSeries dataSeries = new DataSeries(axisLabels, "Months", "People", "Popular Events");
            dataSeries.addIAxisPlotDataSet(axisChartDataSet);

            ChartProperties chartProperties = new ChartProperties();
            AxisProperties  axisProperties  = new AxisProperties();
            axisProperties.setYAxisRoundValuesToNearest(0);
            LegendProperties legendProperties = new LegendProperties();

            AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350);

            BufferedImage bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB);

            axisChart.setGraphics2D(bufferedImage.createGraphics());
            axisChart.render();

            base.setVariableValue("ChartImage", bufferedImage);
        }
        catch (ChartDataException chartDataException)
        {
            throw new JRScriptletException(chartDataException);
        }
    }
Example #2
0
        public static BufferedImage getJChart()
        {
            BufferedImage bufferedImage = null;

            try
            {
                //string reports_dir = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "reports");
                //string fileName = System.IO.Path.Combine(reports_dir, "AreaChart.jpg");
                //bufferedImage = ImageIO.read(new File(fileName));
                AreaChartProperties areaChartProperties = new AreaChartProperties();
                double[][]          data = new double[][] {
                    new double[] { 10, 15, 30, 53 },
                    new double[] { 6, 30, 10, 21 },
                    new double[] { 20, 25, 20, 8 }
                };
                Paint[]          paints           = { new Color(0, 255, 0, 100), new Color(255, 0, 0, 100), new Color(0, 0, 255, 100) };
                String[]         legendLabels     = { "Games", "Events", "Players" };
                AxisChartDataSet axisChartDataSet = new AxisChartDataSet(data, legendLabels, paints, ChartType.AREA, areaChartProperties);

                String[]   axisLabels = { "January", "March", "May", "June" };
                DataSeries dataSeries = new DataSeries(axisLabels, "Months", "People", "Popular Events");
                dataSeries.addIAxisPlotDataSet(axisChartDataSet);

                ChartProperties chartProperties = new ChartProperties();
                AxisProperties  axisProperties  = new AxisProperties();
                axisProperties.setYAxisRoundValuesToNearest(0);
                LegendProperties legendProperties = new LegendProperties();

                AxisChart axisChart = new AxisChart(dataSeries, chartProperties, axisProperties, legendProperties, 500, 350);

                bufferedImage = new BufferedImage(500, 350, BufferedImage.TYPE_INT_RGB);

                axisChart.setGraphics2D(bufferedImage.createGraphics());
                axisChart.render();
            }
            catch (ChartDataException chartDataException)

            {
                throw new JRScriptletException(chartDataException);
            }
            return(bufferedImage);
        }