Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
380
Column Color in StackColumnChart
posted

I'm trying to set the colors of my columns in a stacked bar chart and can't seem to get it working.  The code works in a regular column chart, but not a stacked one.  This is the code I'm using:

    Protected Sub UltraChart1_ChartDrawItem(ByVal sender As Object, ByVal e As Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs) Handles UltraChart1.ChartDrawItem
        Dim box As Box = TryCast(e.Primitive, Box)
        If box Is Nothing Then
            Exit Sub
        End If

        If box.Path Is Nothing Then
            Select Case box.Column
                Case 0
                    box.PE.Fill = Color.Red
                    box.PE.FillStopColor = Color.Red
                Case 1
                    box.PE.Fill = Color.Yellow
                    box.PE.FillStopColor = Color.Yellow
                Case 2
                    box.PE.Fill = Color.Green
                    box.PE.FillStopColor = Color.Green
            End Select
        End If
    End Sub

Can someone please point me in the right direction?

Thanks!

  • 26458
    Verified Answer
    Offline posted

    StackColumnChart boxes have their Path set to "Border.Title.Grid.Chart", so your select statement never gets hit. I think it would be better to change the condition to use Row and Column instead of Path.

    if box.Row >=0 and box.Column>=0 then
    select ...