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
230
Stack Bar Chart - colour stacks at runtime.
posted

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.

Parents
No Data
Reply
  • 28496
    Verified Answer
    Offline posted

    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);
    }

    };

Children