Hi
We are implementing a Winforms StackBarChart. The chart will always have a single column with two stacks. We need to assign a different but specific color to each stack. Stack color is determined at runtime. How can this be achieved?
We use version 12.2. Many thanks.
Thank you, that worked out fine, here is the vb implementation we used...
Private Sub uchPopUp_ChartDrawItem(sender As Object, e As Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs) Handles uchPopUp.ChartDrawItem Dim box As Box = TryCast(e.Primitive, Box) If box Is Nothing Then Return End If Dim isDataPrimitive As Boolean = TypeOf box.Layer Is BarLayer If isDataPrimitive Then If Not box Is Nothing AndAlso box.Row = 0 AndAlso box.Column = 1 Then box.PE = New PaintElement(Color.Red) ElseIf Not box Is Nothing AndAlso box.Row = 0 AndAlso box.Column = 0 Then box.PE = New PaintElement(Color.Green) End If End If End Sub
try using the ChartDrawItem event. that, along with the FillSceneGraph event, is the most flexible way to apply custom coloring logic.
myChart.ChartDrawItem += (oo, ee) => { Box box = ee.Primitive as Box; if (box == null) { return; } bool isDataPrimitive = box.Layer is ColumnLayer; if (isDataPrimitive) { // todo: configure PaintElement box.PE based on runtime conditions // consider box.Row, box.Column, box.Value, and other properties for contextual information. box.PE = new PaintElement(Color.Red); }
};