Resize LegendPalette

TeeChart for Microsoft Visual Studio .NET, Xamarin Studio (Android, iOS & Forms) & Monodevelop.
Post Reply
John
Newbie
Newbie
Posts: 7
Joined: Fri Aug 20, 2010 12:00 am
Contact:

Resize LegendPalette

Post by John » Sun Mar 13, 2011 6:02 pm

I have a chart with a ColorGrid and a LegendPalette. I position the LegendPalette to the right of the chart as shown:

mLegendPalette = new LegendPalette(tChart1.Chart);
mLegendPalette.PositionUnits = PositionUnits.Pixels;
mLegendPalette.Axis = LegendPaletteAxis.laOther;
mLegendPalette.Width = 60;
mLegendPalette.Pen.Visible = false;

int right = tChart1.Chart.ChartBounds.Right;
int top = tChart1.Chart.ChartBounds.Top;
int bottom = tChart1.Chart.ChartBounds.Bottom;

mLegendPalette.Left = right - 70;
mLegendPalette.Top = (bottom - top) / 2 - mLegendPalette.Height / 2;
mLegendPalette.Chart.Axes.Right.Maximum = mColorBarMax;
mLegendPalette.Chart.Axes.Right.Minimum = mColorBarMin;
mLegendPalette.Chart.Axes.Right.Increment = mColorBarStep;

When the user resizes the Form that the chart is in I update the legend position using the SizeChanged event handler as follows:

private void tChart1_SizeChanged(object sender, EventArgs e)
{
int right = tChart1.Chart.ChartBounds.Right;
int top = tChart1.Chart.ChartBounds.Top;
int bottom = tChart1.Chart.ChartBounds.Bottom;
mLegendPalette.Left = right - 70;
mLegendPalette.Top = (bottom - top) / 2 - mLegendPalette.Height / 2;
}

Sometimes it resizes to the correct position and sometimes it is does not. If I make a call to tChart1.Draw() at beginning of the SizedChanged event handler it works but the response time to draw is very very slow. Without this the response time is fast. I am using System.Drawing.Drawing2D.SmoothingMode.HighSpeed. What is the proper way to do this and have fast redrawing? By the way, my colorgrid has a lot of data points (1048576 data points).

Sandra
Site Admin
Site Admin
Posts: 3132
Joined: Fri Nov 07, 2008 12:00 am

Re: Resize LegendPalette

Post by Sandra » Mon Mar 14, 2011 12:32 pm

Hello John,

I have modified your project and works faster than before, using next lines of code in ChartRisize Event:

Code: Select all

        void tChart1_Resize(object sender, EventArgs e)
        {
            tChart1.AutoRepaint = false;
            right = tChart1.Chart.ChartBounds.Right;
            top = tChart1.Chart.ChartBounds.Top;
            bottom = tChart1.Chart.ChartBounds.Bottom;
            mLegendPalette.Left = right - 70;
            mLegendPalette.Top = (bottom - top) / 2 - mLegendPalette.Height / 2;
            tChart1.AutoRepaint = true;
            tChart1.Refresh();
            tChart1.AutoRepaint = false;
        }
Could you tell us if using previous code your application works faster? If it doesn't solve your problem of performance , please send us a simple project so we try to help you to solve your problem.

Thanks,
Best Regards,
Sandra Pazos / Development & Support
Steema Software
Avinguda Montilivi 33, 17003 Girona, Catalonia
Tel: 34 972 218 797
http://www.steema.com
Image Image Image Image Image Image
Instructions - How to post in this forum

Post Reply