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).
Resize LegendPalette
Re: Resize LegendPalette
Hello John,
I have modified your project and works faster than before, using next lines of code in ChartRisize Event:
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,
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;
}
Thanks,
Best Regards,
Sandra Pazos / Development & Support Steema Software Avinguda Montilivi 33, 17003 Girona, Catalonia Tel: 34 972 218 797 http://www.steema.com |
Instructions - How to post in this forum |