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

Possible bug: cannot zoom in on a Cartesian plot with multiple axes

Alex Huang 9 лет назад 0
// How to reproduce: add the bold line to original example. And then try to zoom in with either mouse wheel or Page Up

[Example("Four axes")]
public static PlotModel FourAxes()
{
var plotModel1 = new PlotModel();
plotModel1.PlotType = PlotType.Cartesian;
plotModel1.Axes.Add(new LinearAxis { Maximum = 36, Minimum = 0, Title = "km/h" });
plotModel1.Axes.Add(new LinearAxis { Maximum = 10, Minimum = 0, Position = AxisPosition.Right, Title = "m/s" });
plotModel1.Axes.Add(new LinearAxis
{
Maximum = 10,
Minimum = 0,
Position = AxisPosition.Bottom,
Title = "meter"
});
plotModel1.Axes.Add(new LinearAxis
{
Maximum = 10000,
Minimum = 0,
Position = AxisPosition.Top,
Title = "millimeter"
});
return plotModel1;
}
0
На рассмотрении

Real time sample

Vahid N. 10 лет назад обновлен 10 лет назад 3
I've created a new sample about adding real time data to line series and then updating the plot at the same time. you can download it from here: OxyPlotWpfTests.zip

Tooltip for legend elements

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

vindex wrote at 2012-09-09 18:59:

Hi,

Is it possible to add a tooltip for each series in the legend? Maybe adding a "Description" property to series... I've tried with Tag property but didn't work.

Movable (drag-able) Annotation

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

ChevyCP wrote at 2012-03-19 20:25:

Hi,

   I have a wpf plot with multiple, user-selectable line series.  The X axis is date time.  I have two vertical annotation lines.  I was wondering if it would be possible somehow to make those annotation lines drag-able along the X axis.  I want to do this so the user can then re-run my evaluation software using data between those two date points.

Thanks!


ChevyCP wrote at 2012-03-19 21:37:

Basically these annotation lines would function as a slider, (time slider in my case).


objo wrote at 2012-03-20 18:35:

I would like to add MouseDown, MouseMove and MouseUp events on the PlotElement class - then it should be possible to handle mouse events on both annotations, axes and series. This should not be difficult, but it is a little bit of work to implement the hit testing (I would not depend on the presentation layer to do this (wpf/silverlight/winforms)).


ChevyCP wrote at 2012-03-22 21:00:

Isn't there hit testing already on the series, since there is tracker functionality?

 

Would it be easier to put hit testing/mouse events on the annotation class or create a custom annotation class that is based on a (re-skinned) slider control?  (That way the needed functionality already exists.)  Just a thought.


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

Series: yes, I would use the code from the hit testing - probably some refactoring is needed.

I would like to add mouse events to the PlotElement class, and implement the hit testing on each of the derived classes (annotations, axes, series). The hit testing should be done in the OxyPlot library to make it platform independent (which means I would not use the hit testing of the WPF/Silverlight elements...)

I think the mouse events should be sufficient to make the annotation lines draggable, no need for Slider controls here.


sharethl wrote at 2014-03-06 03:22:

Current Oxyplot example shows only one annotation is movable,
How to implement multiple annotations in one plot, and move one individually?
I try to for loop through all annotations and hittest each one, but hittest is protected.

Following code try to follow oxyplot design pattern, but have problem on finding which annotation currently focused.
Class PlotExample:Plot{
var arrow = new ArrowAnnotation();
arrow.StartPoint = new DataPoint(50, 0);
arrow.EndPoint = new DataPoint(50, 100);
arrow.MouseDown += NormalTool.OnMouseDown;
arrow.MouseMove += NormalTool.OnMouseMove;
arrow.MouseUp += NormalTool.OnMouseUp;
this.Annotations.Add(arrow);
}

static class NormalTool {
        public static void OnMouseDown(object sender, OxyMouseEventArgs e) {
            if (e.ChangedButton == OxyMouseButton.Left) {
                // cannot access to arrow....
            }
        }
        public static void OnMouseMove(object sender, OxyMouseEventArgs e) { 

        }
        public static void OnMouseUp(object sender, OxyMouseEventArgs e) { 
        
        }
 }


sharethl wrote at 2014-03-07 15:35:

Found one solution without changing original source.
made an new annotation that inherits from arrow annotation, and override mouse even in "new annotation" class.
In this way, don't need to use external tool class to modify annotation's properties.
public class SelectableArrowAnnotation:ArrowAnnotation { // any better name?

        DataPoint lastPoint = DataPoint.Undefined;
        bool moveStartPoint = false;
        bool moveEndPoint = false;
        OxyColor originalColor = OxyColors.White;

        protected override void OnMouseDown(object sender, OxyPlot.OxyMouseEventArgs e) {
            if (e.ChangedButton != OxyMouseButton.Left) {
                return;
            }
            
            lastPoint = this.InverseTransform(e.Position);
            moveStartPoint = e.HitTestResult.Index != 2;
            moveEndPoint = e.HitTestResult.Index != 1;
            originalColor = this.Color;
            this.Color = OxyColors.Red;
            var model = this.PlotModel;
            model.InvalidatePlot(false);
            e.Handled = true;
        }
        protected override void OnMouseMove(object sender, OxyPlot.OxyMouseEventArgs e) {
            var thisPoint = this.InverseTransform(e.Position);
            double dx = thisPoint.X - lastPoint.X;
            double dy = thisPoint.Y - lastPoint.Y;
            if (moveStartPoint) {
                this.StartPoint = new DataPoint(this.StartPoint.X + dx, this.StartPoint.Y + dy);
            }

            if (moveEndPoint) {
                this.EndPoint = new DataPoint(this.EndPoint.X + dx, this.EndPoint.Y + dy);
            }

            lastPoint = thisPoint;
            var model = this.PlotModel;
            model.InvalidatePlot(false);
            e.Handled = true;
        }
        protected override void OnMouseUp(object sender, OxyPlot.OxyMouseEventArgs e) {
            this.Color = originalColor;
        }
    }

wolf9s wrote at 2014-06-09 16:24:

Mark!

Random Color Picker

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

jpnavarini wrote at 2012-03-19 17:44:

I would like to create a trend with multiple LineSeries, however it would be necessary to pick a different color for each added LineSeries. Is there a color picker function to choose "random" colors, or I would have to do it manually?


objo wrote at 2012-03-20 18:26:

See the DefaultColor property of the PlotModel, you can change this to a list of random colors. The default value uses a predefined palette, not random colors. 

ps. I will change the DefaultColor property to an IList<Color>


jpnavarini wrote at 2012-03-20 18:50:

When I add a new LineSeries to the Series list, it plots using the same default color (dark green). However, when I add multiple plots at once (inside the same loop, for example), each lineseries get a different color. That color rotation is what I wanted, however with lineseries added at different moments.


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

Sorry, I don't quite understand. Is this a bug in the library? Do you add all series to the same plot?

I would like the plot always to generate the same colors (no randomness), if you want random colors to be generated when adding new series, this should be handled by your code.


JeanBisson wrote at 2014-01-09 17:27:

I believe I have a good handle with regard to random colors being assigned when adding LineSeries to a plot.

If you add a new LineSeries without its Color property set, the LineSeries will be assigned a Color (assigned to the ActualColor property) based on the number of LineSeries in the plot with its Color property still set to its default value (0x000001). Therefore, if you have 5 LineSeries in a plot of which 2 still have their Color property set to default, the Color assigned to the third LineSeries will be the third Color in the DefaultColors IList<> collection.

If you elect to assign a Color to a LineSeries (thereby assigning a non-default value to its Color property) and Refresh the plot, all other LineSeries may have their ActualColor property re-assigned a new color based on the number of LineSeries with default Colors remaining in the Series collection.

For example: First four colors in the DefaultColors IList<> collection are Red, Blue, Brown and Violet. The first LineSeries added with a default Color will have Red assigned to its ActualColor. Blue for the second, Brown for the third. Now, if you assign say Yellow to the second LineSeries and refresh the plot, you will find that the first LineSeries remains Red but the third LineSeries (previously Brown) will be re-assigned to Blue (since its the next in line in the IList<>).

In short, default / random colors are only assigned if their Color property is set to its default value of 0x000001. Once added to a plot, updating its Color can affect the color of other LineSeries (defpending on their order in the Series collection with regard to other LineSeries with a default Color property.

Hope this helps and thank you for this excellent library.

Cheers,
Jean

objo wrote at 2014-01-10 09:20:

Thanks Jean, great explanation!

Panning with Category Axis

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

bedidos wrote at 2012-05-26 02:28:

This library is great!

Is it possible to pan with a category axis?  So far, I have not been able to get panning to work on a category axis using latest source code.

 


objo wrote at 2012-05-26 08:24:

Yes, it is now! I fixed the bug (a simple change in CategoryAxis.UpdateActualMaxMin)

Possible bug: zoom and smooth

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

everytimer wrote at 2013-09-04 23:14:

If you zoom at a LineSeries whose property Smooth has been set to true you will notice an increasing memory usage and in few seconds an exception is thrown saying that you're out of memory. You can experience this in the examples too. The problem is with the generation of the segments, I think that the whole curve is being "smoothed" even if it's not visible in the plot.

Is there something that can be done to solve this?

PD. I've tested and even if you don't zoom at the Smoothed LineSeries but to an empty place you'll get the same problem.

objo wrote at 2013-09-05 07:53:

I see the problem, the Canonical spline creates a list and does not know the total number of points (depends on coordinates), so every time the plot renders, a new list is created.

Yes, I think the line should be clipped before smoothing. But we need a new clipping algorithm, which should include some points outside the clipping rectangle, otherwise the spline will be interpolated differently.

I have added it to the issues:
https://oxyplot.codeplex.com/workitem/10075

Can't display oxyplot in Xaml.

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

MartijnCarol wrote at 2013-10-30 16:32:

I've used the OxyPlot.Wpf nugetpackage and added in the Xaml.
   xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
and
          <oxy:Plot Margin="0" Grid.Column="1" Model="{Binding ViewModelTest.ChartModelECG, Source={StaticResource Locator}}"/> />
But keep getting this error

Method 'DrawEllipse' in type 'OxyPlot.Wpf.ShapesRenderContext' from assembly 'OxyPlot.Wpf, Version=2013.2.107.1, Culture=neutral, PublicKeyToken=75e952ba404cdbb0' does not have an implementation

If I change the nugetpacked to OxyPlot.Wpf_noPCL can see the chart in Xaml but cant start the prodject due to conflicts with he mvvm-light libery where as soon as I add plotModel1 = new PlotModel(); the following error acures

An exception of type 'System.Reflection.TargetInvocationException' occurred in mscorlib.dll but was not handled in user code

anny Idea what i'm dooing wrong?


Martijn Carol

_Noctis_ wrote at 2013-11-01 10:07:

Weird, I'm using OxyPlot with Mvvm-Light, and it works like a charm (well, I do need to bend some things backwards, but hey, it's still great)

Did you try downloading the dll's, and just adding them to your references in the project ? (I think this is what I did ... )

_Noctis_ wrote at 2013-11-04 14:01:

Weird ... I just ran into this problem with a new project after installing it from Nuget ...
Did you try installing the Nuget, cleaning the project, closing the VS and opening it again ?
(Seems it worked for some people, and between this and actually installing local dll's , it might have been the solution ...)

richardfen wrote at 2013-11-04 20:01:

I had exactly the same problem when I used NuGet. The suggestion above to just download the DLL's worked. You do this by going to:

http://oxyplot.codeplex.com/releases/view/76035

download the zip file and extract all the DLL's. I took the 4.5 versions and referenced the following:

OxyPlot.dll
OxyPlot.Wpf
OxyPlot.Xps.dll

The program that I used the above to build successfully was SimpleDemo. You can get this sample by doing to:

https://oxyplot.codeplex.com/SourceControl/latest#readme.txt

Then from the tree select: Source | Examples | WPF | SimpleDemo

objo wrote at 2013-11-05 19:00:

I just realized there was an error in the Nuget package, the dependency to the OxyPlot.Core package was pointing at the wrong version.
This should be fixed from version 2013.2.114.1!

akmm94 wrote at 2014-06-20 04:40:

Hi All,

When I am calling a new window to show up Oxy plot it just does not show up at all. If I open the window by itself it shows the plot. But if I call from another window it just does not show up. What can be the reason? Any help would be appreciated.

Xaml binding isnt working....

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

VadimTr wrote at 2013-10-21 22:49:

Hi,
When i create graph in XAML, then binding to observable collection - it isn't working.
Why?
        <oxy:Plot Margin="10">
            <oxy:LineSeries x:Name="OxyPlotLine"
                            Width="Auto"
                            Height="Auto" ItemsSource="{Binding Mode=OneWay, Source={StaticResource ChartPoints}}" />
        </oxy:Plot>
            for (double i = 0; i <= stopValue; i++)
            {
                ii =+ i;
                CPColl.Add(new ChartPoint(i, CPColl.Count););             
            }
    class ChartPoint
    {
        private double _X;
        private double _Y;

        public ChartPoint(double X, double Y)
        {
            _X = X;
            _Y = Y;
        }

        public double X
        { get { return _X; } set { _X = value; } }

        public double Y
        { get { return _Y; } set { _Y = value; } }
    }
    class ChartPointsCollection: ObservableCollection<ChartPoint>
    {
        public ChartPointsCollection() : base()
        {  }
    }

objo wrote at 2013-10-22 22:55:

OxyPlot is not automatically refreshing the plot when the collection changes (this was a design choice and I know it is different from normal WPF control behaviour). You need to trig the Invalidate or Refresh method on the Plot control yourself. I'll consider again if the OxyPlot.Wpf.ItemsSeries should listen to collection changes (and item property changes...)

VadimTr wrote at 2013-10-22 23:14:

Thank your for answer

Can your write a sample?

VadimTr wrote at 2013-10-22 23:21:

Can i use observable collections?

objo wrote at 2013-10-23 07:59:

Yes, you can use any collection. See the examples in Source\Examples\Wpf

Making an axis invisible

Oystein Bjorke 10 лет назад 0
This discussion was imported from CodePlex

dpru wrote at 2012-10-09 16:16:

How can I make an axis invisible?  I have tried setting "IsAxisVisible" to false on each of my axes, but nothing happens when I do so (and yes, I am refreshing the plot).  I am using WPF.

I have tried setting IsAxisVisible to false in both XAML and in code - I don't get anything happening with either way of doing things.

I simply want my axes to be black lines...no labels...nothing.  


objo wrote at 2012-10-09 22:00:

I added an example using the IsAxisVisible, see "Axis examples | Invisible axis" examples in the example browsers. It is possible there is an error in the OxyPlot.Wpf.Axis class, but I couldn't reproduce the bug.

Сервис поддержки клиентов работает на платформе UserEcho