Discussions
Categories
Groups
Community Home
Categories
INTERNAL ENABLEMENT
POPULAR
PUBLIC CLOUD
PRIVATE CLOUD
Quick Links
MY LINKS
HELPFUL TIPS
Back to website
Home
Intelligence (Analytics)
Displaying Data on an image.
vensw
Hello People,
I am working on BIRT. I have an issue of displaying data on an image. I took that image as a background and then in the layout editor I am trying to insert the data on the image using a table. I tried displaying the data using trial and error method but nothing worked out for me. The image has multiple blocks and are not linear. So, help me out guys how can I print the data exactly on the blocks under the names in the blocks.
Thanks!!
Find more posts tagged with
Comments
mwilliams
Is it static data that you're tying to put on the image? Or dynamic data from your dataSet?
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75605" data-time="1302190211" data-date="07 April 2011 - 08:30 AM"><p>
Is it static data that you're tying to put on the image? Or dynamic data from your dataSet?<br /></p></blockquote>
<br />
Thanks for the reply Williams. As of now I am working on sample data given to me. It's actually static but later I'll be getting the data as dynamic. Please help me out with this. ASAP.<br />
<br />
Thanks!!
mwilliams
You're not able to set the background image of a grid or table and do this? If it's a text rotation issue, have you tried using the rotated text element plugin?
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75620" data-time="1302195292" data-date="07 April 2011 - 09:54 AM"><p>
You're not able to set the background image of a grid or table and do this? If it's a text rotation issue, have you tried using the rotated text element plugin?<br /></p></blockquote>
No, you got it wrong. I'm tryin to insert data on an image. I set the image as background in the master page since I was not able to insert data on it. In the layout editor I'm inserting the data. Task is to display data on that image according to the corresponding values of the names on that block. Okay, let's make it easy. Let's say for our comfort we have a US map with different state names displayed on it and it is a image file. Now, we have to display the total population in each state below the name of the state. what's the approach for it. How can we display the data below the name of the state.
mwilliams
It is probably going to be pretty difficult. If you're only using HTML, you could create bookmarks for all of your values and use client side script in a text control to absolutely position all the values. This is a very limited option though, since it doesn't work in PDF.
The only other way I can think of would be to make your entire page a grid and then use grids within that grid to get all of your text boxes where you want them.
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75639" data-time="1302211617" data-date="07 April 2011 - 02:26 PM"><p>
It is probably going to be pretty difficult. If you're only using HTML, you could create bookmarks for all of your values and use client side script in a text control to absolutely position all the values. This is a very limited option though, since it doesn't work in PDF.<br />
<br />
The only other way I can think of would be to make your entire page a grid and then use grids within that grid to get all of your text boxes where you want them.<br /></p></blockquote>
<br />
Thanks for the reply but I did tried the way you said earlier but the data is not displayed as per the requirement and I'm missing alignment too. So as of now I am working on the alignment. Using some logic I tried to display data on the grid right below the state but I'm missing the alignment. Goal is to display the report in pdf format. So trying hard for it.
mwilliams
Here's an example of using grids to get the data where you want it. Like I said, it's not going to be a simple task to do this as BIRT wasn't exactly made to do this sort of thing. Save the image in your resource folder. Everything else is set up to run. When you run the report, the label will be right under the word Texas on the map.
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75664" data-time="1302272135" data-date="08 April 2011 - 07:15 AM"><p>
Here's an example of using grids to get the data where you want it. Like I said, it's not going to be a simple task to do this as BIRT wasn't exactly made to do this sort of thing. Save the image in your resource folder. Everything else is set up to run. When you run the report, the label will be right under the word Texas on the map.<br /></p></blockquote>
<br />
Well, grid does not have the ability to read multiple values of an attribute in the data set. I already did this but this didn't work. But anyways, will try to run the file in the attachment. Coming to the issue which I am facing I created a style sheet and applied the style to the data set attribute in the map. Its nothing but creating many style sheets and applying the same to the corresponding data set element. Then I tried using a table in the grid and on that gave a filter condition for the data set element so that if the name of the state equals to xxxx then the corresponding population of that state should be displayed. But I see no change in the alignment. This is done by dragging the data set element in the detail row and placing it in detail row in that table. This is done by using a grid in the layout and having the image in the resource folder. But, it didn't work.
mwilliams
Using grids would take a lot of time to get set up perfectly, I'm sure, but I don't know that there's going to be a better or different way to do it. To get the correct dynamic data, you won't be able to just drop a column into your grid cell if there are multiple rows from a dataSet you'll need to use. You'll most likely have to create some sort of array or hash map in the onFetch of your dataSet and use script to select the correct data to display in each element in your design. As I said before, BIRT wasn't made to put labels on an image. It can do it, but it'll take a lot of work, I'm sure. At least in an application like labels under state names in an image of the US.
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75682" data-time="1302289684" data-date="08 April 2011 - 12:08 PM"><p>
Using grids would take a lot of time to get set up perfectly, I'm sure, but I don't know that there's going to be a better or different way to do it. To get the correct dynamic data, you won't be able to just drop a column into your grid cell if there are multiple rows from a dataSet you'll need to use. You'll most likely have to create some sort of array or hash map in the onFetch of your dataSet and use script to select the correct data to display in each element in your design. As I said before, BIRT wasn't made to put labels on an image. It can do it, but it'll take a lot of work, I'm sure. At least in an application like labels under state names in an image of the US.<br /></p></blockquote>
<br />
Thanks for your help. Appreciate all of it.
mwilliams
You're welcome. Sorry I couldn't tell you a painless way to do it. Let us know whenever you have questions.
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75688" data-time="1302292519" data-date="08 April 2011 - 12:55 PM"><p>
You're welcome. Sorry I couldn't tell you a painless way to do it. Let us know whenever you have questions.<br /></p></blockquote>
<br />
That's okay. But thanks for the solution.
vensw
You showed me how to do with population for one state but if it's for multiple states, let say we wanted to display the population for New Jersey. How can we insert the figure on that state. And, I saw another post in the forum and even he has the same issue which I have but you gave the solution with the output format as HTML. I tried doing that way but the number is not exactly positioned on the state which I intend to display. You inserted a text on the layout with HTML formatting. Can you explain me how you did that. Thanks!!
mwilliams
Doing it for another state would require the same thing as what I did for Texas. As I said, it will be a lot of work to get the setup correct for something like the values for states. Lots of merging of grid cells and grids inside of grid cells to get everything to sit exactly where you want it. If your image had a simpler layout, it'd be easier. The way it was done in the other post will not work for PDF, that's why I didn't show you that. The way that is done is by adding a bookmark to the element that you want to dynamically place. Then, in the text box, you use HTML script tags to enter client side script to make an absolute position for the bookmarked element. You'd have to do this for all the elements you want to place on your image. But, like I said, this only works in HTML outputs, not with PDF, so I didn't think it'd be an option for you.
vensw
Hey Williams,
Referring to the post on 08 April 2011, you gave me a solution by saying that we need to use an array or a hash map in the onFetch of the dataSet and use script to select the correct data to display in each element in your design. Could you elaborate on that, how to use array or a hash map on the dataset. Thanks!!
mwilliams
Well, in your onFetch method of your dataSet is where the rows are retrieved from your database. So, in this method you have access to all the data in the dataSet one row at a time. You could use an array or hash map to store the values as each row comes through and then you'd need to be sure you knew which values to pull out of your array where for your display. Another way you could do it would be to set persistentGlobalVariables. For example if your dataSet has a field called state(string) and another called population(int), you could set your PGV like:
reportContext.setPersistentGlobalVariable(row["state"],row["population"].toString());
Now you'd have a PGV named after each state in your dataSet with the value of its population, so in your elements in your layout, you could recall these values by their state:
reportContext.getPersistentGlobalVariable("Texas");
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75842" data-time="1302705013" data-date="13 April 2011 - 07:30 AM"><p>
Well, in your onFetch method of your dataSet is where the rows are retrieved from your database. So, in this method you have access to all the data in the dataSet one row at a time. You could use an array or hash map to store the values as each row comes through and then you'd need to be sure you knew which values to pull out of your array where for your display. Another way you could do it would be to set persistentGlobalVariables. For example if your dataSet has a field called state(string) and another called population(int), you could set your PGV like:<br />
<br />
reportContext.setPersistentGlobalVariable(row["state"],row["population"].toString());<br />
<br />
Now you'd have a PGV named after each state in your dataSet with the value of its population, so in your elements in your layout, you could recall these values by their state:<br />
<br />
reportContext.getPersistentGlobalVariable("Texas");<br /></p></blockquote>
<br />
<br />
How can I set the PGV and where do I write the reportContext set and get methods. The datasource is xml file.
mwilliams
The setPGV would be done in your onFetch() script of your dataSet. The getPGV would be called in your dynamic textbox or whatever you're using to display your data in your report.
To set a PGV, you just need to have a string name (the first value in the parentheses, in this case row["state"]) and an object to store in it. It can be in string form or an array object or something (In this example it was row["population"].toString()). If your row data was state = Texas and population = 20000000, you'd have a pgv named Texas with a stored value of "20000000", which you would recall in your dynamic textbox with the getPGV statement above.
Let me know if you have questions.
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75857" data-time="1302727675" data-date="13 April 2011 - 01:47 PM"><p>
The setPGV would be done in your onFetch() script of your dataSet. The getPGV would be called in your dynamic textbox or whatever you're using to display your data in your report.<br />
<br />
To set a PGV, you just need to have a string name (the first value in the parentheses, in this case row["state"]) and an object to store in it. It can be in string form or an array object or something (In this example it was row["population"].toString()). If your row data was state = Texas and population = 20000000, you'd have a pgv named Texas with a stored value of "20000000", which you would recall in your dynamic textbox with the getPGV statement above.<br />
<br />
Let me know if you have questions.<br /></p></blockquote>
what is onFetch() script. Where can we write the onFetch script. Could you please explain. Thanks !!
mwilliams
If you select your dataSet in the data explorer and then click on the script tab under your design window, you'll see a drop down box at the top. In that drop down, select onFetch. You'll now be in the onFetch method script area.
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75871" data-time="1302783631" data-date="14 April 2011 - 05:20 AM"><p>
If you select your dataSet in the data explorer and then click on the script tab under your design window, you'll see a drop down box at the top. In that drop down, select onFetch. You'll now be in the onFetch method script area.<br /></p></blockquote>
Appreciate your patience in explaining this. Thanks a lot!!
mwilliams
Not a problem at all!
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75880" data-time="1302789336" data-date="14 April 2011 - 06:55 AM"><p>
Not a problem at all!<br /></p></blockquote>
I implemented what you said, wrote set method in onFetch and in the layout I'm using grid. So, I wrote get method but it didn't work out. The data is not displayed on the pdf file. I also tried using dynamic text but it didn't work either. Need your help on this. Thank you !
mwilliams
Can you attach your design file? If you cannot because of company rules, can you create a simple recreate with the sample database and attach that in here?
mwilliams
Actually, before you do that, I might have an idea on what it is. Do you have anything in your report design that is bound to the dataSet? If not, bind your dataSet to the most outer grid or put a text element at the very top of your report, bind it to your dataSet, and then hide it using the visibility in the property editor. If your dataSet is not bound to an item at all or not bound to an item prior to where you're trying to access data from the dataSet, it will not run or won't run in time, so you'll never get your values.
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75888" data-time="1302792812" data-date="14 April 2011 - 07:53 AM"><p>
Actually, before you do that, I might have an idea on what it is. Do you have anything in your report design that is bound to the dataSet? If not, bind your dataSet to the most outer grid or put a text element at the very top of your report, bind it to your dataSet, and then hide it using the visibility in the property editor. If your dataSet is not bound to an item at all or not bound to an item prior to where you're trying to access data from the dataSet, it will not run or won't run in time, so you'll never get your values.<br /></p></blockquote>
I am trying to solve by binding the data set. If that works, fine or else will upload the data source file and the rptdesign file. Thanks for the solution.
vensw
Thanks for the solution. It's working but my task is to display population in other states as well. How do I do that. Since, I'm using grid eventually it takes only value of a state but the population of other state is not displayed.So, is there any script or something I need to write to display the values of other states. And as you said wrote the get and set methods but it popping an error. The error is "reportContext.setPersistentGlobalVariable(row["state"],row["population"].toString());" and the Reference error is row is not defined. I'm writing the get method in the expression field of dataset element. Did I do anything wrong or else is it correct?
vensw
Can I find the solution for this in the book "BIRT A field Guide" of Third Edition. Can you suggest any? Or can I find it in the other one "Integrating and Extending BIRT".
mwilliams
Can you just attach your report design and I'll take a look at what you've done?
vensw
<blockquote class='ipsBlockquote' data-author="'mwilliams'" data-cid="75925" data-time="1302822555" data-date="14 April 2011 - 04:09 PM"><p>
Can you just attach your report design and I'll take a look at what you've done?<br /></p></blockquote>
sure..will do that