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
145
Set the minimum value on the Y-Axis to a negative value in a ColumnChart
posted

Hi, I am trying to have the minimum value on the Y-Axis as a negative value and make it the start of every column in a ColumnChart.

As example, I have, let's say, 5 values: (1,10); (2,15); (3,0); (4,-10); (5,-5). And I set the minimum value as -20 for example.

I want the chart to show me a bar that goes from

-20 to 10 for the first value; -20 to 15, for the 2nd; -20 to 0, -20 to -10 and -20 to -5.

It will be as if I had the -20 as the zero-base. I don't want the negative values to go downards and the positive upwards. Everything goes upwards starting at the value set.

Any ideas on how to achieve this?

 Thanks,

Imad

 

 

Parents
  • 2406
    posted

    Hi Imad,

    There is not a property which you can use to achive the desired functionality.

    There are two approachies you can use to achive it manually:

    - change the axis labels texts, i.e. 0 become -20 etc... or

    - use FillSceneGraph event handler, get every box of the chart and change its rectangle height with the difference to the x axis. For example:

    void ultraChart1_FillSceneGraph(object sender, Infragistics.UltraChart.Shared.Events.FillSceneGraphEventArgs e)
    {
        IAdvanceAxis xAxis = (IAdvanceAxis)e.Grid["X"];
        for (int i = 0; i < e.SceneGraph.Count; i++)
        {
            Box b = e.SceneGraph[i] as Box;
            if (b != null)
            {
                Rectangle currentRect = b.rect;
                int difference = (xAxis as Axis).startPoint.Y - currentRect.Y;
                currentRect.Height = currentRect.Height + difference;
                b.rect = currentRect;
            }
        }
    }

    Let me know if you need further assistance.

Reply Children
No Data