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

Re-sizing of image in imageannotation

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

BlindMonk wrote at 2013-07-25 16:31:

I can display an oxyimage in a plotmodel using imageannotation.

There is a weird issue with the image zoom and resize. When I resize the window horizontally, horizontal axes changes values, which is fine, but the image also resizes, and the Y axis doesnt change. So I end with different height.

I tried to set both width and height, but then image is missing. Its a simple code. I am pasting below.
                byte[] b = new byte[160000];
                for (int i = 0; i < b.Length; i++) b[i] = 125;


                image = OxyImage.FromArgb(200, 200, b,96);

            
                model.Annotations.Add(new ImageAnnotation
                {
                    ImageSource = image,
                    X = new PlotLength(0, PlotLengthUnit.Data),
                    //Y = new PlotLength(0, PlotLengthUnit.Data),
                    Interpolate=false,
                    Width = new PlotLength(200, PlotLengthUnit.Data),

                    //Height = new PlotLength(200, PlotLengthUnit.Data),
                    //HorizontalAlignment = OxyPlot.HorizontalAlignment.Center,
                    //VerticalAlignment = OxyPlot.VerticalAlignment.Top

                });
Any tips are deeply appreciated.

PS: I checked other annotation examples, there they dont have such issue.

BlindMonk wrote at 2013-07-30 16:00:

Is it a possible bug??

If I set both width and height of imageannotation, the image is not rendered.

yetangye wrote at 2013-08-27 17:33:

I also encountered the same problem.
Is there any method can avoid this problem?
Thanks.

BlindMonk wrote at 2013-08-27 17:42:

yes. It is a bug. I posted a solution. you have to recompile after fixing here.

objo wrote at 2013-08-28 00:00:

Thank you! I have submitted the bug-fix. I also added some examples using reverse axes.

yetangye wrote at 2013-08-28 05:48:

BlindMonk wrote:
yes. It is a bug. I posted a solution. you have to recompile after fixing here.
Thank you very much!
I have built and tested it, it works. Your solution saved my life :)

How do get DateTime of a TrackerHitResult?

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

lars_fagerbakke wrote at 2013-10-25 12:49:

I've implemented MouseDown on my plot, it has a LineSeries with Y as a int type and X as a DateTime. Its displayed nicely, but when I click it i get a double as date:
Plot plot = sender as Plot;

var series = plot.GetSeriesFromPoint(new ScreenPoint(e.GetPosition(plot).X, e.GetPosition(plot).Y), 10);
var result = series.GetNearestPoint(new ScreenPoint(e.GetPosition(plot).X, e.GetPosition(plot).Y), true);
var data = result.DataPoint;
data's X should be a DateTime value, its a double, but how can i convert it back to DateTime?

how to get the max point coordinate on the showing screen?

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

aoi wrote at 2014-05-21 05:22:

I use oxyplot to show 2048 points, when I zoom specific area, how to get the max point coordinate on the showing screen, not the max point of the whole data?
Any ideas how I can do that?

everytimer wrote at 2014-05-21 07:32:

What do you need for getting the maximum of the whole data is:
MyData.Select( p => p.Y).Max();
For the data shown in the ViewPort: Get the ActualMinimum/ActualMaximum of the X axis in your Model (MyModel.Axes[0].ActualMinimum etc), perform the same operation as before but only for the interested points:
MyData.Select( p => p.Y && p.X > myMin && p.X < myMax).Max();
I haven't tested the code above, but should be enough to point you in the right direction.

Good luck

aoi wrote at 2014-05-21 09:52:

Thanks, the operation can find the max point in the ViewPort.
Further, if there are two or more lines in the ViewPort, I need to run the operation specific times to get the max point of these lines. Have any methods to make the "MyData" cover all the points in different lines in the ViewPort?

everytimer wrote at 2014-05-21 11:22:

MyData in my example is a collection of points. You can loop for each of your LineSeries if you don't want/can't use the "source" data of that LineSeries:
List<string> names = new List<string>();
List<double> maxima = new List<double>();
foreach(LineSeries ls in MyModel.Series.OfType<LineSeries>())
{
    double max = ls.Points.Select( p => p.Y && p.X > myMin && p.X < myMax).Max();
    maxima.Add(max);
    names.Add(ls.Title);
}

//Show gathered maxima

for(int i=0; i<names.Count; i++)
{
    MessageBox.Show("Maximum of " + names[i] + " in the current view is " + maxima[i]);  
}
(Untested)

EDIT: I think the way of obtaining the maximum of a range is not correct (you wont be able to compile that), you can select the range using .Where from Linq namespace.

var range = MyData.Where(p => p.X > MyMin && p.X < MyMax);
double max = range.Select( p => p.Y).Max();
Good luck

aoi wrote at 2014-05-21 11:53:

Thank you very much for helping me solve this problem with patience.That solved the problem.

req: disable scroll wheel zoom.

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

steunissen wrote at 2011-08-10 08:37:

Again : I love OxyPlot.  Keep it going !

I am now using a plot inside a scroll viewer. Scrolling (with the scroll wheel of my mouse) through my scroll viewer while reaching my plot, interferes with the scroll zoom of the plot, mixing up my plot.

It would be nice if the scroll zoom could be disabled while keeping the zoom by rectangle enabled.

 

Sander.


objo wrote at 2011-08-10 13:24:

set IsZoomEnabled = false on the axes where you want the scroll wheel to be disabled. The property is only available when defining a PlotModel, I will add it to the WPF Axis controls later.

See the "Zooming disabled" example in the ExampleBrowser application (working for both WPF and Silverlight).


steunissen wrote at 2011-08-10 14:57:

IsZoomEnabled=false  disables both the zoom by scrollwheel and zoom by drawing a rectangle on the chart.

I would like to have a property like : ScrollWheelZoomEnabled=false;

 


objo wrote at 2011-08-24 07:34:

I added IsMouseWheelEnabled to the WPF and SL Plot controls. This will enable/disable the mouse wheel for all axes. If you need individual settings for each axis, we need to add a property to the Axis class.


watbywbarif wrote at 2014-05-22 15:45:

It would be excellent if only one axis could be locked. Imagine some long set of data where some value is monitored in time. Desired behavior is to lock value axis, and to zoom time axis so that you can see what happened in some shorter time period. Please add this.

How to compile OxyPlot?

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

goicox wrote at 2013-09-09 17:12:

Dear all,

Are there instructions on how to compile OxyPlot? I am trying to compile the source code using VS2010 professional, but I am getting problems opening .csproj files.

Thank you in advance, Javier

objo wrote at 2013-09-09 17:35:


goicox wrote at 2013-09-10 09:42:

Hello Objo,

Thank you for the pointer. I am able to open some projects now. Still there are some others that are not available, so I probably need to install additional libraries or packages.

Bellow is the list of project unavailable / incompatible:

OxyPlot.Metro
OxyPlot.MonoForAndroid
OxyPlot.OpenXml
OxyPlot.Pdf
OxyPlot.Pdf.Test
OxyPlot.Pdf.SL5
OxyPlot.Silverlight
OxyPlot.Tests
OxyPlot.WindowsForms
OxyPlot.Wpf
OxyPlot.Wpf.Test
OxyPlot.Xps
OxyPlot.MfA

Could you please point to the additional resources needed?

Thank you in advance, Javier

objo wrote at 2013-09-11 19:55:

Metro: you need VS2012/Win8
OxyPlot.MonoForAndroid: you need to install mono for android
Silverlight: you need Silverlight 4/5 SDK
.NET 4.5 projects: you need VS 2012

The others should work without any additional libraries.

Try OxyPlot.WindowsForms_NET40.sln or OxyPlot.WPF_NET40.sln, these should work on VS2010 (it is possible you need to modify the version number on the top of the sln files)

How to plot in Windows Forms application

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

JohnnyPP wrote at 2012-07-11 23:35:

Hello,

 

I would like to make a simple plot in a Windows Forms Application. After pressing a button the plot should be displayed. So far I have done following steps:

1. Created Windows Forms Application project,

2. Added one button that should display the plot,

3. Added OxyPlot Package by choosing Tools->Library Package Manager-> Package Manager Console and printing Install-Package OxyPlot.WindowsForms

4. I chose one Plot from the examples:

[Example("LineSeries")]

       public static PlotModel LineSeries()

       {

           var plotModel1 = new PlotModel();

           plotModel1.LegendSymbolLength = 24;

           plotModel1.Title = "LineSeries";

           plotModel1.Axes.Add();

           plotModel1.Axes.Add();

           plotModel1.Series.Add();

          var linearAxis1 = new LinearAxis();

           linearAxis1.Position = AxisPosition.Bottom;

           plotModel1.Axes.Add(linearAxis1);

           var linearAxis2 = new LinearAxis();

           plotModel1.Axes.Add(linearAxis2);

           var lineSeries1 = new LineSeries();

           lineSeries1.Color = OxyColors.SkyBlue;

           lineSeries1.MarkerFill = OxyColors.SkyBlue;

           lineSeries1.MarkerSize = 6;

           lineSeries1.MarkerStroke = OxyColors.White;

           lineSeries1.MarkerStrokeThickness = 1.5;

           lineSeries1.MarkerType = MarkerType.Circle;

           lineSeries1.Title = "Series 1";

           lineSeries1.Points.Add(new DataPoint(0,10));

           lineSeries1.Points.Add(new DataPoint(10,40));

           lineSeries1.Points.Add(new DataPoint(40,20));

           lineSeries1.Points.Add(new DataPoint(60,30));

           plotModel1.Series.Add(lineSeries1);

           return plotModel1;

       }

End there is my question. I have the code for the button like this:

 

  private void button1(object sender, EventArgs e)

        {

        }

 

How to use the code from [Example("LineSeries")] in button1?

Any help appreciated.

JohnnyP

 


objo wrote at 2012-07-11 23:43:

You need to add an OxyPlot.WindowsForms.Plot control to your Form.

Then set the Model property of that control to the model provided by your LineSeries method.

See Examples/WindowsForms/WindowsFormsDemo/Form1.cs


JohnnyPP wrote at 2012-07-12 00:17:

Hello Objo,

 

Thanks for the answer. In Examples\WindowsForms\WindowsFormsDemo\ I can find only these flies: OxyPlot.dll, OxyPlot.WindowsForms.dll, WindowsFormsDemo.exe and no Form1.cs


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

See the "Source code" tab on top of the page

Problem with dataseries

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

MikeRam wrote at 2013-01-24 15:00:

Hi!  I' ve a big problem on displaying a dataseries because in some cases not all points are being show in the graph

This is a dynamic dataseries which is refreshed every 5 second because it's done by incoming signals. The other dataseries are static. 

 

When i move the mouse or i try to zoom into the graph there are some points ( or segments ) which disappear and some others which appear.

Anyone could help me to solve this problem?

 

Thank you

 

Mike


objo wrote at 2013-02-10 23:24:

Can you create a short example (just the code defining the PlotModel is necessary) that demonstrates the problem?
Could this be a thread synchronization problem? The PlotModel has a SyncRoot object!

Does anyone have exampls of using oxyplot to performing trending

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

drj1000 wrote at 2013-01-26 21:21:

I have an app where I need to trend data from a simullator as the simulator is running. I want to have a window of data and is changing as the simulator changes. I will display a fixed number of data on the plot and as the data changes the graph shifts left. It would be nice to only have to add the latest data point the graph shifts - i.e. to reduce CPU time.

 

Anybody got any ideas , I would like to hear them.

 

Thanks

 

Jerry


objo wrote at 2013-02-10 23:17:

If the minimum or maximum values of the axes change, everything must be redrawn. I think this happens most of the time (except when you have fixed the axis ranges) in a general plotting library like this. Making it smarter and faster would be great, but I think this will result in quite big changes in the code (also in the 'IRenderContext' interface)...

Bound MarkerFill for LineSeries

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

Jerry007 wrote at 2013-11-14 14:24:

Hello
I'm newbie user of OxyPlot. It looks impressive, however I can not find how to do the following:
I have a LineSerie bound to list of POCO's. One of the property of the poco is "status" enum
...I'd like to bind the state to a particular MarkerFill (like red/gree/blue)...is there a way how to achieve this?

As a workaround I would have to create additional 3 ScatterSeries with just points per each status with constant MarkerFill....

objo wrote at 2013-11-14 21:03:

Right, LineSeries does not support different fill color for each marker, and converters have not been implemented for the property bindings.
The workaround sounds like a good solution! Or you can populate the points of the scatter series yourself, not using binding.

Jerry007 wrote at 2013-11-15 07:56:

Thanks, I got inspired by this, which seems to scale better than adding additional series just for markers.

Sparklines using OxyPloy

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

dpraveen9 wrote at 2013-12-30 19:38:


objo wrote at 2014-01-07 21:38:

Thanks for the links! Would you like to see examples for WPF or Win8?
There is an example for Silverlight, see Source\Examples\Silverlight\SparklineDemo.
I think it can be done the same way for WPF and Win8!