Quantcast
Channel: OxyPlot (moved to GitHub)
Viewing all 2061 articles
Browse latest View live

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
Thanks for Oxyplot!
I had this bug (OxyPlot paint Exception : XAxis not defined ) in my code. If I scale the plot with mouse it goes away but I can always see it when something is newly plotted. I did add axes to my Model.

Here's the code
newPlot.DrawGraph(graphMain);// this calls DrawGraph function

public void DrawGraph(OxyPlot.WindowsForms.PlotView iptGraph)
        {
            var tmp=new OxyPlot.Series.LineSeries();
            tmp.StrokeThickness= 0.4;
            for (int i = 0; i < _resampledPoints.Count(); i++)
            {
                tmp.Points.Add(_resampledPoints[i]);
            }
            iptGraph.Model.Series.Add(tmp);
        }
Thanks a lot!

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
So just a few things, first of all you can use a foreach loop or even just AddRange over what you're currently doing (and it's less bug prone):
foreach (var p in _resampledPoints)
    tmp.Points.Add(p);
Alternatively:
tmp.Points.AddRange(_resampledPoints);
Both require _resampledPoints to be an IEnumerable<DataPoint> collection.

Second, please provide the code you use to assign the horizontal axis (or just all of them) to the PlotModel, can't really help when you're just adding points to a series =P.

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
Thank you for your suggestion! I'm pretty new to C# :)
These are the codes that I use to add axies to the PlotModel (graphMain).
        OxyPlot.Axes.LinearAxis XAxis = new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Bottom, MinimumPadding = 10, MaximumPadding = 15, AbsoluteMinimum = 0,Maximum=80};
        OxyPlot.Axes.LinearAxis YAxis = new OxyPlot.Axes.LinearAxis { Position = OxyPlot.Axes.AxisPosition.Left, MinimumPadding = 10, MaximumPadding = 15, AbsoluteMinimum = 0, Maximum=400};
            graphMain.Model.Axes.Add(YAxis);
            graphMain.Model.Axes.Add(XAxis);

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
Just out of curiosity, why are you setting a min and max for the axes? They will actually automatically resize based on the points in the series collection, so unless you want to see a certain range it's better to leave them to do the work instead. I'd suggest setting their min and max until after you add data to the series (same with the padding, it'll calculate that stuff itself). Also, it's probably best to use an axis Key, and a YAxisKey on the series. Just as a quick example:
using System.Linq;

using OxyPlot;
using OxyPlot.Axes;
using OxyPlot.Series;

// cut out namespace and class definitions to save indention levelsprivatevoid InitializeChart() 
{
    // didn't see it in your code, but you should initialize your own PlotModel and assign it to the// PlotView before using PlotView.Modelvar model = new PlotModel();

    model.Axes.Add(new LinearAxis
    {
        Key = "xAxis",
        Position = AxisPosition.Bottom,
        Title = "X Axis"
    });

    // just to show another way of using the new axisvar yAxis = new LinearAxis 
    {
        Key = "yAxis",
        Position = AxisPosition.Left,
        Title = "Y Axis"
    };

    // the series title will show up in the legendvar series = new LineSeries {Title = "Resampled Points", YAxisKey = "yAxis"};
    foreach (var p in _resampledPoints)
        series.Points.Add(p);

    // two examples of how to get the axes, highly suggest LINQ if you're in dotNet 3.0+
    model.Axes.OfType<LinearAxis>().First(a => a.Key == "xAxis").AbsoluteMinimum = 0;
    model.Axes.OfType<LinearAxis>().First(a => a.Key == "xAxis").Maximum = 80;

    yAxis.AbsoluteMinimum = 0;
    yAxis.Maximum = 400;

    // I'm guessing your graphMain is your PlotView
    graphMain.Model = model;
}
Note: this might have some errors, just put it together quickly in Sublime Text from memory.

Not really sure what you mean by defining it under the drawgraph function, you'll have to elaborate.

Also, welcome to C#! I've been in this space for around 5 months now, came from Python and Java myself, mainly for work. Quite enjoying the language (don't really like the framework restrictions though, being a linux guy), hope you like it here! I'm currently playing around with F# myself, really falling for functional programming lately.

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
Thanks for your response. I did initialized model. But my problem is, I am passing PlotView to another function to add a line series. Then the exception comes. If I add line series at where i define the Model, the bug disappears. I don't understand why.

Thanks!

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
Tip: put a space and "C#" after the triple back tick for code highlighting =). DrawGraph sounds a bit misleading, since you're just adding data to the graph, not actually effecting how it will draw itself. I'd consider moving the functionality of adding points to series into the class that handles the PlotView directly over passing the PlotView around like that (or at least pass the PlotModel instead, don't need the view).

For example in your chart class you can have an InitializeChart() method that sets up basic axes and series, (or for more dynamic control, InitializeChart(), AddSeries(various series info arguments), and AddAxis(various axes info arguments), and some kind of AddPoints(object tag, IEnumerable<DataPoints>) to add data to the series, using the tag to look up the correct one with linq (view.Model.Series.First(s => s.Tag == tag), or Single if you're only expecting one result).

I'm actually doing something similar to this in a simplified custom control I'm making for work, if you need a more comprehensive example I'd be happy to share.

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
Thanks for your suggestion! I finally fixed the bug. What I did is every time I plot the data set, I create a new model and add all the lines to the model. Then I assign it to PlotView. I'm guessing I should not add line separately? This will require extra work because each time a new line is added, I need to plot old ones together. But I guess it's just linear time so I'll leave it like that.
I'll try the Linq! It looks very handy.

Thanks again!

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
Hmm that's a good point, kind of annoyed I missed that lol, yea you're remaking and assigning the PlotModel everytime that function is called. It'd probably be better to add the series and points separately, that way you can separate adding a new line series and adding data to an already existing line series on the plot. Also, if you don't already know, you need to make the PlotView refresh manually, calling Model.InvalidatePlot(bool), boolean being true/false depending on if you want the axes to recalculate and resize themselves based on new data in the line series (this is actually called every time you pan or zoom automatically).

New Post: OxyPlot paint Exception : XAxis not defined

$
0
0
It's great to know the InvalidatePlot thing! I was required to add zoom functionality to zoom specific part according to user input.

New Post: Oxyplot XamarinAndroid "Zoom"-Question

$
0
0
Hi,
I wanted to know if it is possible to make a "Center-Button" for a PlotView with your library. I created an plotview in my application that is zoomable with touch gesture. And I need a method to reset the Zoom. But I couldn't find a property or method for this. Is this implemented or do i need to figure out a way to do is?

Btw: Thanks for this great library :D

Greetings

(If anything is unclear, just ask.)

New Post: Oxyplot XamarinAndroid "Zoom"-Question

$
0
0
You could hook up your own input to call PlotModel.ResetAllAxes(), the PlotController already defines 'a' and double mouse button 3 to do this if you want an example (it's in PlotCommands).

Commented Unassigned: DateTimeAxis should be able to break labels over two lines [10228]

$
0
0
It should be possible to show date on one line, time on other line
See https://oxyplot.codeplex.com/discussions/550763
Comments: 2 format strings would give additional flexibility

New Post: Using DateTimeIntervalType.Manual

$
0
0
I ended up doing this by overriding the GetTickValues method.

New Post: Oxyplot XamarinAndroid "Zoom"-Question

$
0
0
Ok so if i do something like this:
centerButton.Click += (object sender, EventArgs e) =>
            {
                centerButton_Click(sender, e, view, plotView);
            };
and handle it with this:
private void centerButton_Click(object sender, EventArgs e, View view, PlotView plotView)
        {
            plotView.Model.ResetAllAxes();
            plotView.Model.InvalidatePlot(true);
        }
then nothing happens. Is that what you suggested?

New Post: Oxyplot XamarinAndroid "Zoom"-Question

$
0
0
Hmm, well you can simplify it assuming it's in the same class as you're setting up the plot view:
centerButton.Click += (s, args) =>
{
    plotView.Model.ResetAllAxes();
    plotView.InvalidatePlot(false);
}
As a side note, the boolean on InvalidatePlot tells the axes whether or not to recalculate based on the data in series linked to them. Also, this just resets all axes zoom levels so that it displays everything in the plot, it'll do nothing if you're not zoomed in some form or haven't panned.

Other than that I'm not really sure. I haven't had a chance to play with Xamarin or Mono at all (and the only android dev I've done was in Java), so not sure if it might be an issue with that =. I'm sure Objo will be around at some point and will have some better input on it.

New Post: Oxyplot XamarinAndroid "Zoom"-Question

$
0
0
Ok with your version it works. The wrong part in my code was:
plotView.Model.InvalidatePlot(true);
Thank you for your help.

New Post: Moving the project to GitHub

New Post: Any interest in a gauge control?

New Post: Is there any example of 'OxyPlot for Xamarin.Android using' can reference???

$
0
0
Is there any example of 'OxyPlot for Xamarin.Android using' can be referenced???

Please send to my e-mail starrycheng@live.com,thanks. There is no example in the website which named 'http://oxyplot.org/'.

It shows:
Xamarin.Android Example
Under construction

Download component
Add references
Add a PlotView control
Bind to a PlotModel

Created Unassigned: Can't install packages“OxyPlot.Core 2014.1.319.1” [10232]

$
0
0
Install-Package : Can't install packages“OxyPlot.Core 2014.1.319.1”。You are trying to install this package to a "MonoAndroid, Version = v2.2" as the target project,But this package does not contain any compatible with the framework of the assembly references or content files. For more information, please contact the author package.
Location: 1 character: 16
所在位置 行:1 字符: 16
+ Install-Package <<<< OxyPlot.Core
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidOperationException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand

Viewing all 2061 articles
Browse latest View live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>