Click here to Skip to main content
14,739,758 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I'm using ZedGraph in my project and its awesome! But there is still one thing I cant figure out. Im looking for some possibility of plotting description of LineItem directly in chart, like on fig.:[^]

I tried to use TextObj, but still I have a problem correctly calculate the angle, it doesnt correspond to the slope of line:

// centre of line
PointPair pt = new PointPair(0.5 * (ptA.X + ptB.X), 0.5 * (ptA.Y + ptB.Y));

TextObj text = new TextObj("desc", pt.X, pt.Y, CoordType.AxisXYScale, AlignH.Center, AlignV.Center);
text.ZOrder = ZOrder.A_InFront;

double dX = ptB.X - ptA.X;
double dY = ptB.Y - ptA.Y;

float alfa = (float)(Math.Atan2(dY, dX) * (180.0 / Math.PI));

text.FontSpec.Angle = alfa;


This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900