Quantcast
Channel: SQL Server Reporting Services, Power View Forum
Viewing all articles
Browse latest Browse all 4035

How to Change Bar Chart Color Based on Value in Database?

$
0
0
        For Each dp As DataPoint In Chart1.Series("Wilma").Points
            For i As Integer = 0 To grpDT.Rows.Count - 1
                    If (grpDT.Rows(i).Item("Status").ToString() = "2") Then
                        dp.Color = Color.Green
                    Else
                        dp.Color = Color.Crimson
                    End If
                Next
        Next

Hi,

how can I change the color of bar chart based on value in database column?

For example, in table "STATUS" in my database, I have 3 value.  What I want is:

1) If the value = 0, then color will change to blue.

2) If the value = 1, then color will change to red.

3) If the value = 2, then color will change to green.

I use MSChart to create the chart.

I set the default color as blue. I tried to store STATUS value in dataset and do for loop to retrieve the value. If i found value = 2, then it will change to green. else the color will be red. but its not worked.

Here is the code:

 

Can someone help me? i'm stuck at this at almost a week :(


Viewing all articles
Browse latest Browse all 4035

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>