Skip to content

Commit 4505dfd

Browse files
boguscoderobjorke
authored andcommitted
Adding basic Xamarin.Android code example to docs (#15)
Update hello-xamarin-android.rst Adding very basic code examples
1 parent 6e11e9e commit 4505dfd

File tree

1 file changed

+51
-1
lines changed

1 file changed

+51
-1
lines changed

getting-started/hello-xamarin-android.rst

+51-1
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,63 @@ Add the ``OxyPlot.Xamarin.Android`` NuGet package to the project. References to
1313

1414
Add a PlotView control
1515
----------------------
16+
In your layout:
17+
18+
.. sourcecode:: xml
19+
20+
<OxyPlot.Xamarin.Android.PlotView
21+
android:id="@+id/plot_view"
22+
android:layout_width="match_parent"
23+
android:layout_height="match_parent"/>
24+
25+
then in your Activity/Fragment code:
26+
27+
.. sourcecode:: csharp
28+
29+
using OxyPlot.Xamarin.Android;
30+
/*...*/
31+
PlotView view = FindViewById<PlotView>(Resource.Id.plot_view);
1632

1733

1834
Bind to a PlotModel
1935
-------------------
2036

37+
.. sourcecode:: csharp
38+
39+
using OxyPlot;
40+
using OxyPlot.Axes;
41+
using OxyPlot.Series;
42+
/*...*/
43+
view.Model = CreatePlotModel();
44+
45+
private PlotModel CreatePlotModel()
46+
{
47+
var plotModel = new PlotModel { Title = "OxyPlot Demo" };
48+
49+
plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Bottom });
50+
plotModel.Axes.Add(new LinearAxis { Position = AxisPosition.Left, Maximum = 10, Minimum = 0 });
51+
52+
var series1 = new LineSeries
53+
{
54+
MarkerType = MarkerType.Circle,
55+
MarkerSize = 4,
56+
MarkerStroke = OxyColors.White
57+
};
58+
59+
series1.Points.Add(new DataPoint(0.0, 6.0));
60+
series1.Points.Add(new DataPoint(1.4, 2.1));
61+
series1.Points.Add(new DataPoint(2.0, 4.2));
62+
series1.Points.Add(new DataPoint(3.3, 2.3));
63+
series1.Points.Add(new DataPoint(4.7, 7.4));
64+
series1.Points.Add(new DataPoint(6.0, 6.2));
65+
series1.Points.Add(new DataPoint(8.9, 8.9));
66+
67+
plotModel.Series.Add(series1);
68+
69+
return plotModel;
70+
}
2171

2272
References
2373
----------
2474

25-
The source code can be found in the `HelloWorld\\AndroidApp1 <https://github.com/oxyplot/documentation-examples/tree/master/HelloWorld/AndroidApp1>`_ folder in the `documentation-examples <https://github.com/oxyplot/documentation-examples>`_ repository.
75+
The source code can be found in the `HelloWorld\\AndroidApp1 <https://github.com/oxyplot/documentation-examples/tree/master/HelloWorld/AndroidApp1>`_ folder in the `documentation-examples <https://github.com/oxyplot/documentation-examples>`_ repository.

0 commit comments

Comments
 (0)