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
Under review

Access data points.

Paul Mankowski fa 10 anys updated by anonymous fa 10 anys 5
Hello,
All I am trying to do is to export my data points. I have 4 "detectors". Please help. This is not an example of my attempts to do so but shows how I am adding data. I would like to export to csv in the long run but I can handle that. I just need the raw data points.

public void UpdateModel()
{
List<Measurement> measurements = Data.GetUpdateData(lastUpdate);
var dataPerDetector = measurements.GroupBy(m => m.DetectorId).OrderBy(m => m.Key).ToList();

foreach (var data in dataPerDetector)
{
      var lineSerie = PlotModel.Series[data.Key] as LineSeries;
      if (lineSerie != null)
      {
      data.ToList()
             .ForEach(d => lineSerie.Points.Add(new DataPoint(DateTimeAxis.ToDouble(d.DateTime), d.Value)));
       }
var x = lineSerie.Points.ToString();
}

lastUpdate = DateTime.Now;
}

iOS - Live Updating of Graphs

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

benhysell wrote at 2014-03-02 19:32:

When I have a new entry to update on my graphs, after initial draw, I'm not sure I'm using the most efficient method. Thoughts?
await graph.UpdateDataSources ();
((PlotView)View).Model.Update ();
View.SetNeedsDisplay ();
First graph the latest data from the database and set the ItemSource to the new data. Call Model.Update() to update the graph, and then invalidate the view.

It doesn't 'feel correct', wanted to know if anyone else had any thoughts on a better way to do it.

objo wrote at 2014-03-02 21:43:

The PlotView.InvalidatePlot method should do this.
I also recommend testing the version on the fork
https://hg.codeplex.com/forks/objo/issue9625
where touch events are being implemented. I hope to be able to merge fork with default soon.

benhysell wrote at 2014-03-06 01:06:

((PlotView)View).Model.InvalidatePlot (true);
View.SetNeedsDisplay ();
I still needed to call View.SetNeedsDisplay (); for my view to update. I stayed in default, for my testing.
0

CategoryAxis for CandleStickAndVolumeSeries

Samuel Guedon fa 9 anys actualitzat fa 9 anys 1
Hi all,

I am making a candlestick chart to plot financial data and realised the datetime axis isn't the perfect fit for this as it will show gaps when the market are closed, while a proper graph should just join the data.

So I tried to do the trick using a category axis. It will be a bit harder as I will have to manage through code the format of the axis (going from a hh:mm to a dd MMM yyyy while dezooming) but this should be manageable.

My only problem now is that nothing is shown by the plotmodel. I guess this comes from the fact that the CandleStickAndVolumSeries refers X as double, while my axes is labelled. So how can I "explain" to the plot model that when he has 38016.69 for X it should make it appear on the 30 jan. 2004 label of my axis? Note that the CandleStickAndVolumSeries and the axis data follow the same order (indexes or equivalent).

I checked in the example but I couldn't find anything relevant.

Any help will be greatly appreciated
0

Tracker Disappearing Behind Other Panels

Alex Young fa 9 anys 0
Is there a way to make the tracker display box stay inside the graph window at all times? The tracker keeps going behind other panels and edges making it impossible to read the information on the side. Is there a setting to keep it inside the graph? If so, how can I change it?


Image 17

Adding multiple instances of a LineSeries to OxyPlot

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

amodedude1 wrote at 2014-07-24 15:14:

Hello,

I am trying to add multiple LineSeries to my OxyPlot graph. I am using WPF so I decided to switch to OxyPlot. I am not used to the way OxyPlot works as I am used to using Winforms chart controls so please bare with me. I have read the example project code for plotting multiple series on a PlotModel, but this does not seem to be helping me.

My approach so far:

I am taking a c# List array and adding a new copy of the LineSeries that holds new data to be plotted. My code:
        // Function to plot data
        private void plotData(double numWeeks, double startingSS)
        {

            // Initialize new Salt Split class for acess to data variables
            Salt_Split_Builder calcSS = new Salt_Split_Builder();
            calcSS.compute(numWeeks, startingSS, maxDegSS);

            // Create the OxyPlot graph for Salt Split
            OxyPlot.Wpf.PlotView plot = new OxyPlot.Wpf.PlotView();
            
            var model = new PlotModel();

            // Add Chart Title
            model.Title = "Salt Split Degradation";

            // Create new Line Series
            LineSeries linePoints = new LineSeries() { StrokeThickness = 1, MarkerSize = 1, Title = numWeeks.ToString() + " weeks" };


            // Add each point to the new series
            foreach (var point in calcSS.saltSplitCurve)
            {
                DataPoint XYpoint = new DataPoint();
                XYpoint = new DataPoint(point.Key, point.Value * 100);
                linePoints.Format("%", XYpoint.Y);
                linePoints.Points.Add(XYpoint);
            }

            listPointAray.Add(linePoints);


            // Define X-Axis
            var Xaxis = new OxyPlot.Axes.LinearAxis();
            Xaxis.Maximum = numWeeks;
            Xaxis.Minimum = 0;
            Xaxis.Position = OxyPlot.Axes.AxisPosition.Bottom;
            Xaxis.Title = "Number of Weeks";
            model.Axes.Add(Xaxis);

            //Define Y-Axis
            var Yaxis = new OxyPlot.Axes.LinearAxis();
            Yaxis.MajorStep = 15;
            Yaxis.Maximum = calcSS.saltSplitCurve.Last().Value * 100;
            Yaxis.MaximumPadding = 0;
            Yaxis.Minimum = 0;
            Yaxis.MinimumPadding = 0;
            Yaxis.MinorStep = 5;
            Yaxis.Title = "Percent Degradation";
            model.Axes.Add(Yaxis);

            // Add Each series to the
            foreach (var series in listPointAray)
            {
                LineSeries newpoints = new LineSeries();
                newpoints = linePoints;
                model.Series.Add(newpoints);
            }


            // Add the plot to the window
            plot.Model = model;
            SaltSplitChartGrid.Children.Add(plot);
            
        }
My code works the first time I press my "Graph Data" button, but fails on consecutive attempts with the following error:
The element cannot be added, it already belongs to a Plot Model
The following plot is the type of plot I would like to produce (it worked fine using WinForms Chart control):

Image


I would like a new line with a new color to be plotted each time I run the method.

amodedude1 wrote at 2014-07-24 17:04:

Anyone with an idea?

...bump

everytimer wrote at 2014-07-24 18:17:

In my opinion you are doing it wrong, try to follow any example where the model is linked using "Binding". That way you only need to create a LineSeries and then to add it to the Series collection of the PlotModel.
Note that you will need to update the plot using MyModel.RefreshPlot(true); after that.

Good luck!

amodedude1 wrote at 2014-07-24 19:44:

Thanks, I'll try to create a DataBinding so I don't have to do all the work from code-Behind. Maybe things will work better, but won't I still have the issue of adding multiple LineSeries to the same PlotModel?

amodedude1 wrote at 2014-07-24 21:47:

For the record, I answered my own question. The answer can be found here:
"http://stackoverflow.com/questions/24938689/how-to-plot-multiple-lineseries-on-an-oxyplot-chart/24942582#24942582"

Build server issue?

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

tibel wrote at 2014-03-11 09:47:

Is there an issue with the build server?
Latest version on nuget is 2014.1.240.1 from March 01 2014.

objo wrote at 2014-03-11 10:09:

Yes, there is currently a broken internet connection to the build server. Hopefully it will be fixed in a couple of days!

Can attributes be added to the bar items SVG polygon for a bar series chart

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

taramclean wrote at 2014-07-10 11:54:

I'm trying to find a way to add my own attributes to the polygon's that are rendered for a bar series chart,

Is this possible in any way? I've looked at extending the bar series and overriding the render method but have run into a few obstacles.

Any pointers to how to achieve this would be great.

objo wrote at 2014-07-10 12:12:

I think this is limited by IRenderContext.
Can you use the tooltip feature to define the values that should be written to the svg?
What attributes can be added to the SVG polygon? Is "title" supported?

OxyPlot DataPoint and Drawing Point extension methods

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

Slxe wrote at 2014-06-18 20:05:

I've had a reason come up to store values as PointF and convert them to DataPoints so that the user doesn't have to have the OxyPlot namespace when interacting with a simple control built around it. So for the hell of it I wrote some extension methods that I figured I'd share in case anyone else found them helpful:

https://gist.github.com/Slxe/a0c1e2cfbde4b95df650

(Let me know if you see any errors, learning advanced C# stuff as I go atm, so any feedback at all is helpful =D)

Date label (horizontal axis) in Financial Series [Solved]

Oystein Bjorke fa 10 anys 0
This discussion was imported from CodePlex

maxambrogi wrote at 2013-04-14 23:26:

Hi, could you kindly share an example where understand how set a date label in the horizontal axis when using financial series?
Thanks in advance.
Best Regards
MaxAmbrogi

maxambrogi wrote at 2013-04-28 01:02:

        PlotModel model = new PlotModel("HighLowSeries") { LegendSymbolLength = 24 };

        DateTimeAxis dateAxis = new DateTimeAxis(AxisPosition.Bottom, "Date", "MM/dd") { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot };
        model.Axes.Add(dateAxis);
        LinearAxis valueAxis = new LinearAxis(AxisPosition.Left, 0) { MajorGridlineStyle = LineStyle.Solid, MinorGridlineStyle = LineStyle.Dot, Title = "Price" };
        model.Axes.Add(valueAxis);

        DateTime dt = DateTime.Now;

        var s1 = new HighLowSeries("random values")
        {
            Color = OxyColors.Black,
        };
        var r = new Random();
        var price = 100.0;
        for (int x = 0; x < 24; x++)
        {
            price = price + r.NextDouble() + 0.1;
            var high = price + 10 + r.NextDouble() * 10;
            var low = price - (10 + r.NextDouble() * 10);
            var open = low + r.NextDouble() * (high - low);
            var close = low + r.NextDouble() * (high - low);
            s1.Items.Add(new HighLowItem(DateTimeAxis.ToDouble(dt.AddDays(x)), high, low, open, close));
        }
        model.Series.Add(s1);

Multiple axes

Oystein Bjorke fa 10 anys updated by Henrik Erevik Riise fa 8 anys 1
This discussion was imported from CodePlex

Ivan_kol wrote at 2013-07-13 15:02:

I want to display two graphs, the X-axis have a common Y-axis are different.
They need to be displayed in different areas, ie to a schedule does not run into the other.
When I refinable or scroll one graph, the other is to repeat these changes.

I tried to do it in two different charts, Chart try through one but with two axes Y, does not come out.
What to do?

Ivan_kol wrote at 2013-07-14 08:27:

So, I was able to bring several mutually dependent areas.
<oxy:Plot Grid.Row="1" Model="{Binding ModelPower}" >
            <oxy:Plot.Axes>
                <oxy:LinearAxis Position="Left" Title="Power" StartPosition="0.5" EndPosition="1" Key="Power"/>
                <oxy:LinearAxis Position="Left" Title="Price" StartPosition="0" EndPosition="0.5" Key="Price"/>
                <oxy:DateTimeAxis Position="Bottom" EndPosition="1" StartPosition="0" StringFormat="hh:mm:ss.fff" IntervalType="Seconds"/>
            </oxy:Plot.Axes>
            <oxy:Plot.Series>
                <oxy:LineSeries ItemsSource="{Binding DataCollection}" MarkerType="Circle" Color="Blue" YAxisKey="Power" DataFieldX="DateTime" DataFieldY="APower"/>
                <oxy:LineSeries ItemsSource="{Binding DataCollection}" MarkerType="Circle" Color="Green" YAxisKey="Power" DataFieldX="DateTime" DataFieldY="BPower"/>

                <oxy:LineSeries ItemsSource="{Binding DataCollection}" MarkerType="Circle" Color="Blue" YAxisKey="Price" DataFieldX="DateTime" DataFieldY="BestA"/>
                <oxy:LineSeries ItemsSource="{Binding DataCollection}" MarkerType="Circle" Color="Green" YAxisKey="Price" DataFieldX="DateTime" DataFieldY="BestB"/>
            </oxy:Plot.Series>
        </oxy:Plot>

_Noctis_ wrote at 2013-11-05 14:32:

Did you have any success with this?

Ivan_kol wrote at 2013-11-06 01:21:

The above code is written as I did.

ivl64 wrote at 2013-12-10 08:37:

Thank You, Ivan_kol

Please, add this sample to example library.