Click here to Skip to main content

beginner pavel asked:

Open original thread
Hello,
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.:
 
http://www.imagesup.net/?di=113548312290[^]
 
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;
 
graph.GraphPane.GraphObjList.Add(text);
Tags: C#, ZedGraph

Preview



When answering a question please:
  1. Read the question carefully.
  2. Understand that English isn't everyone's first language so be lenient of bad spelling and grammar.
  3. If a question is poorly phrased then either ask for clarification, ignore it, or edit the question and fix the problem. Insults are not welcome.
Let's work to help developers, not make them feel stupid.
Please note that all posts will be submitted under the The Code Project Open License (CPOL).



Advertise | Privacy | Mobile
Web03 | 2.8.140721.1 | Last Updated 26 Mar 2009
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100