Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to Create a ZedGraph Static Label

Tags:

zedgraph

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.

like image 898
user1735169 Avatar asked Oct 06 '22 09:10

user1735169


1 Answers

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

like image 158
SanVEE Avatar answered Oct 10 '22 04:10

SanVEE