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

Contour Axis Min/Max

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

Schnitzos wrote at 2013-10-02 16:36:

Hi everybody!
First of all - oxyPlot is really cool - many thanks to objo (and other contributers)!
I have a problem with ContourSeries, it looks as if the X axis is scaled to the Y extent of the contour and vice versa (not easy to see in the example because the axis extent is almost the same). Could it be that in UpdateMaxMin() in ContourSeries Column- and Rowcoordinates are switched?
Thanks!
Schnitzos

objo wrote at 2013-10-03 19:46:

Thanks - I think this is a bug in the ContourSeries. I added an example with a 121×41 array - this failed. I have done a modification that seems to work. See the latest build. It is strange that it was working for the old examples...

Possible bug with mouse event on WPF chart [RESOLVED]

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

raphay wrote at 2013-06-13 11:06:

Hello everyone,

I am creating an application with Oxyplot, which is great, but i recently faced with a problem : when i have my chart empty of rectangle annotation the mouse event doesn't trigger at all (i can't zoom or pan even with the middle button, except from the axes mouse over event). I resolved it by adding a white rectangle annotation, but it seems a bit ugly...

I may have done something bad, but i hope there is better fix to this problem.

Have a nice day...

raphay wrote at 2013-07-04 14:17:

I found the problem, the backround was set to null, so the chart didn't handle the mouse events anymore...
<oxy:Plot Margin="0,0,4,0" Name="chart" Background="{x:Null}"/>
Regards

Rectangular annotation and mouse events in WPF

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

ChevyCP wrote at 2012-10-19 19:27:

Hi,

Great work, 2 quick questions:

1 - Would it be possible to create the code to use the rectangular annotations in wpf 4.0 xaml instead of just in the c# code? 

 

2 - For mouse events on line annotations, can the functions be created in xaml or do those have to be done in code? (ie -MouseDown="LA_MouseDown")

 

Thanks!


objo wrote at 2012-10-21 21:53:

1. I checked in the missing annotation adapter classes. See WpfExamples / AnnotationDemo

2. No, I don't think this is possible to do in XAML. I have not the events in the WPF adapter classes. But you can subscribe to the event of the "InternalAnnotation" properties of the annotations.


ChevyCP wrote at 2012-10-23 15:14:

Awesome, thanks! 


ChevyCP wrote at 2012-10-23 16:35:

Now, if I create a line annotation in xaml and I want to add mouse events for it, is that possible?  It already has a mousedown/up/etc, but those are not the oxyplot events.  I need to create the annotation in xaml since I am binding the text and 'X' property to a data class and I don't think I can use .setbinding.  So, how can I attach oxyplot mouse events to an annotation created in xaml, or how can I create bindings in c and create the whole annotation in c?

 

Thanks!


ChevyCP wrote at 2012-10-23 17:23:

I should clarify that I can set bindings on OxyPlot.wpf.Annotations just not on OxyPlot.LineAnnotation items.  And since I can't convert them, I can't add them to my xaml created plot.  The last two lines of code fail and can't have .setbinding, so I'm at a loss as to add mouse events to a line annotation that has binded properties.

 

 var la = new LineAnnotation { Type = LineAnnotationType.Vertical, X = 4 };

chartingOxyPlot.Annotations.Add(la);

chartingOxyPlot.Annotations.Add((OxyPlot.Wpf.LineAnnotation)la);


ChevyCP wrote at 2012-10-23 19:56:

I should have dug around a bit more.  The internalannotation property did the trick.

Printing in WPF with XPS/PrintVisual

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

bitmatic wrote at 2014-02-15 20:10:

I am trying to print an OxyPlot chart in WPF.

I have made a UserControl containing the charts and a few other controls, and it looks perfectly well in the xaml designer.

When i try to print it via XPS and PrintVisual the charts do not show up on the print (the rest of the controls do).

Have any of you had any experience printing OxyPlot's from WPF, and how did you do it ??

objo wrote at 2014-02-16 14:34:

Did you try the OxyPlot.Xps library? I have not checked this recently, but it should be possible to create xps and print from the XpsExporter class

bitmatic wrote at 2014-03-15 12:28:

I found a solution. I had to call UpdateLayout() before doing the actual printing.

So. If you have a UserControl (mine is called DefaultPrintControl) with some OxyPlot's and some other stuff on them, you can print it like this:
private void ButtonPrint_OnClick(object sender, RoutedEventArgs e)
        {
            var dialog = new PrintDialog();
            if (dialog.ShowDialog() != true)
            { return; }

            var dpc = new DefaultPrintControl();

            dpc.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
            dpc.Arrange(new Rect(new Point(0, 0), dpc.DesiredSize));
            dpc.UpdateLayout();

            dialog.PrintVisual(dpc, "some description of the print job");
        }

GuruK wrote at 2014-07-07 16:39:

Hi,

I also try to print graph as same way. But I couldn't it even if I call UpdateLayout().
When I create instance of user control on memory empty page is printed out.
But I throw showing visual object to PrintVisual() it's no problem.

Should I set any special configuration to user control(XAML/code behind)?
In my case, user control is very simple as following.
<UserControl
    x:Class="Reports.TestView"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
    mc:Ignorable="d" 
    xmlns:oxy="http://oxyplot.codeplex.com"
    d:DesignHeight="800" d:DesignWidth="600"
    >

    <Grid>
        <oxy:Plot>
            <oxy:Plot.Axes>
                <oxy:LinearAxis Position="Left" Minimum="0" Maximum="100"/>
                <oxy:TimeSpanAxis Position="Bottom" Minimum="0" Maximum="86400" StringFormat="hh:mm"/>
            </oxy:Plot.Axes>
            <oxy:Plot.Series>
                <oxy:LineSeries ItemsSource="{Binding Path=DataList}" DataFieldX="Time" DataFieldY="Value" Color="Red"/>
            </oxy:Plot.Series>
        </oxy:Plot>
    </Grid>
</UserControl>

bitmatic wrote at 2014-07-08 10:38:

If you are using the latest version of OxyPlot it wont work. I updated to the latest version some time ago, and the above code stopped working.

I downgraded to version "2014.1.231.1" and it works with that version, so they must have changed something in the underlying rendering code....

GuruK wrote at 2014-07-08 16:08:

Thank you for your great information!
When I try to use 2014.1.231.1 from NuGet it works fine.

I checked changing point roughly. Cause is probably in InvalidatePlot() (Plot.cs or PlotView.cs).
From following version of source code, it has not rendered if it's not receive Loaded event.

revision : 824 / change set : ffbabf441bcea4e2871c8c86fc56dbe910b3f87f [ffbabf441bce]

This modification is for performance issue.

So... I added uncool code as following it seems be working on latest version of OxyPlot.
"graph" is name of Plot object (<oxy:Plot x:Name="graph">)
    dpc.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
    dpc.Arrange(new Rect(new Point(0, 0), dpc.DesiredSize));
    dpc.graph.RaiseEvent(new System.Windows.RoutedEventArgs(OxyPlot.Wpf.PlotView.LoadedEvent));   
    dpc.UpdateLayout();
or
    dpc.Measure(new Size(dialog.PrintableAreaWidth, dialog.PrintableAreaHeight));
    dpc.Arrange(new Rect(new Point(0, 0), dpc.DesiredSize));
    dpc.graph.IsRendering = true;
    dpc.graph.InvalidatePlot(true);
    dpc.graph.IsRendering = false;
    dpc.UpdateLayout();
Of course this is not correct way... But currently it may be only way.
It should be modified or extended for our case.

bitmatic wrote at 2014-07-09 13:37:

Thanks GuruK. Your hack works :-)

objo wrote at 2014-07-10 13:17:

Have you seen the XpsExporter in the OxyPlot.Xps package? Can this be used? Let us know if there are bugs!

bitmatic wrote at 2014-07-10 13:52:

I looked at the XpsExporter some time ago, but couldn't really use it. It prints the actual OxyPlot - but what i need is much more complex.

What I (and GuruK apparently) need is more complex prints with both OxyPlots and other controls, such as textboxes, images, etc... So we make a UserControl with all the stuff we need to print out, and print it with the above code.

This worked fine until the latest update of the OxyPlot rendering code :-(

OxyPlot is the only control i have come across that can not be printed properly with this method. This could be a bug in OxyPlot(?) When you call Measure, Arrange & UpdateLayout on a control it is supposed to render - OxyPlot doesn't.

objo wrote at 2014-07-10 14:03:

Thanks for the explanation, now I understand. This should be corrected, I guess this also applies when rendering a UserControl to a bitmap?
I have added https://oxyplot.codeplex.com/workitem/10231

Mouse events on CategoryAxis

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

ckoo wrote at 2012-07-16 01:57:

Looking at the CategoryAxis it would be nice to be able to click on the Label to find out the label name and range (start and end points.)

It looks like the Axis class need to inherit from UIPlotElement instead of PlotElement? Is this correct and do you have any hints?


objo wrote at 2012-08-08 23:24:

Yes, the mouse events have not been implemented on the Axis classes yet. It should be covered by issue http://oxyplot.codeplex.com/workitem/9798 - so I have not closed this issue yet. There is some refactoring (due to issue http://oxyplot.codeplex.com/workitem/9595) to be done first, then it should be easier to do the axis hit testing.

reports

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

a5r wrote at 2013-12-04 12:06:

I like the idea of the "simple" report generation. Has anyone a sample running including text, table(s) and graph?

objo wrote at 2013-12-04 20:18:

See the WPF/ExportDemo example - it includes text, tables and graph.
The html, tex and docx outputs work as intended (I just submitted a flushing fix for html output)
Pdf output works, but is really slow (generating a few pages takes minutes, this seems to be a problem in the latest version of MigraDoc, or maybe something is not correct configured).
Xps output works - but formatting is not correct.
So... I think there is some work left to do before this is really usable...

a5r wrote at 2013-12-05 09:05:

Ok, thanks. I didn't notice that example. I'll check it out.

a5r wrote at 2013-12-05 13:01:

Apparently the slowness of rendering pdf's has to do with the migradoc implementation of drawing large tables for pdf, see http://forum.pdfsharp.net/viewtopic.php?f=2&t=679&p=7559&hilit=table#p7559. On this board someone found a solution for this problem which was patched by him. However the maintainers of the project don't want to include the patch in the trunk, due to not being 100% compatible with original implementation. Patch or compiled assemblies are available on te site of the patcher, see http://pakeha_by.my-webs.org/MigraDocFastTableRender.html.

a5r wrote at 2013-12-05 13:37:

ok tried it with the export demo, Normal distribution example with 4004 datapoints. If you choose "Save pdf report" the Original output is finally generated after 30 seconds in my case. I replaced the pdfsharp.dll with version 1.32 and applied the patched assemblies with the WPF versions. After this replacement the pdf report was generated in less than two seconds. This example contains 78 pages of table. The rest of the report looks the same as before the replacement.

objo wrote at 2013-12-06 18:19:

Great! Do I understand correctly - you used the WPF with the patch applied, not the latest official Nuget version?

a5r wrote at 2013-12-08 15:07:

yes, I tested with the wpf versions of the migradoc dll's (not the official version but the patched version). So I did a download of pdfsharp version 1.32 and then I downloaded from http://pakeha_by.my-webs.org/MigraDocFastTableRender.html all the migradoc dll's which are also version 1.32. Because I changed the original migradoc dll's i had to comment one piece of the code which was gdi+ specific. It was about retrieving the image for gdi when there is no cached image. I changed the original dll's to wpf dll's but I guess that isn't exactly necessary because there are also migradoc dll's version 1.32 which are gdi+ like the ones that oxyplot.pdf is referencing now. So maybe only upgrading pdfsharp.dll to 1.32 and applying the patched migradoc dll's will suffice.

sumsum wrote at 2014-05-12 08:33:

Can I ask where is the exact link for example of exporting to pdf containing text, table(s) and graph in Window form?

thanks

objo wrote at 2014-05-12 10:37:

There is only an example for WPF. See Source\Examples\WPF\ExportDemo

Hi I have run into a problem with building the APP package for the Windows Store (Metro)

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

doctorj wrote at 2012-09-29 00:35:

Hi ,

Oxyplot works fine in my app when I run it in the development environment on vs2012.

I tried to package my app today for the windows store and ran into some problems.

I got an error message telling me the one of the components in my package needs VCLIBS version 11.0.50522.1 and that the version of VCLIBS I have installed on the machine is VCLIBS 11.0..... or not the same version needed to the component ( I assume a lower version)

I took vcblibs out of the references and tried to oxyplot  in the development environment and it did not work , so I verified that it is oxyplot that needs vclibs to execute.

Can you help me? do I have to get an updated C++ library from Microsoft to package oxyplot for the Windows Store? which version of the C++ library does oxyplot use?

You help would be greatly appreciated , I what to package the app and submit it to the store as soon as I can.

Thanks Jerry

 

 

 


objo wrote at 2012-09-29 19:08:

see reply in other thread: http://oxyplot.codeplex.com/discussions/396478

Feature suggestion: flashing line

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

typingcat wrote at 2012-11-02 07:01:

Hello,

When there are many lines (something like 20 or 30 lines), it feels quite hard for the user to find out the line of series they selected. If the line has some method like this

  LineSeries.Flash(int interval, int speed),

the user can quickly find out the line they want to see.

I just came up with flashing, but I think any other idea to make a line distinguishable has the same effect. For example, glowing, vibrating, drawing a big arrow to that line, etc.


objo wrote at 2012-11-04 22:17:

good idea :) But it gives me an association to the <blink> element :)

Since this library is targetting multiple platforms, I only want to depend on simple drawing capabilities and no animations. For LineSeries my plan is to use a thicker line with a different color behind the real line. It will increase the rendering time slightly, but no need to calculate new coordinates. Other types of series (e.g. AreaSeries) need other solutions - ideas welcome!

Implementation of selection is covered by http://oxyplot.codeplex.com/workitem/8193


typingcat wrote at 2012-11-08 01:40:

Hello.

Your support is of a level that I have never experienced with any other open-source freeware, or even commercial software. You are working very hard. Thank you for the prompt implementation.

Limiting the zoom and restarting the axes

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

everytimer wrote at 2013-06-22 12:15:

Hello, I'm using OxyPlot for WPF and I can't find a way to reset the axes. I want to achieve the same effect as when you press the button "A" with the plot focused. I've seen in the source that ResetAxes is a public method but somehow I can't access to it.

My second question is how could I limit the zoomable area in code? I can't set it statically in XAML or in the initialization of the plot because my data will change and I want to limit the size depending on the data. Do I need to check before every PlotRefresh(true) my just added Series most extreme values and then use that values or is there something that already does that?

Thank you.

DJDAS wrote at 2013-06-24 10:26:

Hi,
for a project I had the same needs and I solved it by binding the AbsoluteMaximum and AbsoluteMinimum of the axes to a property which changes as per my needs (i.e. the date selected by the user) after this you can call ResetAxes in your code and the axes automatically zoom to your limits.
Hoping to be helpful!
Bye!

everytimer wrote at 2013-06-24 11:23:

Thank you, I can't find that ResetAxes method!! I can create one very easily with this one:
private void AxReset()
{
MyModel.Axes[0].Reset();
MyModel.Axes[1].Reset();
 }
But I wonder why I can't access that ResetAxes of yours! Maybe the version of OxyPlot? I'm using WPF but I only add
using OxyPlot;
using OxyPlot.Series;
using OxyPlot.Annotations;
using OxyPlot.Axes;
Because if I add OxyPlot.Wpf it interfere with others, very odd...

DJDAS wrote at 2013-06-24 11:37:

Sorry! You're right, I did my ResetAxes method too, where the Axis reset part is something like:
foreach (var axis in Plot.Axes)
    axis.InternalAxis.Reset();

Protobuf-net to serialize plot model

Oystein Bjorke 10 years ago 0
This discussion was imported from CodePlex

sharethl wrote at 2014-03-17 15:39:

I am currently exploring how to use protobuf-net to serialize oxyplot.
It should be a nice tool that help on saving and reading plot
But here I got a "Common Language Runtime detected an invalid program." on line "Serializer.Serialize"
Anyone know the issue?
            var PolygonAnnotationType = RuntimeTypeModel.Default.Add(typeof(PolygonAnnotation), false).Add("Points");
            var IDataPointType = RuntimeTypeModel.Default.Add(typeof(IDataPoint), false).Add("X", "Y");
            IDataPointType.AddSubType(100, typeof(DataPoint));

            var poly = new PolygonAnnotation();
            IList<IDataPoint> ps = new List<IDataPoint>() { new DataPoint(0, 0), new DataPoint(1, 0) };
            poly.Points = ps;
            MemoryStream ms = new MemoryStream();
            Serializer.Serialize<PolygonAnnotation>(ms, poly);
            string stringBase64 = Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
            byte[] byteAfter64 = Convert.FromBase64String(stringBase64);
            MemoryStream afterStream = new MemoryStream(byteAfter64);
            var newPlot = Serializer.Deserialize<PolygonAnnotation>(afterStream);
            Console.Write(stringBase64);
The following code works. difference is NewDataPoint is a class, instead of structure.
private static void Test1() {

            var poly = new NewPolygon() {
                Points = new List<IDataPoint>(){
                    new NewDataPoint(0,0),new NewDataPoint(1,1)
                }
            };
            RuntimeTypeModel.Default.Add(typeof(NewPolygon), false).Add("Points");
            RuntimeTypeModel.Default.Add(typeof(IDataPoint), false).Add("X","Y").AddSubType(100,typeof(NewDataPoint));

            MemoryStream ms = new MemoryStream();
            Serializer.Serialize<NewPolygon>(ms, poly);
            string stringBase64 = Convert.ToBase64String(ms.GetBuffer(), 0, (int)ms.Length);
            byte[] byteAfter64 = Convert.FromBase64String(stringBase64);
            MemoryStream afterStream = new MemoryStream(byteAfter64);
            var newpoly = Serializer.Deserialize<NewPolygon>(afterStream);
            Console.Write(stringBase64);
        }

class NewDataPoint : IDataPoint {
        public double X { get; set; }
        public double Y { get; set; }
        public NewDataPoint() { }
        public NewDataPoint(double x, double y) {
            this.X = x;
            this.Y = y;
        }
    }
    class NewPolygon : TextualAnnotation {
        public IList<IDataPoint> Points { get; set; }
    }


objo wrote at 2014-03-19 08:31:

This is interesting. How is protobuf handling versioning? The PlotModel and related classes will continue to evolve...

sharethl wrote at 2014-03-19 14:28:

Found the link about versioning. Haven't test yet. Actually I am also have no ideas about this.

Protobuf-net: the unofficial manual