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
680
Axis Label Colors
posted

I would like to change the axis labels to various colors depending upon value. For example, with a zero aligned chart, I would like the negative values to be in red and the positive values in black. Is this possible? I tried IRenderLabel but it returns a string object. If I go through ChartDrawItem, I am unsure what the primitive would be for the label item.

 

Thanks,

Alan

  • 17605
    posted

    Hi Alan,

    the primitive for label item is Text. In your case you can try code like this:

    Text text = e.Primitive as Text;

    if (text == null)

    return;

    double val;

    if (double.TryParse(text.GetTextString(), out val) == false)

    return;

    if (val < 0)

    {

    text.PE.Fill =
    Color.Blue;

    }

    else

    {

    text.PE.Fill =
    Color.Red;

    }