Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » BIRT » How to highlight one bar in Bar Chart(Chaneg One Bar color based on user selection)
How to highlight one bar in Bar Chart [message #528918] Thu, 22 April 2010 11:56 Go to next message
Amy  is currently offline Amy Friend
Messages: 29
Registered: April 2010
Junior Member
Hi all,

I'm new to use the BIRT Chart. I created a bar chart.


Y - axis is the amount.
X - axis is the levels. ( 50, 60, 70 , 80...)

When user select a preference level, I need to change one bar color to highlight the user selected.

Can I do this is bar chart?

Thanks in advance!

[Updated on: Thu, 22 April 2010 11:57]

Report message to a moderator

Re: How to hightlight one bar in Bar Chart [message #528949 is a reply to message #528918] Thu, 22 April 2010 13:42 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Amy,

How do they select the level? A report Parameter? Or clicking on the
chart?

Jason

Amy wrote:
> Hi all,
> I'm new to use the BIRT Chart. I created a bar chart.
>
>
> Y - axis is the amount. X - axis is the levels. ( 50, 60, 70 , 80...)
>
> When user select a preference level, I need to change one bar color to
> highlight the user selected.
> Can I do this is bar chart?
>
> Thanks in advance!
>
Re: How to hightlight one bar in Bar Chart [message #529083 is a reply to message #528949] Thu, 22 April 2010 20:37 Go to previous messageGo to next message
Amy  is currently offline Amy Friend
Messages: 29
Registered: April 2010
Junior Member
Jason,

The user select the level done on Java Windon based application GUI part.

I use script to created the datset, outer table has one value tell me which level user selected.

From the inner table, I have all level values display on the chart. I can using data binding to get which level need highlight.

For example: I display data for Level 5, 6,7 and 8 on the chart. I know level 6 need display different color to show user selected.

In this case, how I can make color different on chart?

No color change on click event. The report is PDF.

Thanks!

[Updated on: Fri, 23 April 2010 13:33]

Report message to a moderator

Re: How to hightlight one bar in Bar Chart [message #529221 is a reply to message #529083] Fri, 23 April 2010 13:55 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Amy,

Take a look at this example.

http://www.birt-exchange.org/devshare/designing-birt-reports /1203-set-the-color-of-one-bar-based-on-parameter/#descripti on

Jason


On 4/22/2010 4:37 PM, Amy wrote:
> Jason,
>
> The user select the level done on Java Windon based allpication GUI part.
>
> I use script to created the datset, outer table has one value tell me
> which level user selected.
>
> From the inner table, I have all level values display on the chart. I
> can using data binding to get which level need highlight.
> For example: I display data for Level 5, 6,7 and 8 on the chart. I know
> level 6 need display different color to show user selected.
> In this case, how I can make color different on chart?
>
> No color change on click event. The report is PDF.
>
> Thanks!
>
>
Re: How to hightlight one bar in Bar Chart [message #529325 is a reply to message #529221] Fri, 23 April 2010 19:48 Go to previous messageGo to next message
Amy  is currently offline Amy Friend
Messages: 29
Registered: April 2010
Junior Member
Jason,

Thank you so much!

I tried this and the bar color chaneged on my chart !

But I still have a question for how I get the userSelected value pass in this function.

You use this:
var hl = icsc.getExternalContext().getScriptable().getParameterValue( "HighlightColumn");
to get the user input.

I hard code the vlalue: var hl = 60; It works for my Level 60.

I don't know how I can set value hl based on the outer table data.

I have the user selected value in outer table.

For inner table, display chart .

I try this:

var hl = row._outer["CCCovLevel"] ;

This didn't work.

I try to create a variable when I create the inner table,:
selectedLevel =0;

Insert a data filed in inner table, binding the outer table data CCCovLevel(60 ).
Increase the variable value based on the outer table data .

selectedLevel = parseInt(this.getValue());


I can display the value 60 in the inner table footer. But

hl ==selectedLevel didn't work.

Can you help ?

Thanks!!!
Re: How to hightlight one bar in Bar Chart [message #529337 is a reply to message #529325] Fri, 23 April 2010 20:45 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

In the outer table you need to put an oncreate script on the data item
that holds the selected value or on a row of that dataset and enter
something like

//on data item
var sv = this.getValue();
//on row - Use this if you are not displaying the value but it is in
//the bindings
var sv = this.getRowData().getColumnValue("NameOfDataBinding");
reportContext.setPersistentGlobalVaraible("selectedbar", sv );

Then in the chart script:
//this returns reportContext
var rc =icsc.getExternalContext().getScriptable();
var sv = rc.getPersistentGlobablVariable("selectedbar");


One other note:
if the selected value is not a string you may have to do something like
var sv = parseInt(rc.getPersistentGlobalVariable("selectedbar"));


Jason
On 4/23/2010 3:48 PM, Amy wrote:
> Jason,
>
> Thank you so much!
>
> I tried this and the bar color chaneged on my chart !
>
> But I still have a question for how I get the userSelected value pass in
> this function.
>
> You use this:
> var hl = icsc.getExternalContext().getScriptable().getParameterValue(
> "HighlightColumn");
> to get the user input.
>
> I hard code the vlalue: var hl = 60; It works for my Level 60.
>
> I don't know how I can set value hl based on the outer table data.
>
> I have the user selected value in outer table.
> For inner table, display chart .
>
> I try this:
>
> var hl = row._outer["CCCovLevel"] ;
> This didn't work.
>
> I try to create a variable when I create the inner table,:
> selectedLevel =0;
> Insert a data filed in inner table, binding the outer table data
> CCCovLevel(60 ).
> Increase the variable value based on the outer table data .
>
> selectedLevel = parseInt(this.getValue());
>
> I can display the value 60 in the inner table footer. But
> hl ==selectedLevel didn't work.
>
> Can you help ?
>
> Thanks!!!
>
Re: How to hightlight one bar in Bar Chart [message #529704 is a reply to message #529337] Mon, 26 April 2010 19:59 Go to previous messageGo to next message
Amy  is currently offline Amy Friend
Messages: 29
Registered: April 2010
Junior Member
Jason,

Thank you so much for the instruction.

It works now.

I really appreciate your help!!!

Amy
How to highlight one bar in Bar Chart and change that highlighted bar label font [message #544474 is a reply to message #528918] Fri, 02 July 2010 19:08 Go to previous messageGo to next message
Amy  is currently offline Amy Friend
Messages: 29
Registered: April 2010
Junior Member
Jason,

I asked you question about how to hightlight one bar in bar chart based on users selected in April. Your answer work well.

Now, I need do more function on top of it. The user want me to change the hightlighted bar label .

Example: If user selected coverage level = 60, ( x = 60, Y =$550) the bar is hightlighted. I set the series label on top of the bar, that label show Y value -> $550. User want to bold that lable and make the font size large.

Can you tell me how I can make this happen?

Thank you so much for your help !


Emily
Re: How to highlight one bar in Bar Chart and change that highlighted bar label font [message #544555 is a reply to message #544474] Sat, 03 July 2010 17:18 Go to previous messageGo to next message
Jason Weathersby is currently offline Jason WeathersbyFriend
Messages: 9167
Registered: July 2009
Senior Member

Emily,

Add a beforeDrawDataPointLabel script like:
function beforeDrawDataPointLabel( dph, label, icsc )
{
var hl =
icsc.getExternalContext().getScriptable().getParameterValue( "HighlightColumn");
if( dph.getBaseDisplayValue() == hl ){
label.setVisible(true);
label.getCaption().getFont().setBold(true);
label.getCaption().getFont().setSize(14);
label.getCaption().getFont().setName("Arial");
}else{
label.setVisible(false);
}

}

This turns off all series labels but the one. If you want them all on
just remove the else.

Jason

On 7/2/2010 3:08 PM, Amy wrote:
> Jason,
>
> I asked you question about how to hightlight one bar in bar chart based
> on users selected in April. Your answer work well.
> Now, I need do more function on top of it. The user want me to change
> the hightlighted bar label .
> Example: If user selected coverage level = 60, ( x = 60, Y =$550) the
> bar is hightlighted. I set the series label on top of the bar, that
> label show Y value -> $550. User want to bold that lable and make the
> font size large.
>
> Can you tell me how I can make this happen?
>
> Thank you so much for your help !
>
>
> Emily
Re: How to highlight one bar in Bar Chart and change that highlighted bar label font [message #545322 is a reply to message #544555] Wed, 07 July 2010 12:57 Go to previous message
Amy  is currently offline Amy Friend
Messages: 29
Registered: April 2010
Junior Member
Jason,

Thank you so much!

The code works well !

Amy
Previous Topic:cube: derived measure as new line
Next Topic:how to change the viewer language labels
Goto Forum:
  


Current Time: Fri Apr 26 17:02:47 GMT 2024

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

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

Back to the top