我正在以编程方式创建一个堆积条形图 (DataVisualization.Charting.Chart),并且还在以编程方式向其中添加图例项。我希望将图例显示在图表底部。
但是,在这样做时,图例会与图表的 X 轴重叠。
以下是我正在使用的代码:
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
以下语句将该图表添加到图例中。
_msChart.Legends.Add(GetLegend("SomeValue1", 10.0F))
有什么问题,缺少了什么?我想只在底部显示图例,但它不应与X轴重叠。