4

如何为 ZedGraph 图表中绘制的每个点显示标签?

4

2 回答 2

8

由于该站点现在已关闭,这里有一个代码片段来举例说明如何做到这一点:

myLine.GetRange(out other, out other, out minY, out maxY, false, false, myPane);
                double Yinterval = Math.Abs(maxY - minY) / 25;
                // Loop to add text labels to the points
                for (int i = 0; i < tempPoints.Count; i++) {
                    // Get the pointpair
                    ZedGraph.PointPair pt = tempPoints[i];
                    // Create a text label from the Y data value
                    ZedGraph.TextObj text = new ZedGraph.TextObj(pt.Y.ToString(), pt.X, pt.Y + Yinterval,
                        ZedGraph.CoordType.AxisXYScale, ZedGraph.AlignH.Left, ZedGraph.AlignV.Center);
                    text.FontSpec.FontColor = tempHolder.Color;
                    text.ZOrder = ZedGraph.ZOrder.A_InFront;
                    // Hide the border and the fill
                    text.FontSpec.Border.IsVisible = false;
                    text.FontSpec.Fill.IsVisible = false;
                    text.FontSpec.Size = 10f;
                    text.FontSpec.Angle = 45;


                    string lblString = "name";

                    Link lblLink = new Link(lblString, "#", "");
                    text.Link = lblLink;

                    myPane.GraphObjList.Add(text);
                }
于 2011-07-27T23:42:42.037 回答
1

对于每个点,使用您的标签文本创建一个文本对象,并将其添加到图表中。

标签演示演示...

于 2009-05-02T20:37:19.210 回答