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

Event triggers only once

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

everytimer wrote at 2013-09-30 21:31:

I'm using OxyPlot for animating a simple sinusoidal motion:
    void ViewMotion()
    {
        foreach (File item in LoadedFiles())
        {
            LineSeries skeleton = new LineSeries();
            skeleton.MarkerType = MarkerType.Circle;
            skeleton.MarkerSize = 10;

            AnimationPlot.Series.Add(skeleton );

            var worker = new BackgroundWorker { WorkerSupportsCancellation = true };

            foreach (Channel node in item.ChannelAnim)
            {
                double x = 0;
                worker.DoWork += (s, e) =>
                {
                    while (!worker.CancellationPending)
                    {
                        x += 0.02;
                        if (skeleton.Points.Count > 0)
                        {
                            skeleton.Points.Remove(ss.Points.First());
                        }

                        skeleton.Points.Add(new DataPoint(50, 50 + (30 + x) * Math.Sin(x)));
                        AnimationPlot.RefreshPlot(true);
                        MessageBox.Show("");
                        Thread.Sleep(25);

                    }
                };

            }
            worker.RunWorkerAsync();


        }
    }
Basically is just a dot going up and down. The problem that the event only triggers once, so I don't see a motion but the initial position. It's not a binding problem, it is something wrong with the event. I've tried changing the order but without success.

By the way, this is working correctly: (Two dots going up and down)
 ScatterSeries ss = new ScatterSeries();
    ScatterSeries ss2 = new ScatterSeries();
    public void TemporalMethod(object param)
    {
        ss.MarkerType = MarkerType.Circle;
        ss.MarkerSize = 20;
        ss.MarkerFill = OxyColors.Violet;
        MyModel.Series.Add(ss);

        ss2.MarkerType = MarkerType.Triangle;
        ss2.MarkerSize = 20;
        ss2.MarkerFill = OxyColors.Green;
        MyModel.Series.Add(ss2);

        var worker = new BackgroundWorker { WorkerSupportsCancellation = true };
        double x = 0;
        double y = 0;

        worker.DoWork += (s, e) =>
        {
            while (!worker.CancellationPending)
            {
                x += 0.02;
                y += 0.001;
                if (ss.Points.Count > 0)
                {
                    ss.Points.Remove(ss.Points.First());
                }
                if (ss2.Points.Count > 0)
                {
                    ss2.Points.Remove(ss2.Points.First());
                }

                ss.Points.Add(new DataPoint(50, 50 + (30 + x) * Math.Sin(x)));
                ss2.Points.Add(new DataPoint(55, 50 + 30 * Math.Sin(x + y)));
                MyModel.RefreshPlot(true);

                Thread.Sleep(25);
            }
        };

        worker.RunWorkerAsync();
    }

everytimer wrote at 2013-09-30 21:50:

EDIT: The solution is pretty dumb, I mistakenly wrote
                            if (skeleton.Points.Count > 0)
                        {
                            skeleton.Points.Remove(ss.Points.First());
                        }
instead of:
                            if (skeleton.Points.Count > 0)
                        {
                            skeleton.Points.Remove(skeleton.Points.First());
                        }
I don't know why but I haven't got any errors.

Lines vanishing near the border

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

RickNZ wrote at 2012-09-08 01:28:

I'm using LinearAxis and LineSeries, and some segments of the lines with zero values, that should appear along the X axis, do not appear.

I have <oxy:Plot> object with about a dozen <oxy:LinearAxis>, each with their own <oxy:LineSeries>, configured in XAML. Each LinearAxis is positioned along the Y axis using StartPosition and EndPosition, with a small gap between them. Minimum is set to 0, but no Maximum, so they auto-scale. I'm using MajorGridLines and MinorGridLines.

Each LineSeries uses YAxisKey to select the corresponding LinearAxis, and sets a Color for the line. I'm using the default line style.

The zero-valued line segments only disappear on some of the LinearAxis.

If I vertically resize the graph, the zero-valued line segments appear in some areas where they were missing, and disappear in others where they were visible.

I've tried changing StrokeThickness to be 2 or 3, but that doesn't make any difference.

Freezing UI

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

willmoore88 wrote at 2013-10-24 11:17:

What are the causes for an update to an oxyplot freezing the UI?

everytimer wrote at 2013-10-24 14:20:

Not only OxyPlot, but everything will freeze your UI if you do not use a separate Thread for performing that operation. I think this can be done in OxyPlot using
InvalidatePlot(true);
instead of
RefreshPlot(true);
You may like to take a look at Threads and BackgroundWorker.

willmoore88 wrote at 2013-10-24 15:43:

It is exactly this call that is temporarily freezing the UI. The function which updates my plots ItemsSource and calls InvalidatePlot(true) is already running on a separate thread. I have no idea what i'm doing wrong! :(

willmoore88 wrote at 2013-10-25 13:05:

Its

public void Update(bool updateData = true)

in PlotModel.cs. This is running on the main thread - updating thousands of points. How can I make this update run on a separate thread?

Unable to deploy MonoTouch Demo

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

Devin19 wrote at 2013-10-29 16:36:

Hi, last week I succesfully implemented the MfA variant from OxyPlot in my Android application using Xamarin.
This week I started working on the iOS version, but I'm not able to deploy the MonoTouch Demo to my iOS-simulator on my Mac.
I've tried to implement it into my iOS app but the app won't run after I've implemented it either.

This is the error I'm getting:
Log generated on 29-10-2013 13:33:37

Operation failed (Build Server)
Operation status: Operation failed
HTTP status: 200 (No error)
OK
Build server returned an error.
Failed to debug MonoTouchDemo
Does/Did anyone have the same problem, or does anyone have a solution to this?

Devin19 wrote at 2013-10-31 17:15:

This seems to be a Xamarin/Visual Studio related issue.

something is not right on the hascode

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

chage wrote at 2014-03-27 23:46:

Hi Objo,
While testing, I found an issue where i added a series into a dictionary as key and later retrieve it using the series as a key. Exception is thrown claiming no such key.

After some digging of this weird behaviour, i believe it comes down to the a new added gethashcode override method in PlotElememt.
public override int GetHashCode()
        {
            // Get the values of all properties in the object (this is slow, any better ideas?)
            var propertyValues = this.GetType().GetProperties().Select(pi => pi.GetValue(this, null));
            return propertyValues.GetHashCode();
        }
I can't tell whats wrong with this method of using reflection to retrieve properties value, but a simple test shows that this is not working.
LineSeries series = new LineSeries();
int hash1 = series.GetHashCode();
int hash2 = series.GetHashCode(); // different hash returned...
Any idea? thanks!

Placing marker at custom location

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

endorphing wrote at 2013-01-25 20:54:

Is there a way to place a marker at a custom location. If I had 5 points in my LineSeries, and I only want to put markers at the 2nd and 4th points, what's the best way to achieve that? 

Thanks in advance for your help. 


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

I would add a ScatterSeries for the markers. The ScatterSeries class has more options for the markers. I don't think there should be more marker features in the LineSeries.

endorphing wrote at 2013-02-26 21:59:

Thanks for the tip. A ScatterSeries would work, except I need mouse events on the series to be enabled.

I ended up implementing a custom LineSeries. I re-defined the MarkerFill & MarkerStroke properties, so that setting them here doesn't enable markers in the base class.
    public class MarkerLineSeries : LineSeries
    {
        public IList<int> MarkerLocations { get; private set; }

        new public OxyColor MarkerFill { get; set; }

        new public OxyColor MarkerStroke { get; set; }

        public MarkerLineSeries()
            : this(string.Empty)
        {
        }

        public MarkerLineSeries(string title)
            : this(title, new Collection<int>())
        {
        }

        public MarkerLineSeries(string title, IList<int> markerLocations)
            : base(title)
        {
            MarkerLocations = markerLocations;
        }

        public override void Render(IRenderContext rc, PlotModel model)
        {
            base.Render(rc, model);
            foreach (var location in MarkerLocations)
            {
                if (location < 0 || location > Points.Count - 1) break;
                var pt = XAxis.Transform(Points[location].X, Points[location].Y, YAxis);
                rc.DrawMarker(
                    pt,
                    GetClippingRect(),
                    MarkerType,
                    MarkerOutline,
                    MarkerSize,
                    MarkerFill,
                    MarkerStroke,
                    MarkerStrokeThickness);
            }
        }
    }

Add a arrow at the endpoint of axis

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

liqinyong wrote at 2013-11-09 04:25:

Hi all,
  How could I add a arrow at the endpoint of LinearAxis?Like follows:
      ![Image](http://epaper.tianjinwe.com/cskb/images/2006-10/31/11622367346049419299632320046.jpg)
  Thank you very much~

objo wrote at 2013-11-11 19:36:

Try to subclass LinearAxis and override the Render method. The arrow head can simply be added at the end!
I cannot open the image, but try something like this: https://gist.github.com/oeb/7419304

liqinyong wrote at 2013-11-14 02:59:

Thanks for reply , I will try it!

How to avoid PlotModel being affected by different RenderContext

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

heromyth wrote at 2011-10-20 04:53:

It seems that The Render(IRenderContext rc) for the PlotModel will change the PlotModel accord to the different RenderContext.

For example, I have a OxyPlot in a winform. Now, I export it to a PNG or PDF which have different size with the winform.
Then, the looking of the OxyPlot in the winform will also be changed.

To solve it, all can be thinked of by me are clone the PlotModel, and render a new PlotModel in another RenderContext.

How about this?

Thanks.


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

You are right, the PlotModel contains a lot of render specific data. It should only be used in one plot control. 

It should be possible to print the PlotModel of a control, you should just make sure the control is updated after printing. 

Touch Support on Windows 8

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

ez1 wrote at 2012-12-04 22:24:

Hi, 

I have a question regarding the touch support of OxyPlot on Windows 8:

I ran the Metro Example Browser application and it seems that panning with one finger and pinch-zooming with two fingers of a plot is not enabled there.

The WPF Example Browser application has support for those touch-interactions, however the update-rate of a plot while doing any of those gestures feels pretty laggy compared to doing the same thing with regular mouse-interactions.

Has anybody experienced similar issues?

Thanks a lot!


objo wrote at 2012-12-05 22:34:

Right, the touch manipulation events are not implemented on the windows 8 app control. I have not looked at the API yet, but hope the events will be similar to the ones in WPF.

I remember I noticed the same response problems as you describe when I implemented the WPF touch events. I don't have any touch capable hardware now, so need info from others to solve those bugs.


vicente001 wrote at 2013-11-08 06:47:

I am trying to implement touch support in the Metro version of OxyPlot.

I have added
this.ManipulationMode = ManipulationModes.Scale | ManipulationModes.TranslateX | ManipulationModes.TranslateY;
to the contructor of the Plot class. This enables the overridden Manipulation methods to be called.
I have reached the point where I have noticed that OnManipulationDelta only happens once and OnManipulationCompleted never gets called. If I comment out the Panning and Zooming code in OnManipulationDelta then the methods are called. It seems like the calls to UpdateVisuals is somehow stopping the framework from calling the OnManipulationDelta more than once as well as OnManipulationCompleted.

Any ideas why this is happening? is there a lock or something else in UpdateVisuals that is preventing the UI thread from processing the touch manipulation events, Panning and Zooming done with the mouse (via the OnPointerxx methods) seems to work fine.

thanks

Update, the culprit seems to be this.canvas.Children.Clear(); in UpdateVisuals()
see a similar problem on
http://stackoverflow.com/questions/6418899/in-windows-phone-7-manipulationdelta-event-does-not-work-as-expected
Any ideas on how to fix this?

barchart with label

Oystein Bjorke vor 10 Jahren 0
This discussion was imported from CodePlex

steunissen wrote at 2011-12-16 10:42:

Hi,

Is it possible to display the values of individual bars inside the bar chart ?

I guess I need a textannotation for this, but as far as I can see it is not implemented yet...

 

btw:

Really, really great work !


objo wrote at 2011-12-19 12:13:

See the "Simple barseries with labels" example in the Example browser. This is implemented in the bar series, not as annotations.


steunissen wrote at 2011-12-19 14:29:

Ah.. I see. I was working with an old source code. And only checked the online examples...

Thanks!

Sander.


steunissen wrote at 2011-12-19 16:43:

Hmmm... unfortunately I can't get the latest built to work. It crashes in ShapesRenderContext.cs at line 658.  (I have added an issue to the issue tracker.)

 

Sander.


objo wrote at 2011-12-21 21:52:

I hope everything is ok now. Let us know if there are still problems!