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

click over elements

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

dapim wrote at 2011-11-19 20:04:

I have no words for this lib, it rocks.

I would like to let the user configure the axis or legend by double clicking then (wpf). Any tips?

Cheers 


objo wrote at 2011-11-23 06:29:

hi dapim, you can subscribe to the mouse events on the plot control and use the GetAxesFromPoint or GetSeriesFromPoint to determine which object was hit.

I am planning to add selection and mouse click events (cross platform), but have not had time to do this yet. 


dapim wrote at 2011-11-24 16:24:

Hi objo.

I added a small method to the plotmodel to select only the vertical axis and avoid miss selections (by default the GetAxesFromPoint returns the first vertical or horizontal axis when clicking inside the chart area).

I tried inheriting from plotmodel, but the AxisBase PositionTierMinShift and Maxshift are internal, so it was a no deal.

(ps I shamelessly copyed the original method and just tweeked it).

        public IAxis GetExactYAxesFromPoint(OxyPlot.ScreenPoint pt)
        {
            // Get the axis position of the given point. Using null if the point is inside the plot area.
            AxisPosition? position = null;
            double plotAreaValue = 0;
            if (pt.X < this.PlotArea.Left)
            {
                position = AxisPosition.Left;
                plotAreaValue = this.PlotArea.Left;
            }
            else if (pt.X > this.PlotArea.Right)
            {
                position = AxisPosition.Right;
                plotAreaValue = this.PlotArea.Right;
            }
            else //clicked on the midlle of the chart no response
                return null;
 
            double posValue = pt.X;
            foreach (var axis in this.Axes)
            {
                if (position == axis.Position && axis.IsVertical())
                {
                    // Choose right tier
                    var a = axis as AxisBase;
 
                    double positionTierMinShift = a.PositionTierMinShift;
                    double positionTierMaxShift = a.PositionTierMaxShift;
                    
                    bool isLeft = position == AxisPosition.Left;
 
                    if (position == AxisPosition.Left)
                    {
                        if (posValue <= plotAreaValue - positionTierMinShift && posValue > plotAreaValue - positionTierMaxShift)
                            return axis;
                    }
                    else
                    {
                        if (posValue >= plotAreaValue + positionTierMinShift && posValue < plotAreaValue + positionTierMaxShift)
                            return axis;
                    }
                }
            }
 
            return null;
        }        

Cheers

0

WPF C# problems with minimum and maximum -> axis reset

Aleš Brelih 9 years ago 0
Hi.

I have a problem with setting minimum and maximum of a specific axis.

So the problem is with this. I have a chart that displays "something". On this chart are also timestamps where important stuff happened which are also listed in some datagrid on the right.
Functionality that i want to have is that when you click on a timestamp in the datagrid chart current view moves you to the location of that timestamp (zoomed).

Now first problems came when i tried changing min and max of an axis to the specific two points i wanted to display. It didn't want to work properly untill i called .Reset() function on the the axes before i tried to change minimum and maximum (and yes i did use PlotModel.InvalidatePlot(true)). Now when i tried to use the default double middle mouse button click to reset the view to the default it just doesn't do anything. If i dont call the .Reset() function, it resets properly.

Now the questions: What am i missing. Is just setting .Minimum and .Maximum a correct way to handle what i want to achieve. And how to i set the limits I want the chart to reset to (with implemented reset) after axis is reset.


Best regards and thanks for the help
0

DateTimeAxis MinorStep Problem

Issame Kastite 9 years ago 0
I am trying to plot some data for a month, so I set the MajorStep to week and the MinorStep to Days, like this, and it's working well.

DateTimeAxis1.IntervalType = DateTimeIntervalType.Weeks;
DateTimeAxis1.MinorIntervalType = DateTimeIntervalType.Days;
DateTimeAxis1.MinorStep = 1;
DateTimeAxis1.MajorStep = 7;
But If I change the IntervalType to Auto, like this, It shows the MajorStep as Weeks, but it doesn't show the MinorStep (days) interval at all

DateTimeAxis1.IntervalType = DateTimeIntervalType.Auto;
DateTimeAxis1.MinorIntervalType = DateTimeIntervalType.Days;(
DateTimeAxis1.MinorStep = 1; 

Heatmap and SVG

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

digitalnelson wrote at 2013-11-16 13:00:

I am having trouble getting the heatmap to save to SVG. Axes, legend, and labels show but no heatmap itself. Any thoughts?

digitalnelson wrote at 2013-11-16 13:14:

Nevermind. Just updated to the latest code base and looks like it was fixed.

Get ScreenPoint from DataPoint

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

magikorion wrote at 2014-05-26 10:36:

Hi everybody,

I'm currently blocked by an issue that is I want to get a list of screen points from the list of data points. My list of data points is filled and is valued but when I apply a tranform to get screen points, the result is always 0,0 per each point. Can you tell me why?

Here is my code :
foreach (DataPoint dp in series.Points)
{
      Console.WriteLine(dp);
      Console.WriteLine(this.xAxis.Transform(dp.X, dp.Y, this.yAxis));
}
And the result in console :
41695 1.3715
0 0
41696 1.3697
0 0
41697 1.37545
0 0
41700 1.37595
0 0
41701 1.37375
0 0
41702 1.3737
0 0
41703 1.37945
0 0
41704 1.3867
0 0
41707 1.3875
0 0
41708 1.38665
0 0
41709 1.3881
0 0
41710 1.3885
0 0
41711 1.389
0 0
41714 1.39145
0 0
41715 1.39265
0 0
41716 1.3882
0 0
41717 1.38045
0 0
41718 1.3784
0 0
41721 1.38145
0 0
41722 1.3831
0 0
41723 1.3803
0 0
41724 1.37595
0 0
41725 1.37455
0 0
41728 1.3762
I made this after giving model to the plot view and after adding series. I add that my x axis is a DateTime axis and my Y axis is a linear axis.

Finally I need to get the real points coordonates.

Thank's for help.

objo wrote at 2014-06-06 21:29:

The transforms on the axes are defined when rendering (since they depend on the width/height of the client area). Are you trying to transform before the plot is rendered? Maybe you can subscribe to the Axis.TransformChanged event and do this after the transform has been set?
0
Under review

Tracker not working in pie series

Pablo López Ponce 9 years ago updated 9 years ago 2
Hello there,

I have implemented a Pie Series with several pie slices and it's showing fine, but the tracker is not working.

This is on WPF. 

Tracker is working fine with other kind of series, but not on this one.

No error is showing on the console so I don't know what exactly to report.

This is my code:

PlotModel modelo = new PlotModel();
PieSeries serie = new PieSeries();
serie.InnerDiameter = 0.4;
serie.Diameter = 0.8;
modelo.Series.Add(serie);


int indice = 0;
foreach (MotivoDevolucion motivo in Datos.motivos.Values)
{
double valor = Datos.devoluciones.Values.Where(devolucion => devolucion.motivo == motivo && años[devolucion.fecha.Year] && meses[devolucion.fecha.Month]).Sum(devolucion => devolucion.cantidad);
PieSlice porcion = new PieSlice(motivo.descripcion, valor);
porcion.Fill = Datos.ObtenerOxyColor(indice);
porcion.IsExploded = false;
indice++;
serie.Slices.Add(porcion);
}

few changes to the source and one potential issue found

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

chage wrote at 2013-05-03 19:35:

Hi objo,
I started to use oxyplot not long ago, thanks for the great library.
While developing I traced into oxyplot source and make some changes. Need to know if the changes are good, and could it be included into official trunk?
  1. Added "Resolution" properties to LineSeries to give option on lower resolution drawing in high data count use case.
  2. BoxPlotSeries GetNearestPoint TrackerHitResult.Text should return DateTime for DateTimeAxis.
 -                            result.DataPoint.X,
+                            this.XAxis != null ? this.XAxis.GetValue(result.DataPoint.X) : result.DataPoint.X,
  1. RenderingExtension DrawClippedLine exception when trying to draw a line with single point. So I added a check for single point case and create an offset just like what the code did in latter single point case. Not sure if this is the best way.
// render the line if we are leaving the clipping region););
                    if (!clipping.IsInside(s1))
                    {
                        if (pts.Count > 0)
                        {
                          // Check if the line contains a single point
                          if (pts.Count == 1) {
                            // Add a second point to make sure the line is being rendered as a small dot
                            pts.Add(new ScreenPoint(pts[0].X + 1, pts[0].Y));
                            pts[0] = new ScreenPoint(pts[0].X - 1, pts[0].Y);
                          }

                            rc.DrawLine(
                                pts, stroke, strokeThickness, lineStyle.GetDashArray(), lineJoin, aliased);
                            if (pointsRendered != null)
                            {
                                pointsRendered(pts);
                            }

                            pts = new List<ScreenPoint>();
                        }
                    }

objo wrote at 2013-05-06 10:29:

thanks for the bug reports and correction code! I have corrected #2 and #3, and added examples to make sure it works.
How did you implement lower resolution in #1? The LineSeries has a MinimumSegmentLength property that works in screen coordinates.
Are you sampling the input data points - I think this could be handled by the application, not by the plotting library.

chage wrote at 2013-05-06 18:17:

Hi objo,
Thanks for the updated code, your changes are much elegant by moving the single point handling to a separate method.

As for #1 (resolution), I simply added a Resolution property to LineSeries and pass it along to RenderingExtensions.DrawMarkers.
            if (this.MarkerType != MarkerType.None)
            {
                rc.DrawMarkers(
                    pointsToRender, 
                    clippingRect, 
                    this.MarkerType, 
                    this.MarkerOutline, 
                    new[] { this.MarkerSize }, 
                    this.MarkerFill, 
                    this.MarkerStroke, 
                    this.MarkerStrokeThickness,
                    this.Resolution); // added Resolution property and pass it to draw markers
            }
Some background on my intention: I realize the 100K performance test is only good for non-markers line series. When there is markers, the performance degraded drastically due to markers drawing, obviously markers drawing requires much heavier processing than simple line drawing. Hence I try to reduce the number of markers when they overlapped, which is what DrawMarkers resolution argument is doing. Honestly the resolution method that I use (resolution 5) is just slight better than the original code, still not good enough for my application but I will look at possible way to improve that later.


I was considering handling in application code, but found DrawMarkers method to be resolution capable, so i just reuse it. After take a look at MinimumSegmentLeght, it is mainly to optimize line drawing, the markers drawing is not affected by this property, if I read it correctly... But I do see that I can use ScreenPointHelper.ResamplePoints to get resample screenpoints and pass it to DrawMarkers, what do you think?

objo wrote at 2013-06-08 11:55:

ok, I added a MarkerResolution property to the LineSeries.
Note: the last argument of the DrawMarkers method should also be provided when using the resolution argument (otherwise you will get marker flickering when panning)

chage wrote at 2013-06-13 18:35:

Thanks objo, that works great!

Multiple plot controls in a listbox (WPF)

Oystein Bjorke 10 years ago updated by jcevangelista 8 years ago 1
This discussion was imported from CodePlex

cpuserdi wrote at 2013-06-27 20:13:

I would like to show multiple independent plots using a listbox. I have a collection of PlotModels (collection derives from ObservableCollection) as my resource and ItemsSource for the ListBox. I set the ItemTemplate of the ListBox to a DataTemplate containing just the Plot control binding Model to the item. The PlotModels are initialized in the Window constructor in code behind. Rather than seeing the Plot at runtime, there is blank space. If I take the Plot out of the ListBox, it works fine on its own.

Is this possibly related to this issue? DataTemplate Issue

objo wrote at 2013-07-02 14:59:

This sounds like a bug, and I guess it is related to the DataTemplate issue.
Can you try to turn off virtualization in the ListBox control?
Does the same thing happen if you use an ItemsControl?
Can you create a small example we can use to test (I know it only takes 10min... :-)

cpuserdi wrote at 2013-07-02 15:29:

The XAML:
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:oxy="clr-namespace:OxyPlot.Wpf;assembly=OxyPlot.Wpf"
        xmlns:local="clr-namespace:WpfApplication1"
        Title="MainWindow" Height="350" Width="525">
  <Window.Resources>
    <local:PlotCollection x:Key="Plots" />
  </Window.Resources>
  <ListBox ItemsSource="{DynamicResource Plots}" ScrollViewer.CanContentScroll="False"
           VirtualizingStackPanel.IsVirtualizing="False">
    <ListBox.ItemTemplate>
      <DataTemplate>
        <oxy:Plot Model="{Binding}" />
      </DataTemplate>
    </ListBox.ItemTemplate>
  </ListBox>
</Window>
Additional code:
  public class PlotCollection : System.Collections.ObjectModel.ObservableCollection<OxyPlot.PlotModel> {
    public PlotCollection() {
      this.Add(new OxyPlot.PlotModel("Title 0"));
      this.Add(new OxyPlot.PlotModel("Title 1"));
      this.Add(new OxyPlot.PlotModel("Title 2"));
      this[0].Series.Add(new OxyPlot.Series.LineSeries("Series 0"));
      this[1].Series.Add(new OxyPlot.Series.LineSeries("Series 1"));
      this[2].Series.Add(new OxyPlot.Series.LineSeries("Series 2"));
      (this[0].Series[0] as OxyPlot.Series.LineSeries).Points.Add(
        new OxyPlot.DataPoint(0, 0));
      (this[0].Series[0] as OxyPlot.Series.LineSeries).Points.Add(
        new OxyPlot.DataPoint(1, 1));
      (this[1].Series[0] as OxyPlot.Series.LineSeries).Points.Add(
        new OxyPlot.DataPoint(0, 0));
      (this[1].Series[0] as OxyPlot.Series.LineSeries).Points.Add(
        new OxyPlot.DataPoint(1, 1));
      (this[2].Series[0] as OxyPlot.Series.LineSeries).Points.Add(
        new OxyPlot.DataPoint(0, 0));
      (this[2].Series[0] as OxyPlot.Series.LineSeries).Points.Add(
        new OxyPlot.DataPoint(1, 1));
    }
  }

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

Thanks for the code!
I think you have to set the height of the plot control. But there is also something else that must be done...
It works for ItemsControl, but I am not sure why it doesn't for a ListBox.
    <ItemsControl ItemsSource="{DynamicResource Plots}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <oxy:Plot Model="{Binding}" Height="200"/>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>

cpuserdi wrote at 2013-07-03 14:28:

The height requirement makes sense, it needs something to determine the size. I'm at a loss concerning the ListBox, but I think the ItemsControl will be good enough for what I needed.

Half circle polar plot

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

aec wrote at 2012-08-28 22:56:

Hi objo. Is it possible to have a polar which is not a full circle? I think that an often used case is a semicircle. In general, the polar plot should be an arc of a certain angle range.


objo wrote at 2012-08-29 06:39:

I added this to the issue tracker: http://oxyplot.codeplex.com/workitem/9997

Can you provide a good example?


aec wrote at 2012-08-29 21:15:

Okay, we can can do this. I am thinking of a antenna beamforming. Here we could plot the solution when the beam directs to different positions. The same can be done by using microphone arrays. By the way, here it make sense to have a logarithmic scale for the magnitude axis because the magnitude is measured in decibel.

Under review

MonoDroid version - how is it?

Oystein Bjorke 10 years ago updated 9 years ago 2
This discussion was imported from CodePlex

dpru wrote at 2013-07-03 16:04:

I am working on an Android app using MonoDroid. I am in need of a good plotting library, and I have used OxyPlot in my WPF apps before, so I came to check if there was a MonoDroid version - and indeed there is.

I know it is an "alpha", so I was wondering what known limitations and bugs it has, just so I can be aware of them as I start trying to integrate it into my project?