I'm using the MS Chart component for .Net 3.5, and I'm using it to construct a metafile. (We're embedding it in an RTF report.) In order to work around the issue with WMF coordinates being poor precision, my virtual chart area is large (6000×4000) pixels.
I am rescaling everything with the following method:
public void UpdateScaledElements()
{
float scaleFactor = Chart.Height / 400f;
foreach (Series s in Chart.Series)
{
s.Font = new Font(FONT_NAME, 8 * scaleFactor);
s.BorderWidth = (int)(1.6 * scaleFactor);
s.MarkerSize = (int)(6 * scaleFactor);
}
foreach (Legend l in Chart.Legends) {
l.Font = new Font(FONT_NAME, 8 * scaleFactor);
}
foreach (Axis a in Chart.ChartAreas[0].Axes)
{
a.TitleFont = new Font(FONT_NAME, 10 * scaleFactor);
a.LabelStyle.Font = new Font(FONT_NAME, 8 * scaleFactor);
a.LineWidth = (int)(2 * scaleFactor);
}
}
It's working pretty well. However, I can't work out how to make the line thickness of the lines drawn in the legend/key to scale up. I expected them to come through from the series like the marker scale and colour do. I've searched but I can't find a solution.
I have tried changing l.BorderWidth (it actually does change the border of the key, not lines within it), rebuilding the key in this method, and using the CustomizeLegend event to set BorderWidth on individual items. None of those changed the default behaviour, which seems to be 1 unit – which will be a hairline when this is printed, not a nice bold line like the series.
Edit: I have 'solved' this by painting the line myself in a PostPaint handler. This is a hack so I'm still in the market for an elegant solution.