2012-10-10 92 views
5

我想在我的圖的右下角添加標誌或我的軟件。我使用TextObj,但問題是它的位置通過鼠標滾輪更改圖形比例而改變。我應該使用另一個對象,但我不知道它是什麼。請幫幫我。如何創建ZedGraph靜態標籤

回答

4

這裏有一個簡單的解決方案:

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(); 
} 

將x更改& y值來定位公司名稱。

enter image description here

編輯:

我們必須用圖像對象替換文本對象,那就是:

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

+0

解決的辦法是真實的,但你應該將「(0.6)*(pane.XAxis.Scale.Max)」改爲「0.6」。因爲你應該使用分數。你能找到一種使用徽標而不是文字的方式嗎? – user1735169

+0

請看編輯部分,希望有所幫助... – SanVEE

+0

很好的答案。對於右下角,我會去與新TextObj(sLabel,0.98,0.98,CoordType.PaneFraction,AlignH.Right,AlignV.Bottom) - 使用PaneFraction和.Right,.Bottom將保持對齊更好,如果你的文字修改。 – edhubbell