Click here to Skip to main content
15,885,914 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have a chart with a variable number of series which can be determined by the user. If a small number of series are used then the chart and legends appear correctly (legends are underneath the chart) - if I use a larger number of series then the chart gets smaller and smaller until the point when it virtually disappears and all that is left is the x axis line which appears at the top of the area, and the legend at the bottom with nothing in between.

Putting aside the fact that a chart with over thirty series would be a bit tricky to view anyway, here's some screenshots to demonstrate the issue:

Chart with ten series: http://i62.tinypic.com/dr5n6h.jpg[^]
Chart with sixteen series: http://i59.tinypic.com/2i9qyp1.jpg[^]
Chart with thirty six series: http://i58.tinypic.com/103blhv.jpg[^]
Posted

Solution here: https://social.msdn.microsoft.com/Forums/vstudio/en-US/7a108b04-11d1-4d7a-843a-eaa5d0b97396/how-to-remove-space-bettween-chart-area-and-the-start-point-of-the-chart-picture?forum=MSWinWebChart[^]

Quote: "In the Winforms world, I happen to explicitly set the Position X/Y/Width/Height values for my legend and the chart area itself by doing something like so:

myChart.ChartAreas[0].Position.Autio = false;
myChart.ChartAreas[0].Position.X = 20;
myChart.ChartAreas[0].Position.Y = 0;
myChart.ChartAreas[0].Position.Width = 80;
myChart.ChartAreas[0].Position.Height = 100;
myChart.Legends[0].Position.Auto = false;
myChart.Legends[0].Position.X = 0;
myChart.Legends[0].Position.Y = 0;
myChart.Legends[0].Position.Width = 20;
myChart.Legends[0].Position.Height = 100;

and then my legend takes up 20% of the space horizontally."
 
Share this answer
 
The only solution that I can implement for this situation was to adapt the height of the entire control according to the number of legends that are added. Obviously the setting depends on the width of the control. So what I did was save the original height of the control in a variable and by trial error modify the height by a percentage. In my case I found that approximately for every 10 legends (1 row) I had to increase the height of the control by 3% with respect to its original height. Finally embed the chart inside a panel with autoscroll enabled.

Although my legends were aligned to the bottom, I think it works the same for alignment to the right, in this case modifying the width of the control using the same logic.

I hope it works for you.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900