sysalto / ReactiveReports

Reactive Reports - a framework developed in Scala, designed for generating reports from code.
Other
16 stars 4 forks source link

Is there any example how drawBarChart() works with Java? #6

Closed conniepe closed 5 years ago

conniepe commented 5 years ago

Hi, is there any example how drawBarChart() works with Java?

sysalto commented 5 years ago

This method is not implemented yet. It's just added to the interface. It will be implemented in the next release, and there will be an example for how to use it, in Java and Scala.

conniepe commented 5 years ago

Hi, thanks for your response. Do you have any idea when will be the next release? Also, I'm trying the drawPieChart() and found that seems the color of the Pie Chart is fixed (in blue) which is really hard to see and hard to distinguish each category based on the same color...is there any way to customize the color of the Pie Chart such as each category in different color etc...?

sysalto commented 5 years ago

Hi, we are working towards delivering the next release as soon as possible. We fixed drawPieChart() today. The function drawPieChart( ) was renamed to pieChart() which now belogs to class ReportChart. Similarly, drawBarChart( ) will be renamed to barChart( ), and will be part of the same class.

This change to drawPieChart( ) is available under version 1.0.2-SNAPSHOT (see https://github.com/sysalto/ReactiveReports/blob/master/VERSION%20LOG.md at the top). We will notify you in this issue when the release comes out.

This is the example in Java - https://github.com/sysalto/ReactiveReports/blob/master/examples/src/main/java/com/sysalto/report/examples/MutualFundsNoAkkaJavaReport.java#L222

            final ReportColor color = ReportColor.apply(rnd.nextInt(255), rnd.nextInt(255), rnd.nextInt(255),1);
            chartData.get().add(new scala.Tuple3("" + cc,color, total2.get()));
            ReportCell cr_change = new ReportCell(new ReportTxt(v_change.toString())).rightAlign().inside(m_change);
            ReportCell[] rrow1 = new ReportCell[]{cr_fundName, cr_value1, cr_value2, cr_change};
            Float y3 = report.calculate(rrow1);
            report.print(rrow1);

            if (GroupUtil.isLastRecord(rec)) {
                report.line().from(10, report.getY() + 2).to(m_change.right(), -1).width(0.1f).draw();
            } else {
                report.line().from(10, report.getY() + 2).to(m_change.right(), -1).color(200, 200, 200).lineType(new LineDashType(2, 1)).width(0.5f).draw();
            }
            firstChar.set(firstChar.get() + 1);
            report.nextLine();
        });

        ReportCell[] trow = new ReportCell[]{new ReportCell(new ReportTxt("Total").bold()).inside(m_fundName),
                new ReportCell(new ReportTxt(total1.toString()).bold()).rightAlign().inside(m_value1),
                new ReportCell(new ReportTxt(total2.toString()).bold()).rightAlign().inside(m_value2),
                new ReportCell(new ReportTxt(total3.toString()).bold()).rightAlign().inside(m_change)};
        report.print(trow);
        float chartHeight = report.getY() - firstY.get() - 10;
        ReportChart reportChart=new ReportChart(report);
        reportChart.pieChart(report.font(),"", chartData.get(), m_graphic.left() + 5, firstY.get() - report.lineHeight() + 5, m_graphic.right() -
                m_graphic.left() - 10, chartHeight);
conniepe commented 5 years ago

Thank for fixing the color issue for the pie chart and looking forward the next release that has the bar chart working as well.

conniepe commented 5 years ago

I have tried 1.0.2-SNAPSHOT and pie chart color issues are fixed, but it's causing another issue: throws the exception at line: Float y = report.calculate(row), the ReportCell array (row) has some empty value, for example: ReportCell[] row = new ReportCell[]{"some string", "", ""}; these code was working fine before applied 1.0.2-SNAPSHOT.

Exception details: Exception in thread "main" java.util.NoSuchElementException: head of empty list at scala.collection.immutable.Nil$.head(List.scala:431) at scala.collection.immutable.Nil$.head(List.scala:428) at com.sysalto.render.serialization.RenderReport.wrap(RenderReport.scala:248) at com.sysalto.render.PdfNativeRender.wrap(PdfNativeRender.scala:97) at com.sysalto.report.Report.reportWrap(Report.scala:154) at com.sysalto.report.Report.wrap(Report.scala:369) at com.sysalto.report.Report$$anonfun$7.apply(Report.scala:537) at com.sysalto.report.Report$$anonfun$7.apply(Report.scala:536) at scala.collection.immutable.List.map(List.scala:288) at com.sysalto.report.Report.calculateWrapList(Report.scala:536) at com.sysalto.report.Report.calculate(Report.scala:530) at com.sysalto.report.Report.calculate(Report.scala:544) at com.sysalto.report.Report.calculate(Report.scala:544)

sysalto commented 5 years ago

Hello, I fixed this exception, and it's in the SNAPSHOT version. The change to drawBarChart() is in the works. I'll inform you about it soon when it's done, and I'll provide an example. I'm sorry about the wait.

conniepe commented 5 years ago

Thanks for fixing the exception and continue working on the Bar Chart. I will give it a try later...I also found a performance issue when adding a lot of images to the PDF report by using drawImage(). Without adding any images, the performance looks fine. When I tried to add about 20000 images, the size of image is not big (1KB each), the report generation took about 20 mins to finish. Do you have any idea how to improve the performance when adding images?

sysalto commented 5 years ago

Hi there,

Issue 1 - I fixed the Bar Chart and added this example: BarChart Example It is located in the same SNAPSHOT version. Please, let me know how it's working for you !

Issue 2 - Regarding adding 20,000 images, did you add the same image 20,000 times, or are they different ? How many different unique images do you have, in the 20,000 ?

sysalto commented 5 years ago

Hello,

Our newest version, 1.0.2 was released today. The issue with image optimization was fixed here. After the fix, a report having the same image on 20,000 pages takes only 4 minutes to generate, down from 20 minutes.

Scalaz, another open source software, was used for this optimization. Here is the license for scalaz: Scalaz license

Please, let us know if you have other questions regarding this specific bug. Otherwise, feel free to close it.

Thanks !

conniepe commented 5 years ago

Hi, Thanks for your update. I have just tested the latest version 1.0.2 for the image optimization issue. I was trying to add 20,000 images to the PDF report and there are around 10 different unique images in the 20,000. The report is around 600 pages and each page has about 40 images added. By using 1.0.2 version, It took about 20 mins to generate the report. It doesn't look a good improvement on the performance. Could you help take a look this issue again? Thanks.

conniepe commented 5 years ago

BTW, I have tried the bar Chart with v1.0.2, it works well. Thanks. I will close this issue and open a separate issue for the image optimization.

sysalto commented 5 years ago

Hi,

We are currently fixing the report accessibility feature. We don't have time to analyze further the PDF optimization. Maybe we will, at some point in the future. But, at the moment, this is not a high priority. As long as it works, 20,000 images (10 different individual pictures) in 20 mins doesn't seem that bad for now.

Thanks, SysAlto Team

On Thu, Nov 29, 2018 at 6:03 PM conniepe notifications@github.com wrote:

Hi, Thanks for your update. I have just tested the latest version 1.0.2 for the image optimization issue. I was trying to add 20,000 images to the PDF report and there are around 10 different unique images in the 20,000. The report is around 600 pages and each page has about 40 images added. By using 1.0.2 version, It took about 20 mins to generate the report. It doesn't look a good improvement on the performance. Could you help take a look this issue again? Thanks.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sysalto/ReactiveReports/issues/6#issuecomment-443026868, or mute the thread https://github.com/notifications/unsubscribe-auth/AYXUwp5rmuq89kBGnoToUB3YNcAv8reZks5u0GfNgaJpZM4V2xAl .