使图表文本注释出现在DataPoints后面

时间:2012-04-24 21:48:55

标签: c# .net winforms mschart

有没有办法在C#中的Chart控件中添加TextAnnotation,其中注释出现在数据点后面?似乎没有办法将注释发送到后面。

2 个答案:

答案 0 :(得分:1)

您是否尝试更改PrePaint事件

中文本注释的Z顺序

检查此链接 http://support2.dundas.com/OnlineDocumentation/WebChart2005/Annotations.html

搜索“使用Z顺序”

答案 1 :(得分:0)

我在点图表中使用的脏解决方案。重新绘制其他所有数据点。

Private Sub Chart1_Paint(chart1 As Chart, e As PaintEventArgs) Handles Chart1.Paint
    For Each chartSeries As Series In chart1.Series
        Dim ca As ChartArea = chart1.ChartAreas(chartSeries.ChartArea)
        For Each chartPoint As DataPoint In chartSeries.Points

            'Determine the position, size and color of the original datapoint.
            Dim x As Double = ca.AxisX.ValueToPixelPosition(chartPoint.XValue)
            Dim y As Double = ca.AxisY.ValueToPixelPosition(chartPoint.YValues.First)
            Dim b As New SolidBrush(chartSeries.Color)
            Dim width As Double = chartPoint.MarkerSize
            Dim r As New Rectangle(x - width / 2, y - width / 2, width, width)

            'Draw the new datapoint on top of the original (and on top of any annotations)
            e.Graphics.FillEllipse(b, r)
        Next
    Next
End Sub