May 16, 2013 at 12:59 AM
Hi all,

I'm trying to export an oxyplot to svg using the PlotModel.ToSvg() method. However, I don't quite understand the parameters.

What does the "isDocument" parameter mean?

What does the "textMeasurer" parameter mean?

An example on how to use the method would be great!

Thanks for any idea.
May 17, 2013 at 9:46 PM
I have just found the answer in the ExportDemo in the examples. Simply great !!!

Jun 8, 2013 at 10:00 AM
isDocument - set to true if you want to produce a .svg file. Set to false if you want to create an <svg> element to use in html5.
textMeasurer - the svg render context needs to measure the size of text. You need to provide a platform specific render context that can do this since the core library does not have access to any methods that can measure text
Jul 1, 2013 at 9:20 AM

I am exporting the plot to a HTML5 svg tag. I am not using silverlight or WPF. I need to be able to generate a textMeasurer for this. I have looked through the tests source code and can not find an example of this apart from the silverlight and WPF ones.

If anyone could point me in the correct direction i would be grateful.
Jul 2, 2013 at 12:54 PM
There is also a render context based on Windows Forms, can you reference OxyPlot.WindowsForms in your solution? I think this is the best choice if you are making something for ASP.NET.

You could also create a render context using p/invoke to gdi32 to measure the strings

It would be great to know better solutions to this...
Sep 18, 2013 at 11:59 PM
Edited Sep 19, 2013 at 12:16 AM
Using the clue from above that I could reference Oxyplot.WindowsForms I got it to work by creating my own GraphicsRenderContext class using the existing code. I changed the scope from "Inner" to "Public" and added the Import OxyPlot.WindowsForms
' -------------------------------------------------------------------------------------------
' <copyright file="GraphicsRenderContext.cs" company="OxyPlot">
'   The MIT License (MIT)
'   Copyright (c) 2012 Oystein Bjorke
' -------------------------------------------------------------------------------------------

Imports OxyPlot.WindowsForms

Namespace OxyPlot.WindowsForms

    ''' <summary>
    ''' The graphics render context.
    ''' </summary>
    Public Class GraphicsRenderContext
        Inherits RenderContextBase
Then I was able to do this:
Dim rc As New GraphicsRenderContext
Dim bmpOut As System.Drawing.Bitmap = New System.Drawing.Bitmap(800, 600)
Dim g As System.Drawing.Graphics = System.Drawing.Graphics.FromImage(bmpOut)
Dim svg As String = MyPlot.ToSvg(800, 600, False, rc)