Home
Analytics
Tree view of Legend?
jrep
I'm building pie charts of data with hierarchical structure. Can I get that structure displayed in the Legend? I see I can use controls to "group," but it seems to act only on the displayed chart (I get multiple pies), not the Legend (I still get only a straight list of the categories--grouped, it's true, but not visually distinguished as such). Attachment shows this state.
The data is download counts for various files from various projects in an open-source development site. Some files are present in more than one project; most projects offer more than one file.
My data looks something like this:
value file proj
100 file1 proj1
95 file2 proj1
90 file1 proj2
85 file3 proj3
I don't much care, either way, whether the pie chart gets chopped into little pieces (the effect I have managed to achieve), but I wish I could structure the legend list based on the project grouping:
proj1
..file1
..file2
proj2
..file1
proj3
..file3
Or, actually actually, I just need some way to get the project name and the file name into the chart. I can concatenate the, but they're longer than the area the layout allows for them.
Find more posts tagged with
Comments
mwilliams
Hi jrep,
Where are you doing the concatenation at? In a computed column or are you editing the legend items with the new label value?
jrep
<blockquote class='ipsBlockquote' data-author="mwilliams"><p>Hi jrep,<br />
<br />
Where are you doing the concatenation at? In a computed column or are you editing the legend items with the new label value?</p></blockquote>
<br />
Currently, I'm selecting concat(f1, " (", f2, ")"). But I also select the separate columns. When I group, I group by the un-concated column.<br />
<br />
But I'm happy to change any of that if this offers a solution!
mwilliams
Hi jrep,
Can you put a small sample of data like you posted above in a .csv file and create a quick sample report set up the way you're doing it so I can run it and test on it? If not, can you describe what you're putting for your series value, your category value, optional grouping, etc.? Thanks.
jrep
OK, the attached zipchive contains:
birt/bugreport.rptdesign - a report template containing a single, grouped, pie chart, representing my best attempt at what I want. This is the same layout as in the original report (though the data is not identical).
birt/data/ - a CSV data source (i.e., directory containing .csv files, though only one as it happens) for the report template above.
birt/Birt Report Viewer.pdf - how the resulting report looks on my screen.
birt/hierarchy.sql - the actual SQL used to select the data from the true data-warehouse DB. Not directly involved in this example, but thought it might be interesting
As originally noted:
- the report chart has multiple pies; I can live with this but would prefer a single pie
- the report legend is grouped by the (undisplayed) column "project," which seems to have the effect of ordering the legend lines, but I was hoping for something that more visibly manifests the project info, such as a tree view.
- the legend lines (data column 'File') are composed by concat() during the SQL query, as you can see in the included SQL. This was an attempt to get the project info into the legend as a substitute for the tree view. Even this fails, though, as long names are truncating (with ellipsis) several legend lines. Having the project appended to the file name is not necessarily desired, it's just one of several attempts to get the grouping more visible.
mwilliams
jrep,
The only ways you'll be able to get the entire name to show in the legend that I know of are either to increase the size of the chart or increase the percentage of the chart width allowed to the legend. The default is 33%, so if you increase the chart size enough so that 33% of the size is big enough, you'll fit the legend values. Otherwise, you can open the chart editor, go to the format chart tab, go to the legend section, click on the layout button, and increase the max percent to a value large enough to fit your category names.
As for the grouping layout, I don't think the tree view will be possible. However, if you sort your dataSet by Project, then by file name, your chart should follow that order, so the legend would be "grouped" in that fashion. Since we're using a flat file with this example, I had to do my sorting in a table and use it as the data for the chart, but you can see in the attached file that I was able to achieve the same grouping in the legend that you had with only one pie and by setting the max percent to a higher value, I can see all the legend values.
Hope this helps.
jrep
Thanks.
I can't sort the data set by two columns because then my limit clause is applied inappropriately: the full data set has thousands of lines (thousands of different downloads), and I want to graph "the 20 most commonly downloaded files for the entire site." If I double-group in the SQL, then I get "all of the files from the project with the most-active download, then all of the files from the project with the most-active remaining download," and so on, up to my limit. In practice, I'd get info for only one project, and not even all of that, because the most-active download is in a project with many (mostly boring) downloads. So at the SQL level, I need to hold my grouping to "file X project," order, limit the row count, and *then* regroup and reorder for useful presentation.
Is there some way to get the "Edit Chart" dialog to apply a two-dimensional grouping? I can't find one, and your suggestion that I do that in the SQL seems to imply there isn't one, but I thought I'd ask....
mwilliams
jrep,
If I'm understand correctly, I don't think you'll need to do any grouping in your SQL, just sorting to get the items in the order you'd like to make the legend appear to be grouped. After that, you should be able to use a filter on the the chart to only allow the top N downloads. Like if in the example I posted back, if I wanted just the top 5 files in the chart, I'd set a filter of row["downloads"] topN 5. This would give me the top 5 downloads regardless of the order of the dataSet. Let me know.
jrep
I think you're suggesting that I
- Use the sort capabilities of the database to get things in the right presentation order
- Don't mess with grouping or order within BIRT
- Use a BIRT filter to limit the actual rows used to make up the data set
Sounds good, but it doesn't seem to work. I think BIRT is sorting on the Category Definition column, even though it's marked as "Unsorted." Since the alpha-sort of the file names doesn't in general match the number-sort of their download count, this changes the sort order. See attached screen shot: the three project-subclipse files are grouped and listed in download-count-order in the "data preview" list, as desired, but in the "chart preview" above they're reordered to name-order. (The actual report matches the chart preview.)
I checked all the sort-order buttons in the Chart Editor, and they're all "Unsorted"; also, my read of the XML for this chart (also attached) is that there are no SortKeys specified. My expectation would then be that the data order is not changed by BIRT. But my observations seem otherwise.
For the "Filter" part of the solution, you had suggested a chart-level filter, which seemed to require adjusting the global "data set editor preview page number of rows to display," because the interesting files aren't all within the first 500 (I'm surprised: labels imply this setting only affects the preview, not the ultimate report), after which I got the wrong results described here. So I tried demoting the filter to a Data Set-level filter(TopN). Same results. I mention this primarily because the attached .rptdesign is the "filter at data set" form, rather than your recommended "filter at chart" form.
BIRT is 2.5.2.v20090925, build v20100210-0630
jrep
In addition to all the other things I had to do, I also had to uncheck "Enabled" in the Chart Editor's "Group and sorting" dialog, "Grouping" area, for the Category Definition. That allows the underlying Data Set's order to shine through.
Final, working report attached (this conversation has been all about the last chart on the page).
mwilliams
jrep,
I had suggested the chart level filter or filtering a table and using it as your source because I thought maybe you were using other data from the dataSet elsewhere. If not, definitely limiting the dataSet would probably be the most efficient. Either way, glad you got it working. Hopefully I was of some help. Let us know whenever you have questions.