Reputation: 41
I have an MSChart with annotations, the charting area is sizable so that people using the old school 800x600 can see the chart.
Problem is, when I view my chart under this low resolution, the annotations within it shrink with the chart and begins to cut off the last couple of letters.
For example an annotation with "Hello world" in normal resoultion becomes "Hello W" under the 800x600.
Anyone know how I could set the annotaiton properties so they dont shrink?
Upvotes: 4
Views: 1836
Reputation: 2233
I had the same problem, and I haven't been able to find a way to make the annotation fixed size. I did figure out that the annotation dimensions are set as a percentage of the chart (i.e. the reason it's resizing is that Width = 25
actually means 25% of the chart width), so I wrote a little hack to resize the annotation whenever the chart resizes:
var annotation = new RectangleAnnotation() { ... }
chart.Annotations.Add(annotation);
chart.Resize += (sndr, ev) => {
// Shoot for 60 pixels tall and 130 wide
// Annotation dimensions are set as a percentage of the chart area
annotation.Width = (130d / chart.Width) * 100;
annotation.Height = (60d / chart.Height) * 100;
};
This is kind of ugly, but it works for me.
Upvotes: 1