Repository navigation
Expand file tree
/
Copy pathLine2D.cs
More file actions
147 lines (125 loc) · 4.09 KB
/
Copy pathLine2D.cs
File metadata and controls
147 lines (125 loc) · 4.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
namespace MatplotlibCS.PlotItems
{
/// <summary>
/// Описание линии графика
/// </summary>
[JsonObject(Title = "line")]
public class Line2D : PlotItem
{
#region Fields
/// <summary>
/// Internal X values string representation
/// </summary>
private List<object> _x = new List<object>();
#endregion
#region ctor
/// <summary>
/// Конструктор
/// </summary>
/// <param name="name">Название линии</param>
///
public Line2D(string name) : base(name)
{
X = new List<object>();
Y = new List<double>();
}
#endregion
#region Properties
/// <summary>
/// Line color
/// </summary>
[JsonProperty(PropertyName = "color")]
public Color Color { get; set; } = Color.Black;
/// <summary>
/// Color of markers edge
/// </summary>
[JsonProperty(PropertyName = "markeredgecolor")]
public Color MarkerEdgeColor { get; set; } = Color.Black;
/// <summary>
/// Marker's background
/// </summary>
[JsonProperty(PropertyName = "markerfacecolor")]
public Color MarkerFaceColor { get; set; }
/// <summary>
/// Color transparency
/// </summary>
[JsonProperty(PropertyName = "alpha")]
public double Alpha { get; set; } = 1;
/// <summary>
/// Маркер точки
/// </summary>
[JsonProperty(PropertyName = "marker")]
[JsonConverter(typeof(StringEnumConverter))]
public Marker Marker { get; set; } = Marker.None;
/// <summary>
/// Размер маркера
/// </summary>
[JsonProperty(PropertyName = "markerSize")]
public float MarkerSize { get; set; } = 1;
/// <summary>
/// Width of line
/// </summary>
[JsonProperty(PropertyName = "lineWidth")]
public float LineWidth { get; set; } = 1;
/// <summary>
/// Width of markers edge
/// </summary>
[JsonProperty(PropertyName = "markeredgewidth")]
public float MarkerEdgeWidth { get; set; } = 1;
/// <summary>
/// Маркер точки
/// </summary>
[JsonProperty(PropertyName = "lineStyle")]
[JsonConverter(typeof(StringEnumConverter))]
public LineStyle LineStyle { get; set; } = LineStyle.Solid;
/// <summary>
/// e.g., if Markevery=5, every 5-th marker will be plotted.
/// </summary>
[JsonProperty(PropertyName = "markevery")]
public int Markevery { get; set; } = 1;
/// <summary>
/// Данные для графика, аргумент
/// </summary>
[JsonProperty(PropertyName = "x")]
public List<object> X
{
get
{
return _x.ToList();
}
set
{
if (value == null || value.Count == 0)
{
_x.Clear();
return;
}
var firstItem = value[0];
if (firstItem is DateTime)
{
_x.Clear();
foreach (var item in value)
_x.Add(((DateTime) item).ToString("yyyy-MM-ddTHH:mm:ss,ffffff"));
}
else if (firstItem is double || firstItem is int || firstItem is long || firstItem is float)
{
_x.Clear();
foreach (var item in value)
_x.Add(item);
}
}
}
/// <summary>
/// Данные для графика, значение
/// </summary>
[JsonProperty(PropertyName = "y")]
public List<double> Y { get; set; }
#endregion
}
}