Profile Picture

Auto height NChartControl

Posted By Hasindu Diyabalanage 11 Years Ago
Author
Message
Hasindu Diyabalanage
Posted 11 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 11 Years Ago
Posts: 7, Visits: 1
Hi,

I'm using the following code to display a bar chart. I used to set the height and width for the NChartControl as shown. But if you refer Image 1, if i predefined the height, the legend is cut at the end. Is there any way to make the height stretch automatically?

NChartControl NChartControl1 = new NChartControl();
NLegend m_Legend;

//config chart control
NChartControl1.Width = 700;
NChartControl1.Height = 300;

if (NChartControl1.RequiresInitialization)
{
//Config chart
NChart chart = NChartControl1.Charts[0];
}

Any help is much appreciated.

Best regards,
Hasindu

Attachments
Image 1.gif (80 views, 40.00 KB)
Nevron Support
Posted 11 Years Ago
View Quick Profile
Supreme Being

Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)Supreme Being (4,435 reputation)

Group: Forum Members
Last Active: Last Week
Posts: 3,054, Visits: 4,009

Hi Hasindu,

You need to recalculate the chart layout and check what is the legend height in order to dynamically resize the control – the following code snippet shows how to achieve this:

                NThinChartControl1.Settings.JitterMode = JitterMode.Enabled;
                NThinChartControl1.BackgroundStyle.FrameStyle.Visible = false;

                           // setup chart
                NChart chart = NThinChartControl1.Charts[0];
                chart.BoundsMode = BoundsMode.Stretch;
                chart.Dock = DockStyle.Fill;
                chart.Margins = new NMarginsL(10, 10, 10, 10);

                           for (int i = 0; i < 20; i++)
                           {
                                  NBarSeries bar = new NBarSeries();
                                  bar.Values.Add(i);
                                  chart.Series.Add(bar);
                           }

                           // recalculate layout
                           NThinChartControl1.RecalcLayout();

                           // update height
                           NLegend legend = NThinChartControl1.Legends[0];
                           NThinChartControl1.Height = new Unit(legend.ContentArea.Bottom + 10, System.Web.UI.WebControls.UnitType.Pixel);



Best Regards,
Nevron Support Team





Similar Topics


Reading This Topic