Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » fixed chart bar width(fixed chart bar width)
fixed chart bar width [message #886266] Thu, 14 June 2012 15:19 Go to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
I need to assign a fixed bar width in the chart, I have a report here it contains 3 chart in this report, I have workgroup name for axies and central offices for each workgroup, Im using afterDataSetFiled assigned dynamic block bounds for each work group, this park is ok, now I got dynamic block width. but when 1 work group contains a lots central offices in this workgroup bars getting really thin, and if they have same number of central offices the label on the bar become stack on each other make user hard to read.

var totalBars = 0;

function afterDataSetFilled( series, dataSet, icsc )
{
totalBars = dataSet.getValues().length;
if( dataSet.getValues().length > 9 ){
icsc.getChartInstance().getBlock().getBounds().setWidth(110*dataSet.getValues().length);
//icsc.getChartInstance().getBlock().getBounds().setHeight(300);
}else if(dataSet.getValues().length == 1){
icsc.getChartInstance().getBlock().getBounds().setWidth(600);
}else{
icsc.getChartInstance().getBlock().getBounds().setWidth(200*dataSet.getValues().length);
//icsc.getChartInstance().getBlock().getBounds().setHeight(400);
}
}

is there any way I can assign a fixed bar width for each bar? so they can display the same width for each bar?

here is my rptdesign file, please take look, when it has a lot central offices in one workgroup.

Thanks for your help
Re: fixed chart bar width [message #886268 is a reply to message #886266] Thu, 14 June 2012 15:25 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
forgot to say Im using BIRT 2.6.2. And if there is a way I can get the count of legends thay will help too I can add it into afterDataSetFiled method to calculate the block bounds. That will fix the problem too, and there is another problem is some bars doesnt have value(the count for this bar is 0), but in the chart it still shows in there as a empty space, is there any way I can make empty bars not displayed in the chart?

Thanks
Re: fixed chart bar width [message #889800 is a reply to message #886268] Tue, 19 June 2012 16:57 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
Anybody can give me a help?
Re: fixed chart bar width [message #889847 is a reply to message #889800] Tue, 19 June 2012 22:02 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Take a look at the attached examples that show some bar manipulations.
Widths are determined by unit spacing.

Jason


On 6/19/2012 12:57 PM, Hao Song wrote:
> Anybody can give me a help?
Re: fixed chart bar width [message #890006 is a reply to message #889847] Wed, 20 June 2012 14:34 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
Thank you very much for your help Jeason, finally I have some answer, I do have code to determine the units spacing too, but number of workgroups and number of central office are not fixed, they could be a large number for both, when number of groups greater than 9, I set unit spacing to 10, but that will not fix when in each block have a lots bars(lets say 18 bars in one block), in this situation, even I set units spacing to 0, it still makes bars really thin, and when two bars sit beside each other with the same hight, the label of the bar(there is a counts label on top of each bar) become stack on each other, or too close to each other. Is there any way I can get the counts in the legend area? so I can add it to determine the width of each block. I am not sure I explained this well enough or not, if not please let me know I will give more informations.

Thank you very much

var totalBars = 0;

function afterDataSetFilled( series, dataSet, icsc )
{
totalBars = dataSet.getValues().length;
if( dataSet.getValues().length > 9 ){
icsc.getChartInstance().getBlock().getBounds().setWidth(110*dataSet.getValues().length);
//icsc.getChartInstance().getBlock().getBounds().setHeight(300);
}else if(dataSet.getValues().length == 1){
icsc.getChartInstance().getBlock().getBounds().setWidth(600);
}else{
icsc.getChartInstance().getBlock().getBounds().setWidth(200*dataSet.getValues().length);
//icsc.getChartInstance().getBlock().getBounds().setHeight(400);
}
}

function beforeGeneration( chart, icsc )
{
if(totalBars < 10){
chart.setUnitSpacing(40);
}
if(totalBars > 9){
chart.setUnitSpacing(10);
}
}
Re: fixed chart bar width [message #890070 is a reply to message #890006] Wed, 20 June 2012 21:51 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

On the bar question can you post a picture? You also may want to turn
your data point labels to 90 degrees rotation. What are you displaying
in your legend. What you display will determine how to count it.

Jason


On 6/20/2012 10:34 AM, Hao Song wrote:
> Thank you very much for your help Jeason, finally I have some answer, I
> do have code to determine the units spacing too, but number of
> workgroups and number of central office are not fixed, they could be a
> large number for both, when number of groups greater than 9, I set unit
> spacing to 10, but that will not fix when in each block have a lots
> bars(lets say 18 bars in one block), in this situation, even I set units
> spacing to 0, it still makes bars really thin, and when two bars sit
> beside each other with the same hight, the label of the bar(there is a
> counts label on top of each bar) become stack on each other, or too
> close to each other. Is there any way I can get the counts in the legend
> area? so I can add it to determine the width of each block. I am not
> sure I explained this well enough or not, if not please let me know I
> will give more informations.
>
> Thank you very much
>
> var totalBars = 0;
>
> function afterDataSetFilled( series, dataSet, icsc )
> {
> totalBars = dataSet.getValues().length;
> if( dataSet.getValues().length > 9 ){
>
> icsc.getChartInstance().getBlock().getBounds().setWidth(110*dataSet.getValues().length);
>
> //icsc.getChartInstance().getBlock().getBounds().setHeight(300);
> }else if(dataSet.getValues().length == 1){
> icsc.getChartInstance().getBlock().getBounds().setWidth(600);
> }else{
>
> icsc.getChartInstance().getBlock().getBounds().setWidth(200*dataSet.getValues().length);
>
> //icsc.getChartInstance().getBlock().getBounds().setHeight(400);
> }
> }
>
> function beforeGeneration( chart, icsc )
> {
> if(totalBars < 10){
> chart.setUnitSpacing(40);
> }
> if(totalBars > 9){
> chart.setUnitSpacing(10);
> }
> }
Re: fixed chart bar width [message #890289 is a reply to message #886266] Thu, 21 June 2012 18:56 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
Hi Jason:

Thank you very much for your help, here are the pictures for what it looks like on my computer, maybe after you see these pictures you will know what I mean.

Again thank you.
Re: fixed chart bar width [message #890292 is a reply to message #890289] Thu, 21 June 2012 19:00 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
number of workgroups on axies, and number of items in the legend area are unable to predetermined, they could be 1 or they could be over 20.
Re: fixed chart bar width [message #890315 is a reply to message #890292] Thu, 21 June 2012 21:22 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

From the picture it looks like you are using optional grouping. Is
that the case? If so you will know in the afterDataSet filled, because
it will be called once for the category and then once for each of the
optional groups. You could set a variable outside of the function and
then increment it for each and in the legend script reference it. Or in
the beforeRendering event you could try:

var llh = gcs.getRunTimeContext().getLegendLayoutHints();
var itemsize = llh.length;

If there is something specific I can help you write, use the sample db
to show the issue and then I can help you with the script.

Jason

On 6/21/2012 3:00 PM, Hao Song wrote:
> number of workgroups on axies, and number of items in the legend area
> are unable to predetermined, they could be 1 or they could be over 20.
Re: fixed chart bar width [message #890626 is a reply to message #886266] Fri, 22 June 2012 17:33 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
Hi Jason:

Sorry about I reply late, and thanks for your help. Here is a sample I made use sample DB, when you preview this report please set number of rows to display to 15 in the preview preference, it will shows better, I hope you can give me a example on this one that can display bar label(which will be 1 in this case in my own case I will get it from the database) well in each bar,so they dont get too close to each other. I dont care the width of the chart, because after I embedded into our User Interface it will be in a scroll panel, so user can scroll it as far as they want, I just want the count for each bar (which will be 1 in this case in my own case I will get it from the database) that can display well for user(each bar has enough space to display this number inside).

Thank you
Re: fixed chart bar width [message #890713 is a reply to message #890626] Fri, 22 June 2012 22:33 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Can you not just set the master page to a custom size and expand the
chart? See attached.

Jason

On 6/22/2012 1:33 PM, Hao Song wrote:
> Hi Jason:
>
> Sorry about I reply late, and thanks for your help. Here is a sample I made use sample DB, when you preview this report please set number of rows to display to 15 in the preview preference, it will shows better, I hope you can give me a example on this one that can display bar label(which will be 1 in this case in my own case I will get it from the database) well in each bar,so they dont get too close to each other. I dont care the width of the chart, because after I embedded into our User Interface it will be in a scroll panel, so user can scroll it as far as they want, I just want the count for each bar (which will be 1 in this case in my own case I will get it from the database) that can display well for user(each bar has enough space to display this number inside).
>
> Thank you
>
Re: fixed chart bar width [message #891697 is a reply to message #886266] Mon, 25 June 2012 14:17 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
Hi Jason:

Here is the report with the custom in master page, if you mean use this way to slove this problem, I dont think it will, because all the data in the chart come from our database, and you never know how many will be there, and if there is only one central office(data in the legend area) in the database, it will make that bar very wide, if there are a lots central offices in there, it will make bars very thin.
and count of the bars get really close to each other like in this example. so thats what I want to know, is there anyway I can count how many central offices in this chart so I can use the script to set the width of the chart or master page or set the block bounds.If you can give me an example, that will help me a lot.


Thank you very much
Re: fixed chart bar width [message #891773 is a reply to message #891697] Mon, 25 June 2012 20:40 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

If central offices is the field you use for optional grouping (2nd tab
of the chart wizard)? If so in the beforeGeneration you should be able
to get the number of bars using this script:

var xAxis = chart.getAxes().get(0);
var yAxis = xAxis.getAssociatedAxes().get(0);
var ySerieDef = yAxis.getSeriesDefinitions().get(0);
var numOfBars = ySerieDef.getRunTimeSeries().size() );

In the example you posted it will be 110 bars per category, which is
what your script:
totalBars = dataSet.getValues().length;

returns. That script returns seven (the number of categories)

Jason

On 6/25/2012 10:17 AM, Hao Song wrote:
> Hi Jason:
>
> Here is the report with the custom in master page, if you mean use this way to slove this problem, I dont think it will, because all the data in the chart come from our database, and you never know how many will be there, and if there is only one central office(data in the legend area) in the database, it will make that bar very wide, if there are a lots central offices in there, it will make bars very thin.
> and count of the bars get really close to each other like in this example. so thats what I want to know, is there anyway I can count how many central offices in this chart so I can use the script to set the width of the chart or master page or set the block bounds.If you can give me an example, that will help me a lot.
>
>
> Thank you very much
>
Re: fixed chart bar width [message #891911 is a reply to message #886266] Tue, 26 June 2012 14:12 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
Thank you very much Jason, this is exactly what I want, really appreciated your help.
Re: fixed chart bar width [message #891914 is a reply to message #891911] Tue, 26 June 2012 14:34 Go to previous messageGo to next message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
more questions, in each category there are some bars has no value(probably 0), so birt just left an empty space in there, is there anyway I could make them not show in the chart if the value of the bar is 0?
Re: fixed chart bar width [message #891993 is a reply to message #891914] Tue, 26 June 2012 19:08 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

In script you can move bars but the width the entire category takes up
would stay the same, which would kind of defeat the purpose.

Jason

On 6/26/2012 10:34 AM, Hao Song wrote:
> more questions, in each category there are some bars has no
> value(probably 0), so birt just left an empty space in there, is there
> anyway I could make them not show in the chart if the value of the bar
> is 0?
Re: fixed chart bar width [message #893366 is a reply to message #886266] Tue, 03 July 2012 17:34 Go to previous message
Hao Song is currently offline Hao SongFriend
Messages: 11
Registered: June 2012
Junior Member
ok I will leave it like what it looks like now, thank you very much for your help Jason, really appreciated.
Previous Topic:How to color only specific records within list table?
Next Topic:Performance analyasis of BIRT
Goto Forum:
  


Current Time: Sat Apr 20 01:59:03 GMT 2024

Powered by FUDForum. Page generated in 0.04189 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top