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)
Chart legend spacing of displayed values - fixed??
b2tech
Hello:
[Using BIRT 3.7}
Has anyone figured out how to change the spacing of the values presented -within- a legend? I have a vertical bar chart that has ten values displayed in a horizontally oriented legend that is set to render below the actual chart.
These values are too long (run under the next value) and it appears that Birt always -evenly- spaces all the legend entries.
I have tried:
icsc.getChartInstance().getLegend().setHorizontalSpacing(25);
in the chart's onRender beforeGeneration(chart, iscsc) area and that did nothing.
I also tried:
chart.getLegend().setHorizontalSpacing(25); and that did not work either.
Note: (My code below may be affecting the above issue or... maybe not)
I already have code for this chart under the function beforeDrawLegendItem( lerh, bounds, icsc ) that will populate the legend values from external variables and also hide the legend value(s) when they are not supplied.
// Evaluate the chart number being layed out.
// Then grab the correct persistent global variable holding the chart legend value for each series
var varone = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("testcnt");
// First series labels
if( lerh.getLabel().getCaption().getValue().compareToIgnoreCase("Series 1") == 0 ){
var slabel = icsc.getExternalContext().getScriptable().getPersistentGlobalVariable("seriestitle-" + varone + "-1");
if (slabel != ""){
lerh.getLabel().getCaption().setValue(slabel);
}
else {
bounds.setHeight(0);
bounds.setWidth(0);
lerh.getLabel().setVisible(false);
}
}
.....etc...
Any help would be greatly appreciated.
BillH
Find more posts tagged with
Comments
JasonW
Can you reproduce with a sample report that we can run?
Jason
b2tech
Actually, this is a generic question pertaining to -ALL- charts. I want to display a legend below a chart. The legend will arrange itself into columns by BIRT depending on the Legend-->Layout-->Max Percent field AND the vertical size set for the overall plot area. OK, so how do I fix the following that is done by the BIRT default rendering:
ugly
_______________________|----overlay
|
[ ]_series_1_label_reall[ ]XXXries_3_label______[ ]_series_5_label_really_long_too
[ ]_series_2_label______[ ] series 4 label______[ ]_series_6_label
to:
[ ]_series_1_label_really long___[ ]_series_3_label_______________[ ]_series_5_label_really_long_too
[ ]_series_2_label____________[ ]_series_4_label_______________[ ]_series_6_label
^^^^^^^^^^^ Z ^^^^^^^^^^^^
How do I pass a value (like 29) in to control "Z". I want the same "Z" value for all entries. I do not need different values on a per entry basis but that would be great if possible too.
Bill
JasonW
Legend Spacing can be difficult. You can use some script to bump the label and graphic to line up the second line. Take a look at the attached example.
Jason