Showing posts with label color. Show all posts
Showing posts with label color. Show all posts

Sunday, February 19, 2012

Column Header Color

Is there a way in SSRS to conditionally set the color of a column?

I want to do something like:

=IFF(some condition, Color(Fields!Date, "Green"), Color(Fields!Date, "Red"))

Yes you go into the Color property of the text box in the Detail row of the table and set the color to an <expression..> then in the dialog that comes up enter somthing like this...

=iif(Fields!Name.Value = "Smith", "Green", "Red")

if the name = smith make the color green other wise make it red

the key point being that you go to the property and set the property equal to an expression.

if you need more value/color options you can put in a little code in the report that you can reference from the expression.

1. right click in the little box at the top left of the report (intersection of the vertical and horizontal rulers) in the designer and choose properties.

2. select the code tab

3. type in some VB code

ex.

Public Function GetColor(ByVal sname as String) as String
IF sname = "Smith" Then
Return "Blue"
End IF
IF sname = "Jones" Then
Return "Black"
End IF
IF sname = "Woods" Then
Return "Red"
End IF
End Function

4. set the color or background property to =code.GetColor(Fields!Name.Value)

================= off topic FYI

here is another example of a little code for the report that can be used in an expression

this is used in a calulated field in a dataset =Code.GetBox(Fields!Percentile.Value,Fields!Importance.Value)


Public Function GetBox(ByVal PercentImp As Integer, ByVal Important As Integer) As Integer

Select Case Important
Case 1
Select Case PercentImp
Case 0 To 39
GetBox = 1
Case 40 To 75
GetBox = 2
Case Is > 75
GetBox = 3
End Select

Case 2
Select Case PercentImp
Case 0 To 39
GetBox = 4
Case 40 To 75
GetBox = 5
Case Is > 75
GetBox = 6
End Select
Case 3
Select Case PercentImp
Case 0 To 39
GetBox = 7
Case 40 To 75
GetBox = 8
Case Is > 75
GetBox = 9
End Select

End Select

End Function

|||You've made my day. Totally sweet. Thank you!!!

Column Header Color

Is there a way in SSRS to conditionally set the color of a column?

I want to do something like:

=IFF(some condition, Color(Fields!Date, "Green"), Color(Fields!Date, "Red"))

Yes you go into the Color property of the text box in the Detail row of the table and set the color to an <expression..> then in the dialog that comes up enter somthing like this...

=iif(Fields!Name.Value = "Smith", "Green", "Red")

if the name = smith make the color green other wise make it red

the key point being that you go to the property and set the property equal to an expression.

if you need more value/color options you can put in a little code in the report that you can reference from the expression.

1. right click in the little box at the top left of the report (intersection of the vertical and horizontal rulers) in the designer and choose properties.

2. select the code tab

3. type in some VB code

ex.

Public Function GetColor(ByVal sname as String) as String
IF sname = "Smith" Then
Return "Blue"
End IF
IF sname = "Jones" Then
Return "Black"
End IF
IF sname = "Woods" Then
Return "Red"
End IF
End Function

4. set the color or background property to =code.GetColor(Fields!Name.Value)

================= off topic FYI

here is another example of a little code for the report that can be used in an expression

this is used in a calulated field in a dataset =Code.GetBox(Fields!Percentile.Value,Fields!Importance.Value)


Public Function GetBox(ByVal PercentImp As Integer, ByVal Important As Integer) As Integer

Select Case Important
Case 1
Select Case PercentImp
Case 0 To 39
GetBox = 1
Case 40 To 75
GetBox = 2
Case Is > 75
GetBox = 3
End Select

Case 2
Select Case PercentImp
Case 0 To 39
GetBox = 4
Case 40 To 75
GetBox = 5
Case Is > 75
GetBox = 6
End Select
Case 3
Select Case PercentImp
Case 0 To 39
GetBox = 7
Case 40 To 75
GetBox = 8
Case Is > 75
GetBox = 9
End Select

End Select

End Function

|||You've made my day. Totally sweet. Thank you!!!

Tuesday, February 14, 2012

Colour My World

In SQL Server 2000 Query Analyzer, is there a way to print T-SQL code with
the QA color coding? When I print, even to a color laser printer, everything
including the keywords and comments come out in black and white.
Thanks!>> In SQL Server 2000 Query Analyzer, is there a way to print T-SQL code
Not sure if direct printing is possible or not. This might be silly but if
the code is small enough to fit the screen, you could use a screen print to
a word document and then print it.
Anith|||>> When I print, even to a color laser printer, everything
including the keywords and comments come out in black and white. <<
Just for fun, you might want to research the effect of "colored code"
on maintaining it. There is a standard test for brain damage where you
show the subject a seires of flashcards with the names of colors in
colored ink (I.e. "RED" pritned in green ink) and ask them to call out
the either word or the color. This has nothing to do with being
color-blind.
Since it involves switching brain hemispheres and thus the physical
structure of the brain as a organ, the rate is fairly constant over a
person's lifetime. Unless they get some physical damage to the brain.
Strongly analytical ("left brain, right hand") people have an awful
time with "neon vomit programming tools" because they have to filter
out the colors to abstract the code from the text.
So, I have to ask, why would you ever want to do this? Get a copy of
SQL PROGRAMMING STYLE for some more info on how humans read code. I
did a bit of the work on this back in the 1980's for AIRMICS while I
was a Georgia Tech.|||Well, cut-n-paste it into MS Word - that should do the trick ;)|||Screen capture could work, but the code is many, many pages long.
Is this possible in SQL Server? If not , are there any 3rd party programs
that might work?
Thanks again...
"Anith Sen" wrote:

> Not sure if direct printing is possible or not. This might be silly but if
> the code is small enough to fit the screen, you could use a screen print t
o
> a word document and then print it.
> --
> Anith
>
>|||Nope, tried it. Still black-and-white in MS Word.
"Alexander Kuznetsov" wrote:

> Well, cut-n-paste it into MS Word - that should do the trick ;)
>|||Why would I want color-coded printouts? for the same reason they're
color-coded on the screen. Easier to separate what's code, what's keywords,
and what's comments.
As far as the brain damage research, although it sounds rather intriguing,
considering how many more years of my life I'm going to spend looking at M&M
colored typing, I may be better off not knowing...
"--CELKO--" wrote:

> including the keywords and comments come out in black and white. <<
> Just for fun, you might want to research the effect of "colored code"
> on maintaining it. There is a standard test for brain damage where you
> show the subject a seires of flashcards with the names of colors in
> colored ink (I.e. "RED" pritned in green ink) and ask them to call out
> the either word or the color. This has nothing to do with being
> color-blind.
> Since it involves switching brain hemispheres and thus the physical
> structure of the brain as a organ, the rate is fairly constant over a
> person's lifetime. Unless they get some physical damage to the brain.
>
> Strongly analytical ("left brain, right hand") people have an awful
> time with "neon vomit programming tools" because they have to filter
> out the colors to abstract the code from the text.
> So, I have to ask, why would you ever want to do this? Get a copy of
> SQL PROGRAMMING STYLE for some more info on how humans read code. I
> did a bit of the work on this back in the 1980's for AIRMICS while I
> was a Georgia Tech.
>|||On Fri, 10 Feb 2006 08:51:29 -0800, "Joel"
<Joel@.discussions.microsoft.com> wrote:

>In SQL Server 2000 Query Analyzer, is there a way to print T-SQL code with
>the QA color coding? When I print, even to a color laser printer, everythin
g
>including the keywords and comments come out in black and white.
>Thanks!
I use Macromedia's Homesite. You can set the colors for each entity.
What you see on the screen is what prints. I also use Ultra Edit and
Slick Edit. Both of these allow you to print a selection where
Homesite will only print the entire file. I like the printout from
Homesite best.
--
BettyB -- www.flamingo-code.com
"I have noticed even people who claim everything is
predestined, and that we can do nothing to change it,
look before they cross the road." - Stephen Hawking|||I don't know if it is an option or not, but the 2005 replacement of QA (Mana
gement Studio) does keep
formatting (including colour) when you copy text. Personally, I hate that, b
ut it might be an upside
in these situations.
Tibor Karaszi, SQL Server MVP
http://www.karaszi.com/sqlserver/default.asp
http://www.solidqualitylearning.com/
Blog: http://solidqualitylearning.com/blogs/tibor/
"Joel" <Joel@.discussions.microsoft.com> wrote in message
news:F6077A67-C933-47CA-A4C5-654D2E7881A8@.microsoft.com...
> Nope, tried it. Still black-and-white in MS Word.
> "Alexander Kuznetsov" wrote:
>|||> Personally, I hate that,
me too. Sometimes I need to paste into notepad - that removes colors
and fonts

Colors in CR ...

Hi.

Is there a way ( most likely, but I'm unaware of ) to change the color of just a part of the text in Cr ?

For example: I have a filed which contains the word : Excellent ..

How can I tell Cr to print/display the word in black, except for the last two letters nt, which should be printed/displayed in, say, red ?

Thnx.If it's just a plain text field then yes, it's quite easy - just highlight the letters of the field you want in a different colour, and select Text Formatting.

However, I'm assuming you want it to be one of the dynamic database fields. There doesn't appear to be any functions in Formula Editor that are capable of changing text colour, so I don't think it is possible.

(One idea I had was to split the field into two separate formulas, but it doesn't appear that I can join the result of two text formulas back together. Perhaps you can build on this idea to come up with a solution).

Colors hadling with ReportViewer

Hello,
My doubt is how to change in a LocalReport environment the text color of a
textbox of a report depending on certain condition at runtime.
I will thank any help.
Sincerely,
Arturo Carrión
at Tiempo HardHello Arturo,
My understanding of this issue is: You have a reportviewer control using
the Local Report. And you want to control the color of a textbox in the
runtime. If I misunderstood your concern, please feel free to let me know.
Based on my research, you could only control the color in the report. You
could use the Expression to control the color.
Expressions Commonly Used in Reporting Services
http://msdn2.microsoft.com/en-us/ms157328.aspx
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.|||Thanks Wei,
Until this moment, I have not been able to enter the link that you gave me
because it gives an error of "Server is too busy".
I will try it later, then I tell you.
Sincerely,
Arturo Carrión
at Tiempo Hard
"Wei Lu [MSFT]" <weilu@.online.microsoft.com> escribió en el mensaje
news:bmTJvs%23THHA.1860@.TK2MSFTNGHUB02.phx.gbl...
> Hello Arturo,
> My understanding of this issue is: You have a reportviewer control using
> the Local Report. And you want to control the color of a textbox in the
> runtime. If I misunderstood your concern, please feel free to let me know.
> Based on my research, you could only control the color in the report. You
> could use the Expression to control the color.
> Expressions Commonly Used in Reporting Services
> http://msdn2.microsoft.com/en-us/ms157328.aspx
> Sincerely,
> Wei Lu
> Microsoft Online Community Support
> ==================================================> When responding to posts, please "Reply to Group" via your newsreader so
> that others may learn and benefit from your issue.
> ==================================================> This posting is provided "AS IS" with no warranties, and confers no
> rights.
>|||Jackpot!
I realized that most properties of a textbox accept an expression instead a
value.
Thanks, Wei
<tiempotecnologia@.newsgroup.nospam> escribió en el mensaje
news:eaynrmEUHHA.1636@.TK2MSFTNGP02.phx.gbl...
> Thanks Wei,
> Until this moment, I have not been able to enter the link that you gave me
> because it gives an error of "Server is too busy".
> I will try it later, then I tell you.
> Sincerely,
> Arturo Carrión
> at Tiempo Hard
> "Wei Lu [MSFT]" <weilu@.online.microsoft.com> escribió en el mensaje
> news:bmTJvs%23THHA.1860@.TK2MSFTNGHUB02.phx.gbl...
>> Hello Arturo,
>> My understanding of this issue is: You have a reportviewer control using
>> the Local Report. And you want to control the color of a textbox in the
>> runtime. If I misunderstood your concern, please feel free to let me
>> know.
>> Based on my research, you could only control the color in the report. You
>> could use the Expression to control the color.
>> Expressions Commonly Used in Reporting Services
>> http://msdn2.microsoft.com/en-us/ms157328.aspx
>> Sincerely,
>> Wei Lu
>> Microsoft Online Community Support
>> ==================================================>> When responding to posts, please "Reply to Group" via your newsreader so
>> that others may learn and benefit from your issue.
>> ==================================================>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>|||Hello Arturo,
Glad to hear the information is helpful.
If you have any question, please feel free to let me know.
Have a nice day!
Sincerely,
Wei Lu
Microsoft Online Community Support
==================================================
When responding to posts, please "Reply to Group" via your newsreader so
that others may learn and benefit from your issue.
==================================================This posting is provided "AS IS" with no warranties, and confers no rights.

Sunday, February 12, 2012

Color Property Formatting not working correctly

Hi,

I have a problem with a conditional format of the Color property in a matrix report. When the value of the textbox is greater than 0, the color should be Red otherwise it should be Blue. This is implemented via an IIF statement and works perfectly in Preview in Visual Studio 2005.

When the report is deployed, the formatting appears to be ignored and all values are the default value of Black.

Anyone else experienced this problem and, if so, is there a workaround?

I wish I could help you, however I cannot.

I can however state with confidence that posting 7 times in roughly 1 hour about the same thing is not the best way to get the attention of those who can.

Just my

|||Yea I can't help you either. . .|||

I agree with the sentiment in the above posts - spamming a forum is not the best way to get an answer.

What would also help is if you posted the expression you are using - without it we are just guessing.

Color Property Formatting not working

Hi,

I have a problem with a conditional format of the Color property in a matrix report. When the value of the textbox is greater than 0, the color should be Red otherwise it should be Blue. This is implemented via an IIF statement and works perfectly in Preview in Visual Studio 2005.

When the report is deployed, the formatting appears to be ignored and all values are the default value of Black.

Anyone else experienced this problem and, if so, is there a workaround?

Thanks in advance

If I am not wrong, matrix conditional formatting is applied by default at the details. You may need to do scope it at the right level, e.g.; =Iif(SUM(<field name, "group name")>0, "Red", "Blue"). Also, download your deployed report definition from the Report Manager (General report properties) and make sure the expression is there.

Color of the text inside a textbox

Hi,
is there any way by which i can give different colors to the text inside a
same textbox'
thanks
AtulNo, RS 2000 does not support this. It is on the wish list, basically we
plan to support RTF at some point.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
"Atul" <atul.anjankar@.approva.net> wrote in message
news:ea$RylMXEHA.1356@.TK2MSFTNGP09.phx.gbl...
> Hi,
> is there any way by which i can give different colors to the text inside a
> same textbox'
> thanks
> Atul
>|||No.
--
Ravi Mumulla (Microsoft)
SQL Server Reporting Services
This posting is provided "AS IS" with no warranties, and confers no rights.
"Atul" <atul.anjankar@.approva.net> wrote in message
news:ea$RylMXEHA.1356@.TK2MSFTNGP09.phx.gbl...
> Hi,
> is there any way by which i can give different colors to the text inside a
> same textbox'
> thanks
> Atul
>

Color of pens in Line chart ?

Hi,
how can I change the line color in line charts ?
RitchieTry:
Chart Properties > Tab Data > Edit Value > Tab Appearance
"Ritchie" <Ritchie@.discussions.microsoft.com> escribió en el mensaje
news:898D80BA-E315-4A1E-9D39-2463CBDCE482@.microsoft.com...
> Hi,
> how can I change the line color in line charts ?
> Ritchie|||Hi Mónica,
does this menue item also exists on a .NET 2003 Version ?
I do not saw any configured of the color for each pen ?
Ritchie
"Mónica" wrote:
> Try:
> Chart Properties > Tab Data > Edit Value > Tab Appearance
>
>
> "Ritchie" <Ritchie@.discussions.microsoft.com> escribió en el mensaje
> news:898D80BA-E315-4A1E-9D39-2463CBDCE482@.microsoft.com...
> > Hi,
> >
> > how can I change the line color in line charts ?
> >
> > Ritchie
>
>|||Ummm, I don´t know. I´m using .NET 2005.
I´m sorry I can´t help you :-(
"Ritchie" <Ritchie@.discussions.microsoft.com> escribió en el mensaje
news:04F4DEFE-A23D-420F-A30F-4EAB93C52307@.microsoft.com...
> Hi Mónica,
> does this menue item also exists on a .NET 2003 Version ?
> I do not saw any configured of the color for each pen ?
> Ritchie
> "Mónica" wrote:
>> Try:
>> Chart Properties > Tab Data > Edit Value > Tab Appearance
>>
>>
>> "Ritchie" <Ritchie@.discussions.microsoft.com> escribió en el mensaje
>> news:898D80BA-E315-4A1E-9D39-2463CBDCE482@.microsoft.com...
>> > Hi,
>> >
>> > how can I change the line color in line charts ?
>> >
>> > Ritchie
>>|||Thanks for your help anyway..
Ritchie
"Mónica" wrote:
> Ummm, I don´t know. I´m using .NET 2005.
> I´m sorry I can´t help you :-(
>
> "Ritchie" <Ritchie@.discussions.microsoft.com> escribió en el mensaje
> news:04F4DEFE-A23D-420F-A30F-4EAB93C52307@.microsoft.com...
> > Hi Mónica,
> >
> > does this menue item also exists on a .NET 2003 Version ?
> >
> > I do not saw any configured of the color for each pen ?
> >
> > Ritchie
> >
> > "Mónica" wrote:
> >
> >> Try:
> >>
> >> Chart Properties > Tab Data > Edit Value > Tab Appearance
> >>
> >>
> >>
> >>
> >> "Ritchie" <Ritchie@.discussions.microsoft.com> escribió en el mensaje
> >> news:898D80BA-E315-4A1E-9D39-2463CBDCE482@.microsoft.com...
> >> > Hi,
> >> >
> >> > how can I change the line color in line charts ?
> >> >
> >> > Ritchie
> >>
> >>
> >>
>
>

Color of graphs

Hi,
Is it possible to change the colors of the graphs? Specially the series?
FréYes.
"Frederik Vanderhaeghe" <frederikvanderhaeghe@.gmail.com> wrote in message
news:uJxfU%23gjGHA.4504@.TK2MSFTNGP03.phx.gbl...
> Hi,
> Is it possible to change the colors of the graphs? Specially the series?
> Fré
>|||And how?
Fré
"Tim Dot NoSpam" <Tim.NoSpam@.hughes.net> wrote in message
news:efOvK8ijGHA.4972@.TK2MSFTNGP05.phx.gbl...
> Yes.
> "Frederik Vanderhaeghe" <frederikvanderhaeghe@.gmail.com> wrote in message
> news:uJxfU%23gjGHA.4504@.TK2MSFTNGP03.phx.gbl...
>> Hi,
>> Is it possible to change the colors of the graphs? Specially the series?
>> Fré
>

Color inconsistent on each slice of Pie

Hello all!!
I have created a pie chart that is embedded in a matrix report, therefore
creating a new pie for every row. The problem I am having is the pie slice
for the same series is changing each time there is a new pie. For example,
in the first pie Cars may be designated as green but in the second pie it may
be red. I would like the colors to be consistent; all cars are represented
as green slices. Oh and if there are no cars don't use the color green for
another slice.
I think this can be done using a nested expression but I am unsure how to
write it...I either need an example of an expression that can handle
multiple slices or another way to handle the issue.
Thanks,
AnthonyI suggest to follow the approach discussed in this blog article:
http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
You don't need the part about the custom legend, but you should take a close
look at the custom color part of the sample. You can modify the code so that
instead of having the hashtable approach to apply unique colors for
categories, you replace it with some IF statement to explicitly control
colors.
A trivial RDL sample with two charts using different filters but sharing the
same colors for categories is copied to the bottom of this posting.
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> Hello all!!
> I have created a pie chart that is embedded in a matrix report, therefore
> creating a new pie for every row. The problem I am having is the pie
> slice
> for the same series is changing each time there is a new pie. For
> example,
> in the first pie Cars may be designated as green but in the second pie it
> may
> be red. I would like the colors to be consistent; all cars are
> represented
> as green slices. Oh and if there are no cars don't use the color green
> for
> another slice.
> I think this can be done using a nested expression but I am unsure how to
> write it...I either need an example of an expression that can handle
> multiple slices or another way to handle the issue.
> Thanks,
> Anthony
============================================
<?xml version="1.0" encoding="utf-8"?>
<Report
xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
<RightMargin>1in</RightMargin>
<Author>Robert M. Bruckner</Author>
<Body>
<ReportItems>
<Chart Name="chart2">
<ThreeDProperties>
<Rotation>30</Rotation>
<Inclination>30</Inclination>
<Shading>Simple</Shading>
<WallThickness>50</WallThickness>
</ThreeDProperties>
<ZIndex>1</ZIndex>
<Style>
<BackgroundColor>White</BackgroundColor>
</Style>
<Legend>
<Visible>true</Visible>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Position>RightCenter</Position>
</Legend>
<Palette>Default</Palette>
<ChartData>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Sum(Fields!UnitsInStock.Value)</Value>
</DataValue>
</DataValues>
<DataLabel />
<Style>
<BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
</Style>
<Marker>
<Size>6pt</Size>
</Marker>
</DataPoint>
</DataPoints>
</ChartSeries>
</ChartData>
<CategoryAxis>
<Axis>
<Title />
<MajorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<Min>0</Min>
</Axis>
</CategoryAxis>
<DataSetName>DataSet1</DataSetName>
<PointWidth>0</PointWidth>
<Type>Bar</Type>
<Top>3.125in</Top>
<Title>
<Caption>UK</Caption>
</Title>
<Width>6in</Width>
<SeriesGroupings>
<SeriesGrouping>
<DynamicSeries>
<Grouping Name="chart2_SeriesGroup1">
<GroupExpressions>
<GroupExpression>=Fields!CategoryName.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<SortExpression>=Fields!CategoryName.Value</SortExpression>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
<Label>=Fields!CategoryName.Value</Label>
</DynamicSeries>
</SeriesGrouping>
</SeriesGroupings>
<Subtype>Plain</Subtype>
<PlotArea>
<Style>
<BackgroundColor>LightGrey</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</PlotArea>
<Filters>
<Filter>
<FilterExpression>=Fields!Country.Value</FilterExpression>
<Operator>Equal</Operator>
<FilterValues>
<FilterValue>UK</FilterValue>
</FilterValues>
</Filter>
</Filters>
<Left>0.125in</Left>
<ValueAxis>
<Axis>
<Title />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
<Scalar>true</Scalar>
</Axis>
</ValueAxis>
</Chart>
<Chart Name="chart1">
<ThreeDProperties>
<Rotation>30</Rotation>
<Inclination>30</Inclination>
<Shading>Simple</Shading>
<WallThickness>50</WallThickness>
</ThreeDProperties>
<Style>
<BackgroundColor>White</BackgroundColor>
</Style>
<Legend>
<Visible>true</Visible>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
<Position>RightCenter</Position>
</Legend>
<Palette>Default</Palette>
<ChartData>
<ChartSeries>
<DataPoints>
<DataPoint>
<DataValues>
<DataValue>
<Value>=Sum(Fields!UnitsInStock.Value)</Value>
</DataValue>
</DataValues>
<DataLabel />
<Style>
<BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
</Style>
<Marker>
<Size>6pt</Size>
</Marker>
</DataPoint>
</DataPoints>
</ChartSeries>
</ChartData>
<CategoryAxis>
<Axis>
<Title />
<MajorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<Min>0</Min>
</Axis>
</CategoryAxis>
<DataSetName>DataSet1</DataSetName>
<PointWidth>0</PointWidth>
<Type>Bar</Type>
<Top>0.25in</Top>
<Title>
<Caption>USA</Caption>
</Title>
<Width>6in</Width>
<Height>2.5in</Height>
<SeriesGroupings>
<SeriesGrouping>
<DynamicSeries>
<Grouping Name="chart1_SeriesGroup1">
<GroupExpressions>
<GroupExpression>=Fields!CategoryName.Value</GroupExpression>
</GroupExpressions>
</Grouping>
<Sorting>
<SortBy>
<SortExpression>=Fields!CategoryName.Value</SortExpression>
<Direction>Ascending</Direction>
</SortBy>
</Sorting>
<Label>=Fields!CategoryName.Value</Label>
</DynamicSeries>
</SeriesGrouping>
</SeriesGroupings>
<Subtype>Plain</Subtype>
<PlotArea>
<Style>
<BackgroundColor>LightGrey</BackgroundColor>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</PlotArea>
<Filters>
<Filter>
<FilterExpression>=Fields!Country.Value</FilterExpression>
<Operator>Equal</Operator>
<FilterValues>
<FilterValue>USA</FilterValue>
</FilterValues>
</Filter>
</Filters>
<Left>0.125in</Left>
<ValueAxis>
<Axis>
<Title />
<MajorGridLines>
<ShowGridLines>true</ShowGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MajorGridLines>
<MinorGridLines>
<Style>
<BorderStyle>
<Default>Solid</Default>
</BorderStyle>
</Style>
</MinorGridLines>
<MajorTickMarks>Outside</MajorTickMarks>
<Min>0</Min>
<Margin>true</Margin>
<Visible>true</Visible>
<Scalar>true</Scalar>
</Axis>
</ValueAxis>
</Chart>
</ReportItems>
<Style />
<Height>5.625in</Height>
</Body>
<TopMargin>1in</TopMargin>
<DataSources>
<DataSource Name="Northwind">
<rd:DataSourceID>f646058b-4784-494d-a09d-27fde13a5679</rd:DataSourceID>
<ConnectionProperties>
<DataProvider>SQL</DataProvider>
<ConnectString>data source=(local);initial
catalog=Northwind</ConnectString>
<IntegratedSecurity>true</IntegratedSecurity>
</ConnectionProperties>
</DataSource>
</DataSources>
<Code> Private colorPalette As String() = {"Green", "Blue", "Red",
"Orange", "Aqua", "Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B",
"#352F26", "#F1E7D6", "#E16C56", "#CFBA9B"}
Private count As Integer = 0
Private mapping As New System.Collections.Hashtable()
Public Function GetColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
</Code>
<Width>6.5in</Width>
<DataSets>
<DataSet Name="DataSet1">
<Fields>
<Field Name="ProductID">
<DataField>ProductID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="ProductName">
<DataField>ProductName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="SupplierID">
<DataField>SupplierID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="CategoryID">
<DataField>CategoryID</DataField>
<rd:TypeName>System.Int32</rd:TypeName>
</Field>
<Field Name="QuantityPerUnit">
<DataField>QuantityPerUnit</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="UnitPrice">
<DataField>UnitPrice</DataField>
<rd:TypeName>System.Decimal</rd:TypeName>
</Field>
<Field Name="UnitsInStock">
<DataField>UnitsInStock</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="UnitsOnOrder">
<DataField>UnitsOnOrder</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="ReorderLevel">
<DataField>ReorderLevel</DataField>
<rd:TypeName>System.Int16</rd:TypeName>
</Field>
<Field Name="Discontinued">
<DataField>Discontinued</DataField>
<rd:TypeName>System.Boolean</rd:TypeName>
</Field>
<Field Name="CategoryName">
<DataField>CategoryName</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
<Field Name="Country">
<DataField>Country</DataField>
<rd:TypeName>System.String</rd:TypeName>
</Field>
</Fields>
<Query>
<DataSourceName>Northwind</DataSourceName>
<CommandText>SELECT Products.*, Categories.CategoryName,
Suppliers.Country
FROM Products INNER JOIN
Categories ON Products.CategoryID =Categories.CategoryID INNER JOIN
Suppliers ON Products.SupplierID =Suppliers.SupplierID</CommandText>
</Query>
</DataSet>
</DataSets>
<LeftMargin>1in</LeftMargin>
<rd:SnapToGrid>true</rd:SnapToGrid>
<rd:DrawGrid>true</rd:DrawGrid>
<rd:ReportID>e5564b0f-4fab-4cf7-9cef-bda726589920</rd:ReportID>
<BottomMargin>1in</BottomMargin>
<Language>en-US</Language>
</Report>|||I tried the code in the article but get the following error:
There is an error on line 14 of custom code: [BC30430] 'End Function' must
be preceded by a matching 'Function'.
Build complete -- 1 errors, 0 warnings
Any ideas?
"Robert Bruckner [MSFT]" wrote:
> I suggest to follow the approach discussed in this blog article:
> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
> You don't need the part about the custom legend, but you should take a close
> look at the custom color part of the sample. You can modify the code so that
> instead of having the hashtable approach to apply unique colors for
> categories, you replace it with some IF statement to explicitly control
> colors.
> A trivial RDL sample with two charts using different filters but sharing the
> same colors for categories is copied to the bottom of this posting.
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> > Hello all!!
> >
> > I have created a pie chart that is embedded in a matrix report, therefore
> > creating a new pie for every row. The problem I am having is the pie
> > slice
> > for the same series is changing each time there is a new pie. For
> > example,
> > in the first pie Cars may be designated as green but in the second pie it
> > may
> > be red. I would like the colors to be consistent; all cars are
> > represented
> > as green slices. Oh and if there are no cars don't use the color green
> > for
> > another slice.
> >
> > I think this can be done using a nested expression but I am unsure how to
> > write it...I either need an example of an expression that can handle
> > multiple slices or another way to handle the issue.
> >
> > Thanks,
> > Anthony
>
> ============================================> <?xml version="1.0" encoding="utf-8"?>
> <Report
> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> <RightMargin>1in</RightMargin>
> <Author>Robert M. Bruckner</Author>
> <Body>
> <ReportItems>
> <Chart Name="chart2">
> <ThreeDProperties>
> <Rotation>30</Rotation>
> <Inclination>30</Inclination>
> <Shading>Simple</Shading>
> <WallThickness>50</WallThickness>
> </ThreeDProperties>
> <ZIndex>1</ZIndex>
> <Style>
> <BackgroundColor>White</BackgroundColor>
> </Style>
> <Legend>
> <Visible>true</Visible>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> <Position>RightCenter</Position>
> </Legend>
> <Palette>Default</Palette>
> <ChartData>
> <ChartSeries>
> <DataPoints>
> <DataPoint>
> <DataValues>
> <DataValue>
> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> </DataValue>
> </DataValues>
> <DataLabel />
> <Style>
> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> </Style>
> <Marker>
> <Size>6pt</Size>
> </Marker>
> </DataPoint>
> </DataPoints>
> </ChartSeries>
> </ChartData>
> <CategoryAxis>
> <Axis>
> <Title />
> <MajorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MajorGridLines>
> <MinorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MinorGridLines>
> <Min>0</Min>
> </Axis>
> </CategoryAxis>
> <DataSetName>DataSet1</DataSetName>
> <PointWidth>0</PointWidth>
> <Type>Bar</Type>
> <Top>3.125in</Top>
> <Title>
> <Caption>UK</Caption>
> </Title>
> <Width>6in</Width>
> <SeriesGroupings>
> <SeriesGrouping>
> <DynamicSeries>
> <Grouping Name="chart2_SeriesGroup1">
> <GroupExpressions>
> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> </GroupExpressions>
> </Grouping>
> <Sorting>
> <SortBy>
> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> <Direction>Ascending</Direction>
> </SortBy>
> </Sorting>
> <Label>=Fields!CategoryName.Value</Label>
> </DynamicSeries>
> </SeriesGrouping>
> </SeriesGroupings>
> <Subtype>Plain</Subtype>
> <PlotArea>
> <Style>
> <BackgroundColor>LightGrey</BackgroundColor>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </PlotArea>
> <Filters>
> <Filter>
> <FilterExpression>=Fields!Country.Value</FilterExpression>
> <Operator>Equal</Operator>
> <FilterValues>
> <FilterValue>UK</FilterValue>
> </FilterValues>
> </Filter>
> </Filters>
> <Left>0.125in</Left>
> <ValueAxis>
> <Axis>
> <Title />
> <MajorGridLines>
> <ShowGridLines>true</ShowGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MajorGridLines>
> <MinorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MinorGridLines>
> <MajorTickMarks>Outside</MajorTickMarks>
> <Min>0</Min>
> <Margin>true</Margin>
> <Visible>true</Visible>
> <Scalar>true</Scalar>
> </Axis>
> </ValueAxis>
> </Chart>
> <Chart Name="chart1">
> <ThreeDProperties>
> <Rotation>30</Rotation>
> <Inclination>30</Inclination>
> <Shading>Simple</Shading>
> <WallThickness>50</WallThickness>
> </ThreeDProperties>
> <Style>
> <BackgroundColor>White</BackgroundColor>
> </Style>
> <Legend>
> <Visible>true</Visible>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> <Position>RightCenter</Position>
> </Legend>
> <Palette>Default</Palette>
> <ChartData>
> <ChartSeries>
> <DataPoints>
> <DataPoint>
> <DataValues>
> <DataValue>
> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> </DataValue>
> </DataValues>
> <DataLabel />
> <Style>
> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> </Style>
> <Marker>
> <Size>6pt</Size>
> </Marker>
> </DataPoint>
> </DataPoints>
> </ChartSeries>
> </ChartData>
> <CategoryAxis>
> <Axis>
> <Title />
> <MajorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MajorGridLines>
> <MinorGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MinorGridLines>
> <Min>0</Min>
> </Axis>
> </CategoryAxis>
> <DataSetName>DataSet1</DataSetName>
> <PointWidth>0</PointWidth>
> <Type>Bar</Type>
> <Top>0.25in</Top>
> <Title>
> <Caption>USA</Caption>
> </Title>
> <Width>6in</Width>
> <Height>2.5in</Height>
> <SeriesGroupings>
> <SeriesGrouping>
> <DynamicSeries>
> <Grouping Name="chart1_SeriesGroup1">
> <GroupExpressions>
> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> </GroupExpressions>
> </Grouping>
> <Sorting>
> <SortBy>
> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> <Direction>Ascending</Direction>
> </SortBy>
> </Sorting>
> <Label>=Fields!CategoryName.Value</Label>
> </DynamicSeries>
> </SeriesGrouping>
> </SeriesGroupings>
> <Subtype>Plain</Subtype>
> <PlotArea>
> <Style>
> <BackgroundColor>LightGrey</BackgroundColor>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </PlotArea>
> <Filters>
> <Filter>
> <FilterExpression>=Fields!Country.Value</FilterExpression>
> <Operator>Equal</Operator>
> <FilterValues>
> <FilterValue>USA</FilterValue>
> </FilterValues>
> </Filter>
> </Filters>
> <Left>0.125in</Left>
> <ValueAxis>
> <Axis>
> <Title />
> <MajorGridLines>
> <ShowGridLines>true</ShowGridLines>
> <Style>
> <BorderStyle>
> <Default>Solid</Default>
> </BorderStyle>
> </Style>
> </MajorGridLines>|||Did you try the sample I had attached to the bottom of my previous posting,
or did you download the other sample about custom legends from the blog
article? Both should work as provided.
In your particular case, the error message would indicate that you are
missing the Function keyword for the corresponding End Function statement on
line 14 of the custom code window of the report (VS menu -> report -> report
properties -> custom code)
-- Robert
This posting is provided "AS IS" with no warranties, and confers no rights.
"anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
news:13337779-49F4-44A7-B0B8-4963E58D2B75@.microsoft.com...
>I tried the code in the article but get the following error:
> There is an error on line 14 of custom code: [BC30430] 'End Function' must
> be preceded by a matching 'Function'.
> Build complete -- 1 errors, 0 warnings
>
> Any ideas?
> "Robert Bruckner [MSFT]" wrote:
>> I suggest to follow the approach discussed in this blog article:
>> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
>> You don't need the part about the custom legend, but you should take a
>> close
>> look at the custom color part of the sample. You can modify the code so
>> that
>> instead of having the hashtable approach to apply unique colors for
>> categories, you replace it with some IF statement to explicitly control
>> colors.
>> A trivial RDL sample with two charts using different filters but sharing
>> the
>> same colors for categories is copied to the bottom of this posting.
>> -- Robert
>> This posting is provided "AS IS" with no warranties, and confers no
>> rights.
>>
>> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
>> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
>> > Hello all!!
>> >
>> > I have created a pie chart that is embedded in a matrix report,
>> > therefore
>> > creating a new pie for every row. The problem I am having is the pie
>> > slice
>> > for the same series is changing each time there is a new pie. For
>> > example,
>> > in the first pie Cars may be designated as green but in the second pie
>> > it
>> > may
>> > be red. I would like the colors to be consistent; all cars are
>> > represented
>> > as green slices. Oh and if there are no cars don't use the color green
>> > for
>> > another slice.
>> >
>> > I think this can be done using a nested expression but I am unsure how
>> > to
>> > write it...I either need an example of an expression that can handle
>> > multiple slices or another way to handle the issue.
>> >
>> > Thanks,
>> > Anthony
>>
>> ============================================>> <?xml version="1.0" encoding="utf-8"?>
>> <Report
>> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
>> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
>> <RightMargin>1in</RightMargin>
>> <Author>Robert M. Bruckner</Author>
>> <Body>
>> <ReportItems>
>> <Chart Name="chart2">
>> <ThreeDProperties>
>> <Rotation>30</Rotation>
>> <Inclination>30</Inclination>
>> <Shading>Simple</Shading>
>> <WallThickness>50</WallThickness>
>> </ThreeDProperties>
>> <ZIndex>1</ZIndex>
>> <Style>
>> <BackgroundColor>White</BackgroundColor>
>> </Style>
>> <Legend>
>> <Visible>true</Visible>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> <Position>RightCenter</Position>
>> </Legend>
>> <Palette>Default</Palette>
>> <ChartData>
>> <ChartSeries>
>> <DataPoints>
>> <DataPoint>
>> <DataValues>
>> <DataValue>
>> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
>> </DataValue>
>> </DataValues>
>> <DataLabel />
>> <Style>
>> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
>> </Style>
>> <Marker>
>> <Size>6pt</Size>
>> </Marker>
>> </DataPoint>
>> </DataPoints>
>> </ChartSeries>
>> </ChartData>
>> <CategoryAxis>
>> <Axis>
>> <Title />
>> <MajorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MajorGridLines>
>> <MinorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MinorGridLines>
>> <Min>0</Min>
>> </Axis>
>> </CategoryAxis>
>> <DataSetName>DataSet1</DataSetName>
>> <PointWidth>0</PointWidth>
>> <Type>Bar</Type>
>> <Top>3.125in</Top>
>> <Title>
>> <Caption>UK</Caption>
>> </Title>
>> <Width>6in</Width>
>> <SeriesGroupings>
>> <SeriesGrouping>
>> <DynamicSeries>
>> <Grouping Name="chart2_SeriesGroup1">
>> <GroupExpressions>
>> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
>> </GroupExpressions>
>> </Grouping>
>> <Sorting>
>> <SortBy>
>> <SortExpression>=Fields!CategoryName.Value</SortExpression>
>> <Direction>Ascending</Direction>
>> </SortBy>
>> </Sorting>
>> <Label>=Fields!CategoryName.Value</Label>
>> </DynamicSeries>
>> </SeriesGrouping>
>> </SeriesGroupings>
>> <Subtype>Plain</Subtype>
>> <PlotArea>
>> <Style>
>> <BackgroundColor>LightGrey</BackgroundColor>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </PlotArea>
>> <Filters>
>> <Filter>
>> <FilterExpression>=Fields!Country.Value</FilterExpression>
>> <Operator>Equal</Operator>
>> <FilterValues>
>> <FilterValue>UK</FilterValue>
>> </FilterValues>
>> </Filter>
>> </Filters>
>> <Left>0.125in</Left>
>> <ValueAxis>
>> <Axis>
>> <Title />
>> <MajorGridLines>
>> <ShowGridLines>true</ShowGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MajorGridLines>
>> <MinorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MinorGridLines>
>> <MajorTickMarks>Outside</MajorTickMarks>
>> <Min>0</Min>
>> <Margin>true</Margin>
>> <Visible>true</Visible>
>> <Scalar>true</Scalar>
>> </Axis>
>> </ValueAxis>
>> </Chart>
>> <Chart Name="chart1">
>> <ThreeDProperties>
>> <Rotation>30</Rotation>
>> <Inclination>30</Inclination>
>> <Shading>Simple</Shading>
>> <WallThickness>50</WallThickness>
>> </ThreeDProperties>
>> <Style>
>> <BackgroundColor>White</BackgroundColor>
>> </Style>
>> <Legend>
>> <Visible>true</Visible>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> <Position>RightCenter</Position>
>> </Legend>
>> <Palette>Default</Palette>
>> <ChartData>
>> <ChartSeries>
>> <DataPoints>
>> <DataPoint>
>> <DataValues>
>> <DataValue>
>> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
>> </DataValue>
>> </DataValues>
>> <DataLabel />
>> <Style>
>> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
>> </Style>
>> <Marker>
>> <Size>6pt</Size>
>> </Marker>
>> </DataPoint>
>> </DataPoints>
>> </ChartSeries>
>> </ChartData>
>> <CategoryAxis>
>> <Axis>
>> <Title />
>> <MajorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MajorGridLines>
>> <MinorGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MinorGridLines>
>> <Min>0</Min>
>> </Axis>
>> </CategoryAxis>
>> <DataSetName>DataSet1</DataSetName>
>> <PointWidth>0</PointWidth>
>> <Type>Bar</Type>
>> <Top>0.25in</Top>
>> <Title>
>> <Caption>USA</Caption>
>> </Title>
>> <Width>6in</Width>
>> <Height>2.5in</Height>
>> <SeriesGroupings>
>> <SeriesGrouping>
>> <DynamicSeries>
>> <Grouping Name="chart1_SeriesGroup1">
>> <GroupExpressions>
>> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
>> </GroupExpressions>
>> </Grouping>
>> <Sorting>
>> <SortBy>
>> <SortExpression>=Fields!CategoryName.Value</SortExpression>
>> <Direction>Ascending</Direction>
>> </SortBy>
>> </Sorting>
>> <Label>=Fields!CategoryName.Value</Label>
>> </DynamicSeries>
>> </SeriesGrouping>
>> </SeriesGroupings>
>> <Subtype>Plain</Subtype>
>> <PlotArea>
>> <Style>
>> <BackgroundColor>LightGrey</BackgroundColor>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </PlotArea>
>> <Filters>
>> <Filter>
>> <FilterExpression>=Fields!Country.Value</FilterExpression>
>> <Operator>Equal</Operator>
>> <FilterValues>
>> <FilterValue>USA</FilterValue>
>> </FilterValues>
>> </Filter>
>> </Filters>
>> <Left>0.125in</Left>
>> <ValueAxis>
>> <Axis>
>> <Title />
>> <MajorGridLines>
>> <ShowGridLines>true</ShowGridLines>
>> <Style>
>> <BorderStyle>
>> <Default>Solid</Default>
>> </BorderStyle>
>> </Style>
>> </MajorGridLines>|||I used the code off the site I had to change the Private to Public because I
was getting errors and the only way I got them to go away was to change
Private to Public.
The code I have in the report properties code tab is as follows:
Public colorPalette As String() = {"Green", "Blue", "Red", "Orange", "Aqua",
"Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B", "#352F26", "#F1E7D6",
"#E16C56", "#CFBA9B"}
Public count As Integer = 0
Public mapping As New System.Collections.Hashtable()
Public Function GetColor(ByVal groupingValue As String) As String
If mapping.ContainsKey(groupingValue) Then
Return mapping(groupingValue)
End If
Dim c As String = colorPalette(count Mod colorPalette.Length)
count = count + 1
mapping.Add(groupingValue, c)
Return c
End Function
The Data field for my chart is: YTD
The Series field is: Project_Category
for the Data field properties on my Pie chart I went to the apperance tab
then series style... on the fill tab, color field I put the following FX:
=Code.GetColor(Fields!Project_Category.Value)
Any ideas what I am missing?
I also tried the following code that someone modified off your code example
with no luck either...
In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
function:
= Code.GetColor(Fields!Project_Category.Value)
And in the code for the report I have:
Public Function GetColor(ByVal Project_Category As String) As String
if Project_Category = "Value 1" Then
Return "#CC3333" ' "Red"
end if
if Project_Category = "Value 2" Then
Return "Pink"
end if
if Project_Category = "Value 3" Then
Return "#3300CC" ' "Blue"
end if
if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
(Project_Category
<> "Project_Category") Then
Return "Black"
end if
End Function
again no luck with this one.....
THANKS AGAIN FOR ALL THE HELP!!!
"Robert Bruckner [MSFT]" wrote:
> Did you try the sample I had attached to the bottom of my previous posting,
> or did you download the other sample about custom legends from the blog
> article? Both should work as provided.
> In your particular case, the error message would indicate that you are
> missing the Function keyword for the corresponding End Function statement on
> line 14 of the custom code window of the report (VS menu -> report -> report
> properties -> custom code)
> -- Robert
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> news:13337779-49F4-44A7-B0B8-4963E58D2B75@.microsoft.com...
> >I tried the code in the article but get the following error:
> >
> > There is an error on line 14 of custom code: [BC30430] 'End Function' must
> > be preceded by a matching 'Function'.
> > Build complete -- 1 errors, 0 warnings
> >
> >
> > Any ideas?
> >
> > "Robert Bruckner [MSFT]" wrote:
> >
> >> I suggest to follow the approach discussed in this blog article:
> >> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
> >>
> >> You don't need the part about the custom legend, but you should take a
> >> close
> >> look at the custom color part of the sample. You can modify the code so
> >> that
> >> instead of having the hashtable approach to apply unique colors for
> >> categories, you replace it with some IF statement to explicitly control
> >> colors.
> >>
> >> A trivial RDL sample with two charts using different filters but sharing
> >> the
> >> same colors for categories is copied to the bottom of this posting.
> >>
> >> -- Robert
> >> This posting is provided "AS IS" with no warranties, and confers no
> >> rights.
> >>
> >>
> >> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> >> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> >> > Hello all!!
> >> >
> >> > I have created a pie chart that is embedded in a matrix report,
> >> > therefore
> >> > creating a new pie for every row. The problem I am having is the pie
> >> > slice
> >> > for the same series is changing each time there is a new pie. For
> >> > example,
> >> > in the first pie Cars may be designated as green but in the second pie
> >> > it
> >> > may
> >> > be red. I would like the colors to be consistent; all cars are
> >> > represented
> >> > as green slices. Oh and if there are no cars don't use the color green
> >> > for
> >> > another slice.
> >> >
> >> > I think this can be done using a nested expression but I am unsure how
> >> > to
> >> > write it...I either need an example of an expression that can handle
> >> > multiple slices or another way to handle the issue.
> >> >
> >> > Thanks,
> >> > Anthony
> >>
> >>
> >> ============================================> >>
> >> <?xml version="1.0" encoding="utf-8"?>
> >> <Report
> >> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
> >> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> >> <RightMargin>1in</RightMargin>
> >> <Author>Robert M. Bruckner</Author>
> >> <Body>
> >> <ReportItems>
> >> <Chart Name="chart2">
> >> <ThreeDProperties>
> >> <Rotation>30</Rotation>
> >> <Inclination>30</Inclination>
> >> <Shading>Simple</Shading>
> >> <WallThickness>50</WallThickness>
> >> </ThreeDProperties>
> >> <ZIndex>1</ZIndex>
> >> <Style>
> >> <BackgroundColor>White</BackgroundColor>
> >> </Style>
> >> <Legend>
> >> <Visible>true</Visible>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> <Position>RightCenter</Position>
> >> </Legend>
> >> <Palette>Default</Palette>
> >> <ChartData>
> >> <ChartSeries>
> >> <DataPoints>
> >> <DataPoint>
> >> <DataValues>
> >> <DataValue>
> >> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> >> </DataValue>
> >> </DataValues>
> >> <DataLabel />
> >> <Style>
> >>
> >> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> >> </Style>
> >> <Marker>
> >> <Size>6pt</Size>
> >> </Marker>
> >> </DataPoint>
> >> </DataPoints>
> >> </ChartSeries>
> >> </ChartData>
> >> <CategoryAxis>
> >> <Axis>
> >> <Title />
> >> <MajorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MajorGridLines>
> >> <MinorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MinorGridLines>
> >> <Min>0</Min>
> >> </Axis>
> >> </CategoryAxis>
> >> <DataSetName>DataSet1</DataSetName>
> >> <PointWidth>0</PointWidth>
> >> <Type>Bar</Type>
> >> <Top>3.125in</Top>
> >> <Title>
> >> <Caption>UK</Caption>
> >> </Title>
> >> <Width>6in</Width>
> >> <SeriesGroupings>
> >> <SeriesGrouping>
> >> <DynamicSeries>
> >> <Grouping Name="chart2_SeriesGroup1">
> >> <GroupExpressions>
> >>
> >> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> >> </GroupExpressions>
> >> </Grouping>
> >> <Sorting>
> >> <SortBy>
> >>
> >> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> >> <Direction>Ascending</Direction>
> >> </SortBy>
> >> </Sorting>
> >> <Label>=Fields!CategoryName.Value</Label>
> >> </DynamicSeries>
> >> </SeriesGrouping>
> >> </SeriesGroupings>
> >> <Subtype>Plain</Subtype>
> >> <PlotArea>
> >> <Style>
> >> <BackgroundColor>LightGrey</BackgroundColor>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </PlotArea>
> >> <Filters>
> >> <Filter>
> >> <FilterExpression>=Fields!Country.Value</FilterExpression>
> >> <Operator>Equal</Operator>
> >> <FilterValues>
> >> <FilterValue>UK</FilterValue>
> >> </FilterValues>
> >> </Filter>
> >> </Filters>
> >> <Left>0.125in</Left>
> >> <ValueAxis>
> >> <Axis>
> >> <Title />
> >> <MajorGridLines>
> >> <ShowGridLines>true</ShowGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MajorGridLines>
> >> <MinorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MinorGridLines>
> >> <MajorTickMarks>Outside</MajorTickMarks>
> >> <Min>0</Min>
> >> <Margin>true</Margin>
> >> <Visible>true</Visible>
> >> <Scalar>true</Scalar>
> >> </Axis>
> >> </ValueAxis>
> >> </Chart>
> >> <Chart Name="chart1">
> >> <ThreeDProperties>
> >> <Rotation>30</Rotation>
> >> <Inclination>30</Inclination>
> >> <Shading>Simple</Shading>
> >> <WallThickness>50</WallThickness>
> >> </ThreeDProperties>
> >> <Style>
> >> <BackgroundColor>White</BackgroundColor>
> >> </Style>
> >> <Legend>
> >> <Visible>true</Visible>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> <Position>RightCenter</Position>
> >> </Legend>
> >> <Palette>Default</Palette>
> >> <ChartData>
> >> <ChartSeries>
> >> <DataPoints>
> >> <DataPoint>
> >> <DataValues>
> >> <DataValue>
> >> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> >> </DataValue>
> >> </DataValues>
> >> <DataLabel />
> >> <Style>
> >>
> >> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> >> </Style>
> >> <Marker>
> >> <Size>6pt</Size>
> >> </Marker>
> >> </DataPoint>
> >> </DataPoints>
> >> </ChartSeries>
> >> </ChartData>
> >> <CategoryAxis>
> >> <Axis>
> >> <Title />
> >> <MajorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MajorGridLines>
> >> <MinorGridLines>
> >> <Style>
> >> <BorderStyle>
> >> <Default>Solid</Default>
> >> </BorderStyle>
> >> </Style>
> >> </MinorGridLines>
> >> <Min>0</Min>
> >> </Axis>
> >> </CategoryAxis>
> >> <DataSetName>DataSet1</DataSetName>
> >> <PointWidth>0</PointWidth>
> >> <Type>Bar</Type>
> >> <Top>0.25in</Top>
> >> <Title>
> >> <Caption>USA</Caption>
> >> </Title>
> >> <Width>6in</Width>
> >> <Height>2.5in</Height>
> >> <SeriesGroupings>
> >> <SeriesGrouping>
> >> <DynamicSeries>
> >> <Grouping Name="chart1_SeriesGroup1">
> >> <GroupExpressions>
> >>
> >> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> >> </GroupExpressions>
> >> </Grouping>
> >> <Sorting>|||Robert,
I found the problem with the code that I got from your blog article....in
all the cutting and pasting I ended up with a second end function that I
needed to scroll down to see.
Good thing is that the code is working...bad thing is I am getting the same
results. What I am trying to do is almost like conditional formatting. If
you return a specific value I want to return a specific color, the next value
will have another color assigned, and so on. All in all I should have no
more than 5-6 values that I need to define colors for.
I tried the following code which I think is more like what I am wanting:
In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
function:
= Code.GetColor(Fields!Project_Category.Value)
And in the code for the report I have:
Public Function GetColor(ByVal Project_Category As String) As String
if Project_Category = "Value 1" Then
Return "#CC3333" ' "Red"
end if
if Project_Category = "Value 2" Then
Return "Pink"
end if
if Project_Category = "Value 3" Then
Return "#3300CC" ' "Blue"
end if
if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
(Project_Category
<> "Value 3") Then
Return "Black"
end if
End Function
However, as I stated below I can't seem to get it to work because of the
following error:
There is an error on line 10 of custom code: [BC30201] Expression expected.
Build complete -- 1 errors, 0 warnings
I also thought of writing an IIF but I think the nesting could get pretty
complex....
"anthonysjo" wrote:
> I used the code off the site I had to change the Private to Public because I
> was getting errors and the only way I got them to go away was to change
> Private to Public.
> The code I have in the report properties code tab is as follows:
> Public colorPalette As String() = {"Green", "Blue", "Red", "Orange", "Aqua",
> "Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B", "#352F26", "#F1E7D6",
> "#E16C56", "#CFBA9B"}
> Public count As Integer = 0
> Public mapping As New System.Collections.Hashtable()
> Public Function GetColor(ByVal groupingValue As String) As String
> If mapping.ContainsKey(groupingValue) Then
> Return mapping(groupingValue)
> End If
> Dim c As String = colorPalette(count Mod colorPalette.Length)
> count = count + 1
> mapping.Add(groupingValue, c)
> Return c
> End Function
> The Data field for my chart is: YTD
> The Series field is: Project_Category
> for the Data field properties on my Pie chart I went to the apperance tab
> then series style... on the fill tab, color field I put the following FX:
> =Code.GetColor(Fields!Project_Category.Value)
> Any ideas what I am missing?
> I also tried the following code that someone modified off your code example
> with no luck either...
> In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
> function:
> = Code.GetColor(Fields!Project_Category.Value)
> And in the code for the report I have:
> Public Function GetColor(ByVal Project_Category As String) As String
> if Project_Category = "Value 1" Then
> Return "#CC3333" ' "Red"
> end if
> if Project_Category = "Value 2" Then
> Return "Pink"
> end if
> if Project_Category = "Value 3" Then
> Return "#3300CC" ' "Blue"
> end if
> if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> (Project_Category
> <> "Project_Category") Then
> Return "Black"
> end if
> End Function
> again no luck with this one.....
> THANKS AGAIN FOR ALL THE HELP!!!
> "Robert Bruckner [MSFT]" wrote:
> > Did you try the sample I had attached to the bottom of my previous posting,
> > or did you download the other sample about custom legends from the blog
> > article? Both should work as provided.
> >
> > In your particular case, the error message would indicate that you are
> > missing the Function keyword for the corresponding End Function statement on
> > line 14 of the custom code window of the report (VS menu -> report -> report
> > properties -> custom code)
> >
> > -- Robert
> > This posting is provided "AS IS" with no warranties, and confers no rights.
> >
> >
> >
> > "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> > news:13337779-49F4-44A7-B0B8-4963E58D2B75@.microsoft.com...
> > >I tried the code in the article but get the following error:
> > >
> > > There is an error on line 14 of custom code: [BC30430] 'End Function' must
> > > be preceded by a matching 'Function'.
> > > Build complete -- 1 errors, 0 warnings
> > >
> > >
> > > Any ideas?
> > >
> > > "Robert Bruckner [MSFT]" wrote:
> > >
> > >> I suggest to follow the approach discussed in this blog article:
> > >> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
> > >>
> > >> You don't need the part about the custom legend, but you should take a
> > >> close
> > >> look at the custom color part of the sample. You can modify the code so
> > >> that
> > >> instead of having the hashtable approach to apply unique colors for
> > >> categories, you replace it with some IF statement to explicitly control
> > >> colors.
> > >>
> > >> A trivial RDL sample with two charts using different filters but sharing
> > >> the
> > >> same colors for categories is copied to the bottom of this posting.
> > >>
> > >> -- Robert
> > >> This posting is provided "AS IS" with no warranties, and confers no
> > >> rights.
> > >>
> > >>
> > >> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> > >> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> > >> > Hello all!!
> > >> >
> > >> > I have created a pie chart that is embedded in a matrix report,
> > >> > therefore
> > >> > creating a new pie for every row. The problem I am having is the pie
> > >> > slice
> > >> > for the same series is changing each time there is a new pie. For
> > >> > example,
> > >> > in the first pie Cars may be designated as green but in the second pie
> > >> > it
> > >> > may
> > >> > be red. I would like the colors to be consistent; all cars are
> > >> > represented
> > >> > as green slices. Oh and if there are no cars don't use the color green
> > >> > for
> > >> > another slice.
> > >> >
> > >> > I think this can be done using a nested expression but I am unsure how
> > >> > to
> > >> > write it...I either need an example of an expression that can handle
> > >> > multiple slices or another way to handle the issue.
> > >> >
> > >> > Thanks,
> > >> > Anthony
> > >>
> > >>
> > >> ============================================> > >>
> > >> <?xml version="1.0" encoding="utf-8"?>
> > >> <Report
> > >> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
> > >> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> > >> <RightMargin>1in</RightMargin>
> > >> <Author>Robert M. Bruckner</Author>
> > >> <Body>
> > >> <ReportItems>
> > >> <Chart Name="chart2">
> > >> <ThreeDProperties>
> > >> <Rotation>30</Rotation>
> > >> <Inclination>30</Inclination>
> > >> <Shading>Simple</Shading>
> > >> <WallThickness>50</WallThickness>
> > >> </ThreeDProperties>
> > >> <ZIndex>1</ZIndex>
> > >> <Style>
> > >> <BackgroundColor>White</BackgroundColor>
> > >> </Style>
> > >> <Legend>
> > >> <Visible>true</Visible>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> <Position>RightCenter</Position>
> > >> </Legend>
> > >> <Palette>Default</Palette>
> > >> <ChartData>
> > >> <ChartSeries>
> > >> <DataPoints>
> > >> <DataPoint>
> > >> <DataValues>
> > >> <DataValue>
> > >> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> > >> </DataValue>
> > >> </DataValues>
> > >> <DataLabel />
> > >> <Style>
> > >>
> > >> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> > >> </Style>
> > >> <Marker>
> > >> <Size>6pt</Size>
> > >> </Marker>
> > >> </DataPoint>
> > >> </DataPoints>
> > >> </ChartSeries>
> > >> </ChartData>
> > >> <CategoryAxis>
> > >> <Axis>
> > >> <Title />
> > >> <MajorGridLines>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </MajorGridLines>
> > >> <MinorGridLines>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </MinorGridLines>
> > >> <Min>0</Min>
> > >> </Axis>
> > >> </CategoryAxis>
> > >> <DataSetName>DataSet1</DataSetName>
> > >> <PointWidth>0</PointWidth>
> > >> <Type>Bar</Type>
> > >> <Top>3.125in</Top>
> > >> <Title>
> > >> <Caption>UK</Caption>
> > >> </Title>
> > >> <Width>6in</Width>
> > >> <SeriesGroupings>
> > >> <SeriesGrouping>
> > >> <DynamicSeries>
> > >> <Grouping Name="chart2_SeriesGroup1">
> > >> <GroupExpressions>
> > >>
> > >> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> > >> </GroupExpressions>
> > >> </Grouping>
> > >> <Sorting>
> > >> <SortBy>
> > >>
> > >> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> > >> <Direction>Ascending</Direction>
> > >> </SortBy>
> > >> </Sorting>
> > >> <Label>=Fields!CategoryName.Value</Label>
> > >> </DynamicSeries>
> > >> </SeriesGrouping>
> > >> </SeriesGroupings>
> > >> <Subtype>Plain</Subtype>
> > >> <PlotArea>
> > >> <Style>
> > >> <BackgroundColor>LightGrey</BackgroundColor>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </PlotArea>
> > >> <Filters>
> > >> <Filter>
> > >> <FilterExpression>=Fields!Country.Value</FilterExpression>
> > >> <Operator>Equal</Operator>
> > >> <FilterValues>
> > >> <FilterValue>UK</FilterValue>
> > >> </FilterValues>
> > >> </Filter>
> > >> </Filters>
> > >> <Left>0.125in</Left>
> > >> <ValueAxis>
> > >> <Axis>
> > >> <Title />
> > >> <MajorGridLines>
> > >> <ShowGridLines>true</ShowGridLines>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </MajorGridLines>
> > >> <MinorGridLines>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>
> > >> </MinorGridLines>
> > >> <MajorTickMarks>Outside</MajorTickMarks>
> > >> <Min>0</Min>
> > >> <Margin>true</Margin>
> > >> <Visible>true</Visible>
> > >> <Scalar>true</Scalar>
> > >> </Axis>
> > >> </ValueAxis>
> > >> </Chart>
> > >> <Chart Name="chart1">
> > >> <ThreeDProperties>
> > >> <Rotation>30</Rotation>
> > >> <Inclination>30</Inclination>
> > >> <Shading>Simple</Shading>
> > >> <WallThickness>50</WallThickness>
> > >> </ThreeDProperties>
> > >> <Style>
> > >> <BackgroundColor>White</BackgroundColor>
> > >> </Style>
> > >> <Legend>
> > >> <Visible>true</Visible>
> > >> <Style>
> > >> <BorderStyle>
> > >> <Default>Solid</Default>
> > >> </BorderStyle>
> > >> </Style>|||All is well!!! I took the following code:
= Code.GetColor(Fields!Project_Category.Value)
> And in the code for the report I have:
> Public Function GetColor(ByVal Project_Category As String) As String
> if Project_Category = "Value 1" Then
> Return "#CC3333" ' "Red"
> end if
> if Project_Category = "Value 2" Then
> Return "Pink"
> end if
> if Project_Category = "Value 3" Then
> Return "#3300CC" ' "Blue"
> end if
> if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> (Project_Category
> <> "Value 3") Then
> Return "Black"
> end if
> End Function
Then removed this....
if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> (Project_Category
> <> "Value 3") Then
> Return "Black"
> end if
Everything works great now!!!!
Thanks for all the help!!
"anthonysjo" wrote:
> Robert,
> I found the problem with the code that I got from your blog article....in
> all the cutting and pasting I ended up with a second end function that I
> needed to scroll down to see.
> Good thing is that the code is working...bad thing is I am getting the same
> results. What I am trying to do is almost like conditional formatting. If
> you return a specific value I want to return a specific color, the next value
> will have another color assigned, and so on. All in all I should have no
> more than 5-6 values that I need to define colors for.
> I tried the following code which I think is more like what I am wanting:
> In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
> function:
> = Code.GetColor(Fields!Project_Category.Value)
> And in the code for the report I have:
> Public Function GetColor(ByVal Project_Category As String) As String
> if Project_Category = "Value 1" Then
> Return "#CC3333" ' "Red"
> end if
> if Project_Category = "Value 2" Then
> Return "Pink"
> end if
> if Project_Category = "Value 3" Then
> Return "#3300CC" ' "Blue"
> end if
> if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> (Project_Category
> <> "Value 3") Then
> Return "Black"
> end if
> End Function
> However, as I stated below I can't seem to get it to work because of the
> following error:
> There is an error on line 10 of custom code: [BC30201] Expression expected.
> Build complete -- 1 errors, 0 warnings
> I also thought of writing an IIF but I think the nesting could get pretty
> complex....
> "anthonysjo" wrote:
> > I used the code off the site I had to change the Private to Public because I
> > was getting errors and the only way I got them to go away was to change
> > Private to Public.
> >
> > The code I have in the report properties code tab is as follows:
> > Public colorPalette As String() = {"Green", "Blue", "Red", "Orange", "Aqua",
> > "Teal", "Gold", "RoyalBlue", "#A59D93", "#B8341B", "#352F26", "#F1E7D6",
> > "#E16C56", "#CFBA9B"}
> > Public count As Integer = 0
> > Public mapping As New System.Collections.Hashtable()
> >
> > Public Function GetColor(ByVal groupingValue As String) As String
> > If mapping.ContainsKey(groupingValue) Then
> > Return mapping(groupingValue)
> > End If
> > Dim c As String = colorPalette(count Mod colorPalette.Length)
> > count = count + 1
> > mapping.Add(groupingValue, c)
> > Return c
> > End Function
> >
> > The Data field for my chart is: YTD
> > The Series field is: Project_Category
> >
> > for the Data field properties on my Pie chart I went to the apperance tab
> > then series style... on the fill tab, color field I put the following FX:
> > =Code.GetColor(Fields!Project_Category.Value)
> >
> > Any ideas what I am missing?
> >
> > I also tried the following code that someone modified off your code example
> > with no luck either...
> >
> > In Chart Properties, Data, Values, Edit, Appearance, Series Style I use this
> > function:
> >
> > = Code.GetColor(Fields!Project_Category.Value)
> >
> > And in the code for the report I have:
> >
> > Public Function GetColor(ByVal Project_Category As String) As String
> > if Project_Category = "Value 1" Then
> > Return "#CC3333" ' "Red"
> > end if
> > if Project_Category = "Value 2" Then
> > Return "Pink"
> > end if
> > if Project_Category = "Value 3" Then
> > Return "#3300CC" ' "Blue"
> > end if
> > if (Project_Category <> "Value 1") and (Project_Category <> "Value 2") and
> > (Project_Category
> > <> "Project_Category") Then
> > Return "Black"
> > end if
> > End Function
> >
> > again no luck with this one.....
> >
> > THANKS AGAIN FOR ALL THE HELP!!!
> >
> > "Robert Bruckner [MSFT]" wrote:
> >
> > > Did you try the sample I had attached to the bottom of my previous posting,
> > > or did you download the other sample about custom legends from the blog
> > > article? Both should work as provided.
> > >
> > > In your particular case, the error message would indicate that you are
> > > missing the Function keyword for the corresponding End Function statement on
> > > line 14 of the custom code window of the report (VS menu -> report -> report
> > > properties -> custom code)
> > >
> > > -- Robert
> > > This posting is provided "AS IS" with no warranties, and confers no rights.
> > >
> > >
> > >
> > > "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> > > news:13337779-49F4-44A7-B0B8-4963E58D2B75@.microsoft.com...
> > > >I tried the code in the article but get the following error:
> > > >
> > > > There is an error on line 14 of custom code: [BC30430] 'End Function' must
> > > > be preceded by a matching 'Function'.
> > > > Build complete -- 1 errors, 0 warnings
> > > >
> > > >
> > > > Any ideas?
> > > >
> > > > "Robert Bruckner [MSFT]" wrote:
> > > >
> > > >> I suggest to follow the approach discussed in this blog article:
> > > >> http://blogs.msdn.com/bwelcker/archive/2005/05/20/420349.aspx
> > > >>
> > > >> You don't need the part about the custom legend, but you should take a
> > > >> close
> > > >> look at the custom color part of the sample. You can modify the code so
> > > >> that
> > > >> instead of having the hashtable approach to apply unique colors for
> > > >> categories, you replace it with some IF statement to explicitly control
> > > >> colors.
> > > >>
> > > >> A trivial RDL sample with two charts using different filters but sharing
> > > >> the
> > > >> same colors for categories is copied to the bottom of this posting.
> > > >>
> > > >> -- Robert
> > > >> This posting is provided "AS IS" with no warranties, and confers no
> > > >> rights.
> > > >>
> > > >>
> > > >> "anthonysjo" <anthonysjo@.discussions.microsoft.com> wrote in message
> > > >> news:69E297FD-F5C7-44D4-9463-5E4871B1CEAB@.microsoft.com...
> > > >> > Hello all!!
> > > >> >
> > > >> > I have created a pie chart that is embedded in a matrix report,
> > > >> > therefore
> > > >> > creating a new pie for every row. The problem I am having is the pie
> > > >> > slice
> > > >> > for the same series is changing each time there is a new pie. For
> > > >> > example,
> > > >> > in the first pie Cars may be designated as green but in the second pie
> > > >> > it
> > > >> > may
> > > >> > be red. I would like the colors to be consistent; all cars are
> > > >> > represented
> > > >> > as green slices. Oh and if there are no cars don't use the color green
> > > >> > for
> > > >> > another slice.
> > > >> >
> > > >> > I think this can be done using a nested expression but I am unsure how
> > > >> > to
> > > >> > write it...I either need an example of an expression that can handle
> > > >> > multiple slices or another way to handle the issue.
> > > >> >
> > > >> > Thanks,
> > > >> > Anthony
> > > >>
> > > >>
> > > >> ============================================> > > >>
> > > >> <?xml version="1.0" encoding="utf-8"?>
> > > >> <Report
> > > >> xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefinition"
> > > >> xmlns:rd="">http://schemas.microsoft.com/SQLServer/reporting/reportdesigner">
> > > >> <RightMargin>1in</RightMargin>
> > > >> <Author>Robert M. Bruckner</Author>
> > > >> <Body>
> > > >> <ReportItems>
> > > >> <Chart Name="chart2">
> > > >> <ThreeDProperties>
> > > >> <Rotation>30</Rotation>
> > > >> <Inclination>30</Inclination>
> > > >> <Shading>Simple</Shading>
> > > >> <WallThickness>50</WallThickness>
> > > >> </ThreeDProperties>
> > > >> <ZIndex>1</ZIndex>
> > > >> <Style>
> > > >> <BackgroundColor>White</BackgroundColor>
> > > >> </Style>
> > > >> <Legend>
> > > >> <Visible>true</Visible>
> > > >> <Style>
> > > >> <BorderStyle>
> > > >> <Default>Solid</Default>
> > > >> </BorderStyle>
> > > >> </Style>
> > > >> <Position>RightCenter</Position>
> > > >> </Legend>
> > > >> <Palette>Default</Palette>
> > > >> <ChartData>
> > > >> <ChartSeries>
> > > >> <DataPoints>
> > > >> <DataPoint>
> > > >> <DataValues>
> > > >> <DataValue>
> > > >> <Value>=Sum(Fields!UnitsInStock.Value)</Value>
> > > >> </DataValue>
> > > >> </DataValues>
> > > >> <DataLabel />
> > > >> <Style>
> > > >>
> > > >> <BackgroundColor>=Code.GetColor(Fields!CategoryName.Value)</BackgroundColor>
> > > >> </Style>
> > > >> <Marker>
> > > >> <Size>6pt</Size>
> > > >> </Marker>
> > > >> </DataPoint>
> > > >> </DataPoints>
> > > >> </ChartSeries>
> > > >> </ChartData>
> > > >> <CategoryAxis>
> > > >> <Axis>
> > > >> <Title />
> > > >> <MajorGridLines>
> > > >> <Style>
> > > >> <BorderStyle>
> > > >> <Default>Solid</Default>
> > > >> </BorderStyle>
> > > >> </Style>
> > > >> </MajorGridLines>
> > > >> <MinorGridLines>
> > > >> <Style>
> > > >> <BorderStyle>
> > > >> <Default>Solid</Default>
> > > >> </BorderStyle>
> > > >> </Style>
> > > >> </MinorGridLines>
> > > >> <Min>0</Min>
> > > >> </Axis>
> > > >> </CategoryAxis>
> > > >> <DataSetName>DataSet1</DataSetName>
> > > >> <PointWidth>0</PointWidth>
> > > >> <Type>Bar</Type>
> > > >> <Top>3.125in</Top>
> > > >> <Title>
> > > >> <Caption>UK</Caption>
> > > >> </Title>
> > > >> <Width>6in</Width>
> > > >> <SeriesGroupings>
> > > >> <SeriesGrouping>
> > > >> <DynamicSeries>
> > > >> <Grouping Name="chart2_SeriesGroup1">
> > > >> <GroupExpressions>
> > > >>
> > > >> <GroupExpression>=Fields!CategoryName.Value</GroupExpression>
> > > >> </GroupExpressions>
> > > >> </Grouping>
> > > >> <Sorting>
> > > >> <SortBy>
> > > >>
> > > >> <SortExpression>=Fields!CategoryName.Value</SortExpression>
> > > >> <Direction>Ascending</Direction>
> > > >> </SortBy>
> > > >> </Sorting>
> > > >> <Label>=Fields!CategoryName.Value</Label>
> > > >> </DynamicSeries>
> > > >> </SeriesGrouping>
> > > >> </SeriesGroupings>
> > > >> <Subtype>Plain</Subtype>
> > > >> <PlotArea>
> > > >> <Style>
> > > >> <BackgroundColor>LightGrey</BackgroundColor>
> > > >> <BorderStyle>
> > > >> <Default>Solid</Default>
> > > >> </BorderStyle>
> > > >> </Style>
> > > >> </PlotArea>
> > > >> <Filters>
> > > >> <Filter>
> > > >> <FilterExpression>=Fields!Country.Value</FilterExpression>
> > > >> <Operator>Equal</Operator>