user1735169
user1735169

Reputation: 53

How to Create a ZedGraph Static Label

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.

Upvotes: 5

Views: 1910

Answers (1)

SanVEE
SanVEE

Reputation: 2060

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

Upvotes: 4

Related Questions