Xceed Chart for WinForms v4.4 Documentation
Welcome to Xceed Chart for WinForms v4.4 / User Guide / Watermarks / Dynamic Watermarks

In This Topic
    Dynamic Watermarks
    In This Topic

    Besides the ability to specify a static image for the watermark, you can also render images that are dynamically generated by your Windows Forms or ASP.NET application and pass them to the watermark's Bitmap property (via its FillEffect property), which accepts a System.Drawing.Bitmap object. In this way you can display custom data in the Xceed Chart for WinForms canvas. The following code generates a simple bitmap containing some text and passes it to the watermark.

    VB.NET  

    Dim watermark As Watermark = New Watermark()

    ' OpenGL texture dimensions must be a power of 2.
    ' Otherwise the control will internally perform a stretch.
    Dim simpleDrawing As Bitmap = New Bitmap(256,256)
    Dim graphics As Graphics = Graphics.FromImage(simpleDrawing)

    graphics.Clear(Color.FromArgb(0, 255, 255, 255))
    graphics.DrawString("Car sales this year have\r\nbeaten all expectations", New Font("Arial", 14), New SolidBrush(Color.Blue), New PointF(50, 50))
    graphics.Dispose()

    watermark.FillEffect.Bitmap = simpleDrawing
    watermark.HorzAlign = HorzAlign.Left
    watermark.VertAlign = VertAlign.Top
    watermark.HorizontalMargin = 0
    watermark.VerticalMargin = 0

    chartControl.Watermarks.Add(watermark)
    C#  

    Watermark watermark = new Watermark();

    // OpenGL texture dimensions must be a power of 2.
    // Otherwise the control will internally perform a stretch.
    Bitmap simpleDrawing = new Bitmap(256, 256);
    Graphics graphics = Graphics.FromImage(simpleDrawing);

    graphics.Clear(Color.FromArgb(0, 255, 255, 255));
    graphics.DrawString("Car sales this year have\r\nbeaten all expectations", new Font("Arial", 14), new SolidBrush(Color.Blue), new PointF(50, 50));
    graphics.Dispose();

    watermark.FillEffect.Bitmap = simpleDrawing;
    watermark.HorzAlign = HorzAlign.Left;
    watermark.VertAlign = VertAlign.Top;
    watermark.HorizontalMargin = 0;
    watermark.VerticalMargin = 0;

    chartControl.Watermarks.Add(watermark);

    The following image illustrates this: 

    Related Examples

    Windows Forms: Watermarks\General 

    Web Forms:Watermarks\General

    See Also

    ChartControl | Watermark | Watermarks General