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

Plot.ResetAllAxes vs. ResetManipulator

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

seveland12 wrote at 2013-04-19 16:31:

I'm trying to programmatically reset the view of my plot to a state as if the user had double-clicked the middle mouse button. It seemed to me that Plot.ResetAllAxes is the appropriate method, but this no longer seems to work as I intend it to in recent builds of OxyPlot that I have tried (unfortunately I don't have the change set info on the version of the DLLs that works). Is this method still the appropriate one to use?

objo wrote at 2013-04-24 11:01:

It should be possible to iterate over the Axes collection in the PlotModel and call the Reset method of each axis. Then call the RefreshPlot on the PlotModel. If this does not work, there is probably a bug (I have not tested myself).

How to Create HighLowSeries/CandlestickSeries

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

kcbtdev wrote at 2013-06-13 18:11:

I am using the latest version of OxyPlot from NuGet. However when searching the series types via wpf designer I do not see the HighLowSeries or the CandlestickSeries. How do I create these types of series in WPF? I am using the version NoPCL as mentioned in the notes.

objo wrote at 2013-06-13 23:35:

Sorry, these series are not included in the OxyPlot.Wpf namespace yet. This is issue 9999.
https://oxyplot.codeplex.com/workitem/9999

How do I display a graph in Visual Studio?

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

faroskalin wrote at 2013-12-06 16:39:

Hello.

So I am using the Example Browser application, and I have pasted the code to VS 2013, like so:

Image

I understand that the return type of the Notinterpolatedvalues() method is a PlotModel. Now - how do I display that? As in, what is the method I need to use in my main method in order to play Notinterpolatedvalues()?

Thank you.

faroskalin wrote at 2013-12-06 17:43:

I understand now. And it appears this is the reason: stackoverflow.com/a/3422732/1913389

Essentially, it's a convenience factor in the use of var in this instance like "when the type is elsewhere on the same line".

Linechart over stream of numbers

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

Alxandr wrote at 2012-03-29 13:02:

I'd like to make a linechart over a stream of numbers that continuously get's generated. Sort of like a cpu-usage graph or something along those lines; where the new data enters on the right side, and the old data exits on the left. Also, I do not know beforehand the maximum number that will be generated in this series (but I do know it will never be below 0). What I tried so far was something like this:

        private class NetworkPlotModel : PlotModel
        {
            private LineSeries ups, downs;
            private LinearAxis vax;
            public NetworkPlotModel()
            {
                Axes.Clear();
                Axes.Add(new TimeSpanAxis(pos: AxisPosition.Bottom, title: "Time", min: -60, max: 0));
                Axes.Add(vax = new LinearAxis(AxisPosition.Right, "Value"));
                vax.MaximumPadding = 0.03;

                Series.Add(ups = new LineSeries(OxyColor.FromRGB(1, 0, 0), strokeThickness: 3, title: "Up"));
            }

            public void Push(TimeSpan delta, double up)
            {
                for (int i = 0; i < ups.Points.Count; i++)
                {
                    IDataPoint p = ups.Points[i];
                    ups.Points[i] = new DataPoint(p.X - delta.TotalSeconds, p.Y);
                }
                ups.Points.Add(new DataPoint(0, up));
                this.Update(true);
            }
        }

However, this does not seem to draw a line at all (even though I call the Push-method 1 time, 100 times or 1000 times, and I've also tried to call it once a sec, and up to 10 times a second).

Could I please get an example of how to make something like this work?


ckoo wrote at 2012-03-29 14:36:

I implemented something similar using an observable. Here is the code below, which might give you a few hints.

Random rand = new Random();

Observable.Interval(TimeSpan.FromSeconds(0.1)).Where( x => x < 100).Subscribe( x => 
		{
			var series = ((LineSeries) pm.Series[0]);
			
			if( x > 50)
			{
				// Remove the first point in the series when we readh 50 data points.
				series.Points.RemoveAt(0);
				
				// Reset the minimum value on the xAxis.
				pm.Axes[0].Minimum = series.Points[0].X;
			}
			
			// Add the new point
			series.Points.Add( new DataPoint(3 + x, rand.Next(10)));
			
			// Set maximum value
			pm.Axes[0].Maximum = x;
			
			// Need to reset the xAxis for it refresh properly
			((LineSeries) pm.Series[0]).XAxis.Reset();
			
			plotControl.Refresh();
		}
	);

 

I think the PlotModel class also has a .Refresh() method.


objo wrote at 2012-03-30 13:16:

PlotModel.Update updates the model, but does not refresh the plot control.

Use PlotControl.Refresh or PlotModel.Refresh to redraw the plot.

Will add examples on the wiki page http://oxyplot.codeplex.com/wikipage?title=Refreshing%20a%20plot


Alxandr wrote at 2012-03-30 13:47:

Thank you :)

LineSeries: Strange behaviour

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

frozzzyy wrote at 2012-06-19 11:16:

Hi, objo!

Сan You look at this screenshot

May I get rid of this?


objo wrote at 2012-06-19 12:24:

First guess: Try to change the LineJoin property on the LineSeries from Miter to Round.


frozzzyy wrote at 2012-06-19 12:58:

Thank You! Works well!

LineSeries in Cartesian plot does not redraw correctly.

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

endorphing wrote at 2013-08-16 23:57:

This is a strange drawing issue with Cartesian type plots that I don't see with regular XY types.
Steps to reproduce,

1) Set the PlotType to Cartesian,
2) Re-size the main Window of your application to a very small horizontal width.
3) Now click on the top-right corner of your window to make it full-screen.

Result: The line series does not redraw in the plot area, and retains the previous small size.

This issue can also be seen in your ExampleBrowser application in the Cartesian axes examples. Any idea what might be causing this?

Thanks in advance for your help.

everytimer wrote at 2013-08-17 20:45:

I think the root of the problem is the requirement of being at the same scale, the X and Y axes. When you reduce the width, the X remains the same but the Y axis range is going up. When the width of the plot is zero the Y range should be infinity and there I think is the problem. This happens not only when you Maximize the window but even if you just resize manually.

To solve this you could associate the Window State Changed to a method that resets the axes.
void ResetAxes()
{
foreach (var axis in plotter.Axes)
{
axis.Reset();
}
}
Good luck

endorphing wrote at 2013-10-08 21:24:

Thanks for the response. I ended up resetting the axes, as you described ( my code is below). I do wish there was a way to detect the size change at the Model level though (that feels like a more reusable and maintainable solution).
<oxy:Plot Name="MyPlot" Model="{Binding MyPlot.Model}" SizeChanged="MyPlot_SizeChanged" />

private void MyPlot_SizeChanged(object sender, SizeChangedEventArgs e)
{
    var plotter = sender as Plot;
    var model = plotter.Model;
    if (!ReferenceEquals(model, null) && model.PlotType == PlotType.Cartesian)
        plotter.ResetAllAxes();
}

thomasdr wrote at 2013-12-12 12:45:

If you don't mind modifying the OxyPlot source code, I have a fix for this problem. Go to the Issues section of this site and look for an issue entitled "Cartesian axes zoom in one direction only"

objo wrote at 2013-12-12 20:27:

thomasdr: thanks for the contribution! but I agree with you that it is a bit quick&dirty, so I am waiting for a simple&clean solution before merging this into the main branch!
The best solution would be to solve the 'cartesian axes' in a more general way, as described in https://oxyplot.codeplex.com/workitem/10095

No WinForms Plot Control!

Oystein Bjorke 10 years ago updated by HugaHaga 7 years ago 1
This discussion was imported from CodePlex

jacakk wrote at 2013-01-10 20:54:

I'm using OxyPlot.WindowsForms and VS 2010 Ultimate.

I'm trying to add Control Plot but in Controls Menu there is no such thing like "Plot"!

Help!


objo wrote at 2013-01-12 17:58:

The following is based on VS2012, but I think VS2010 is similar
  • Right click in the toolbox
  • Select "Choose items..."
  • Press "Browse..." under ".NET framework components
  • Select the OxyPlot.WindowsForms.dll assembly (note that there are versions for both .NET 4.0 and .NET 4.5)
  • The "Plot" control should appear under "OxyPlot.WindowsForms Components" in the ToolBox

jfraschilla wrote at 2013-08-18 19:37:

I am a new user to OxyPlot and tried to create an WinForms example in VS2012 Professional. I followed the steps to add OxyPlot to the VS designer toolbox but I get the following error when I add OxyPlot.WindowForms.dll:

There are no components in 'xxx\OxyPlot.WindowsForms.dll' that can be placed on the toolbox.

John

morty77 wrote at 2013-09-27 13:25:

jfraschilla wrote:
I am a new user to OxyPlot and tried to create an WinForms example in VS2012 Professional. I followed the steps to add OxyPlot to the VS designer toolbox but I get the following error when I add OxyPlot.WindowForms.dll:

There are no components in 'xxx\OxyPlot.WindowsForms.dll' that can be placed on the toolbox.

John
I created a WPF project in VS 2012 Express, and I can't see the OxyPlot in the toolbox either (installed through NuGet). I tried to add the OxyPlot.Wpf.dll like you did for the OxyPlot.WindowsForms.dll and I get the same error message (although for Wpf):

"There are no components in '...\OxyPlot.Wpf.dll' that can be placed on the toolbox."

Have you found a solution to your problem?
Thanks.

Gimly wrote at 2013-09-27 13:56:

morty77> Don't think there is a toolbox component for OxyPlot, you should simply add the xmlns for it in your Control, like so:
xmlns:oxy="http://oxyplot.codeplex.com"
And then you can simply put the plot wherever you want in your WPF control.
<oxy:Plot>
</oxy:Plot>
If you're new to WPF, you'll see quickly that the designer is not really the way to create your interface, you shouldn't use it really and use the XAML editor instead.

Still can't seem to dislay anything in Metro , does anyone have it working in Metro

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

doctorj wrote at 2012-09-18 23:58:

Thank you for your response. That helped , I had to download the metro stuff again and I from the xaml file. I took the commands from it for oxy and inserted in my xaml file and these commands were recognized ok. However when I executed the code with my vb code , no graph came up. I was expecting to see at the axes of the graph. Do I need the other xaml files you have in the BasicSample directory also? I also noticed that the BasicSample directory did not have a Project file so I could execute the project - is it supposed to be like that? in my VB project I have a Visual Basic Project File that I click on to start the project. Is it possible that I am not executing the right oxy commands in my vb code. I am posting the code here again.

 Dim plotControl As New OxyPlot.Metro.Plot
        Dim plotModel1 As New OxyPlot.PlotModel
        plotModel1.Title = "Outside"
        plotModel1.Axes.Add(New LinearAxis(AxisPosition.Bottom, -20, 80))
        plotModel1.Axes.Add(New LinearAxis(AxisPosition.Bottom, -10, 10))
        plotControl.Model = plotModel1
        plotModel1.RefreshPlot(True)

 

 

//xmlns:oxy="using:OxyPlot.Metro"

 

 

 

 

 

 

 

 

//<//oxy:Plot Model="{Binding PlotModel

 

 

 

 code I put in my xaml file 

 

 

 

 

 

 

//}"/>

0

zoom

thierno 9 years ago 0
Hello,
Does someBody know why curves(staireStepSeries disapear) at certain level of zooming and ahow to prevent from that ?

situation:
linear Y axis : IsZoomEnabled= false, IsPanEnabled= false
DateTime X Axis: IsZoomEnabled= true, IsPanEnabled= true
thank you

how to run tests?

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

chronodekar wrote at 2012-07-13 08:12:

I just checked out the source-code and built, what I assume are the Oxyplot libraries.

There is a project called "Oxyplot.Tests", which I assume contains the unit tests for this project. What tool do I need to use to run them? Or rather, HOW do I even run the tests?

The code does not look like nUnit or xUnit stuff to me.

Puzzled,
chronodekar


objo wrote at 2012-07-13 09:35:

the *.Tests assemblies contain standard NUnit tests.

Note that some of the tests are asserting on images. I have not checked in the baseline of the plot bitmaps (*.png). The baseline is generated first time the tests are executed.


chronodekar wrote at 2012-07-13 12:35:

Ah, thank you for your reply! I opened the files "OxyAssert.cs" and "TestModels.cs" from the upper level in Visual Studio. There were no [Test] attributes or even [TestFixture]  in them and I was wondering if I missed anything.

After reading your reply, I went digging a bit deeper and found Axes/AxisTests.cs which has something I'm familiar with. :)

I'm trying to understand the code base - at least at a very high level initially, before digging further. Any suggestions on where I should start?

-chronodekar


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

To understand the code base, I would look at the PlotModel, LineSeries and LinearAxis classes (and ancestor classes). See the PlotModel.Render method, that's the 'main' method of the plots!