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

Draw series by mouse click

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

liuzu wrote at 2012-11-08 05:35:

I am afraid that just write with poor English.

I want to draw a series by the mouse left button click.

1)       Mouse left click to get the Point form the chart and the Point’s value is relation with x,y axes that don’t relation with screen point.

2)       Add the getting Point to the series ‘s DataPoint

 

So,how can I get the point that value relation with x,y axes from the chart?

 

Best Regards.


objo wrote at 2012-11-08 06:12:

see the "Mouse events > LineSeries and PlotModel MouseDown event" example in the example browser, I think that one does exactly what you need.


liuzu wrote at 2012-11-08 06:27:

I appreciate your help very much. objo

Bug while plotting gridlines.

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

amity2001 wrote at 2012-10-18 07:09:

I am using this great tool to plot ECG graph.

As ECG graph requires grid, I used MajorGridlineColor and MinorGridlineColor property to draw grid. But when I maximize the form the grid gets distorted

Please look at this Snapshot for details.

 

Thanks in advance.


objo wrote at 2012-10-18 07:40:

I think this is the same problem as in http://oxyplot.codeplex.com/discussions/357350. Change from dashed/dotted to solid grid lines. It is probably a bug in WPF!



amity2001 wrote at 2012-10-18 08:09:

Hi objo,

Thank you very much...!

I used solid grid line with color having low alpha.

 

Happy coding...!

Updating HeatMapSeries

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

guevara123 wrote at 2013-12-19 12:00:

Hello,

is there a way to update a PlotModel which contains a HeatMapSeries, without creating a new instance of a PlotModel and overwriting the old one?

I am using the MVVM pattern and WPF here.

I tried using PlotModel.Update(true), PlotModel.RefreshPlot(true) and PlotModel.UpdateAxisTransforms(), but nothing happens.

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

The InvalidatePlot/RefreshPlot methods in the PlotModel should update the plot. The Update and UpdateAxisTransforms are not sufficient (these should probably not be public...)

Is this a problem with the HeatMapSeries only? Can you try using some other series (e.g. a LineSeries) just to test that the updating works.

guevara123 wrote at 2014-01-12 12:00:

Thanks for your answer. I tested the LineSeries and it works fine. The problem I have only happens when I change the LinearColorAxis on a HeatMapSeries..


Image

Both plots are created the same way, except for plot 2 I comment out Line 3 and 4:
   HeatMapModel = new PlotModel("Peaks");
   HeatMapModel.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Jet(500)  });
   // ((LinearColorAxis)HeatMapModel.Axes[0]).Minimum = 0; // __for the lower plot..__
   //  ((LinearColorAxis)HeatMapModel.Axes[0]).Maximum = 5; 
    var hms = new HeatMapSeries { X0 = x0, X1 = x1, Y0 = y0, Y1 = y1, Data = peaksData };
   HeatMapModel.Series.Add(hms); 
Now I want to change the Maximum and Minimum of the LinearColorAxis at runtime, by a button click i.e. This only works when I create a new PlotModel!
So this code wont work:
   ((LinearColorAxis)HeatMapModel.Axes[0]).Minimum = 0; 
    ((LinearColorAxis) HeatMapModel.Axes[0]).Maximum = 10;  
    HeatMapModel.RefreshPlot(true);
I have the feeling that this behaviour occurcs, because the HeatMapSeries itself is a PlotModel ( just an assumption..)

guevara123 wrote at 2014-03-01 10:49:

I still have this problem. Any Idea how to solve it? The HeatMapPlot won't react to changes to the ColorAxis till a new PlotModel is created..

objo wrote at 2014-03-01 13:07:

Thanks for the bug report! I have two possible solutions for this:
  1. Create an Invalidate method in the HeatMapSeries that forces the heatmap to be regenerated at next rendering pass. Then call InvalidatePlot/RefreshPlot as you already do.
  2. Let the HeatMapSeries Render method detect when the ColorAxis has changed. It should then call the UpdateImage method. No changes needed to your code.
See the newly checked in code, I think this solves the problem. The hash code calculation used to solve #2 is questionable, I am interested in input on this!

objo wrote at 2014-03-01 13:10:

Note how I wrote the examples to reproduce the problem. Providing examples in the example library makes it much faster to get to the solution. It also makes it easy to verify that it works (also in the online Silverlight example browser).

guevara123 wrote at 2014-03-01 15:47:

Wow thank you ! I have a huge Overhead in my code because of this issue and now I can finally clean it up :)

Next time I'll try to give a better example for a faster solution!


edit: I just saw your question in the sourcecode, about a faster way to get a HashCode.

It would be a little faster to make a HashCode only from those properties that are responsible for a HeatMapSeries invalidation. For example: Minimum, Maximum and Palette directly change the look of the HeatMapSeries, though changes to properties like TextColor, Titlefont and so on shouldnt invoke a invalidation..

guevara123 wrote at 2014-03-02 20:30:

I've found another potential Bug. When ColorAxis.RenderAsImage is true, then the mapping of the HighColor of the ColorAxis with the displayed colors in the HeatMap isn't correct.

This can be seen in the LinearColorAxis -> RenderAsImage(vertical reversed) Example..

Image

Auto-scroll/pan for real-time data

Oystein Bjorke 10 years ago updated by Robert Perez 9 years ago 1
This discussion was imported from CodePlex

armensg wrote at 2014-02-10 20:11:

Hi before I ask the question I just want to say that I really like OxyPlot! Well done and keep up the great work!

Now down to businessI am using OxyPlot in a C# winforms app. My axese are LinearAxis type.

I am trying to plot some real-time data which i have managed to do by adding points to my series and refreshing the plot as data becomes available. However, I am having trouble figuring out how to make the plot move to the right with the time series.

Each time series data point has an X value incremented by (int) 1 and I have tried to get the auto scrolling to happen using .Pan() like so:

xAxis.Pan(-1);
Obviously this hasn't worked since I am assuming the method takes pixel inputs or something and consequently the panning is much slower than the data incrementation.

I have also tried replacing -1 with -MajorTIckSize and -MajorStepSize with no luck as these are generally too small of a move.

My question is, how can i determine the delta i need to be using to pan with the real-data? I am assuming this will depend on the zoom level and obviously it would be nice if it would continue to work as I zoomed in and out.I imagine the solution involves some sort of function that relies on the pixel width of the tick interval or something but I can't figure it out.

Thanks,

Armen

decatf wrote at 2014-02-11 17:06:

The Transform function in the Axis class will convert data coordinates to screen coordinates. There is an InverseTransform to do the opposite.

So you could try:
double panStep = xAxis.Transform(-1 + xAxis.Offset);
xAxis.Pan(panStep);
There is some offset from the axis zero position (I think?) so we need to account for that in the transform to get a unit step.

armensg wrote at 2014-02-12 12:31:

Thanks decatf, this works perfectly.
Armen

WhizzWr wrote at 2014-03-17 16:14:

Hi,

I am also currently using Oxyplot to display real time data too.. The plot data are coming from serial port per 100 ms.

The auto-pan method suggested above does work but I'm not able to sync panning and plotting speed.

Plotted line appear to accelerate (or the perhaps it's the panning speed that decelerate) and eventually the line end point will be gone from the plot screen. (i.e Panning speed lags behind)

Any pointer?

Thanks in advance.

Binding ScatterSeries to ObservableCollection

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

tboloo wrote at 2013-03-18 15:46:

Apologies if this is trivial, but I have not found the solution so far.
Basically I am trying to bind ObservableCollection<MyType> to Scatter series, in hope that it would automatically reflect in points being added / removed to a plot. Now, I do not get any binding errors, but the points are not shown. Code is simple:
        private ObservableCollection<TestPointViewModel> testPoints = new ObservableCollection<TestPointViewModel>();
        private ReadOnlyObservableCollection<TestPointViewModel> readonlyTestPoints = null;
        public ReadOnlyObservableCollection<TestPointViewModel> TestPoints
        {
            get
            {
                if (readonlyTestPoints == null)
                    readonlyTestPoints = new ReadOnlyObservableCollection<TestPointViewModel>(testPoints);
                return readonlyTestPoints;
            }
        }
in the ViewModel, and
            
                <oxy:Plot.Series>
                    <oxy:ScatterSeries Name="singleShotSeries" Title="Shot" MarkerType="Cross" DataFieldX="B" DataFieldY="G" ItemsSource="{Binding Admittance}"/>
                </oxy:Plot.Series>
in the View.
Am I doing something wrong, or binding to ObservableCollection is just a no-go?

I got the metro version working - is there a way to fill an area under a graph?

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

doctorj wrote at 2012-09-19 22:42:

Hi ,

 

I have a graph that is bounded by two vertical lines - is there a way to fill the area with a color?

 

 

 

Thanks,

 

Jerry


objo wrote at 2012-09-24 10:23:

under a graph: use an AreaSeries

between two vertical lines: use a RectangleAnnotation with MinimumY=MaximumY=NaN


doctorj wrote at 2012-09-24 15:26:

actually it is bounded by two vertical lines and the graph line above and the x axis so it is an enclosed area , I have plotted. I have used lineseries to plot the curve and two straight lines , do I still use an AreaSeries function? Thanks for your help

 

Also do I need to update my libraries since you have updated your PCL/Metro for Windows Store auth. ?

 

Thanks

Using AngleAxis in WinForms application

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

PanCotzky wrote at 2012-09-19 11:18:

Good day!

 

I'm trying to use AngleAxis in my application, but encountering a problem.

var linearAxis3 = new AngleAxis();
linearAxis3.Position = AxisPosition.Right;
plotModel1.Axes.Add(linearAxis3);

When i'm starting my program, it writes "OxyPlot paint exception: Magnitude axis not defined". What am i doing wrong?

 

Thank you in advance!


objo wrote at 2012-09-19 11:33:

Angle/Magnitude axes are used for polar plots. See the polar plot example!

Will improve the error message!


PanCotzky wrote at 2012-09-19 12:13:

Thanks a lot! Unfortunately it is not what i wanted it to be. I need an ordinary linear axis, but labeled in degrees. Can LinearAxis be configured this way or should i use custom labels (if there are something like it)?


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

yes, you should use a LinearAxis. Set the StringFormat property if you want custom formatting of the labels.

0

Export to PDF that has Arabic character

ahmad awada 9 years ago 0
when I export the model that has Arabic character to PDF the character doesn't display correctly. I tried to use the streamWriter to change the encoding but it doesn't work because the export method takes only stream this is my code

using (Stream fileStream =File.Create(filePath)){
var exporter = new PdfExporter() { Width = 600, Height = 400};
exporter.Export(plotView.Model,fileStream);
fileStream.Close();
}
Note: I am using oxyplot in xamarin-android
thank you

How to not show numbers on a LinearAxis?

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

RickNZ wrote at 2012-08-29 03:32:

Is it possible to disable the numbers on a LinearAxis without also disabling the axis label?

If not, can the size of the numbers be changed independently of the size of the label?


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

Currently it is not possible to disable the numbers. (maybe you can find a workaround by setting MajorStep to a large number? or create a derived LinearAxis that only renders the axis title)

The same size (+font and color) is used for both the axis title and the tick labels. This is based on the 'plot style' recommendations in Tufte's and Few's books (see links on the home page). It is of course possible to make everything customizable, but I think that will be on the cost of simplicity.


RickNZ wrote at 2012-08-29 09:29:

Using a large MajorStep causes the high-end value of the axis not to be displayed, but the low-end is still there.

In addition to using this capability on a single axis, this might also be useful as a way to provide a second level of axis labels when you have multiple panes / axes sharing a single major axis (so there's not a separate scale/axis that would be applicable for PositionTiers).

 

Nice and Beautiful Library....

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

sanndeb wrote at 2011-11-22 21:12:

Ohow, thanks for such hard work. Just want to know that will it be very hard to implement zooming just by left mouse pressing & dragging as in WPF we can do that in datavisualization.charting & just a mouse hover over the lines to show the values, i.e i don't want to use keyboard at all.

Also an optional property for Plot can be like not only i want to see values over thr lines as tooltip when we move over them but at any point inside the chart will show the corrosponding value.

And lastly can i use this library in my company's application for commertial purpose. :) Thanks again.


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

right now the mouse gestures are hard coded (in the Plot.GetManipulator method), but I am planning to make this customizable. I'll add it to the issue tracker.

Yes, you can use the library in commercial applications, the license is Ms-PL.