Skip to content

Commit f6ac89a

Browse files
authored
Merge pull request oxyplot#38 from VisualMelon/AreaLineScatterDocs
Improve documentation for Line, Area, and Scatter series
2 parents 073f4d1 + b4c6a77 commit f6ac89a

File tree

5 files changed

+189
-9
lines changed

5 files changed

+189
-9
lines changed

models/series/AreaSeries.png

348 Bytes
Loading

models/series/AreaSeries.rst

+87-5
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,55 @@ AreaSeries
44

55
.. note:: This section is under construction. Please contribute!
66

7-
A ``AreaSeries`` shows an area between two sets of points, or between a
8-
set of point and a baseline.
7+
An ``AreaSeries`` shows an area between two lines defined by two sets
8+
of points, or a set of points and a baseline.
99

1010
.. image:: AreaSeries.png
1111

12+
Axes
13+
----
14+
15+
An ``AreaSeries`` requires a horizontal and a vertical axis.
16+
17+
By default, the ``AreaSeries`` will use the default horizontal and
18+
vertical axes in the parent ``PlotModel``. If there are more than one
19+
horizontal/vertical axis, the axes can be specified by the ``XAxisKey``
20+
and ``YAxisKey`` properties. This requires the ``Key`` property to be
21+
set on the desired axes.
22+
23+
Data
24+
----
25+
26+
Use the ``Points`` and ``Points2`` collections to add data points to
27+
the first and second lines of the ``AreaSeries`` respectively:
28+
29+
.. code:: csharp
30+
31+
areaSeries1.Points.Add(new DataPoint(0, 5));
32+
areaSeries1.Points.Add(new DataPoint(10, 8));
33+
34+
areaSeries1.Points2.Add(new DataPoint(0, 2));
35+
areaSeries1.Points2.Add(new DataPoint(10, 1));
36+
37+
Alternatively, you can specify a collection in the ``ItemsSource`` properties.
38+
39+
- If the ``Mapping`` property is set, each element in the collection
40+
will be transformed
41+
- If the collection is a list of ``DataPoint``, or a type that implements
42+
``IDataPointProvider``, it will be used with no mapping
43+
- If the ``DataFieldX`` and ``DataFieldY`` properties are set, each
44+
element of the collection will be reflected to create a data point
45+
for the first line
46+
- If the ``DataFieldX2`` and ``DataFieldY2`` properties are set, each
47+
element of the collection will be reflected to create a data point
48+
for the second line
49+
50+
The ``Points2`` property will not be ignored if the ``ItemSource`` property
51+
is non-null.
52+
53+
If no data points are provided for the second line, the baseline value
54+
``ConstantY2`` along with ``X`` values of the first and last data points
55+
in the first line will be used instead.
1256

1357
Tracker
1458
-------
@@ -39,16 +83,54 @@ See `MSDN`_ for more information about format strings.
3983
The ``TrackerKey`` property may be used to specify a `custom tracker`_.
4084
This makes it possible to use different trackers for each series.
4185

86+
Color and Style
87+
---------------
88+
89+
The ``Color`` and ``Color2`` properties determine the colors of the first and second
90+
line respective. The default value of ``Color2`` is ``Automatic``, which causes the
91+
second line to have the same color as the first. The default value of ``Color`` is
92+
``Automatic``. In this case the color will be set automatically from the colors
93+
specified in the ``DefaultColors`` property of the parent ``PlotModel``.
94+
95+
The ``LineStyle`` defines the line style. The default is ``Solid``. The
96+
``StrokeThickness`` defines the thickness of lines.
97+
98+
Markers can be included by specifying the ``MarkerType`` and ``MarkerStroke``. The
99+
default ``MarkerType`` is ``None``. If the ``Custom`` marker type is used, then a
100+
list of relative screen points in screen-space must be provided in the
101+
``MarkerOutline`` property.
102+
103+
The ``MarkerStroke`` defines the stroke color of the markers. The ``MarkerFill``
104+
defines the fill color of the markers. The ``MarkerStrokeThickness`` defines the
105+
thickness of the lines in the marker. The ``MarkerSize`` defines the size of the
106+
markers.
107+
108+
The ``Fill`` defines the color of the fill color of the areas. The default value is
109+
``Automatic``. In this case the color will be set automatically based on the color
110+
of the first line.
111+
42112
Example
43113
-------
44114

45115
.. sourcecode:: csharp
46116

47117
var model = new PlotModel { Title = "AreaSeries" };
48-
var areaSeries = new AreaSeries());
49-
...
118+
model.Axes.Add(new LinearAxis() { Title = "Day", Position = AxisPosition.Bottom });
119+
model.Axes.Add(new LinearAxis() { Title = "Output", Position = AxisPosition.Left });
120+
121+
var areaSeries = new AreaSeries() { Color2 = OxyColors.Transparent };
122+
123+
var r = new Random(1);
124+
var dailyOutput = 10;
125+
for (int i = 0; i <= 100; i++)
126+
{
127+
areaSeries.Points.Add(new DataPoint(i, dailyOutput));
128+
129+
dailyOutput = Math.Max(0, dailyOutput + r.Next(-2, 3));
130+
}
131+
50132
model.Series.Add(areaSeries);
51133

52134
.. _tracker: ../tracker
53135
.. _MSDN: http://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx
54-
.. _custom tracker: ../tracker
136+
.. _custom tracker: ../tracker

models/series/LineSeries.rst

+38-4
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ property.
3535

3636
- If the ``Mapping`` property is set, each element in the collection
3737
will be transformed
38-
- If the collection is a list of ``DataPoint``, or a type that implements ``IDataPointProvider``, it will be used with no
39-
mapping
38+
- If the collection is a list of ``DataPoint``, or a type that implements
39+
``IDataPointProvider``, it will be used with no mapping
4040
- If the ``DataFieldX`` and ``DataFieldY`` properties are set, each
4141
element of the collection will be reflected to create a data point
4242

@@ -72,9 +72,43 @@ default value is ``true``.
7272
The ``TrackerKey`` property may be used to specify a `custom tracker <../tracker>`_.
7373
This makes it possible to use different trackers for each series.
7474

75-
Color
76-
-----
75+
Color and Style
76+
---------------
7777

7878
The ``Color`` defines the color of the line. The default value is
7979
``Automatic``. In this case the color will be set automatically from the
8080
colors specified in the ``DefaultColors`` property of the parent ``PlotModel``.
81+
82+
The ``LineStyle`` defines the line style. The default is ``Solid``. The
83+
``StrokeThickness`` defines the thickness of lines.
84+
85+
The ``BrokenLineColor``, ``BrokenLineStyle``, and ``BrokenLineThickness`` properties
86+
define the color, style, and thickness of broken segments in the line, signalled by
87+
data points with an ``X`` or ``Y`` value of ``NaN``.
88+
89+
Markers can be included by specifying the ``MarkerType`` and ``MarkerStroke``. The
90+
default ``MarkerType`` is ``None``. If the ``Custom`` marker type is used, then a
91+
list of relative screen points in screen-space must be provided in the
92+
``MarkerOutline`` property.
93+
94+
The ``MarkerStroke`` defines the stroke color of the markers. The ``MarkerFill``
95+
defines the fill color of the markers. The ``MarkerStrokeThickness`` defines the
96+
thickness of the lines in the marker. The ``MarkerSize`` defines the size of the
97+
markers.
98+
99+
Example
100+
-------
101+
102+
.. sourcecode:: csharp
103+
104+
var model = new PlotModel { Title = "LineSeries" };
105+
var lineSeries = new LineSeries();
106+
lineSeries.Points.Add(new DataPoint(0, 0));
107+
lineSeries.Points.Add(new DataPoint(10, 4));
108+
lineSeries.Points.Add(new DataPoint(30, 2));
109+
lineSeries.Points.Add(new DataPoint(40, 12));
110+
model.Series.Add(lineSeries);
111+
112+
.. _tracker: ../tracker
113+
.. _MSDN: http://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx
114+
.. _custom tracker: ../tracker

models/series/ScatterSeries.png

10.7 KB
Loading

models/series/ScatterSeries.rst

+64
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,44 @@ A ``ScatterSeries`` shows a set of points. The points can also have a size and c
1111
Axes
1212
----
1313

14+
A ``ScatterSeries`` requires a horizontal and a vertical axis.
15+
16+
By default, the ``ScatterSeries`` will use the default horizontal and
17+
vertical axes in the parent ``PlotModel``. If there are more than one
18+
horizontal/vertical axis, the axes can be specified by the ``XAxisKey``
19+
and ``YAxisKey`` properties. This requires the ``Key`` property to be
20+
set on the desired axes.
21+
1422
Data
1523
----
1624

25+
Use the ``Points`` collection to add data to the ``ScatterSeries``:
26+
27+
.. code:: csharp
28+
29+
scatterSeries1.Points.Add(new ScatterPoint(10, 20));
30+
scatterSeries1.Points.Add(new ScatterPoint(30, 80, size: 8, value: 8, tag: "B"));
31+
32+
Each ``ScatterPoint`` has 5 properties:
33+
34+
- ``X``: the X coordinate
35+
- ``X``: the X coordinate
36+
- ``Size``: the rendered size of the point, with default ``NaN``
37+
- ``Value``: the logical value of the point, with default ``NaN``
38+
- ``Tag``: an arbitrary tag, with default ``null``
39+
40+
Alternatively, you can specify a collection in the ``ItemsSource``
41+
property.
42+
43+
- If the ``Mapping`` property is set, each element in the collection
44+
will be transformed
45+
- If the collection is a list of ``DataPoint``, or a type that implements
46+
``IScatterPointProvider``, it will be used with no mapping
47+
- If the ``DataFieldX`` and ``DataFieldY`` properties are set, each
48+
element of the collection will be reflected to create a scatter point
49+
from these two fields, as well as the ``DataFieldSize``,
50+
``DataFieldValue``, and ``DataFieldTag`` fields
51+
1752
Tracker
1853
-------
1954

@@ -30,9 +65,34 @@ The format string may use the following arguments:
3065

3166
To show the x and y values with one digit, use the format string ``"{2:0.0},{4:0.0}"``.
3267

68+
If an item was hit, it is also possible to use the extended format
69+
string syntax, e.g. ``{PropertyX:0.##}``, where the value of
70+
``PropertyX`` will be found by reflection of the item.
71+
3372
The default format string for ``ScatterSeries`` is ``"{0}\n{1}: {2:0.###}\n{3}: {4:0.###}"``
3473

74+
See `MSDN`_ for more information about format strings.
75+
76+
The ``TrackerKey`` property may be used to specify a `custom tracker`_.
77+
This makes it possible to use different trackers for each series.
78+
79+
Color and Style
80+
---------------
3581

82+
The ``MarkerType`` defines the type of markers to plot. The default is ``Square``.
83+
If the ``Custom`` marker type is used, then a list of relative screen points in
84+
screen-space must be provided in the ``MarkerOutline`` property.
85+
86+
The ``MarkerStroke`` defines the stroke color of the markers. The ``MarkerFill``
87+
defines the fill color of the markers. The ``MarkerStrokeThickness`` defines the
88+
thickness of the lines in the marker.
89+
90+
The ``Size`` property of each point determines the size of the plotted marker.
91+
If a point has the default size of ``NaN``, then its size will be determined by
92+
the ``MarkerSize`` property.
93+
94+
If a ``ColorAxis`` is defined, the color of each point will be determined by its
95+
value. Points with a ``Value`` of ``NaN`` will not be plotted.
3696

3797
Example
3898
-------
@@ -53,3 +113,7 @@ Example
53113

54114
model.Series.Add(scatterSeries);
55115
model.Axes.Add(new LinearColorAxis { Position = AxisPosition.Right, Palette = OxyPalettes.Jet(200) });
116+
117+
.. _tracker: ../tracker
118+
.. _MSDN: http://msdn.microsoft.com/en-us/library/system.string.format(v=vs.110).aspx
119+
.. _custom tracker: ../tracker

0 commit comments

Comments
 (0)