Wednesday, March 28, 2012

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

No comments:

Post a Comment