5

I want to add a logo or my software name in the bottom right corner of my graph. I used TextObj but the problem is that its location changes by changing graph scale by mouse wheel. I should use another object but i don't know what it is. please help me.

1 Answers1

4

Here's a simple solution:

private void Form1_Load(object sender, EventArgs e)
{
     GraphPane pane = zedGraphControl1.GraphPane;
     var text = new TextObj("Your Comapany Name Ltd.",(0.6)*(pane.XAxis.Scale.Max), 1.1, CoordType.ChartFraction, AlignH.Left, AlignV.Top);
     text.ZOrder = ZOrder.D_BehindAxis;
     pane.GraphObjList.Add(text);            
     zedGraphControl1.Refresh();
 }

Change x & y values to position company name.

enter image description here

EDIT:

You just have to replace text object with an Image Object and here it is:

private void Form1_Load(object sender, EventArgs e)
{
     GraphPane pane = zedGraphControl1.GraphPane;            
     Image img = Image.FromFile(@"C:\i.jpg");
     var logo = new ImageObj(img, new RectangleF(0.8f, 1.1f, 0.08f, 0.1f), CoordType.ChartFraction, AlignH.Left, AlignV.Top);             
     pane.GraphObjList.Add(logo);
     zedGraphControl1.Refresh();
 }

enter image description here

SanVEE
  • 2,009
  • 5
  • 34
  • 55
  • The solution is true but you should change "(0.6)*(pane.XAxis.Scale.Max)" to "0.6" . Because you should use a fraction. Can you find a way to use a logo instead of text? – user1735169 Oct 16 '12 at 14:03
  • Good answer. For lower right corner, I'd go with New TextObj(sLabel, 0.98, 0.98, CoordType.PaneFraction, AlignH.Right, AlignV.Bottom) - Using PaneFraction and .Right, .Bottom will keep the alignment better if your text changes. – edhubbell Dec 04 '17 at 18:06