BIRT Exchange Forum: dynamic size of labels in Y-Axis - BIRT Exchange Forum

Jump to content


 

BIRT Poll: To best make a table fill a pdf page before breaking (PL=page layout, PBI=page break interval) set:

PL: auto, PBI: 0PL: fixed, PBI: 0PL: auto, PBI: 1000000PL: fixed, PBI: 1000000
Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

dynamic size of labels in Y-Axis Rate Topic: -----

#1 User is offline   digiSeryog Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 30
  • Joined: 10-February 12


Posted 17 February 2012 - 05:08 AM

hi i have a problem with the Y-axis

i want to modify the labels on the Y-Axis with a dynamic suffix e.g

5,20 MWh
13,20 KWh
1,20 KWh
500,00 Wh

etc

i tried with:

function Wh(val)
{
if(val<1000)
return format("# Wh",val);
else if(val<1000000)
return format("#,## KWh",val/10);
else if(val <1000000000)
return format("#,## MWh",val/10000);
return format("#,## GWh",val/10000000);
}

function beforeDrawAxisLabel( axis, label, icsc )
{
if(axis.getTitle().getCaption().getValue() == "Y")
label.getCaption().setValue(Wh(label.getCaption().getValue()));
}

i works but only if i set a fixed label span with 60 points

but i want to set the span dynamic without fixed!

if i uncheck it some labels are not complete visible :/

is it possible to insert a dynamic size??
0

#2 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 17 February 2012 - 02:31 PM

If you check the data in the AfterDataSetFilled to find how high your data goes or if you find the largest value outside the chart somewhere and pass it in, you can grab the yAxis in the beforeGeneration and set the left inset value for the label accordingly.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#3 User is offline   digiSeryog Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 30
  • Joined: 10-February 12


Posted 18 February 2012 - 12:48 PM

can u give me an example how to set the inset of a label?
0

#4 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 21 February 2012 - 09:38 AM

Yeah. What's your BIRT version? I'll post a simple example.
Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#5 User is offline   digiSeryog Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 30
  • Joined: 10-February 12


Posted 22 February 2012 - 11:50 PM

3.7
0

#6 User is offline   mwilliams Icon

  • BIRT Guru
  • Icon
  • View blog
  • Group: Administrators
  • Posts: 12937
  • Joined: 16-May 08


Posted 23 February 2012 - 10:16 PM

Take a look at this example. Both charts have the same script changing the label values. The second chart has beforeGeneration script changing the axis label inset value. Hope this helps.

Attached File(s)


Regards,

Michael

Twitter
Facebook
Blog
Yahoo: mwilliams_actuate@yahoo.com
Google: mwilliams.actuate@gmail.com
0

#7 User is offline   digiSeryog Icon

  • Advanced Member
  • PipPipPip
  • Group: Members
  • Posts: 30
  • Joined: 10-February 12


Posted 24 February 2012 - 12:08 AM

edit: wrong thread ...
0

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users