asp.net - ZedGraph labels -
In Jheddraf, I'll point and XAxis how all text labels shall show together?
If I do
myPane.XAxis.Type = AxisType.Text; MyPane.XAxis.Scale.TextLabels = array_of_string; Let me get labels on xx like this
And I do this, then
for (I int = 0; I & lt; myCurve.Points.Count; i ++) {PointPair pt = myCurve .Points [i]; // Y data values to create a text label TextObj text = new TextObj (pt.Y.ToString ( "f0"), pt.X, pt.Y + 0.1, CoordType.AxisXYScale, AlignH.Left, AlignV.Center); Text.ZOrder = ZOrder.A_InFront; Text.FontSpec.Angle = 0; MyPane.GraphObjList.Add (text); } I get labels on the curve, like
But if I do both at the same time, the label on the curve disappears.
Is there a way to combine both types of labels?
After you clarified the question, I changed my answer to correctly position you the label Remember to:
& lt;% System.Collections.Generic.List & lt; ZedGraphWebPointPair & gt; Points = new system Selection. GenericList & lt; ZGraphPointPoint & gt; (); To do some fun with the mathematics (int i = 0; I & lt; 15; i ++) {// points with the math. New (New ZedGraphWebPointPair {X = I, Y = Math.Pow (I-10, 2) * -1 + 120}); } System.Collections.Generic.List & lt; String & gt; Xxisabalabs = new system.collection GenericList & lt; String & gt; (); TestGraph.CurveList.Add (New ZedGraphWebLineItem {Color = System.Drawing.Color.Red}); TestGraph.XAxis.Scale.FontSpec.Size = 9; Int j = 1; Foreach (ZedGraphWebPointPair point in points) {// We calculate the digits TestGraph.CurveList [0]. Points.Add (point); // add labels to points TestGraph.GraphObjList.Add (make new ZedGraphWebTextObj {location = {CoordinateFrame = ZedGraph.CoordType.XChartFractionYScale, // make sure we position them according to CoordinateFrame X = Convert.ToSingle (J) / points. Count - 0.05f, Y = Convert.ToSingle (point.Y) + 3F, AlignV = ZedGraph.AlignV.Top}, text = point.Y.ToString (), FontSpec = {angle = 90, size = 9, range = {Iswasy = false}}}}; // add labels to XXx XAxisLabels.Add (String.Format ( "P {0}", j)); J ++;} TestGraph.RenderGraph + = delegate (ZedGraphWeb ZGW, System.Drawing.Graphics G, ZedGraph.MasterPane mp) {ZedGraph.GraphPane GP = mp [0]; Gp.XAxis.Type = ZedGraph.AxisType.Text; Gp.XAxis.Scale.TextLabels = XAxisLabels.ToArray ();} ; & Gt% ; This code will produce this graph:
Comments
Post a Comment