This is the discussion forum for OxyPlot.
For bugs and new features, use the issue tracker located at GitHub.
Also try the chat room!
Under review

Oxyplot Xamarin.Forms Version

Oystein Bjorke 10 jaar geleden bijgewerkt 10 jaar geleden 3
This discussion was imported from CodePlex

rmarinho wrote at 2014-07-23 23:34:

Hi, just found about OxyPlot and it looks really amazing, i have to say i didn't tried yet, but it looks a great open source tool for lob apps.
So Xamarin has this new platform that is Xamarin.Forms, it's pcl based, and me and others have a open source project to share some common functionally not present yet in the platform : https://github.com/XForms/Xamarin-Forms-Labs

One of the features i thought about working on that project was Simple Chart support:
https://github.com/XForms/Xamarin-Forms-Labs/issues/38

After finding about Oxyplot and that it has all the platform support that Xamarin Forms needs, IOS; Android; WP8, i think this can be used also in Forms if we just work on some wrappers.

So what i wanted to discuss, if it sounds good to work in a new branch here for Xamarin.Forms support.

Thanks.
Best Regards
Rui

Example for touch in Win7?

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

jhudson216 wrote at 2014-06-19 20:18:

Hi, all.

I've just obtained the OxyPlot.WPF package, which I'm trying to use in VS2010. I created the trivial application (just a PlotView in a Grid in a Window, with a bit of view-model code to load up a PlotModel, a couple of axes and a series). It displays quite nicely.

However, when I touch within the window (I have a touch-monitor), it immediate crashes with a NullReference Exception in PlotView.OnManipulationStarted. I'm assuming that I haven't wired up the manipulation features correctly, but I cannot find a demo for this. The "Code" button in the browser examples only show the function that builds the PlotModel. Where can I find a FULL example of a touch-enabled OxyPlot application?

Many thanks!

Jim Hudson

When Using WPF from NUGET I get an Assembly Mismatch Error

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

DrStrangeLove wrote at 2013-09-11 17:18:

I get the following error when I compile:
Assembly 'OxyPlot.Wpf, Version=2013.1.80.1, Culture=neutral, PublicKeyToken=75e952ba404cdbb0' uses 'OxyPlot, Version=2013.1.80.1, Culture=neutral, PublicKeyToken=638079a8f0bd61e9' which has a higher version than referenced assembly 'OxyPlot, Version=2013.1.74.1, Culture=neutral, PublicKeyToken=638079a8f0bd61e9'


objo wrote at 2013-09-11 23:31:

This seems to be fixed now!

Metro build errors - Payload file does not exist

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

rajah wrote at 2012-10-19 05:32:

Here is something odd that i am finding:

When I reference the "OxyPlot.dll" and the "OxyPlot.Metro.dll" and try and build my project, I get the following error:

Error 1 Payload file 'D:\Development\OxyPlot\Source\OxyPlot.Metro\bin\Debug\OxyPlot.Metro\Themes\Generic.xaml' does not exist. App1

The error goes away if I add the projects directly to my solution and reference the projects instead of the dlls.

It looks like multiple people are having this issue (eg: http://social.msdn.microsoft.com/Forums/en-US/winappswithcsharp/thread/b20ca4a5-8293-4da7-859e-6759a2a76f9d), though I havent found a solution that fixes this issue.

Anybody else out here who has figured out a solution for this?


objo wrote at 2012-10-19 05:54:

It seems to work for Callisto, but I could not find out why...

https://github.com/timheuer/callisto


aazavvar wrote at 2013-09-26 09:07:

I had also this problem. This occurs because "Generic.xaml" does not exist in OxyPlot.Metro. I have simply create a new directory "Themes" in OxyPlot.Metro and copy Generic.xaml from "OxyPlot.WPF\Themes" to it. The problem then solved for me.

Scatter Series and Date Time axis

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

willmoore88 wrote at 2013-07-24 16:29:

Is it possible to use a scatter series with a dateTime axis?

Jasper1986 wrote at 2013-10-20 17:23:

yes~

var s2 = new ScatterSeries
        {
            Title = "testScatter",
            DataFieldX = "Time",
            DataFieldY = "Value",
            ItemsSource = data
        };
however, i can't compile the codes above with current dlls, it seems something is wrong when cast datetime to double.

_Noctis_ wrote at 2013-10-21 06:23:

Yep.
Here's a screenshot:
Image

I'm using something along:
X = DateTimeAxis.ToDouble(your_date_here)
when adding the points... seems to work.

Cannot create WPF control

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

starrynite1959 wrote at 2012-07-19 23:29:

This looks like a great tool, but I'm having a hard time getting to first base.  I'm a newbie with WPF, though.  I'm using VS 2010, and used NuGet to install the OxyPlot packages into my project.  OxyPlot, OxyPlot.Wpf and others now show up in my References.

The second bullet step I'm to do is to "Create a PlotModel in your ViewModel."  What the heck is a ViewModel?

In my XAML, I added a line

xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"

in my Window element.  Then in my Grid element beneath, I added

<oxy:Plot Model="{Binding myPlotModel}" Height="401" HorizontalAlignment="Left" Margin="222,12,0,0" VerticalAlignment="Top" IsEnabled="False" Background="#FFF2F296" BorderThickness="1" Width="573"/>


Then back in my MainWindow c# code, I added the WPFExample1 code you have, but when I build it complains that 'myPlotModel' does not exist in the current context.  I then added a Name="myPlotModel" attribute in the XAML and it no longer complained, but in the last line -- myPlotModel = temp; -- it gave me a type conversion error, saying that it can't convert OxyPlot.PlotModel to OxyPlot.Wpf.Plot.

I'm guessing I'm doing some basic VS or C# mis-step, that has nothing to do with OxyPlot, but I've played around with OxyPlot and OxyPlot.Wpf references and I get one error or another.

Sorry for taking your time on a noob question, but what am I doing wrong in the package references and/or XAML?

Thanx.


starrynite1959 wrote at 2012-07-24 18:36:

So the "ViewModel" referred to is the new MVVM religion?


asychow wrote at 2012-07-27 11:36:

Plot and PlotModel are completely different. You can't assign an instance of PlotModel to a Plot.

You should define myPlotModel in a ViewModel and assign the DataContext of the View (the MainWindow) to the ViewModel.

For more details, refer to the examples in the source code.


starrynite1959 wrote at 2012-07-27 14:54:

Yeah, somehow I missed a statement on oxyplot.codeplex.com that there were examples in the Source Code.  I figured that out two days ago and have been playing.  The code above that I tried to use was based on what is shown on oxyplot.codeplex.com/wikipage?title=WpfExample1&referringTitle=Home.  Thanx.


objo wrote at 2012-08-09 00:13:

Yes, most WPF/SL examples are using the MVVM design pattern. I will not add examples using named plot controls (even if it is possible) as I don't think this is good practice.

Will try to improve the 'getting started' documentation as soon as I get time! 


_Noctis_ wrote at 2013-11-05 13:42:

I'll take it time was not kind to you, good ser? :)

objo wrote at 2013-11-05 18:55:

:) You're right! Time is passing more quickly than it used to! But documentation is coming, I am working on it :) If anyone really likes writing documentation and would like to give a hand, please shout out!

_Noctis_ wrote at 2013-11-06 03:40:

Howling into the night ...

Nobody likes writing documentation, everybody loves reading it and complains if it's not there ...
That's what differentiates good code from bad code ...

Having said that, how could I help?

objo wrote at 2013-11-06 23:04:

I will submit what I have 'very' soon! The documentation will be written in wiki syntax as plain text files under a new ~/Documentation folder. Create a fork and make a pull request when ready. The build machine will convert the wiki files to html, chm and pdf, and upload to http://oxyplot.org/doc. The API documentation will be generated from the XML comments and also included there. This should make everything googlable!

Captions Above Datapoints

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

bigN13 wrote at 2013-06-19 15:20:

Hi, I am using an Oxyplot LineSeries in WPF app, and would like to add a captions above points (e.g. 1,2,3,4)
sample.Points.Add(new DataPoint(x, y));
Is it Possible?
Thanks

objo wrote at 2013-06-19 20:42:

this is not yet supported, see issue
https://oxyplot.codeplex.com/workitem/9893

michaeldjackson wrote at 2013-07-24 20:38:

Hi bigN13,

I accomplished this by using TextAnnotations.
It's slows the plot down somewhat, but still usable for my purpose.

exporting plot to png.

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

vdepa wrote at 2012-03-02 12:13:

 

Hi all,

Can anyone please share  code for exporting plot to png from the step onwards.

It's very urgent to me.

Please help.

 

 

 


ffiala wrote at 2012-03-02 22:40:

This is my file "BitmapRenderContext.cs" which is originally copied from SvgRenderContext.cs substituting the calls to svg writer through calls to Graphic class. This Class returns a Bitmap.

// --------------------------------------------------------------------------------------------------------------------
// 
//   http://oxyplot.codeplex.com, license: Ms-PL
// 
// --------------------------------------------------------------------------------------------------------------------

namespace OxyPlot
{
    using System;
    using System.Collections.Generic;
    using System.Drawing;
    using System.Drawing.Drawing2D;
    using System.Drawing.Text;

    /// 
    /// The Bitmap render context.
    /// 
    public class BitmapRenderContext : RenderContextBase, IDisposable
    {
        #region Constants and Fields

        public Bitmap objBmpImage;
        Graphics objGraphics;

        #endregion

        #region Constructors and Destructors

        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// <param name="s" />
        /// The s.
        /// 
        /// <param name="width" />
        /// The width.
        /// 
        /// <param name="height" />
        /// The height.
        /// 
        /// <param name="isDocument" />
        /// The is document.
        /// 
        public BitmapRenderContext(double width, double height)
        {
            this.Width = width;
            this.Height = height;
            this.PaintBackground = true;
            objBmpImage = new Bitmap((int)width, (int)height);
            objGraphics = Graphics.FromImage(objBmpImage);
            objGraphics.Clear(Color.White);
            objGraphics.SmoothingMode = SmoothingMode.AntiAlias;
            objGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
        }

#if !METRO

        /// 
        /// Initializes a new instance of the  class.
        /// 
        /// <param name="path" />
        /// The path.
        /// 
        /// <param name="width" />
        /// The width.
        /// 
        /// <param name="height" />
        /// The height.
        /// 
        public BitmapRenderContext(string path, double width, double height)
        {
        }

#endif

        #endregion

        #region Public Methods

        /// 
        /// The close.
        /// 
        public void Close()
        {
        }

        /// 
        /// The complete.
        /// 
        public void Complete()
        {
        }

        /// 
        /// The dispose.
        /// 
        public void Dispose()
        {
            objBmpImage.Dispose();
        }

        /// 
        /// The draw ellipse.
        /// 
        /// <param name="rect" />
        /// The rect.
        /// 
        /// <param name="fill" />
        /// The fill.
        /// 
        /// <param name="stroke" />
        /// The stroke.
        /// 
        /// <param name="thickness" />
        /// The thickness.
        /// 
        public override void DrawEllipse(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            Pen pen = stroke == null ? null : new Pen(Color.FromArgb(stroke.A, stroke.R, stroke.G, stroke.B), (int)thickness);
            Rectangle grect = new Rectangle((int)rect.Left, (int)rect.Top, (int)rect.Width, (int)rect.Height);
            SolidBrush brush = fill == null ? null : new SolidBrush(Color.FromArgb(fill.A, fill.R, fill.G, fill.B));
            if (pen != null) objGraphics.DrawEllipse(pen, grect);
            if (brush != null) objGraphics.FillEllipse(brush, grect);
        }

        /// 
        /// The draw line.
        /// 
        /// <param name="points" />
        /// The points.
        /// 
        /// <param name="stroke" />
        /// The stroke.
        /// 
        /// <param name="thickness" />
        /// The thickness.
        /// 
        /// <param name="dashArray" />
        /// The dash array.
        /// 
        /// <param name="lineJoin" />
        /// The line join.
        /// 
        /// <param name="aliased" />
        /// The aliased.
        /// 
        public override void DrawLine(
            IList points, 
            OxyColor stroke, 
            double thickness, 
            double[] dashArray, 
            OxyPenLineJoin lineJoin, 
            bool aliased)
        {
            Point[] Gpoints = new Point[points.Count];
            for (int i=0; i
        /// The draw polygon.
        /// 
        /// <param name="points" />
        /// The points.
        /// 
        /// <param name="fill" />
        /// The fill.
        /// 
        /// <param name="stroke" />
        /// The stroke.
        /// 
        /// <param name="thickness" />
        /// The thickness.
        /// 
        /// <param name="dashArray" />
        /// The dash array.
        /// 
        /// <param name="lineJoin" />
        /// The line join.
        /// 
        /// <param name="aliased" />
        /// The aliased.
        /// 
        public override void DrawPolygon(
            IList points, 
            OxyColor fill, 
            OxyColor stroke, 
            double thickness, 
            double[] dashArray, 
            OxyPenLineJoin lineJoin, 
            bool aliased)
        {
            Point[] Gpoints = new Point[points.Count];
            for (int i = 0; i < points.Count; i++)
            {
                Gpoints[i].X = (int)points[i].X;
                Gpoints[i].Y = (int)points[i].Y;
            }
            Pen pen = stroke == null ? null : new Pen(Color.FromArgb(stroke.A, stroke.R, stroke.G, stroke.B), (int)thickness);
            if (pen != null) objGraphics.DrawPolygon(pen, Gpoints);
            SolidBrush brush = fill == null ? null : new SolidBrush(Color.FromArgb(fill.A, fill.R, fill.G, fill.B));
            if (brush != null) objGraphics.FillPolygon(brush, Gpoints);
        }

        /// 
        /// The draw rectangle.
        /// 
        /// <param name="rect" />
        /// The rect.
        /// 
        /// <param name="fill" />
        /// The fill.
        /// 
        /// <param name="stroke" />
        /// The stroke.
        /// 
        /// <param name="thickness" />
        /// The thickness.
        /// 
        public override void DrawRectangle(OxyRect rect, OxyColor fill, OxyColor stroke, double thickness)
        {
            Pen pen = stroke==null ? null : new Pen(Color.FromArgb(stroke.A,stroke.R,stroke.G,stroke.B), (int)thickness);
            Rectangle grect = new Rectangle((int)rect.Left, (int)rect.Top, (int)rect.Width, (int)rect.Height);
            SolidBrush brush = fill == null ? null : new SolidBrush(Color.FromArgb(fill.A, fill.R, fill.G, fill.B));
            if (pen!=null) objGraphics.DrawRectangle(pen, grect);
            if (brush != null) objGraphics.FillRectangle(brush, grect);
        }

        /// 
        /// The draw text.
        /// 
        /// <param name="p" />
        /// The p.
        /// 
        /// <param name="text" />
        /// The text.
        /// 
        /// <param name="c" />
        /// The c.
        /// 
        /// <param name="fontFamily" />
        /// The font family.
        /// 
        /// <param name="fontSize" />
        /// The font size.
        /// 
        /// <param name="fontWeight" />
        /// The font weight.
        /// 
        /// <param name="rotate" />
        /// The rotate.
        /// 
        /// <param name="halign" />
        /// The halign.
        /// 
        /// <param name="valign" />
        /// The valign.
        /// 
        /// <param name="maxSize" />
        /// Max size of the text (clipping rectangle).
        /// 
        public override void DrawText(
            ScreenPoint p, 
            string text, 
            OxyColor c, 
            string fontFamily, 
            double fontSize, 
            double fontWeight, 
            double rotate, 
            HorizontalTextAlign halign, 
            VerticalTextAlign valign, 
            OxySize? maxSize)
        {
            double SizeCorrectingFactor = 0.8;
            double VerticalCorrectingFactor = fontSize * 0.3;
            Point Gp = new Point((int)(p.X-VerticalCorrectingFactor), (int)(p.Y));
            Font font = new Font(fontFamily,(float)(fontSize*SizeCorrectingFactor), FontStyle.Regular);
            SolidBrush brush = c == null ? null : new SolidBrush(Color.FromArgb(c.A, c.R, c.G, c.B));
            StringFormat stringFormat = new StringFormat();
            /* dont know how to vertically align text, so this setting is skipped */
            if (brush != null)
            {
                if (Math.Abs(rotate) < 0.1)
                {
                    switch (halign)
                    {
                        case HorizontalTextAlign.Center:
                            stringFormat.Alignment = StringAlignment.Center;
                            break;
                        case HorizontalTextAlign.Left:
                            stringFormat.Alignment = StringAlignment.Near;
                            break;
                        case HorizontalTextAlign.Right:
                            stringFormat.Alignment = StringAlignment.Far;
                            break;
                    }
                    objGraphics.DrawString(text, font, brush, Gp, stringFormat);
                }
                else
                {
                    switch (halign)
                    {
                        case HorizontalTextAlign.Center:
                            stringFormat.Alignment = StringAlignment.Center;
                            break;
                        case HorizontalTextAlign.Left:
                            stringFormat.Alignment = StringAlignment.Near;
                            break;
                        case HorizontalTextAlign.Right:
                            stringFormat.Alignment = StringAlignment.Far;
                            break;
                    }
                    stringFormat.Alignment = StringAlignment.Far;
                    SizeF size = objGraphics.MeasureString(text, font);
                    Bitmap tempImage = new Bitmap((int)(size.Height * 1.2), (int)(size.Width * 1.2));
                    Graphics tempGraphics = Graphics.FromImage(tempImage);
                    tempGraphics.TextRenderingHint = TextRenderingHint.AntiAlias;
                    tempGraphics.SmoothingMode = SmoothingMode.AntiAlias;

                    Rectangle rect = new Rectangle((int)tempGraphics.VisibleClipBounds.X, (int)tempGraphics.VisibleClipBounds.Y, (int)tempGraphics.VisibleClipBounds.Width, (int)tempGraphics.VisibleClipBounds.Height);
                    tempGraphics.TranslateTransform(0, 0);
                    tempGraphics.RotateTransform(270);
                    tempGraphics.DrawString(text, font, brush, new PointF(0, 0), stringFormat);
                    objGraphics.DrawImage(tempImage, Gp);

                    objGraphics.DrawImage(tempImage, Gp);
                    tempGraphics.Dispose();
                    tempImage.Dispose();
                }
            }
        }
        /// 
        /// The flush.
        /// 
        public void Flush()
        {
            objGraphics.Flush();
        }

        /// 
        /// The measure text.
        /// 
        /// <param name="text" />
        /// The text.
        /// 
        /// <param name="fontFamily" />
        /// The font family.
        /// 
        /// <param name="fontSize" />
        /// The font size.
        /// 
        /// <param name="fontWeight" />
        /// The font weight.
        /// 
        /// 
        /// 
        public override OxySize MeasureText(string text, string fontFamily, double fontSize, double fontWeight)
        {
            if (string.IsNullOrEmpty(text))
            {
                return OxySize.Empty;
            }

            // todo: should improve text measuring, currently using p/invoke on GDI32
            // is it better to use winforms or wpf text measuring?
            return Gdi32.MeasureString(fontFamily, (int)fontSize, (int)fontWeight, text);
        }

        #endregion
    }
}

In PlotModel.cs the following method is added:

        /// 
        /// Create a Drawing 
        /// 
        /// <param name="width" />
        /// The width. 
        /// 
        /// <param name="height" />
        /// The height. 
        /// 
        /// <param name="isDocument" />
        /// if set to true [is document]. 
        /// 
        /// 
        /// The to svg. 
        /// 
        public Bitmap ToBitmap(double width, double height)
        {
            var bmrc = new BitmapRenderContext(width, height);
            this.Update();
            this.Render(bmrc);
            bmrc.Complete();
            bmrc.Flush();
            return (bmrc.objBmpImage);
        }

To send the image to the client:

Response.Clear();
Response.ContentType = "image/png";
Bitmap bmp = plot.GetBitmap(800, 500);
bmp.Save(Response.OutputStream, ImageFormat.Png);

In this version only solid lines are rendered.
Franz


vdepa wrote at 2012-03-05 08:13:

Franz,

Thanks a lot for the code.


vdepa wrote at 2012-03-06 19:06:

Hi fmoses,

 I am unable to save the png. The above code is not working at the draw line.

 I writting the below sample code for testing. I have used plot model and plot as in the example

 Can you please correct the mistake in the below code. XAML Code:

 C# Code :

 using OxyPlot;

 using OxyPlot.Wpf;

 try

 {

 InitializeComponent(); Model = TwoLineSeries();

 DataContext = this; Plot objPlot = this.plot1;

var path = GetFilename(".png files|*.png", ".png");

if (path != null) { objPlot.SaveBitmap(path); } } catch (Exception ex) { string abc = ex.Message.ToString(); }

public static PlotModel TwoLineSeries()

{

var model = new PlotModel();

 OxyPlot.LinearAxis abcd = new OxyPlot.LinearAxis();

abcd.Key = "Hours";

abcd.Position = AxisPosition.Left;

abcd.Title = "Hours";

abcd.MajorGridlineStyle = LineStyle.Solid;

model.Axes.Add(abcd);

 OxyPlot.LinearAxis abc = new OxyPlot.LinearAxis();

 abc.Key = "Men";

 abc.Position = AxisPosition.Bottom;

 abc.Title = "Men"; model.Axes.Add(abc);

var s1 = new OxyPlot.LineSeries("Series 1")

{

Color = OxyColors.SkyBlue, };

 s1.YAxisKey = abcd.Key; for (int i = 0; i < 300; i++)

{

s1.Points.Add(new DataPoint(i, i + 10));

 }

model.LegendPlacement = LegendPlacement.Outside;

model.LegendOrientation = LegendOrientation.Horizontal;

return model;

Please help me.

Thanks & Regards

 vdepa

Printing OxyPlot example in WinForm

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

heromyth wrote at 2011-10-20 05:13:

Here are some code snippets for Printing OxyPlot. 
The OxyPlot can be printed into a partial section in the cava.
There also including another way exporting the OxyPlot to PNG.

======================================= private void printPreviewBtn_Click(object sender, EventArgs e) { PrintPreviewDialog ppd = new PrintPreviewDialog(); ppd.Document = reportPrintDocument; ppd.ShowDialog(); } private void reportPrintDocument_PrintPage(object sender, PrintPageEventArgs e) { Graphics graphBoard = e.Graphics; float sectionWidth = e.PageBounds.Width; PointF strLocation = new PointF(); strLocation.X = 50f; strLocation.Y = 50f; graphBoard.DrawString("Test Text",new Font("Tahoma", 16, FontStyle.Bold), Brushes.Black, strLocation); int width = (int)sectionWidth - 10; int height = 300; width = plot1.Width; height = plot1.Height; Bitmap bm = new Bitmap(width, height); plot1.DrawToBitmap(bm, new Rectangle(0,0,width,height)); bm.Save("C:\\test.bmp"); bm.Save("C:\\test.png", ImageFormat.Png); graphBoard.DrawImage(bm, new Point(50, 150)); } }

 


objo wrote at 2011-10-20 08:05:

thank you, I will include this in one of the examples!

(I think the definintion of reportPrintDocument is missing in your code)


heromyth wrote at 2011-10-20 13:21:

objo wrote:

thank you, I will include this in one of the examples!

(I think the definintion of reportPrintDocument is missing in your code)

reportPrintDocument = new System.Drawing.Printing.PrintDocument();

You can drag a PrintDocument control from the VS's Toolbox

ToSvg

Oystein Bjorke 10 jaar geleden 0
This discussion was imported from CodePlex

nicolasr75 wrote at 2013-05-16 02:59:

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.
Nick

nicolasr75 wrote at 2013-05-17 23:46:

I have just found the answer in the ExportDemo in the examples. Simply great !!!

Nick

objo wrote at 2013-06-08 12:00:

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

LazyJames wrote at 2013-07-01 11:20:

Hi,

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.

objo wrote at 2013-07-02 14:54:

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
http://www.pinvoke.net/default.aspx/gdi32/gettextextentpoint.html

It would be great to know better solutions to this...

Roark wrote at 2013-09-19 01:59:

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)
rc.SetGraphicsTarget(g)
Dim svg As String = MyPlot.ToSvg(800, 600, False, rc)