Menu

TextObj Padding

Help
Ed Parry
2015-09-23
2015-09-23
  • Ed Parry

    Ed Parry - 2015-09-23

    Hi,

    Is it possible to add padding around the text within a TextObj? I'm looking for some text surrounded with a white box, but would love some padding around the text as it currently pushes up towards the edges?

     
  • John Vickers

    John Vickers - 2015-09-23

    I have never tried to do padding, but I believe you can put a border on the box, make the border white, and make it thick to creating a larger white box.

    If you post your project in a zip file, I will mess with it tonight to see if I can achieve what you are looking for.

    John Vickers

     
  • Ed Parry

    Ed Parry - 2015-09-23

    Hi John,

    Thanks for the response. I'm trying to use a speech bubble image as the fill for a TextObj, and have the text in the middle. I'm unable to far to force the height/width of the box at all, which would also resolve the issue.

    The "lastPoint" is the last point in the curve that's generated. Basically the bubble would show the latest value on the graph at that point.

    The code so far:

                TextObj lineLabel = new TextObj(labelText, (lastPoint.X + 0.02f), (lastPoint.Y + 0.02f), CoordType.AxisXYScale, AlignH.Left, AlignV.Bottom);
                Image bubbleImage = Image.FromFile(HttpRuntime.AppDomainAppPath + "whitebubble.png");
                lineLabel.ZOrder = ZOrder.C_BehindChartBorder;
                lineLabel.FontSpec.StringAlignment = StringAlignment.Center;
                lineLabel.FontSpec.Border.Width = 2f;
                lineLabel.FontSpec.Border.Color = Color.White;
                lineLabel.FontSpec.Border.IsVisible = true;
    
                lineLabel.FontSpec.IsBold = false;
                lineLabel.FontSpec.Size = 10f;
                lineLabel.FontSpec.Fill = new Fill(bubbleImage, System.Drawing.Drawing2D.WrapMode.Clamp);
                lineLabel.FontSpec.Fill.AlignH = AlignH.Left;
                lineLabel.FontSpec.Fill.AlignV = AlignV.Top;
                lineLabel.FontSpec.Fill.IsScaled = true;
                lineLabel.FontSpec.FontColor = GetColorFromHexCode("#333333");
                lineLabel.ZOrder = ZOrder.A_InFront;
                lineLabel.FontSpec.IsAntiAlias = true;
                graph.GraphPane.GraphObjList.Add(lineLabel);
    
     

    Last edit: Ed Parry 2015-09-23
  • John Vickers

    John Vickers - 2015-09-23

    Ed,

    It is really helpfull if you can include a complete application, either what you are working on, or split out just some sample data in a graph. There are so many pieces to how a zedgraph is initialized that the problem could be elsewhere. Also, since you are using an image, I would need the image to duplicate what you are seeing anyway.

    If you can, just zip up your application and send me a link for where to download it. You can PM the link to me if you don't want it in the open forum.

    John Vickers

     

Log in to post a comment.

MongoDB Logo MongoDB