Reference > Methods > RenderVml Method

SharpPlot.RenderVml Method

Return completed chart rendered as Vector Markup (VML).

public string RenderVml();

Return Value

The result of this call is a string representation of a partial HTML document. This may be written to file as text, or returned via HTTP as a section in a normal webpage. You may have several VML sections in a single page. They are automatically named with the current chart name if this is set to a non-default value.

If your page has any VML content, it must begin with the standard VML header to define the behavior of the <v:xxx> tags to the browser.

Example

string myvml = sp.RenderVml();

Overloads

Sizing the rendered graphic

The default is to express all text sizes and positions in pts (72 pts = 1 inch) and to use pts to give the size of the entire block of VML. If you prefer to use pixels, you can pass the required dpi conversion (passing 96 here will have no visible effect on most video adaptors at default resolution). This allows you to fix the size of the graphic more reliably on websites which use pixels for design reasons. It also allows you to make thumbnails of the charts with no extra processing.

Working with VML

Please note that VML is a Microsoft-specific format and is only supported in Internet Explorer 5.5 and above. However it runs ‘native’ in the browser and can be used to put an entire page inline, rather than required callbacks to the server to obtain charts as SVG or raster images.

To make IE understand the VML tags, you MUST include the appropriate behavior tag in the header, so the sample code shown below is typical of what you need to create a functional webpage:

   // Render to HTML file as VML
    StreamWriter sw = new StreamWriter("Simple.htm",false,System.Text.Encoding.ASCII);
    string chart = sp.RenderVml(false);
    sw.Write("<html>");
    sw.Write("<head>");
    sw.Write(sp.VmlHeader);  // Add the header detail
    sw.Write("<title>SharpPlot - Simple chart</title>");
    sw.Write("</head>");
    sw.Write("<body>");
    sw.Write(chart);
    sw.Write("</body>");
    sw.Write("</html>");
    sw.Close();

This will create a complete page with your chart shown correctly within it.

See also ...

SharpPlot Members | VmlHeader Property | SaveVml Method | SetChartName Method


Send comments on this topic
© Dyalog Ltd 2013