Kristopher Clark

Kristopher is a Solutions Consultant for OpenText Analytics.

Introducing BIRT iHub F-Type: Sharing Designs and Other Resources

Actuate’s BIRT iHub F-Type is an easy to use, feature packed, data visualization platform that takes all the grunt work out of building your data visualization applications. One of the great, new features BIRT iHub F-Type makes available to open source BIRT developers is the ability to enable the secure sharing of reports between users. This is now as simple as a few clicks of your mouse. First, before we can share anything, we need to create groups and users to share with. To create new users and groups, login as Administrator and navigate to BIRT iHub Administration. In the top left of the administration page you’ll notice two links, users and user groups. We’ll start by clicking user groups so we’ll have the groups available during user creation. This is where the rubber meets the road with iHub F-Type. Instead of doing things the old fashioned way, with terminal commands such as groupadd and useradd, we can create all our users and groups from this UI. Let’s go ahead and create two groups. Click “Add User Group.” This is where you’ll name the new group. Let’s call it “developer,” select “save,” and “ok.” You’ll notice you can also assign users to the new group at the same time using “Assign Users” from the left. Go ahead and repeat the same steps, this time naming your group “users.” Take note of the down arrows next to the group names. You can edit or delete groups from this menu, which again is easier than the method many server administrators are used to. Now that both of our groups are created, we can add users to the system. Select “Users” from the upper left of the page. If this is a fresh install of iHub F-Type, then you will only see one user, Administrator. Let’s create a user by selecting “adduser.” On this page you’ll find everything you’d expect to see when creating a new user. For more information about this, visit the iHub documentation. We’ll create two users, Developer and User. After entering the required information for the new users click “Assign User Groups.” You can assign, one, multiple, or no groups to the user account from here. Assign developer to the developer account and user to the user account, and click “Save.” Just as with the user groups, you can choose to edit user details from the drop-down menus next to each user name. So you have groups and users created and your users are assigned to the groups. Now the fun begins. As administrator, go back and view your default volume. From here, locate a report that you’d like to share and show. Before we can share this, we need to allow “Developer” access to read the folder. Hover your mouse over the folder icon and select “Share.” Next, assign Developer and give that group “Read” permissions. This allows that group to read that folder. To actually see the items we’ll need to share them individually. Now locate the “rptdesign” that you’d like to share, show the Options drop-down by selecting the down arrow next to it, and select “Share.” From here, you can get as specific or as broad as you want. You can restrict a report to be viewed and executed by one user or a handful. For more of a broad scope, you can also assign permissions to entire groups. To switch between users and groups, use the two radio buttons located near the bottom labeled “User Groups” and “Users.” Go ahead and assign Visible, Read, Execute, and Write to the group “Developer.” Log out and log back in as Developer. You’ll notice that you can see, execute, and edit this “rptdesign,” but you can’t share it with other users. This is because we didn’t give Developer grant rights to this design. To correct this, back in as Administrator and find the design that you had shared. Click the drop-down and select “Share.” Find the group under the “Selected” portion of this screen, choose Developer, then select “Grant” and “Save.” You just gave the entire group Developer rights to share this design with other groups and users. Log in is as Developer, find the design, and choose share from the drop-down. Let’s give User both “Read” and “Execute” privileges. With the just a few clicks of the mouse we’ve changed that group’s permissions; no extra work was needed. By assigning the right groups to the right users, we’ve made it easier to focus on more important aspects of your application. Now you don’t need to fiddle around with the small details that should just work. If you want to test this and make sure it works, login as User, then find and run the report that we just shared. As if that wasn’t enough for your sharing needs, Actuate’s JavaScript API (JSAPI) makes sharing just as simple when viewing the report. With just a click of a button, you can choose to share the report you’re currently viewing straight out of the toolbar. By clicking the drop-down menu from the JSAPI toolbar, you’re given a Share option. From here you are given the direct URL to the report. In that same place, JSAPI also gives you the code needed to embed the report in a web application. For more information on how to share a report via JSAPI you can read the documentation here. Use the live report below to interact with this feature. There you have it, the basics of how you can easily and securely share and collaborate with other BIRT iHub F-Type users. Thanks for reading. If you have any questions or comments, please feel free to use the comments section below or visit the BIRT iHub F-Type forum. You can also find more information about the BIRT iHub F-Type in the deployment guide and documentation. -Kris For more blogs in the “Introducing BIRT iHub F-Type” series, see the list below: Installing iHub F-Type: Windows | Linux | VMWare Image Connecting to Data and Creating a Design Integrating into Applications

Read More

How to Charge Credit Cards from a BIRT Design, and Other Posts From This Week

Last weekend I had the opportunity to attend a local hackathon put together by hackmidwest. If you’re not familiar with hackathons, I encourage you to seek one out. They are a lot of fun. Rules can change from event to event, but typically you have 24 hours to create an application of your choosing, either by yourself or as a team. For my hack, I used BIRT iHub Free Edition and Mastercard’s Simplify API. By leveraging the Simplify API, I was able to charge credit cards directly from a BIRT Design. It was as simple as creating a JAR and including it in my design. public void chargeCard(String creditcard, long amount, String cvc, int expMonth, int expYear, String desc, String currency) { PaymentsApi.PUBLIC_KEY = "PUBLICKEY"; PaymentsApi.PRIVATE_KEY = "PRIVATEKEY"; try { Payment payment = Payment.create(new PaymentsMap() .set("amount", amount) .set("card.cvc", cvc) .set("card.expMonth", expMonth) .set("card.expYear", expYear) .set("card.number", creditcard) .set("description", desc) .set("currency", currency)); }catch(Exception ex) { ex.printStackTrace(); } } By creating a JAR with this method, I was able to leverage a few global persistent variables and a simple script like this in the onCreate() of a label. if(params["Payment"].value == true) { var simplify = com.actuate.developer.SimplifyBIRT(); simplify.chargeCard(reportContext.getPersistentGlobalVariable("card"), reportContext.getPersistentGlobalVariable("amount"), "123", 8, 16, "BIRT Payment", "USD"); this.text = "Paid" }else{ this.text = "Pending" }params["Payment"].value This grabs the card number to be charged from the global persistent variable “card” as well as the amount to charge from “amount”. Then I changed the label to show that the credit card has been charged. Now that the card has been charged, let’s check the Simplify website to make sure it has been approved. And that’s all there is to it! Simplify has several other calls you can use in your BIRT Designs. This is just a quick and simple example of how you can use third-party APIs in your BIRT Designs. Which third-party APIs have you used in your designs, and which ones are your favorites? I’m always looking for more ways to integrate other libraries with BIRT! Here are some other BIRT Forum posts worth taking a look at: List-Box Multiple Values Parameter – “Select All” issues Mobile average Installation error when installing Free Edition on Windows 2008 R2 Also, here are some unanswered posts from this week: Hiding crosstab through javascript Month report in arrears Chart height relative/percentage to the height of grid row? If you have suggestions or solutions for any of these, please post them in the thread. As the week comes to an end I hope everyone has a good weekend. Thanks for reading! If you have any questions or comments please feel free to comment below. -Kris Group photo courtesy of hackmidwest. Credit card sign photo by Shawn Rossi. 

Read More

Introducing BIRT iHub F-Type: Installing on Linux

Last week, Actuate released a new, free BIRT server called the BIRT iHub F-Type. It incorporates all the functionality of BIRT iHub and is limited only by the capacity of output it can deliver on a daily basis. It is ideal for departmental and smaller scale applications. When BIRT F-Type reaches its maximum output capacity, additional capacity can be purchased on a subscription based model. Some of the key features of BIRT iHub F-Type that will help improve your BIRT content applications are: Interactivity – Allow end-users to modify and personalize reports, and answer questions themselves. Scheduling – Automate report generation based on rules and calendar, and then notify users. Sharing – Secure document management and distribution that allows users to only access content/data they are entitled to. Excel Emitter – Export as native Excel (not CSV) with formulas/pivot tables/worksheets/charts. Integration – JavaScript API to embed dynamic reports and visualizations in your web app. Downloading BIRT iHub F-Type Before we get started with the installation process, we need to download BIRT iHub F-Type. There are three downloads available: Windows, Linux, and a VMware image. This blog will cover the Linux installation process. If you’re installing either of the other types, you’ll find links to guides for them at the bottom of this blog post. Once you click on your chosen download, you’ll be asked to register. If you’ve already registered, click the “Click to Login” button. If not, fill out the short registration form to get started. Next, read and accept the license agreement. Once you’ve done that, click the checkbox, and a link for the download will appear. Click that to start your download. At this point, you should also receive an email with an activation code. Be sure to check your spam folder if you don’t see it in your inbox. Before getting started take a quick glance at the system requirements. System Requirements Linux: x64 compatible RAM: 4 GB minimum Free Disk Space: 3 GB minimum Supported Operating Systems Red Hat Enterprise Linux AS 5.3-5.6, 6.1- 6.4 SUSE Linux Enterprise Server 11 OpenSUSE Linux 12.2 CentOS 6.3, 6.5 Oracle Linux 5.5 As well as the target system I’ve install iHub F-Type on My target system CentOS 6.5 2 CPUs 4GB RAM 80 GB Free Disk Space With the required reading out of the way, we can jump right in to the installation. First, we need to make sure that libstdc++.i686 is installed $ rpm -qa | grep libstdc++ libstdc++-4.8.2-16-el6.x86_64 libstdc++-devel-4.8.16.el6.x86_64 From my output above, I can tell that we have the 64-bit libstdc++ libraries installed, but iHub also needs the 32-bit libraries. Before I start the installation process we can satisfy that dependency using yum or whatever package management your system uses. $ sudo yum install libstdc++.i686 -y After this has successfully installed I can move on to the iHub installation without needing to worry about missing packages. After downloading iHub from the Actuate products site I moved and decompressed it in /usr/local/src $ sudo mv $HOME/Downloads/ActuateBIRTiHubFType.tar.gz /usr/local/src $ cd /usr/local/src $ sudo tar xvf ActuateBIRTiHubFType.tar.gz $ sudo chown kclark:kclark -R ./BIRTiHubFType Note: You can place these files anywhere you want, I just like to keep them in /usr/local/src Next, we move into the BIRTiHubFType directory and start the installation. It should be noted that you do not want to run these commands with elevated privileges. Completing the installation as the currently logged in user is recommended. $ cd BIRTiHubFType $ ./install.sh After you’ve read the license, you can press y to accept and enter. Depending on your system specs, the install shouldn’t take more than a minute or two. If successful, your terminal will give you the following. Installation complete To log in to BIRT iHub F-Type, open a browser window and type the following URL: http://localhost:8700/iportal The last step is to enter the activation code that you should have received in an e-mail. Find the email that you received when downloading and enter the activation code from it. If you have a valid activation code, you should quickly be told that your code was accepted and the iHub F-Type should start initializing services. When that has completed, you get to the login screen. As seen in the image, the user name is “administrator” and the password is blank for your first log in. You’ll be able to change this once logged in. Hit “Log In” and you’re done. You’ll now be dropped into a tutorial to help you get started loading your BIRT content and required resources. If you’re already familiar with how to do this, you can bypass the tutorial by hitting the “Exit Tutorial” button at the top right. Thanks for reading. Now, it’s time to unleash the full power of BIRT into your application. If you have any questions or comments, please feel free to use the comments section below or visit the BIRT iHub F-Type forum. -Kris For more blogs in the “Introducing BIRT iHub F-Type” series, see the list below: Installing iHub F-Type: Windows | VMware Connecting to Data and Creating a Design Sharing Designs and Other Resources Integrating into Applications

Read More

Using Google Maps in a Text Item, and Other Posts From This Week

This week in the BIRT Forums, someone asked about using Google Maps in a BIRT report. While there is a plugin for this already, in some cases you might want to use a text item instead. In this post I’ll show you some code I’ve used to display a Google Map in a report. As you would expect, you’ll need to start with an empty text item on your report. Make sure to change it from “Auto” to “HTML” in the text item UI. Once you’ve done this you can use my sample code below. <!DOCTYPE html> <html> <head> <title>Asynchronous Loading</title> <meta name="viewport" content="initial-scale=1.0, user-scalable=no"> <meta charset="utf-8"> <script> function initialize() { alert("init"); var mapOptions = { zoom: 8, center: new google.maps.LatLng(-34.397, 150.644) }; var map = new google.maps.Map(document.getElementById('map-canvas'), mapOptions); alert("done"); } function loadScript() { alert("loading"); var script = document.createElement('script'); script.type = 'text/javascript'; script.src = 'https://maps.googleapis.com/maps/api/js?v=3.exp&sensor=false&' + 'callback=initialize'; document.body.appendChild(script); alert("done"); } window.onload = loadScript(); </script> </head> <body> <div id="map-canvas" style="width:400px;height:600px;"></div> </body> </html> </pre> There are two tricks to get this to work.  The first is to use Google’s asynchronous loading example. The second, which took me some time and a big headache to figure out, is explicitly setting the height and width for the div that the Google Map will be displayed in. Using this same code in an HTML document, everything works right out of the box. In a BIRT design, the div will not auto-size for you. So take special note of this portion of the code style="width:400px;height:600px;" which is a workaround for my auto-sizing headache. This is a quick and simple example of how you can use a text item to display a Google Map. You can also do other Google Map-related functions, such as setting pins from longitude and latitude. As far as I know you can set a maximum of 50 pins, which was more than enough for me! Have you used a Google Map in your BIRT design using the Google Map plugin or the method shown here? If you have, please post a screenshot in the comments. I always like to see what people are working on! Here are some other BIRT Forum posts worth taking a look at: Adding a logout button to the Example Viewer Displaying total on top of a stacked bar chart How to use mutliselect parameters in a SQL query Also, here are some unanswered posts from this week: Add calandar to a report in maximo7.5 Add a column header in a crosstab Excel worksheet names group value If you have suggestions or solutions for any of these, please post them in the thread! As the week comes to an end I hope everyone has a good weekend. Thanks for reading! If you have any questions or comments please feel free to comment below! Happy 4th of July everyone! -Kris

Read More

Writing Back to a Database, and Other Posts From This Week

This week in the BIRT Forums there was a question about how to write data back to a database.  Generally when you’re using BIRT the goal is to consume data from a database, but sometimes you want to write back data too.  To accomplish this, I simply created a Class that took the connection parameters and query, and let the Class take care of the heavy lifting. Here’s the code: package com.actuate.developer; import java.sql.Connection; import java.sql.DriverManager; import java.sql.Statement; public class WriteBackSQL { // User properties private String username; private String password; private String database; private String hostname; private int port; public WriteBackSQL(String username, String password, String database, String hostname, int port) { this.username = username; this.password = password; this.database = database; this.hostname = hostname; this.port = port; } public void executeQuery(String query) { try { Class.forName("com.mysql.jdbc.Driver"); // Create the URL, connection, and statement String url = "jdbc:mysql://" + hostname + ":" + port + "/" + database; Connection conn = DriverManager.getConnection(url, username, password); Statement stmt = conn.createStatement(); // Execute the query stmt.executeUpdate(query); // Close the connection conn.close(); }catch(Exception ex) { ex.printStackTrace(); } } public void setUsername(String username) { this.username = username; } public void setPassword(String password) { this.password = password; } public void setDatabase(String database) { this.database = database; } public void setHostname(String hostname) { this.hostname = hostname; } public void setPort(int port) { this.port = port; } public String getUsername() { return username; } public String getDatabase() { return database; } public String getHostname() { return hostname; } public int getPort() { return port; } } As you can see, this is pretty basic. The constructor takes the connection parameters and executeQuery() executes the query that was passed to it. And while they aren’t needed for this example, I added a few getters and setters for completeness. The next step is to create a JAR and add it to my resources. To do this you’ll need to drag the JAR into your BIRT Projects then add it to your resources from Property Editor > Resources > Add File. Once the JAR has been added to your project, the last step is to use it in your design. To do this you’ll need to use the following script. For my example I added the script to the onCreate() of a label, though you can add it just about anywhere in your design. //username, password, database, hostname, port test = new WriteBackSQL("root", "root", "test", "localhost", 3306); test.executeQuery("INSERT INTO test values('Name', 5);"); And that’s it! The ability to use JavaScript and Java in your design opens a whole new world of flexibility and integration. If you’ve integrated a custom Class into your report let me know about it in the comments. I’m always looking to see how people are using BIRT out in the world! Here are some other BIRT Forum posts worth taking a look at: Creating a horizontal table Displaying total on top of a stacked bar chart Where do BIRT scripts run? Also, here are some unanswered posts from this week: Export to Print View in Microsoft Word Setting the response header in the sample viewer Set a range of dates when using JSCal2 as a date parameter If you have a suggestion or solution for any of these, please post them in the thread! As the week comes to an end I hope everyone has a good weekend. Thanks for reading! If you have any questions or comments please feel free to comment below! -Kris

Read More

Using the Power of Bookmarks

One of my favorite features in BIRT that doesn’t get a lot of attention are bookmarks. Bookmarks can be one of those features that can go a long way when you want to do some simple scripting but don’t want to reinvent the wheel. Think of a bookmark as a div. Once you’ve bookmarked a report item you can call it using JavaScript just like you would any other div in web development. In this post, I’ll show you a simple example showing you how this feature might be used in a BIRT Design. Before we get started, it might be helpful to know where to set the bookmark. If you click a report item from the Property Editor > Properties > Bookmark. It’s important to note that your bookmark name must be in double quotes. Now that we know where to create the bookmark, let’s get down to code. In this example I built a simple chart with a table underneath it. Both are grouped by year. I’ve placed my chart in the header of my table so it will stay on each page. I then used a text box underneath the chart. This is where I need to place my JavaScript to show and hide the chart. This example is as simple as it gets. I use the following JavaScript to perform the show/hide. <script> var show = true; function showHide() { if(show == true) { document.getElementById('paymentchart').style.display = 'none'; show = false; }else{ document.getElementById('paymentchart').style.display = 'block'; show = true; } } </script> As you can see above, at this point we can call on our chart just like any other div in a webpage. You can play with this example below.   While I only covered one use of the bookmark, there are several other ways you can leverage this tool in your own design. If you’re needing more help with this then ask in the forums or you can search through the Devshare that houses hundreds of examples that you might find useful. As always, if you have done something neat using bookmarks that you’d like to share with the world then feel free to post it here, or better yet, write a Devshare post! -Kris

Read More

Five Reasons You’ll Want to Switch to the BIRT ViewerToolkit

Reasons you’ll want to switch to BIRT ViewerToolkit Editor’s note: If you already have BIRT Viewer Toolkit (BVT), the information in this blog post gives you good reasons to use it. But if you do not currently have BVT, try BIRT iHub Free Edition, our free BIRT server, instead. BIRT iHub Free Edition provides a much richer and more powerful experience at no cost. When new products are released in the software world it’s hard to cut through all the noise and decide if it’s worth upgrading or if it’s the same old stuff with a new version or name behind it.  BIRT ViewerToolkit is a game changer.  With so many new features available to the open source BIRT developer it’s hard to focus on just one or two features that add that extra something to your data visualization projects.  BVT is a closed source toolkit provided by Actuate for use with open source BIRT reporting applications.   That’s why I’ve decided to cut out all the fluff and get straight to my top 5 features that will get you installing BVT before this blog is over. New look and feel “Link to this page” link Progressive Viewing Easy Integration Easier customization New look and feel I’ve touched a little on this in my previous blogs, but the importance cannot be understated.  You are developing applications centered around visualization after all.  So the container matters almost as much as your content when trying to create that seamless application that will make heads turn.  BVT has overhauled how your reports are viewed by providing a cleaner look and feel.  Some of these include the parameter page, table of contents, the toolbar, and others. BVT’s toolbar has been tucked away into a dropdown box in the upper left corner of the container.  By doing this it removes a lot of clutter and increases the viewing area for your design.  By placing the toolbar items into a drop down menu it also gives your report a more native feel. The parameter page is also easily accessed through the menu drop down.  When selected, the parameter page appears in a frame below your report so the user doesn’t need to navigate away when changing his or her selections. Other items of note that can be found in the menu drop down are the table of contents, export content, export report, print, and help. “Link to this page” hyperlink Sometimes it’s the small stuff that can make all the difference in your application.  Actuate didn’t skimp on the small yet valuable features in BVT.  One of my favorite features that you’ll find in the drop down menu of BVT is “Link to this page”.  This menu item makes it easier for you to share reports by providing you a direct URL that you can e-mail a co-worker.  It even provides you the JavaScript you’ll need if you want to embed that report somewhere else so you don’t have to worry about looking up any APIs.  Simply copy and paste into an HTML document and make any changes desired like height, width, etc. Progressive Viewing Have you ever been waiting for a report to render and wished you could just view the first few pages while the report finishes in the background?  Well consider that wish granted!  Actuate has added the “Progressive Viewing” feature in BVT which does exactly that.  Instead of having to wait around for the entire report to finish, you’re allowed to view and interact with the report as each page continues to render.  Perfect for those days where you need to get information fast!  I could post screenshots but the best way to understand the importance of this feature is to test drive BVT for yourself. Easy Integration Using the JSAPI you can embed reports into any number of web technologies that allow you to use JavaScript with minimal effort.  Some of these might include PHP, .NET, or JSF.  To get an idea of how you could do this visit this blog that explains how to embed reports in HTML, PHP, .NET, and others.  Or, for you PHP fans out there, I also wrote a blog showing how you can create a template for BVT in PHP using smarty for even easier deployment of your reports. Reportlets with JSAPI Using the JSAPI you can easly embed reportlets into your projects, too!  Below this paragraph I used the JSAPI to embed two of them to show how easy this was.  Nothing special was required, I just copied and pasted my JSAPI into WordPress.  This makes it extremely easy to embed your designs while maintaining control over the look and feel of your application.  The design shown above is hosted on iHub but has the same look and JSAPI as you would expect to come from open source. Sales Dashboard To see the full report, click here Easier Customization BVT also makes customization a breeze with the JSAPI.  With the old example viewer it was required edit JSP pages and work with a limited tag library.  The JSP tag library is a thing of the past now!  To get a better understanding of how you can make use of the JSAPI for your customization needs make sure to check out the JSAPI guide. BVT has also kept a lot of the same functionality that was included in the example viewer, too.  You can still export to all of the same document types, the viewer is still paginated, deployment to your application server is just as easy by dropping the WAR/EAR into it.  BVT also comes with a sample report that you can view to make sure everything has been setup correctly.  As you can tell from this short list of new features you’re going to have at your disposal it’s at least worth downloading to see if BVT fits into any of your BIRT projects.  So, what are you waiting for?  Download it for FREE here!  We’re not leaving you in the dark after you’ve downloaded BVT either, in fact we’ve designed an entire deployment center to make sure you have access to BVT and JSAPI documentation. Have you already downloaded and deployed BVT?  Leave a comment with a screenshot of it below, I’d love to see how everyone is using BVT in the world! -Kris (editor’s note: iHub Free Edition now correctly named)

Read More

Using BIRT Viewer Toolkit as the Default Viewer

Editor’s note: If you already have BIRT Viewer Toolkit (BVT), the information in this blog post will help you make it your default viewer. If you do not currently have BVT, try BIRT iHub Free Edition, our free BIRT server, instead. BIRT iHub Free Edition provides a much richer and more powerful experience at no cost. —– The BIRT Viewer Toolkit (BVT) has brought a new look and feel to the way a design is consumed. This left me wondering how to use BVT as the default viewer from Eclipse. By following these steps you’ll be able to go from this     To this   Download BVT Rename the WAR to viewer.war – viewer is the default value BIRT will be looking for on your application server. Deploy the war to your application server. From Eclipse go to Window → Preferences → Report Design → Preview → Preview Server Change the hostname or IP in the first field. For me this was localhost. Change the port to match your application server. For me this was 8080. Select “Always use an external browser” from Report Design →Preview You’ll need to make sure you’re workspace is in a location that tomcat can access. If you’re using windows then you can create a new workspace inside of the viewer location. I run Mint 16, so I created a workspace in the same location as the viewer and chmoded the new workspace to 777 since I’m running this locally for report development. View your design If all went well your default output will now be BVT and you can start testing your reports against it before they are deployed. If you haven’t downloaded BVT yet then now’s the time to get started! Not only will you’re designs get an updated look and feel, but you’ll also have access to the JavaScript API for easier, more flexible integration. -Kris   (editor’s note: iHub Free Edition now correctly named)

Read More

Creating a Custom ODA [Part 1]

In BIRT there are several ways we can connect to data. Some of these methods are out of the box such as MySQL while others require a little more work. This blog series aims to teach you how to bring in the power of scripted data sources and POJO’s while adding an easy to use interface for the report designer. By the end of this series you should know how to -Design an ODA UI -Create an ODA runtime driver -Deploy and distribute your custom ODA What is an ODA? ODA stands for Open Data Access, it’s what allows you to connect to and retrieve data that will be used as the content of your design. If you’ve created a report with BIRT then you’ve used an ODA. ODA’s can either be used in the designer or used with the BIRT API’s.   Why build an ODA? This is an interesting question by itself because all of the other options available to you. While it is true you can decide to build a scripted data source or a POJO to retrieve data for use in BIRT, every project is different. An ODA has many advantages, while I won’t go over all of them I will give you my two favorite reasons to build one. 1. Easy deployment. Once you’ve created an ODA you only need to worry about distributing the jars to your designers and the server. It’s a one size fits all solution instead of having to keep code in your design. 2. A cleaner design file If you have lots of data that needs to be retrieved and you decide to build a scripted data set, reading, debugging, and maintaining that script can start to get complicated depending on how complex it is. How complicated is this? If you’re like me, then you want to get up and running as soon as possible. The good news is that the designer already has two wizards available. One will generate the base code for your runtime driver while the other generates the base code for the UI. Since all of this is already generated for us then we only need to be concerned with the data retrieval and our ODA specific UI components. Enough talk, let’s do this! Today we won’t get too deep into the ODA. By the end of this blog post you’ll know how to -Create an ODA Runtime project -Create an ODA UI project -Run your new ODA in Eclipse without any data – yet. Create the runtime project The first step in our journey of creating an ODA is to create the runtime project. We need to create the runtime project before the UI or the UI project will complain that it can’t find the runtime. To do this we need to open up eclipse and go to File > New > Project and find “ODA Runtime Driver Plug-in Project” inside of “Business Intelligence and Reporting Tools”. Then we’ll need to name the runtime project. For this blog I’ll be using developer.actuate.oda.blog.runtime Click “Next” then we can tell the wizard what the name of our ODA will be. This name will appear in the ODA creation UI. In the next screen make sure to select “ODA Data Source Runtime Driver” then finish. Once this has all been completed you should see the runtime project in your workspace. We’ll now repeat the same steps for the UI. Go to File > New > Project and select “ODA Designer Plug-in Project” For this project name we’ll be using developer.actuate.oda.blog.ui Again, we’ll need to name the project. Just like before, we’ll need to make sure and choose the correct project type. Then click finish. You should now have two projects in your workspace. One for the runtime and the other for the UI. We need to make two small changes to the UI project before we can run this. First, open up “MANIFEST.MF” located under META-INF in the UI project. Then click of the “MANIFEST.MF” tab. Replace line 11 with developer.actuate.oda.blog.runtime Then open CustomDataSetWizardPage.java and change line 243 to this IDriver customDriver = new developer.actuate.oda.blog.runtime.impl.Driver(); Now we can test our new ODA by pressining Ctrl+F11 from within that same java code and selecting “Eclipse Application.” Go ahead and create a BIRT project inside the new eclipse instance that just opened up and create a design. You can now see the beginnings of your ODA when you create a new data source. And that’s it! At least for now As you can see from today’s blog, BIRT takes care off all that pesky setup and let’s us jump right into having a barebones ODA that dosn’t do much until we start to make our changes, which will be covered in next week’s blog discussing the ODA UI creation. I’ll wait to post example code until next week when we have something more substational to run, for now, the wizard will help get you this far. If you’re waiting for the next post in this series, take a look at the code, break some stuff, fix that stuff, and have fun with it! -Kris

Read More

Creating an IoT Dashboard with BIRT

This month marked the 10th annual EclipseCon. I was able to attend and talk about BIRT with the community and show off some of the cool things we’ve been working on at Actuate. One of the main themes that I was able to contribute to was the Internet of Things. If you’re not familiar with the Internet of Things trend then take a look at Eclipse’s February newsletter. To showcase how BIRT can be used within this emerging trend we partnered with Eurotech. Eurotech is a European company that, among other things, manufactures sensors that can be used to measure environmental data in a given area. For this project, Eurotech provided sensors that measured population, carbon dioxide , temperature, and other environmental data points that I used to build a dashboard to compare historical trends during EclipseCon. You can view the finished dashboard on our demo server. The finished dashboard showcases how you can take data from several sources, combine them into one design, and extract meaningful correlations that otherwise wouldn’t exist if the data wasn’t able to be aggregated in the same place. In this blog I’ll walk you through the steps I took to go from a new design to this dashboard. At a high level, this project contained four main steps. 1. Create a POJO to be used as my Data Source 2. Create a Data Object that makes use of the POJO 3. Creating the design 4. Deployment 1. Creating the POJO Before anything can be designed we need access to the data. In several scenarios, any one of the ODA’s included in the designer can be used. For this project we had some non-traditional data that needed to be retrieved from Eurotech. This leaves us with two options. We can either create a scripted data source or create a POJO. I decided that a POJO would best meet the needs of this project. I won’t be covering the POJO creation in detail, if you’re new to building a POJO as a data source then take a look at this devshare. Eurotech provides a library in maven that I was able to use for the data retrieval, the documentation can be found here. By making use of the Eurotech API’s which implement Kura, I was able to make simple calls to the Eurotech hardware and retrieve the historical data by passing it which sensors I wanted, the max records, and how many seconds in the past to retrieve from. Once I had access to this data I only needed to place it in an ArrayList as described in the above devshare. Now that the data has been retieved from the eurotech hardware I can choose to use it as-is or I can perform any calculations I might need so everything is ready for me before it gets to BIRT. In this case I had to decide how I would show data points in the same chart that could have values with a difference as much as 1,000 on greater. To keep the scale of these data points I normalized the data using normalizedValue = (currentValue – minimumValue) / (maximumValue – minimumValue) This returns a value between 0 and 1 which allowed me to show in the bottom chart how each data point acts on the other. 2. Creating the Data Object After the POJO has been created we now need to make a decision that will affect the deployment of the design. While the POJO can be used in Open Source BIRT, I decided to use iHub3 which brings in Data Objects. Creating a data object instead of the alternative gave me several features that can directly the impact the performance of the finished dashboard. The main feature I want to call out is scheduling. By creating a Data Object I can schedule the Data Object to generate every x minutes and point my design at the resulting data file. This means instead of several clients trying to pull data from the same server at once I can make sure only one client is pulling, aggregating, and returning data. In this case that client is iHub3. Creating the data object is just as easy as creating a data source and data set in the designer. You create a POJO data source pointing at the JAR’s, create a data source, and publish the data object to iHub. If you’re viewing the source to this project then you’ll notice I’ve also created a second data object called currentvalues.datadesign. This data object isn’t scheduled because it needs to grab the current values that you see centered around the logos. Since this isn’t performing any calculations and is only pulling data with a maximum of 1 record I determined it’d be best to allow several client connections for these data points. 3. Creating the design Now we have data! This is where the real fun starts, creating the design. Since we’ve already gathered the data in the POJO and performed our calculations on it, this report is very straight forward. The basic concept is I have one large grid that contains everything you see. I created 7 line charts that show how that data point compares to the previous days, next to those charts are the current values. Then at the bottom is where I used the normalized values to compare how the data interacts on itself. I also added marker ranges so we can see when people are in sessions and at lunch. Using this format we can quickly see trends such as particulate matter, CO2, and population all tend to rise and fall together. Alternatively, I could have created an actual dashboard in BIRT Designer Pro. To do this I would have created several reports and pulled them in as reportlets to help increase the flexibility and performance of the design. 4. Deployment The last part to this whole project is the deployment. Now that the POJO is created along with the Data Object and scheduled and the report has been designed and points to the data file that is being generated we can put it all together using the JavaScript API. If you haven’t yet had a chance to look at the JSAPI then take a look at my other blog post. If the data was coming in at a higher rate I could have opted to use the isRead() JSAPI function to refresh elements of the report when new data became available. This might be the easiest part, which is good because after you do all this work you want to get it up and running, maybe even brag about what you’ve just created to your coworkers a little bit. I created three viewers in the background that render the report every 55 seconds. Once one viewer is done rendering then I switch over and allow the last one to start rendering a new report. This creates a seamless experience that has no visible load time. To recap, to create this dashboard, I had to create a POJO to retrieve the data from the Eurotech hardware, create a data object and schedule it, create the design with the items I want to display, and deploy the dashboard using the JSAPI. Have you created any cool IoT projects using BIRT? I’d like to hear about them in the comments section! If anyone has any question on this project then feel free to ask in the comments, in the forums, or a PM. -Kris

Read More

Create a PHP Template for BIRT Viewer Toolkit

In my last blog I briefly spoke about a few simple ways you can use BIRT Viewer Toolkit (BVT) and the JavaScript API (JSAPI) to easily embed your reports in HTML, PHP, ASP .NET, and others. Those simple examples work well, but what if you wanted to create a PHP template of BVT in your project? In this blog I’ll show you how easy it is to add value to your project by making use of the Smarty framework to build a BVT PHP template. If you’re unfamiliar with Smarty I suggest you read over their getting started guide here. The quickest way to embed a report into your PHP is to use the JSAPI and add your PHP tags somewhere in the body like this. <HTML> <BODY onload="init()"> <script type='text/javascript' language='JavaScript' src="http://192.168.1.110:8080/birt/jsapi"></script> <script type='text/javascript'> function init( ){ actuate.load('viewer'); actuate.initialize( "http://192.168.1.110:8080/birt", null,null,null,myInit ); } function myInit(){ viewer1 = new actuate.Viewer( 'container1' ); viewer1.setReportDesign('test.rptdesign'); viewer1.setSize(750,800); viewer1.submit( ); } </script> <?php echo "Hello PHP World from BIRT!"; ?> <div id='container1' style=' border-width: 1px; border-style: solid;' /> </BODY> </HTML> This works well, but after a while it could get old using this everywhere you wanted to embed a report. Not to mention all of these values are static. To spice this up a little we’ll create a template using almost the exact same code. After you’ve got done reading and setting up the Smarty frame work on your machine create the following template. <HTML> <BODY onload="init()"> <script type='text/javascript' language='JavaScript' src="http://localhost:8080/birt/jsapi"></script> <script type='text/javascript'> function init( ){ actuate.load('viewer'); actuate.initialize( "http://localhost:8080/birt", null,null,null,myInit ); } function myInit(){ viewer1 = new actuate.Viewer( 'container1' ); viewer1.setReportDesign('{$name}'); viewer1.setSize({$width},{$height}); viewer1.submit( ); } </script> Hello {$name}! <div id='container1' style=' border-width: 1px; border-style: solid;' /> </BODY> </HTML> As you can tell from this code we are using variable for the height, width, and report name. You can add or remove these were you see fit, I chose these parameters because you can easily see what’s changed. Now that we have our BVT template we just need to make use of it in our PHP using something like this. <?php // put full path to Smarty.class.php require('/usr/local/lib/php/Smarty/Smarty.class.php'); $smarty = new Smarty(); $smarty->setTemplateDir('/usr/local/www/apache24/data/web/smarty/templates'); $smarty->setCompileDir('/usr/local/www/apache24/data/web/smarty/templates_c'); $smarty->setCacheDir('/usr/local/www/apache24/data/web/smarty/cache'); $smarty->setConfigDir('/usr/local/www/apache24/data/web/smarty/configs'); $smarty->assign('name', 'test.rptdesign'); $smarty->assign('height', '750'); $smarty->assign('width', '800'); $smarty->display('index.tpl'); Now go to your new page and you should have an embeded BIRT report. If you write a lot of PHP this ends up being a time saver and cleans up your code quite a bit. If you have any questions or comments on this feel free to leave them here or in the forums! -Kris

Read More

Using the JavaScript API to Embed BIRT Viewer Toolkit into PHP, .NET, and More

Earlier this month Actuate released the new BIRT Viewer Toolkit (BVT) for the BIRT developer community. The BVT makes integration into your project a breeze by making use of the JavaScript API (JSAPI). With the JSAPI, you can embed whole reports or portions of reports anywhere that JavaScript can be used. Along with easy, seamless integration, BVT also has an updated look over the open-source viewer, giving your new or existing BIRT application a more modern, cleaner look and feel. In this blog I’ll show how you can quickly and easily deploy your report in HTML, PHP, and ASP .NET starting with HTML. Deploying a report to an HTML page can be done with as little as 19 lines of code from <HTML> to </HTML> and includes all of the features you’d expect to get with a BIRT Report. As shown above, this method will give you access to the toolbar which includes page navigation, access to the parameters, table of contents and more. To display your report as shown you’ll need to use the following code and make sure to change the URL’s to point to the application server that’s running BVT. <HTML> <BODY onload="init()"> <script type='text/javascript' language='JavaScript' src="http://localhost:8080/birt/jsapi"></script> <script type='text/javascript'> function init( ){ actuate.load('viewer'); actuate.initialize( "http://localhost:8080/birt", null,null,null,myInit ); } function myInit(){ viewer1 = new actuate.Viewer( 'container1' ); viewer1.setReportDesign('test.rptdesign'); viewer1.setSize(750,800); viewer1.submit( ); } </script> <tbody> <div id='container1' style=' border-width: 1px; border-style: solid;' /> </BODY> </HTML> If you’d like to strip down the viewer and embed just a reportlet you’d need to modify the JavaScript to use the following options instead. <HTML> <BODY onload="init()"> <script type='text/javascript' language='JavaScript' src="http://localhost:8080/birt/jsapi"></script> <script type='text/javascript'> function init( ){ actuate.load('viewer'); actuate.initialize( "http://localhost:8080/birt", null,null,null,myInit ); } function myInit(){ viewer2 = new actuate.Viewer( 'container2' ); viewer2.setReportDesign( 'test.rptdesign' ); viewer2.setReportletBookmark( 'myChart' ); var options2 = new actuate.viewer.UIOptions( ); options2.enableToolBar(false); viewer2.setUIOptions( options2 ); viewer2.setSize(400,300); viewer2.submit( ); } </script> <tbody> <div id='container2' style=' border-width: 1px; border-style: solid;' /> </BODY> </HTML> Now that you have seen the basics of how the JSAPI can be used to embed reports you can use this same approach with other languages. Take a look at the following code that I named birt.php. In this simple example I recycled the code from the first example into a PHP page. Using this as a starting point I can place my PHP code anywhere I need it. <HTML> <BODY onload="init()"> <script type='text/javascript' language='JavaScript' src="http://localhost:8080/birt/jsapi"></script> <script type='text/javascript'> function init( ){ actuate.load('viewer'); actuate.initialize( "http://localhost:8080/birt", null,null,null,myInit ); } function myInit(){ viewer1 = new actuate.Viewer( 'container1' ); viewer1.setReportDesign('test.rptdesign'); viewer1.setSize(750,800); viewer1.submit( ); } </script> <?php echo "Hello PHP World from BIRT!"; ?> <div id='container1' style=' border-width: 1px; border-style: solid;' /> </BODY> </HTML> The same can be said for ASP .NET and others. Instead of needing to reivent the wheel to get data to your customers all you need to do is use the JSAPI. <asp:Content ID=”BodyContent” runat=”server” ContentPlaceHolderID=”MainContent”> <h2>Hello World</h2> <p>Hello ASP .NET 4.0 from BIRT! </p> <HTML> <BODY onload="init()"> <script type='text/javascript' language='JavaScript' src="http://localhost:8080/birt/jsapi"></script> <script type='text/javascript'> function init( ){ actuate.load('viewer'); actuate.initialize( "http://localhost:8080/birt", null,null,null,myInit ); } function myInit(){ viewer1 = new actuate.Viewer( 'container1' ); viewer1.setReportDesign('test.rptdesign'); viewer1.setSize(750,800); viewer1.submit( ); } </script> <div id='container1' style=' border-width: 1px; border-style: solid;' /> </BODY> </HTML> </asp:Content> As you can tell from these basic examples you can use BIRT just about anywhere you can use our API which means less time integrating and more time working. If you’re looking for the JSAPI doc then make sure to visit the deployment center and don’t forget to ask on the forums if you need any help! -Kris

Read More

Highlighting Duplicate Entries, Creating a Variable Based SQL Query, BIRT RAP Application Bar Chart, and More

Sometimes when creating a report, it’s beneficial to suppress duplicate entries in a table. There are also situations that might require you to draw attention to the duplicate entries instead of hiding them. To do something like this we can leverage the highlight functionality that is built into the table item. Before the table is told what to highlight, we’ll need to store the data in an ArrayList so we can check to see if there are duplicate entries. To do this I created my ArrayList in the beforeOpen() of the data set. array = new java.util.ArrayList(); After that I just added each row of data I want to compare later. I did this from onFetch() of my data set. array.add(row["QUANTITYORDERED"]); Once we have all the data that needs to be compared it will need to be stored as a global persistent variable in the afterClose() the data set. This was we use it in our highlight rule. reportContext.setPersistentGlobalVariable("array", array); The last step is to create a highlight rule using the ArrayList I created eariler. To do this I simply selected the cell we want to highlight > property editor > highlights > add. Then I used the following scripts for the logic. var array = reportContext.getPersistentGlobalVariable("array"); var first = array.indexOf(row["QUANTITYORDERED"]); first; “Not equal to” var array = reportContext.getPersistentGlobalVariable("array"); var last = array.lastIndexOf(row["QUANTITYORDERED"]); last; Now all thats left is choosing our highlight color. Once this is all done the final result should look something like this. To download the full example visit this devshare entry. Some other posts worth taking a look at: create a variable based select result report in xls output and page breaks every 40 rows BIRT RAP Application Bar Chart Here are some unanswered posts from this week: Aggregation in grid Table not centered when exporting/printing to PDF Actuate One Jobs If you have a suggestion or solution for any of these, please post in the thread! As the week comes to an end I hope everyone has a good week!

Read More

New Changes in the BIRT Community, Chart with Zoom Functionality, and Other Topics.

The last few weeks on BIRT Exchange have ushered in some exciting changes for the BIRT developer community. We’ve released a whole new developer focused site that contains a large repository of information that will help developers from newbie to experts alike. In this blog, I’ll talk a little about the new site, along with the normal “This Week in the Forums” content. The new BIRT Developer Center has been broken down into five major sections. Design Center – The design center can be used to find getting started guides, documentation product manuals, and video’s all focused on helping you learn to build designs that will stand above the rest. Deployment Center – In the deployment center you can find getting started guides, deployment guides, product manuals, a video gallery, and even instructions on how to integrate BIRT with a wide selection of technologies. Community – Don’t worry, the community hasn’t gone anywhere! The forums, devshare, challenges, awards, advisory council, and social groups can be found under this section with a whole new look and feel. Want to connect your BIRT-exchange account to your Facebook? Well go to the forums and connect away! Blog – No major changes to the blog have occurred and made sure they are easily accessible from the top navigation. Actuate – Want to find more about the BIRT Company? Make sure to visit the Actuate page! Okay. Now, back to business… With all of the new changes happening on the community site I also got to work on some fun questions in the forums this week. This week there was a question that asked how you would implement zoom functionality with a chart. While there are a few different ways you can accomplish this I chose to use the built in drill-through hyperlinks in the chart builder. Imagine you have a chart with a lot of data that looks very busy like this one. The customer numbers can be rotated to allow more labels along the X-Axis but it still will not show all of them. One way to get around this problem is to implement this zoom in solution. The first step is to build a standard bar chart. For this example I had to build two data sets. The first data set will retrieve the customer numbers while the second will retrieve the payment data for our chart. Once we have both data sets we need to create a hidden and required parameter. This will allow us to tell the report what customer to zoom in on. The default value is -1 which tells us that there should be no zoom at all. Then we need to build our chart. I used the customer number for the X-Series and amount for the Y-Series. Make sure to enable Mouse Click interactivity. Now the report is setup to pass the category that was selected back to itself via drill-through links. The zoom actually happens in the beforeOpen(), beforeClose(), and onFetch() of the first data set and beforeOpen() of the second. In the beforeOpen() of the first data set we need to create a new array. customers = new Array(); In the onFetch() of the first data set customers[customers.length] = row["CUSTOMERNUMBER"]; Then we need to remember to set it as a persistent global variable in the beforeClose() reportContext.setPersistentGlobalVariable("myArray",customers); Finally we can remove data we don’t want to display in the chart creating a “zoom” in our query of the second data set. customers = reportContext.getPersistentGlobalVariable("myArray"); twoBack = null; oneBack = null; if (params["customernumber"] != -1){ for(i=0;i<customers.length;i++){ if(customers[i] != params["customernumber"]){ twoBack = oneBack; oneBack = customers[i]; } else{ i=customers.length; } } } if(twoBack != null){ this.queryText = this.queryText + " where CUSTOMERNUMBER >= " + twoBack.toString(); } You can download this example from this devshare. Some other posts worth taking a look at: Reference database columns with more user friendly names TOC with PageNumber and dots PNG’s not displaying in Firefox! Here are some unanswered posts from this week: Line chart remove second Y-Axis series space How to link database from SQLyog to BIRT Eclipse BIRT with PHP without using Tomcat If you have a suggestion or solution for any of these, please post in the thread! As the week comes to an end I hope everyone has a good week!

Read More

Refresh BIRT Report to Next Page, Multiple String Values in Where Clause, Scatter Chart Category Problems and More

This week I worked on a thread with a table that had been grouped. The table also had an aggregation in the group footer. He wanted to take the previous group aggregation value and subtract it by the current group aggregation. This was done easily by using a persistent global variable to store each value.First I had to create my PGV in the initialize() of the report. reportContext.setPersistentGlobalVariable("lastValue","0.00"); Next, in the onRender() of the aggregation item I used the following script. var oldValue = parseFloat(reportContext.getPersistentGlobalValue("lastValue"));if(oldValue ==0){// do nothing because this is the first group}else{var newValue = oldValue -this.getValue(); reportContext.setPersistentGlobalVariable("newValue", newValue.toString()); reportContext.setPersistentGlobalVariable("lastValue",this.getDisplayValue());} This will take the last value and subtract the current value from it. Finally we place our new value into a PGV so we can use it somewhere else. In this case I placed it in a label to the right of the aggregation in the group footer.Some other posts worth taking a look at: Refresh BIRT Report to next page Report Parameter – Multiple String Values in where clause Scatter chart category problems Here are some unanswered posts from this week: Stacked Area Chart tooltip Charts don’t display – birt.war deployed in Virgo Tomcat Server Error including class files in BIRT Report If you have a suggestion or solution for any of these, please post in the thread!As the week comes to an end I hope everyone has a good week! 

Read More

Collapsible Crosstab

Crosstabs are a great tool to summarize data in a BIRT report. The problem is the fine line between a neatly organized report and too much data being displayed at the same time. One way to keep your report looking tidy is to make your crosstab expandable and collapsible on each group. This will allow the reader to view just the information that is important at the time of viewing.Take the following crosstab as an example of something we could clean up a little better.Something as simple as this can be broken up in several different ways. By making it collapsible it becomes interactive and immediately more intuitive for the end user.To achieve the desired results we’ll just use one hidden parameter, a drill through link, and one computed column to let the report know what it should be hiding or showing.First I start with a simple query and created a hidden parameter called “collapse”. select country, customername, status from customers, orders Next I had to create one computed column called “newCustName” var col =newString(); col =params["collapse"].value if(col.indexOf(row["COUNTRY"])!=-1){ row["CUSTOMERNAME"];}else{"";} This get’s the value of our hidden parameter. If the parameter contains the same value as the row our data set is currently in that means it should be visible. So we return row[“CUSTOMERNAME”]. Otherwise that data should be hidden so we return NULL.After that I created a data cube with two groups, “COUNTRY” and “newCustName” with one summary field “STATUS” that sums each status code.The final crosstab will look like thisFinally our last step is to create a hyperlink on “COUNTRY” in the crosstab. Make sure to choose drill-through as the hyperlink type, select the report, and add “collapse” as a parameter with the following script. var col =newString(); col =params["collapse"].value if(col.indexOf(data["COUNTRY"])!=-1){// Has this string removeMe = data["COUNTRY"]+","; newVal = col.replace(removeMe,""); newVal;}else{ newVal = col + data["COUNTRY"]+","; newVal;} This will check to see if the value is already in the parameter. If it is then we remove it so it will be hidden. Otherwise the value gets added to the parameter and sent back to itself when clicked.The end result is a simple, orginized, and interactive crosstab that allows your end user to consume just the data that is important at that moment.Download the example rptdesign here. 

Read More

Birt.war Not Getting Imported In Eclipse, Customize Query For Parameter, Alternating Crosstab Row Colors

  This week in the forums we were asked another good charting question. In the thread he wanted to know how you would have a running sum of each series in a bar chart and display it on it’s own. This can be achieved with the use of one global persistent variable and the Y-Series expression builder.In the initialize() of the report you’ll need to set a PGV to 0. We’ll use this to store the previous series values. reportContext.setPersistentGlobalVariable("lastValue","0") Then I created a three series bar chart from my data cube. My X-Axis series is date grouped on Month. The first two Y-Series are checknumber (count) and customernumber (count).The third series is where we’ll show our running sum. var lastValue = parseInt(reportContext.getPersistentGlobalVariable("lastValue"));var currentValue = data["Summary Field1/CHECKNUMBER"]+data["Summary Field/CUSTOMERNUMBER"]var newValue = currentValue + lastValue; reportContext.setPersistentGlobalVariable("lastValue", newValue.toString()); newValue; First I grabbed the lastValue PGV, next I summed the first two series, finally I add the currentValue and lastValue to get what we would like to display in this series. Before returning the value to the chart I made sure to set it as the lastValue PGV so we can build off this as the chart continues.Some other posts worth taking a look at: Birt.war not getting imported in Eclipse how to customizes query for parameter Crosstab alternate rows coloring Here are some unanswered posts from this week: PDF with Watermark Performance Issues Conditionally displaying a BLOB image XML dataset: BIRT selects wrong data If you have a suggestion or solution for any of these, please post in the thread!As the week comes to an end I hope everyone has a good week! 

Read More

Generate One PDF For Every Group, Create A Multi-Tab Report, Dynamically Change Column Background Color

A few weeks ago in the forums I worked on a fun piece of code that I wanted to share in my blog. I was asked if there was an easy way to render a PDF for each group in a table. If you’ve ever rendered a simple report design using the BIRT Java API’s then it’s not much more complicated than that. If you haven’t there are several good examples in this devshare. Or you can use this code as a jumping off point too.I decided to use a hidden parameter which will allows me to tell the SQL statement what customers we want to pull back each time the report is run. I named this parameter ?group?. Then I created a parameterized SQL statement that looks like this. select*from orderdetails, customers where customernumber =? Make sure to link “customernumber” to “group” in the parameters section of the data set UI.I kept this report very simple. I have one chart that shows the top 5 orders and a table that lists all orders that customer has placed. You can save this report to any location you wish. Make sure to note where you placed it because we’ll need to change it later.I have two classes in my Java project, Main() and Groups(). Since all the work in Groups() is done in the constructor Main() only has 15 lines of code. import java.util.Scanner;publicclassMain{publicstaticvoid main(String[] args){int selection =0;System.out.println("Enter a customer number or 0 for all: ");Scanner input=newScanner(System.in); selection = input.nextInt();System.out.println("Generating...");Groups test =newGroups(selection);System.out.println("Done!");}} First we need to create a connection to the database. I do this using the followingNow we want to see if the customer told us to render a report for just one customer or all. if(selection ==0){ rs = st.executeQuery("select distinct customernumber from customers");}else{ rs = st.executeQuery("select customernumber from customers where customernumber = "+ selection);} This will select all of the customers or one of the customers and store it in the result set or “rs”.Now that we have either one or all of the customer numbers we can place them in an ArrayList() so they can be worked with a little bit easier later. ArrayList<String> results =newArrayList<String>();while(rs.next()){ results.add(rs.getString("customernumber"));} Now that we have the customer numbers in an ArrayList() we can loop through each one passing them as a parameter to the report and render the PDF. As mentioned earlier only one group will be in each PDF since we are telling the report design which customer to work with through our “groups” parameter. for(int i=0;i<results.size();i++){System.out.println(i+1+" of "+Integer.toString(results.size()-1));IReportRunnable design =null; design = engine.openReportDesign("C:/Users/kclark/Desktop/test.rptdesign");IRunAndRenderTask task = engine.createRunAndRenderTask(design); task.setParameterValue("group",Integer.parseInt(results.get(i))); task.validateParameters();PDFRenderOption options =newPDFRenderOption(); options.setOutputFileName("D:/output/group"+ results.get(i)+"Report.pdf"); options.setOutputFormat("pdf"); task.setRenderOption(options); task.run(); task.close();} This takes just a few minutes to run and you can see the progress in the console or in the output folder. To save time and strain on your eyes I left out some code.Additionally with just a few minor modifications to this code it can be used imported and called from a report design script to burst several reports from a design.Some other posts worth taking a look at: Multi tab report How can I dynamically change a column background color need to show “Continue..” if GROUP continue in next page Here are some unanswered posts from this week: Index Cards with different dataset on front and back page drill through hyper link is not working for pdf format Problem in accessing jars placed in birt/scriptlib If you have a suggestion or solution for any of these, please post in the thread!As the week comes to an end I hope everyone has a good week! 

Read More

PageNumber TOC Links Do Not Work in Word, Link US Map Gadget to Other Gadget Reports

This week in the forums there was a good question about percentile data as series labels with a pie chart. Sometimes it may be nessecary to filter the top n series because the pie chart may seem cluttered if it contains too much data. If you filter the top n and display the percentile values the chart will recalculate the percentages based on how many series are displayed. If you are wanting to change the percentile data to be calculated against the entire data set you will need to do a little scripting.First I created a computed column to sum the data the pie chart series is using. Next I created a persistent global variable to store this value so it can be recalled later in the chart script.Then I use the following script. function beforeDrawDataPointLabel( dph, label, icsc ){var totals = parseFloat(icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("totals"));var current = label.getCaption().getValue(); current = current.replace(",","");var percentage = parseFloat((current/totals)*100); label.getCaption().setValue(percentage +"%"+" ("+ current +")")} First it retrieves the value we stored in the PGV and store the current series value. Next I removed the comma so I can use parseFloat() to convert it from a string. Then I’m able to calculate the percentage with var percentage = parseFloat((current/totals)*100); Finally I set the series label with the new value.  Some other posts worth taking a look at: PageNumber TOC links do not work in Word Link US Map Gadget to other Gadget Reports Count of columns and get column names in fetched dataset Here are some unanswered posts from this week: Issue in report after migrating to Birt 4.2 Displaying multiple dynamic filter parameters in report sub-title as a “human readable” string Pie Chart Drill Down If you have a suggestion or solution for any of these, please post in the thread!As the week comes to an end I hope everyone has a good week! 

Read More

Colored Vertical Bar on One Side of the Report, Multiple Parameters Not Passed to Sub Report, Who is Viewing My Report

This week I got to work on another chart formatting question. He wanted to know how to start a line chart on the y axis instead of set off to the side. To do this we can set the area format insets to make the chart look like this. You can easily do this from the chart builder UI > Format Chart > Plot > Area Format. Here you can set the left inset to a negative value so the series will start on the y axis. Giving the inset a negative value in 4.2 will result in an error, this can be ignored.Some other posts worth taking a look at: Colored vertical bar on one side of the report Multiple Parameters not passed to sub report Who is viewing my report Here are some unanswered posts from this week: Export to word/ppt problem on Mac OS Dual group in the same axis for 3D Charts Birt report – Display data in table if user has access If you have a suggestion or solution for any of these, please post in the thread!As the week comes to an end I hope everyone has a good week! 

Read More