Asp.net Charts: Legend Overlaps with X Axis

I create a chart (DataVisualization.Charting.Chart) programmatically, which is a gated histogram.

I also add Legend program records to it. I want to show the Legend at the bottom of the chart.

But at the same time, Legend overlaps with the X axis of the chart.

Here is the code I'm using:

Private Function GetLegend(ByVal legendName As String, ByVal s As Single) As     System.Windows.Forms.DataVisualization.Charting.Legend

 Dim objLegend As System.Windows.Forms.DataVisualization.Charting.Legend = New System.Windows.Forms.DataVisualization.Charting.Legend()

 objLegend.Name = legendName
 objLegend.Font = New System.Drawing.Font("Verdana", s)
 objLegend.IsDockedInsideChartArea = False
 objLegend.Docking = Docking.Bottom
 Return objLegend
End Function

Below the operator adds Legend to the diagram

_msChart.Legends.Add(GetLegend("SomeValue1", 10.0F))

Any idea what is missing? I want to show the legend only below, but it should not overlap with the X axis.

+3
source share
2 answers

I had the same problem today. Try adding:

objLegend.Position.Auto = true
objLegend.DockedToChartArea = "yourChartAreaName"

This did not help me, but I found on the net that this might be useful (and a clean solution).

, , , . , :

chart.ChartAreas[0].Position.Y = 15

, , , 20 chart.Size.

, .

+2

/, . , , .

, , .

Chart1.ChartAreas[0].InnerPlotPosition = new ElementPosition(15, 5, 90, 75);

intellisense , , , - ( , ). , , , , 15% 5% 90% 75%.

0

Source: https://habr.com/ru/post/1782596/


All Articles