0

I'm using VS2019 and the default Winforms Pie Chart. The legend appears as in the attached image.

I've tried playing with the chart size, and the larger I make the chart, the less truncated the legend text becomes, but it's going to have to be huge to fit it all in...

Any ideas why and how to change that so it's never truncated regardless of text length or chart size?

enter image description here

Thanks

EDIT:

Looking at the TextWrapThreshold and IsTextAutoFit properties of the Legend, the text is still graphically truncated, although it seems it is being "wrapped" like specified. This is still an undesired result.. What other solution is there besides enlarging the chart..?

enter image description here

Yafim Simanovsky
  • 531
  • 7
  • 26
  • Have you tried enabling IsTextAutoFit in the Legends property? Also, you can make the font for the legend a bit smaller by setting a smaller AutoFitMinFontSize – FandangoOnCore May 09 '20 at 18:42
  • @FandangoOnCore I tried both tips you suggest. IsTextAutoFit had no effect. I tried adding also the AutoFitMinFontSize as small as possible, which is 5, and that expanded the text a bit better but still getting cut off. I need a way to either make the text Wrap, or to have it not truncate. – Yafim Simanovsky May 11 '20 at 16:25
  • There's another interesting property for the legend, called TextWrapThreshold. The documentation states if you put a space in the description and set TextWrapThreshold to a sufficiently small size, the text will wrap on the space character. [link](https://learn.microsoft.com/en-us/dotnet/api/system.web.ui.datavisualization.charting.legend.textwrapthreshold?view=netframework-4.8) – FandangoOnCore May 11 '20 at 18:21
  • @FandangoOnCore Thanks. I've added another image regarding your comments. – Yafim Simanovsky May 12 '20 at 20:20
  • 1
    Did you set the InnerPlotPosition or the Position properties if the ChartArea manually or are they both set to Auto? Strange, the doughnut diameter should resize automatically to show more of the legend text...anyway: if you don't mind the position of the graph and the position of the legend in the control area, you can change the ChartArea to position [0, 0, smaller_width, smaller_height] to move the chart on the upper left side of the area and resize it a bit, then, on the Legend property, change the Position to move the Legend below the doughnut and set Width at 100 (maximum) – FandangoOnCore May 12 '20 at 21:53
  • @FandangoOnCore Thanks! It got better. I set the ChartArea Position and InnerPlotPosition to Auto=True, and the same for the Position on the Legend properties, because I want the legend in the center right, not the bottom. I also set the Legend MaximumAutoSize from 50 to 100. This shows the full legend texts. I have a label in the middle of the doughnut, graphically it's nicer. When I have all these settings on, the graph resizes depending on the legend and the label gets shifted and overlaps the chart. How would you group the label and chart so that they are always center-center? – Yafim Simanovsky May 14 '20 at 15:59

1 Answers1

0

@Yafim I'm moving the answer here because I need to post some images. You mean this is happening?

enter image description here

If this is the case, and you don't want the full legend text to appear inside the sections of the doughnut (because they are overlapping the doughnut itself), you can show the values only by setting the Series->Label->IsValueShownAsLabel property to true and get something similar to this:

enter image description here

Not sure if this was your problem, (you already showed in you photos you know about this)...

FandangoOnCore
  • 269
  • 2
  • 9
  • Thanks. This wasn't actually my problem, I explained myself poorly. What is happening is I placed a Label object from the ToolBox onto my Form, separate from the Pie Chart altogether, but I positioned it right in the center of the doughnut, but because the chart area resizes according to legend length etc, the Label is overlapping the pie chart. I'm wondering if there is a way to make their relationship center-to-center more permanent with some positioning properties...? Thank you – Yafim Simanovsky May 15 '20 at 06:58
  • 1
    @Yafim A solution for this can be found here: [link](https://stackoverflow.com/questions/45626619/place-label-at-center-of-doughnut-chart) – FandangoOnCore May 15 '20 at 11:02