Showing posts with label chart. Show all posts
Showing posts with label chart. Show all posts

Wednesday, March 28, 2012

How to change the color of a bar in a bar chart?

I am having a problem setting the colors of the bars in a bar chart. It seems like it would be the simplest thing, but apparently it's not.

The "series" is grouped on whether or not the value is positive -- if so, the bars are blue (by default) and if not, green (by default). I want to change it so the positive color is blue and the negative color is red.

I found that I can change ALL the bars to one color by going to chart properties, Data tab, Values Edit, Appearance tab, Series Style, Fill. There I set the color to red and ALL the bars became red. But this is not what I want.

I tried using a conditional statement like IIf(Fields!IsPositive.Value=True,Blue,Red) for the color, but (not surprisingly), it told me I hadn't defined Blue and Red.

Does anyone know exactly how to do this?

Nobody has even a clue how to do this? I can't find it documented anywhere .. is it impossible?|||

hi there

there is some information on the following link - not sure if it will help but look at figure 14 P10

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/MoreSSRSCharts.asp

cheers

|||

IIf(Fields!IsPositive.Value=True,Blue,Red)

Try to use blue and red in double quotes, it should solve the problem.

i hope by now you figured how to change the colors of the bars , the previous link has all the information, but to be in depth, for your case, you can write a code snippet in the code tab of the report properties by writing a simple vb code. for the logic you want to do it.

you can do something like this, pass a parameter ( i mean the value : fields!Positive.Value )

If (so and so.. )

Color = '03938x'

-- something like this.

Let me know if this helps.

and call this method in the data field properties.

=Code.YourFunc(Parameters)

--

Kishore

|||Yes, thank you very much! Putting the colors in quotes does it (duh!). And that link has great information. Thanks again!|||

Hi!!

I do it in this way: in the "Chart Properties", data tab, I edit the value and in "Appearance" I go to "Series style..." and in fill tab, in Color, I set the next sentence:

=Code.GetColor(Fields!Criticity.Value)

And in the Report Properties, Code tab:

Public Function GetColor(ByVal strCriticity As String) As String
Select Case strCriticity
Case 0
Return "LemonChiffon"
Case 1
Return "Gold"
Case 2
Return "DarkOrange"
Case 3
Return "DarkRed"
End Select
End Function

Well, it works... but this has a problem: if in the bar chart appear the 4 colors in the different rows but the last bar only has 2 of them, in the legend only will appear that two colors, and the other 2 will be by default (a blue and a green, it will depend of the selected palette)...

How can I do it to show the legend with the correct colors?

If I put the code like cedubose:

= Switch (Fields!Criticity.Value = 0, "LemonChiffon", Fields!Criticity.Value = 1, "Gold", Fields!Criticity.Value = 2, "DarkOrange", Fields!Criticity.Value = 3, "DarkRed")

it works different but not correctly, i means, in 3 of the 4 legends appear the same color and in the other legend the another color...

All suggestions will be wellcome... thx!!

|||

Problem solved!!!

If somebody has the same problem, here is the solution:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=13958&SiteID=1

|||

The only way I've found of doing it is to

1) Select Tools/Options/Color

2) Modify the colours in "Chart Fill"

...should be easier, but.

How to change the color of a bar in a bar chart?

I am having a problem setting the colors of the bars in a bar chart. It seems like it would be the simplest thing, but apparently it's not.

The "series" is grouped on whether or not the value is positive -- if so, the bars are blue (by default) and if not, green (by default). I want to change it so the positive color is blue and the negative color is red.

I found that I can change ALL the bars to one color by going to chart properties, Data tab, Values Edit, Appearance tab, Series Style, Fill. There I set the color to red and ALL the bars became red. But this is not what I want.

I tried using a conditional statement like IIf(Fields!IsPositive.Value=True,Blue,Red) for the color, but (not surprisingly), it told me I hadn't defined Blue and Red.

Does anyone know exactly how to do this?

Nobody has even a clue how to do this? I can't find it documented anywhere .. is it impossible?|||

hi there

there is some information on the following link - not sure if it will help but look at figure 14 P10

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/MoreSSRSCharts.asp

cheers

|||

IIf(Fields!IsPositive.Value=True,Blue,Red)

Try to use blue and red in double quotes, it should solve the problem.

i hope by now you figured how to change the colors of the bars , the previous link has all the information, but to be in depth, for your case, you can write a code snippet in the code tab of the report properties by writing a simple vb code. for the logic you want to do it.

you can do something like this, pass a parameter ( i mean the value : fields!Positive.Value )

If (so and so.. )

Color = '03938x'

-- something like this.

Let me know if this helps.

and call this method in the data field properties.

=Code.YourFunc(Parameters)

--

Kishore

|||Yes, thank you very much! Putting the colors in quotes does it (duh!). And that link has great information. Thanks again!|||

Hi!!

I do it in this way: in the "Chart Properties", data tab, I edit the value and in "Appearance" I go to "Series style..." and in fill tab, in Color, I set the next sentence:

=Code.GetColor(Fields!Criticity.Value)

And in the Report Properties, Code tab:

Public Function GetColor(ByVal strCriticity As String) As String
Select Case strCriticity
Case 0
Return "LemonChiffon"
Case 1
Return "Gold"
Case 2
Return "DarkOrange"
Case 3
Return "DarkRed"
End Select
End Function

Well, it works... but this has a problem: if in the bar chart appear the 4 colors in the different rows but the last bar only has 2 of them, in the legend only will appear that two colors, and the other 2 will be by default (a blue and a green, it will depend of the selected palette)...

How can I do it to show the legend with the correct colors?

If I put the code like cedubose:

= Switch (Fields!Criticity.Value = 0, "LemonChiffon", Fields!Criticity.Value = 1, "Gold", Fields!Criticity.Value = 2, "DarkOrange", Fields!Criticity.Value = 3, "DarkRed")

it works different but not correctly, i means, in 3 of the 4 legends appear the same color and in the other legend the another color...

All suggestions will be wellcome... thx!!

|||

Problem solved!!!

If somebody has the same problem, here is the solution:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=13958&SiteID=1

|||

The only way I've found of doing it is to

1) Select Tools/Options/Color

2) Modify the colours in "Chart Fill"

...should be easier, but.

How to change the color of a bar in a bar chart?

I am having a problem setting the colors of the bars in a bar chart. It seems like it would be the simplest thing, but apparently it's not.

The "series" is grouped on whether or not the value is positive -- if so, the bars are blue (by default) and if not, green (by default). I want to change it so the positive color is blue and the negative color is red.

I found that I can change ALL the bars to one color by going to chart properties, Data tab, Values Edit, Appearance tab, Series Style, Fill. There I set the color to red and ALL the bars became red. But this is not what I want.

I tried using a conditional statement like IIf(Fields!IsPositive.Value=True,Blue,Red) for the color, but (not surprisingly), it told me I hadn't defined Blue and Red.

Does anyone know exactly how to do this?

Nobody has even a clue how to do this? I can't find it documented anywhere .. is it impossible?|||

hi there

there is some information on the following link - not sure if it will help but look at figure 14 P10

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/MoreSSRSCharts.asp

cheers

|||

IIf(Fields!IsPositive.Value=True,Blue,Red)

Try to use blue and red in double quotes, it should solve the problem.

i hope by now you figured how to change the colors of the bars , the previous link has all the information, but to be in depth, for your case, you can write a code snippet in the code tab of the report properties by writing a simple vb code. for the logic you want to do it.

you can do something like this, pass a parameter ( i mean the value : fields!Positive.Value )

If (so and so.. )

Color = '03938x'

-- something like this.

Let me know if this helps.

and call this method in the data field properties.

=Code.YourFunc(Parameters)

--

Kishore

|||Yes, thank you very much! Putting the colors in quotes does it (duh!). And that link has great information. Thanks again!|||

Hi!!

I do it in this way: in the "Chart Properties", data tab, I edit the value and in "Appearance" I go to "Series style..." and in fill tab, in Color, I set the next sentence:

=Code.GetColor(Fields!Criticity.Value)

And in the Report Properties, Code tab:

Public Function GetColor(ByVal strCriticity As String) As String
Select Case strCriticity
Case 0
Return "LemonChiffon"
Case 1
Return "Gold"
Case 2
Return "DarkOrange"
Case 3
Return "DarkRed"
End Select
End Function

Well, it works... but this has a problem: if in the bar chart appear the 4 colors in the different rows but the last bar only has 2 of them, in the legend only will appear that two colors, and the other 2 will be by default (a blue and a green, it will depend of the selected palette)...

How can I do it to show the legend with the correct colors?

If I put the code like cedubose:

= Switch (Fields!Criticity.Value = 0, "LemonChiffon", Fields!Criticity.Value = 1, "Gold", Fields!Criticity.Value = 2, "DarkOrange", Fields!Criticity.Value = 3, "DarkRed")

it works different but not correctly, i means, in 3 of the 4 legends appear the same color and in the other legend the another color...

All suggestions will be wellcome... thx!!

|||

Problem solved!!!

If somebody has the same problem, here is the solution:

http://forums.microsoft.com/MSDN/ShowPost.aspx?PostID=13958&SiteID=1

|||

The only way I've found of doing it is to

1) Select Tools/Options/Color

2) Modify the colours in "Chart Fill"

...should be easier, but.

How to change the color of a bar in a bar chart

For the life of me, I can't find how to change the color of the bar in a bar chart.

It seems like it would be a simple thing, but I can't find anything in the properties that seems to relate to it.

I have a bar chart with subtype as "bar chart" -- i.e., just a bar for each data point, either positive or negative. The positive should be blue; the negative red. As it is now, the default color for positive is blue, for negative green, but management does not like that color combo.

Can anyone help?

Thanks in advance...

Hi,

I'm talking out of my hat a bit on this one, but I believe that what you want to look at is the use of "skins" and "themes." I'm guessing two things, that you are talking about a barchart control that you're using and that you are using ASP.Net 2.0 (Skins and Themes aren't available in 1.1). I'm also guessing that you have used CSS to sytle html, but can't find a way to get it work on the control - you need to use skins and themes. Here's a vid to look athttp://msevents.microsoft.com/cui/WebCastEventDetails.aspx?EventID=1032278423&EventCategory=5&culture=en-US&CountryCode=US

There's one other thing to look athttp://asp.net/CSSAdapters/Default.aspx. I haven't tried them myself, but looks like it might help you to get the control to play nice with CSS. Hope it helps. BRN..

|||

Well thanks Brian, but it looks like what you're talking about is HTML -- my problem is with a chart control inside a report using SQL Server Reporting Service.

I did find a way to get it to change the color of ALL the bars -- properties dialog, data tab, values edit, Appearance tab, Fill tab (something like that -- I don't have it in front of me right now). If I change the color of the fill, ALL the bars change to that color.

However, I don't want ALL the bars to be the same color. I have the "series" grouped according to whether the value is positive or negative. By default, RS makes the positive bars blue and the negative bars green. I need the negative bars to be red.

I tried using an expression like IIf(Fields!IsPositive.Value=True,Blue,Red) but it told me (predictably) that I hadn't defined Blue and Red. But I think perhaps the right expression for the "fill" color might work. I just don't know what it is.

|||

Hi,

Not familiar with the control you mentioned (but I'll try to take a look if I have time). CSS does work on HTML, Themes and Skins were built to offer CSS-like capablities to ASP.Net server controls. Server controls don't always map directly to HTML controls, so something more than CSS is needed to set the properites for the controls, so they'll look the way you want when the page is renderedas HTML on the users browser.

If you're using VS 2005, you should be able to look at all the parts of the control that have properties that you can set. As color is so important to charts and graphs, I have to think that the colors of the bars will be accessable properties.

When you place the control on the page (in design view), does it have a little black arrowhead in the upper right? On a Calendar control (for example), clicking on that lets you select an Auto Format (one of a list of styles for that control). That's one way you might get what you want. If you look at the control in source view, and position the curosr just after the start tag for the control, and hit a space, VS's Intellisense will show a large list of properties. Dbl click one of theose and hit an equal sign, and you'll see a list of values that you can asign to that property. If your control is anything like the calendar control, you should be all set.

Good luck in any event. BRN..

|||

For the record, I have found the answer to this problem. It's detailed in this MSDN article: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnsql90/html/MoreSSRSCharts.asp.

There are ways you can set the color of the bars, but it's not at all intuitive, and doesn't seem to be documented too well (if at all) in the Books Online for SQL Server. But this is a great article for all kinds of chart issues.

|||

Hi,

Glad you got what you needed. Why don't you mark your own post as the answer - then others will see a solution, should they search the forums for an answer to a similar problem. BRN..

|||

I hate to resurrect an old post, but I could really use the information from that article. However, the link above is broken. Can anyone please point me to where the article is currently hiding. Thanks!

|||

Found it.http://msdn2.microsoft.com/en-us/library/aa964128.aspx

sql

Monday, March 19, 2012

How to change chart color.

Hi,

Anyone can help me on how to set the chart color?

let say i got a pie chart. and i want the color is fix with the data i have. can it be done?

regard

terence chua

i found the solution for this question.

<Style>
<BackgroundGradientEndColor>=Switch( Fields!bKeyId.Value = 5, "Red", Fields!bKeyId.Value = 4, "Blue", Fields!bKeyId.Value = 3, "Yellow", Fields!bKeyId.Value = 2, "Cyan", Fields!bKeyId.Value = 1, "Green")</BackgroundGradientEndColor>
<BackgroundGradientType>VerticalCenter</BackgroundGradientType>
<BackgroundColor>=Switch( Fields!bKeyId.Value = 5, "Red", Fields!bKeyId.Value = 4, "Blue", Fields!bKeyId.Value = 3, "Yellow", Fields!bKeyId.Value = 2, "Cyan", Fields!bKeyId.Value = 1, "Green")</BackgroundColor>
<BorderColor>
<Default>#000001</Default>
</BorderColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>

this is apply on Pie chart. so i can fix the color for every color that i use for same category in different question and report. this make the report look more consitant.