Stretching a CrossTab's Cell Horizontally - jasper-reports

How would I get a value cell [in a CrossTab widget] to stretch horizontally, rather than vertically? Stretch on overflow stretches the cell vertically, rather than horizontally.

Background
If I recall correctly, cells in JasperReports were neither designed nor implemented to stretch horizontally. This was a conscious decision made by the lead developers.
You can make them stretch by generating the cross-tab cells according to the width of the data (that sentence alone should give you a feel for the scope of creating a generic solution to this problem). It is possible, but would involve creating your own class using the JasperReports API.
Imagine you have 100,000 rows of data and want the cell to auto-fit to the longest string. JasperReports would have to do one of two things:
Generically modify the developer's SQL statement to query the longest string in each of the corresponding columns before running the final SQL statement. This effectively runs the query twice. If the query uses a volatile function call, then all sorts of problems can happen.
Query all the rows and then determine the longest string. For queries under 10,000 records, this is not a problem. Scaling up to 100,000 rows imparts a large performance hit, and would eat a fair chunk of RAM.
Then you have to answer questions about white space: trim or not to trim? If the reporting software trims it, then the data coming back isn't a true representation of the information in the database. If the data isn't trimmed, then that cascades to more problems (such as unexpectedly super-long columns that look "empty"). Or you can make it one more thing that the developer needs to do.
It is not a trivial problem.
Alternatives
Try DynamicJasper.

Related

How do I reduce the area of the bar graph and increase that of the text in Grafana? (make labels more readable)

I have long strings as labels which is the full identifier of each deployment. How do I increase the area that the strings occupy and reduce the area for the bar graphs in Grafana.
After many attempts, this is the closest that I have come to displaying label strings in a way that is readable. Ideally a table would also be nice, but I was unable to show a table in which the labels form a column (it always took the row)
You can't change that size. I would rather focus how to make labels shorter. (I would say that "max_Sum/" is not necessary there)
IMHO: the best option is to have a table panel for this - yes, you wasn't not able to achieve it, but you only need right query, result format + transformation eventually.

Crystal Reports: Shift other cells down to avoid overlap

I have a field that can grow vertically and potentially overlap other fields. Is there a way to avoid this overlap? I I wan't all the data to show, I'd like for the other fields to be shifted down as the cell grows. I haven't found something similar online as of yet.
Answered my own question. Place everything that might overlap in one text box and then format accordingly.

GtkTreeViewColumn resizing based on contents

So it turns out that we'd like to use fixed height mode, because it's faster and it doesn't constantly try to update the treeview — we saw a significant decrease in CPU use with a table that, unfortunately, may contain a few thousand rows and some 20-ish columns.
Oddly enough, merely turning off autosizing on all the columns doesn't help, one needs to set fixed height mode too.
But of course, the cell contents are of varying length (they're text and numbers), and it would be nice to update the column size time to time (ie. when I know they should be updated, and not all the time like autosizing unfortunately does).
So what I need is being able to figure out that the newly inserted row / cell has insufficient size (I guess something to do with the GtkCellRendererText and Pango will come handy), and then resize the affected GtkTreeViewColumn using set_fixed_width. I've looked at the source of GTK+ to see what they do when autosizing, but couldn't really make head or tails of it. My main problem here is getting to the text layout and/or the cell size requirements from a given TreeView/ListStore/iter combination.
I use perl-Gtk2, but answers are welcome in any commonly used language.

Data structure for page layout like CSS floats

Suppose I have my own markup language that allows me to consume an array of TextElements and ImageElements. Each of these can have properties like "float: left/right/none" and "clear: none/left/right/both". Additionally, non-floated elements can flow around floated elements. Basically, all like CSS float layout.
For example:
Elem1 Elem2
Elem3
Elem4 Elem5 _Elem6
What's the best data structure to use to store these elements while I'm laying them out? I need something which makes it easy to answer questions like:
Is there enough space to fit Element2 left or right of Element1?
What's the page coordinates of Element1, origin and size?
I'll basically store a structure like:
{ Element, Origin(x, y), Size(w, h) }
for each already-laid-out element in this data structure.
There are things like RTrees, QuadTrees and such, but I want something simple to abstractly represent the layout of rectangles on a page for use in my layout algorithm.
NOTE: I am not doing this in HTML, it is for layout of elements in an iOS App, and I cannot use iOS 6 constraints since I need to support earlier iOS versions.
Thanks!
I believe that a binary heap could be made to work for what you want. Wikipedia explains binary heaps quite well.
The binary heap has two properties that make it nice for what you want:
It is a complete tree, which resembles structurally a laid-out page of elements.
The nodes are ordered such that each node is greater (or less, depending on which you want) than its children. In your case, "greater" means "placed further left and towards the top".
You have a list of elements that, in the absence of floats, would be laid out sequentially, wrapping lines as necessary. Thus, building a heap in the absence of floats would simply add nodes to the tree in the order they are received.
Floats complicate this, because they are placed higher than the nodes that preceded them (or lower than those that follow them in the case of right floats). Fortunately, building a heap allows for this by bubbling new nodes up to their proper place. So, as long as you can define a function that orders a floated element with respect to its peers, this can work.
It's that if that I'm not sure about, and unfortunately, I don't have enough time right now to explore the idea more completely.
Anyway, presuming you have a correct heap, repeatedly removing the topmost element should enumerate the nodes in the order they should be placed on the page.
I think CHDataStructures has a binary heap, but I can't verify that since the server where the documentation is kept seems to be offline at the time of posting.
Good luck and I hope this is helpful.

Is it possible to determine the current rendering position in Crystal Reports?

i would like to create a conditional keeptogether property depending on the space left on the current page, is it possible to get this value from within a formula field?
my goal is a visual clean report without wasting to much space, i already read about a method where you keep track of your position with a linenumber counter. unfortunately i cant use this approach because my lines vary heavy in height because of a note field which holds from 0 to 25 lines.
This is going to sound like a ridiculous and tedious suggestion, but it's the only way I know of making this work. You'll need to use that process of line counting (basically, keeping a running total of how many lines have been printed) that you heard of with one modification: calculate the number of lines Notes needs by the getting the length of that Notes string and dividing by a pre-determined count, which you'll need to do visually, of how many characters are in a line and make the result the line's line count in the overall formula. It's not going to be exactly right because there is no way to make it exactly right, but it will be close. Does that makes sense or do you need me to go into exact detail of how to do this?