I have implemented several AnnotationsXY 'Tables' based on your example.
They have size and location persistence as well as dynamic height based on content.
I need help with the resizing though.
The fonts need to scale as well as the table cell proportions.
Currently, during table creation, I am storing the creation font in the Tag object,
Code: Select all
foreach (AnnotationXY axy in _chart.ViewXY.Annotations)
{
axy.Tag = axy.TextStyle.Font;
}
return elementCount;
Could you PLEASE take a look at it please and tell me where I am going wrong?
Code: Select all
if ((_table_prev_width != width) || (_table_prev_height != height))
{
float ratioWidth = _orig_Width / width;
float ratioHeight = (float)((_orig_ActualHeight / height) * .70); //.70 was a feeble attempt to keep text from overlapping...
float ratioMax = Math.Max(ratioWidth, ratioHeight);
for (int index = _startingCellOfTable; index < _endingCellOfTable - 1; index++)
{
AnnotationXY axy = _chart.ViewXY.Annotations[index];
Font origFont = (Font)axy.Tag;
float origSize = origFont.SizeInPoints;
float newSize = origSize * 1 / ratioMax;
Font newFont = new Font(origFont.Name, newSize, origFont.Style);
axy.TextStyle.Font = newFont;
}
}