use jasper report plugin for charting in web client

Using Servoy to administrate the content of your website? Discuss all webrelated Servoy topics on this forum!

use jasper report plugin for charting in web client

Postby maarten » Thu Nov 25, 2010 11:09 am

Before I dive into Jasper documentation, has anybody ever used jasper reports for generating charts in the web client?
Any pointers/alternatives are welcome.

Google charts works fine but the GET method is limited to +/- 2000 chars in the url. (so you can only send a limited amount of data into a chart)
The Google chart POST method also works fine with the servoy http plugin. However there's no method inside the Servoy Poster object to get the PNG image.
(I've posted a request at Servoy for that)
Code: Select all
//Get poster object to do http (file) posts. If posting files, it will post multipart!
   var poster = plugins.http.getPoster('http://chart.apis.google.com/chart');
   var p1 = poster.addParameter('cht','lc');
   var p2 = poster.addParameter('chtt','This is | my chart');
   var p3 = poster.addParameter('chs','300x200');
   var p4 = poster.addParameter('chxt','x');
   var p5 = poster.addParameter('chd','t:40,20,50,20,100');
   var httpCode    = poster.doPost(); //httpCode 200 is ok
   var pageData    = poster.getPageData()   //need getMediaData() here
   globals.chartImage = pageData;
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Re: use jasper report plugin for charting in web client

Postby ptalbot » Thu Nov 25, 2010 3:12 pm

Do yourself a favor and have a look at the VelocityReport, it is a powerful report engine that also has a built-in charts (and barcode) generator using google-charts or eastwood (using simple JavaScript methods and objects in Servoy).
Using eastwood you get all the google charts (and more) but without the URL limitation and with a higher definition as well (suitable for printing or output to PDF).

Check it on ServoyForge at https://www.servoyforge.net/projects/velocity-report
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: use jasper report plugin for charting in web client

Postby maarten » Wed Dec 01, 2010 3:01 pm

Hi Patrick,
Thanks for your pointer, will check today.

btw: i see you're using Redmine for your projects :-)
That's a great tool!
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Re: use jasper report plugin for charting in web client

Postby maarten » Thu Dec 02, 2010 6:31 pm

Thanks Patrick,
This looks like a great tool :-)

One quick question

It seems that I'm gettin a reference error on CONSTANTS defined in your plugin.

CALL:
var vChartUrl = globals.lgcChartShow(CHART.LINE)
ERROR:
Code: Select all
org.mozilla.javascript.EcmaError: ReferenceError: "CHART" is not defined. (C:\servoyWorkSpace\...\forms\chartsAndRawData.js#65)


However when I put in this method step to onSolutionOpen, the error is gone.
Code: Select all
plugins.VelocityReport.installFonts(fontCallback);


Any relation between these two?
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Re: use jasper report plugin for charting in web client

Postby ptalbot » Fri Dec 03, 2010 1:28 am

maarten wrote:CALL:
var vChartUrl = globals.lgcChartShow(CHART.LINE)
ERROR:
Code: Select all
org.mozilla.javascript.EcmaError: ReferenceError: "CHART" is not defined. (C:\servoyWorkSpace\...\forms\chartsAndRawData.js#65)


However when I put in this method step to onSolutionOpen, the error is gone.
Code: Select all
plugins.VelocityReport.installFonts(fontCallback);


Any relation between these two?

The thing is that until you make at least one call to a method of the plugin, the constants are not known to the scripting environment.
This is a limitation of Servoy due to the fact that IConstantObject implementation (as any Object returned by the plugin) are lazily loaded.

So using installFonts() initializes the constants, but you could also use getVersion() for example and it will do the same...
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: use jasper report plugin for charting in web client

Postby maarten » Mon Dec 06, 2010 12:38 pm

Hi Patrick,

Could you test your velocity Reports solution in web client using true servoyServer - client ?
I'm still getting the reference error.

Everything seems to be ok when using smart client or developerServer - client connection.

Thanks,
Maarten.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Re: use jasper report plugin for charting in web client

Postby ptalbot » Mon Dec 06, 2010 2:56 pm

I just tried the sample solution from a "true" Servoy server using the latest v1.3.8 and it works fine for me here.
Are you sure you have deployed the correct version?
Maybe you could try clearing your cache (client side and/or server side) and try again?
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: use jasper report plugin for charting in web client

Postby maarten » Tue Dec 14, 2010 12:46 pm

High Patrick,
FYI
I just upgraded from 1.3.6 to 1.3.12

Constants problem is gone :D

Thanks!
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Re: use jasper report plugin for charting in web client

Postby david » Tue Dec 14, 2010 7:01 pm

ptalbot wrote:Do yourself a favor and have a look at the VelocityReport, it is a powerful report engine that also has a built-in charts (and barcode) generator using google-charts or eastwood (using simple JavaScript methods and objects in Servoy).
Using eastwood you get all the google charts (and more) but without the URL limitation and with a higher definition as well (suitable for printing or output to PDF).

Check it on ServoyForge at https://www.servoyforge.net/projects/velocity-report


SO much better than Jasper. Much easier to setup and configure, designing reports is normal html/css, can send data to reports in a variety of ways that make sense, tag markup takes about 5 minutes to learn, outputs to all kinds of formats, integrated viewer, etc.

I'm not quite at the point where I want to marry Patrick but I do love this plugin!

Ok, maybe I need to dial down the morning coffee....
David Workman, Kabootit

Image
Everything you need to build great apps with Servoy
User avatar
david
 
Posts: 1727
Joined: Thu Apr 24, 2003 4:18 pm
Location: Washington, D.C.

Re: use jasper report plugin for charting in web client

Postby ptalbot » Tue Dec 14, 2010 7:07 pm

david wrote:Ok, maybe I need to dial down the morning coffee....

Yes, Please!!! :)
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: use jasper report plugin for charting in web client

Postby ptalbot » Tue Dec 14, 2010 10:24 pm

And for those who don't love me like you do David :lol: I have created a little VelocityReport "Excel export How-to" tutorial on the ServoyForge Wiki:
https://www.servoyforge.net/projects/ve ... xcelExport

Works in Smart AND Web clients.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC

Re: use jasper report plugin for charting in web client

Postby maarten » Wed Dec 15, 2010 12:57 am

That's great stuff, Patrick!
Thanks.
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Re: use jasper report plugin for charting in web client

Postby maarten » Wed Dec 15, 2010 3:10 pm

Here's a pretty amazing google chart for displaying dates along the x axis and values along the y axis.
It's got zoom and scroll functions and client side stuff, so I guess no limitations regarding amount of data input.
http://code.google.com/apis/ajax/playgr ... _time_line

You can use the same approach as Davids/Jans google maps solution.
http://www.servoymagazine.com/home/2007 ... tegra.html

1) Create a method globals.showChart() that returns the google code
2) place a text globals.htmlarea on a form with DISPLAY_TYPE = HTML_AREA (make the area big enough to show chart like 900x400) and call
Code: Select all
function setChart(event) {
   globals.htmlarea   = globals.showChart()
}


Code: Select all
function showChart()
{
   var x   = "<html>\
  <head>\
    <script type='text/javascript' src='https://www.google.com/jsapi'></script>\
    <script type='text/javascript'>\
      google.load('visualization', '1', {'packages':['annotatedtimeline']});\
      google.setOnLoadCallback(drawChart);\
      f"+"unction drawChart() {\
        var data = new google.visualization.DataTable();\
        data.addColumn('date', 'Date');\
        data.addColumn('number', 'Sold Pencils');\
        data.addColumn('string', 'title1');\
        data.addColumn('string', 'text1');\
        data.addColumn('number', 'Sold Pens');\
        data.addColumn('string', 'title2');\
        data.addColumn('string', 'text2');\
        data.addRows([\
          [new Date(2008, 1 ,1), 30000, undefined, undefined, 40645, undefined, undefined],\
          [new Date(2008, 1 ,2), 14045, undefined, undefined, 20374, undefined, undefined],\
          [new Date(2008, 1 ,3), 55022, undefined, undefined, 50766, undefined, undefined],\
          [new Date(2008, 1 ,4), 75284, undefined, undefined, 14334, 'Out of Stock','Ran out of stock on pens at 4pm'],\
          [new Date(2008, 1 ,5), 41476, 'Bought Pens','Bought 200k pens', 66467, undefined, undefined],\
          [new Date(2008, 1 ,6), 33322, undefined, undefined, 39463, undefined, undefined]\
        ]);\
      \
        var chart = new google.visualization.AnnotatedTimeLine(document.getElementById('chart_div'));\
        chart.draw(data, {displayAnnotations: true});\
      }\
    </script>\
  </head>\
  <body>\
    // Note how you must specify the size of the container element explicitly!\
    <div id='chart_div' style='width: 700px; height: 240px;'></div>\
   \
  </body>\
</html>";
   return x;
}


snap__2010_12_15__13_59_44.png
snap__2010_12_15__13_59_44.png (24.84 KiB) Viewed 9747 times
Maarten Berkenbosch
User avatar
maarten
 
Posts: 797
Joined: Wed Apr 23, 2003 10:52 pm
Location: Amersfoort, Netherlands

Re: use jasper report plugin for charting in web client

Postby Gary R. Schaecher » Tue Mar 08, 2011 5:17 pm

Is there an easy way to dynamically refresh charts and dials with the Velocity Report engine so one can build dynamic dashboards with it?

Thanks,

Gary
TMA
Gary R. Schaecher
TMA Systems, LLC
www.tmasystems.com
Gary R. Schaecher
 
Posts: 72
Joined: Sat Jan 06, 2007 11:01 pm

Re: use jasper report plugin for charting in web client

Postby ptalbot » Tue Mar 08, 2011 5:40 pm

Gary R. Schaecher wrote:Is there an easy way to dynamically refresh charts and dials with the Velocity Report engine so one can build dynamic dashboards with it?

What do you mean by dynamically refresh charts?

Charts are built by an object containing parameters... it's up to you to fill these parameters and "dynamically" change them whenever you want.
Just set a form variable as a dataprovider to a field of type HTML_AREA, then call plugins.VelocityReport.getChart() to fill the content of it.
Have a look at the sample solution, it does that, all you need to do is to change the parameters depending on your own values.
It's just scripting really, and of course this works on web client as well.
Patrick Talbot
Freelance - Open Source - Servoy Valued Professional
https://www.servoyforge.net
Velocity rules! If you don't use it, you don't know what you're missing!
User avatar
ptalbot
 
Posts: 1654
Joined: Wed Mar 11, 2009 5:13 am
Location: Montreal, QC


Return to Web Development

Who is online

Users browsing this forum: No registered users and 5 guests