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
350
How to fix width in chart.
posted

 Hi All,

I used StackedChart in my project. I want my columns are a fixed width in chart. Currently the width of the columns auto-sizes to the width of the screen. Ex: My chart has one column since the width of this column auto-size to the width of the screen.

Any ideas?

Thanks. 

  • 17605
    posted

    To do this you can use ChartDrawItem Event. The code could be something like:

    this.ultraChart1.ChartDrawItem += new Infragistics.UltraChart.Shared.Events.ChartDrawItemEventHandler(ultraChart1_ChartDrawItem);

    ...

    private const int columnWidth = 100;

    ...

    void ultraChart1_ChartDrawItem(object sender, Infragistics.UltraChart.Shared.Events.ChartDrawItemEventArgs e)

    {

    Box box = e.Primitive as Box;

    if (box == null)

    {

    return;

    }

    if (box.DataPoint == null)

    {

    return;

    }

    int dWidth = box.rect.Width - columnWidth;

    if (dWidth <= 0)

    {

    return;

    }

    box.rect.Width = columnWidth;

    box.rect.X += dWidth / 2;

    }