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

Attaching handler to mousewheel event

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

Tech_Junkie wrote at 2012-05-14 16:30:

Hi all,

objo, good work, I love the ease with which I can plot my data with this package!

 

One thing am wondering about still is if it is possible to attach a handler to the use of the mousewheel. In my application I am already using the clicks and movement of the mouse, but the scrolling of a plot I would also like to use.

I've looked through the source and there you obviously use it, but I cannot find out how (if possible) I can hook into these events.

Do you have a tip where I should look? (or how to attach my handler?)

thanks in advance!


objo wrote at 2012-05-14 20:57:

The mouse wheel is used to zoom, so I did not include this in the plot model's events.

But for WPF/SL you can handle the mouse wheel routed event on the Plot control, I suggest using the PreviewMouseWheel event:

http://msdn.microsoft.com/en-us/library/system.windows.uielement.previewmousewheel.aspx


Tech_Junkie wrote at 2012-05-15 09:20:

Exactly the Zoom is what I also want to trigger on, to check the boundaries of one graph and update them on another too. (though I now realize that binding to the AxisChanged event will also work, as mentioned in http://oxyplot.codeplex.com/discussions/352003)

Thanks for the quick response!

Movable and resizable plot legend

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

aec wrote at 2012-08-24 11:37:

Is there an "easy" way to create a movable and resizable plot legend?


objo wrote at 2012-08-24 12:25:

It is currently not possible to set position and size of the legend box. See the Legend* properties in the Plot model, you can change the placement and orientation.

I am considering to change the legend box to be an 'element' of the plot. That should make it possible to make custom boxes, and even render more than one legend box (e.g. if you have two vertical axes (left&right) you can add legends on both left and right side of the plot)

HeatMapSeries and Reverse Axis

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

michaeldjackson wrote at 2013-07-29 18:50:

I'm using the heatmap series, and reversing the Y axis, which represents "True Vertical Depth". However, my heatmap image is not reversed. Should it be, or do I need to reverse the points myself?

Michael

objo wrote at 2013-08-07 13:28:

Currently, I think you need to reverse the data source. The rendering implementations do not support flipping of images.
But we should check if this could implemented, see https://oxyplot.codeplex.com/workitem/10070
I prefer not to add transforms to the render context - I would like to keep it as simple as possible.
0

oxyplot for windows phone8.1 universal app

sunil joshi hace 10 años actualizado por Andreas T hace 8 años 7
hi,

I am developing windows universal app for windows phone 8.1 and windows 8.1 in visual studio 2013. Can i use OxyPlot for my charting requirements.

where i can download the samples for windows phone 8.1 charting. i am unable to install it form nuget manager.
0
En revisión

Null ref after clearing series points

RyanBuzzInteractive hace 10 años actualizado por ravjak hace 10 años 8
I am working on Xamarin iOS (MonoTouch).

I am trying to clear all of the points from a series and add a fresh collection. If I clear the current list of points, I get a null ref afterwards when I click on the plot (at Oxyplot's LineSeries 'GetNearestPoint' method).

If I don't clear the list and just append the points, the crash is avoided but strangely they show up on a separate line, almost like a new series.

I even tried clearing the PlotModel's list of series and adding a fresh one with the new points, but find the same null ref crash.

It seems that the PlotView is trying to find the 'nearest point' from the old points which no longer exist, and my new points are acting like a separate collection. I can't see why this would be happening.

Annotations with Reversed X Axis Direction

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

seveland12 wrote at 2012-04-23 19:57:


I want to add vertical and horizontal "limit lines" to my graph, so I decided to use Annotations. The problem I'm having is that I occasionally need to reverse the direction of the X axis, thus the binding on StartPosition and EndPosition. The annotations work correctly when the axis is in the normal increasing direction, but they disappear when the direction is reversed. Is this a known problem, or did I do something incorrect?


Thanks in advance.

<oxy:Plot Name="mainPlot" Title="Try This"  HorizontalContentAlignment="Stretch" VerticalContentAlignment="Stretch" >
<oxy:Plot.Axes>
                <oxy:LinearAxis Name="yAxis" AbsoluteMinimum="0.0" Position="Left"  MajorGridlineStyle="Solid" MinorGridlineStyle="Solid" />
                <oxy:LinearAxis Name="xAxis" StartPosition="{Binding Path=reverseXAxisDirection, Mode=OneWay, Converter={StaticResource BooleanToAxisStartPositionConverter}, UpdateSourceTrigger=PropertyChanged}" EndPosition="{Binding Path=reverseXAxisDirection, Mode=OneWay, Converter={StaticResource BooleanToAxisEndPositionConverter}, UpdateSourceTrigger=PropertyChanged}" Position="Bottom" MajorGridlineStyle="Solid" MinorGridlineStyle="Solid" />
            </oxy:Plot.Axes>
            <oxy:Plot.Annotations>
                <oxy:LineAnnotation LineStyle="Dot" Slope="0.1" Intercept="1" Text="First" />
                <oxy:LineAnnotation Slope="0.3" Intercept="2" MaximumX="40" Color="Red" Text="Second" />
                <oxy:LineAnnotation Type="Vertical" X="50" Color="Green" Text="Vertical" />
                <oxy:LineAnnotation Type="Horizontal" Y="2" MinimumX="0" Color="Gold" Text="Horizontal" />
            </oxy:Plot.Annotations>
            <oxy:Plot.Series>
                <oxy:LineSeries Title="Basis" Name="basisSeries" Color="MediumBlue" StrokeThickness="2" MarkerType="Circle" MarkerSize="3" MarkerFill="MediumBlue" DataFieldX="x" DataFieldY="y" ItemsSource="{Binding Path=plots.basisPlot, UpdateSourceTrigger=PropertyChanged}"/>
                <oxy:LineSeries Title="Comparison" Name="comparisonSeries" Color="Maroon" StrokeThickness="2" MarkerType="Circle" MarkerSize="3" MarkerFill="Maroon" DataFieldX="x" DataFieldY="y" ItemsSource="{Binding Path=plots.comparisonPlot, UpdateSourceTrigger=PropertyChanged}"/>

 
            </oxy:Plot.Series>
        </oxy:Plot>

objo wrote at 2012-04-23 21:17:

thanks for the notice! this was a bug - should be corrected now!

Problem changing plot padding and axis position in code....

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

luisfrossi wrote at 2013-07-30 16:25:

Hello,

I got a program that I am using OxyPlot.

I need to add Plots dynamically to a StackPanel.

My problems are the following.

If i define the Plot Padding and Margin, it is not followed.

I need to use DateTimeaxis. If I define the axis Position to AxisPosition.None it create a linear axix and ignore my DateTimeAxis.

What i want to make is to place two plots with no space between them.

Any help on that?

PS: Some code:

Here I set the DateTimeAxis Position
                    dateTimeAxis1 = new DateTimeAxis
                    {
                        CalendarWeekRule = CalendarWeekRule.FirstFourDayWeek,
                        FirstDayOfWeek = DayOfWeek.Monday,
                        MajorGridlineStyle = LineStyle.Solid,
                        MinorGridlineStyle = LineStyle.Dot,
                        Minimum = DateTimeAxis.ToDouble(FirstDate),
                        Maximum = DateTimeAxis.ToDouble(FinalDate),
                        IsPanEnabled = false,
                        IsZoomEnabled = false
                    };
                    if (IsFirstDay)
                        dateTimeAxis1.Position = AxisPosition.Top;
                    else
                        dateTimeAxis1.Position = AxisPosition.None;
                    plotModel.Axes.Add(dateTimeAxis1);
Here I set the Plot Margin and Padding
                    myPlot = new OxyPlot.Wpf.Plot()
                    {
                        Height = 150,
                        IsRendering = true
                    };

                    myPlot.Padding = new Thickness(5, 0, 15, 0);
                    myPlot.PlotMargins = new Thickness(0, 0, 0, 0);

LegendSymbolZoom property is possibly required when rendering ScatterSeries with a tiny MarkerSize

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

sunwayking wrote at 2014-07-06 14:17:

As stated in this subject‘s title, there's lots of complains that symbols in legend are too hard to be recognized if MarkerSize is defined too small. By providing LegendSymbolZoom property in PlotModel class, we can specify a suitable displaying size for symbols of the legend.

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

How small? Can you create an example that demonstrates the problem?
Currently it is showing the legend symbols at the same size as for the points (if size is not specified per point).

sunwayking wrote at 2014-07-12 13:03:

            const double markerSize = 0.5;
            var plotSource = new ScatterSeries
            {
                MarkerFill = OxyColor.FromAColor(235, OxyColors.Black),
                MarkerSize = markerSize,
                MarkerStroke = OxyColors.Transparent,
                MarkerStrokeThickness = 0,
                MarkerType = MarkerType.Square,
                Title = "人工作业"
            };
            PlotModel1.Series.Add(plotSource);
See, I make MarkerSize=0.5. This is very small and hard to be recognized on Legend. However, there's groups of ScatterPoints on the plotter. That makes them obvious.
I suggest introducing a LegendSymbolZoom property to PlotModel class so that we're able to specify the displaying size for symbols of the legend.
0

XAML reference not finding PlotView

Mike Vanderveer hace 9 años actualizado hace 9 años 1
Using Visual Studio 2013, my XAML code can't seem to find the PlotView in the OxyPlot.Wpf library.
I have used
xmlns:oxy="OxyPlot.Wpf"
xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
and a few more that I can't remember, There are several different ones referenced in the docs.
I'm using runtime version v4.0.30319
and version 2014.1.546.0
Any ideas on what reference I should be using or what else it could be?

Inserting a bitmap into axes

Oystein Bjorke hace 10 años 0
This discussion was imported from CodePlex

willmoore88 wrote at 2013-07-24 14:37:

I need to be able to use oxyplot axes, but insert a bitmap that I have already drawn into the graph rather than any other series. This is because the oxyplot axes work perfectly but without drawing the bitmap myself, I would be trying to plot over 20 million points and its too much for this library to handle satisfactorily for me.

Is there anyway I can achieve this? The bitmap would be drawn to the correct scale etc, so would just need to be placed at 0,0 on the graph and sized to the size of the plot and all should be correct.

raphay wrote at 2013-07-24 15:02:

Have you tried with the image annotation ? It sounds to fit with your problem.

willmoore88 wrote at 2013-07-24 15:59:

I haven't. Any pointers? Is there an example?

raphay wrote at 2013-07-24 16:55:

There is an official example here : http://www.oxyplot.org/examplebrowser (in the annotation category).


Here is the source code (from oxyplot) :
[Example("ImageAnnotations")]
        public static PlotModel ImageAnnotations()
        {
            var model = new PlotModel("ImageAnnotations") { PlotMargins = new OxyThickness(60, 4, 4, 60) };
            model.Axes.Add(new LinearAxis(AxisPosition.Bottom));
            model.Axes.Add(new LinearAxis(AxisPosition.Left));

            OxyImage image;
            var assembly = Assembly.GetExecutingAssembly();
            using (var stream = assembly.GetManifestResourceStream("ExampleLibrary.Resources.OxyPlot.png"))
            {
                image = new OxyImage(stream);
            }

            // Centered in plot area, filling width
            model.Annotations.Add(new ImageAnnotation
            {
                ImageSource = image,
                Opacity = 0.2,
                Interpolate = false,
                X = new PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea),
                Y = new PlotLength(0.5, PlotLengthUnit.RelativeToPlotArea),
                Width = new PlotLength(1, PlotLengthUnit.RelativeToPlotArea),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Middle
            });

            // Relative to plot area, inside top/right corner, 120pt wide
            model.Annotations.Add(new ImageAnnotation
            {
                ImageSource = image,
                X = new PlotLength(1, PlotLengthUnit.RelativeToPlotArea),
                Y = new PlotLength(0, PlotLengthUnit.RelativeToPlotArea),
                Width = new PlotLength(120, PlotLengthUnit.ScreenUnits),
                HorizontalAlignment = HorizontalAlignment.Right,
                VerticalAlignment = VerticalAlignment.Top
            });

            // Relative to plot area, above top/left corner, 20pt high
            model.Annotations.Add(new ImageAnnotation
            {
                ImageSource = image,
                X = new PlotLength(0, PlotLengthUnit.RelativeToPlotArea),
                Y = new PlotLength(0, PlotLengthUnit.RelativeToPlotArea),
                OffsetY = new PlotLength(-5, PlotLengthUnit.ScreenUnits),
                Height = new PlotLength(20, PlotLengthUnit.ScreenUnits),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Bottom
            });

            // At the point (50,50), 200pt wide
            model.Annotations.Add(new ImageAnnotation
            {
                ImageSource = image,
                X = new PlotLength(50, PlotLengthUnit.Data),
                Y = new PlotLength(50, PlotLengthUnit.Data),
                Width = new PlotLength(200, PlotLengthUnit.ScreenUnits),
                HorizontalAlignment = HorizontalAlignment.Left,
                VerticalAlignment = VerticalAlignment.Top
            });

            // At the point (50,20), 50 x units wide
            model.Annotations.Add(new ImageAnnotation
            {
                ImageSource = image,
                X = new PlotLength(50, PlotLengthUnit.Data),
                Y = new PlotLength(20, PlotLengthUnit.Data),
                Width = new PlotLength(50, PlotLengthUnit.Data),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Top
            });

            // Relative to the viewport, centered at the bottom, with offset (could also use bottom vertical alignment)
            model.Annotations.Add(new ImageAnnotation
            {
                ImageSource = image,
                X = new PlotLength(0.5, PlotLengthUnit.RelativeToViewport),
                Y = new PlotLength(1, PlotLengthUnit.RelativeToViewport),
                OffsetY = new PlotLength(-35, PlotLengthUnit.ScreenUnits),
                Height = new PlotLength(30, PlotLengthUnit.ScreenUnits),
                HorizontalAlignment = HorizontalAlignment.Center,
                VerticalAlignment = VerticalAlignment.Top
            });

            // Changing opacity
            for (int y = 0; y < 10; y++)
            {
                model.Annotations.Add(
                    new ImageAnnotation
                        {
                            ImageSource = image,
                            Opacity = (y + 1) / 10.0,
                            X = new PlotLength(10, PlotLengthUnit.Data),
                            Y = new PlotLength(y * 2, PlotLengthUnit.Data),
                            Width = new PlotLength(100, PlotLengthUnit.ScreenUnits),
                            HorizontalAlignment = HorizontalAlignment.Center,
                            VerticalAlignment = VerticalAlignment.Bottom
                        });
            }

            return model;
        }
I think in your case, it's the image annotation bind to a point that will be usefull.

willmoore88 wrote at 2013-07-24 17:33:

Thanks very much, this is definitely what I was looking for.

How do I get load a locally saved image (bitmap) into the OxyImage then?

raphay wrote at 2013-07-25 09:14:

Use this code :
OxyImage image;
using (FileStream stream = new FileStream(PathOfYourImage, FileMode.Open))
{
          image = new OxyImage(stream);
 }

willmoore88 wrote at 2013-07-25 09:53:

Is It possible to use a System.Drawing.Bitmap?

Basically I draw my bitmap, and can save it as a file, but would be quicker if I just used the one stored in memory.
Bitmap b = makeBitmap(scatter);

BlindMonk wrote at 2013-07-25 12:32:

Well, i added a bitmapimage, but I cant make it zoom. which property am i missing?

thanks a lot

raphay wrote at 2013-07-25 13:20:

willmoore88 wrote:
Is It possible to use a System.Drawing.Bitmap?

Basically I draw my bitmap, and can save it as a file, but would be quicker if I just used the one stored in memory.
Bitmap b = makeBitmap(scatter);
Save your bitmap in a stream and then use this stream to create your OxyImage
b.Save(Stream, ImageFormat);
image = new OxyImage(Stream);