Resize LegendPalette
Posted: 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).
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).