Как отображать метки в каждой точке в ZedGraph? - PullRequest
4 голосов
/ 03 мая 2009

Как отобразить метки для каждой точки, нанесенной на диаграмму ZedGraph?

Ответы [ 2 ]

8 голосов
/ 28 июля 2011

Поскольку этот сайт сейчас недоступен, вот фрагмент кода, который дает пример того, как это сделать:

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);
                }
1 голос
/ 03 мая 2009

Для каждой точки создайте текстовый объект с текстом метки и добавьте его на график.

Демонстрация меток демонстрирует ...

...