Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Closed
conniepe opened this issue Aug 9, 2018 · 12 comments
Closed

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

conniepe opened this issue Aug 9, 2018 · 12 comments

Comments

@conniepe
Copy link

conniepe commented Aug 9, 2018

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

@sysalto
Copy link
Owner

sysalto commented Sep 3, 2018

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
Copy link
Author

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
Copy link
Owner

sysalto commented Sep 23, 2018

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

sysalto commented Oct 3, 2018

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
Copy link
Author

conniepe commented Oct 5, 2018

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
Copy link
Owner

sysalto commented Oct 23, 2018

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
Copy link
Owner

sysalto commented Oct 28, 2018

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
Copy link
Author

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
Copy link
Author

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
Copy link
Owner

sysalto commented Dec 8, 2018 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants