Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
HorizontalBars.cs
6
8{
16 {
17 private static readonly ArgumentType[] argumentTypes3Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector, ArgumentType.Scalar };
18 private static readonly ArgumentType[] argumentTypes2Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector };
19
29 : base(new ScriptNode[] { Labels, Values }, argumentTypes2Parameters, Start, Length, Expression)
30 {
31 }
32
43 : base(new ScriptNode[] { Labels, Values, Color }, argumentTypes3Parameters, Start, Length, Expression)
44 {
45 }
46
50 public override string FunctionName => nameof(HorizontalBars);
51
55 public override string[] DefaultArgumentNames
56 {
57 get { return new string[] { "labels", "values", "color" }; }
58 }
59
67 {
68 if (!(Arguments[0] is IVector Labels))
69 throw new ScriptRuntimeException("Expected vector for Labels argument.", this);
70
71 if (!(Arguments[1] is IVector Values))
72 throw new ScriptRuntimeException("Expected vector for Values argument.", this);
73
74 int Dimension = Labels.Dimension;
75 if (Values.Dimension != Dimension)
77
78 IElement Color = Arguments.Length <= 2 ? null : Arguments[2];
79
80 ChunkedList<IElement> ReverseLabelOrder = new ChunkedList<IElement>();
81 ChunkedList<IElement> ReverseValueOrder = new ChunkedList<IElement>();
82
83 foreach (IElement Label in Labels.VectorElements)
84 ReverseLabelOrder.AddFirstItem(Label);
85
86 foreach (IElement Value in Values.VectorElements)
87 ReverseValueOrder.AddFirstItem(Value);
88
89 return new Graph2D(Variables, (IVector)Values.Encapsulate(ReverseValueOrder, this), (IVector)Labels.Encapsulate(ReverseLabelOrder,
90 this), new HorizontalBarPainter(), true, false, this, Color?.AssociatedObjectValue ?? Graph.DefaultColor);
91 }
92 }
93}
A chunked list is a linked list of chunks of objects of type T .
Definition: ChunkedList.cs:54
Class managing a script expression.
Definition: Expression.cs:41
Plots a two-dimensional horizontal-bar chart.
Plots a two-dimensional horizontal-bar chart.
override string FunctionName
Name of the function
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
HorizontalBars(ScriptNode Labels, ScriptNode Values, ScriptNode Color, int Start, int Length, Expression Expression)
Plots a two-dimensional horizontal-bar chart.
HorizontalBars(ScriptNode Labels, ScriptNode Values, int Start, int Length, Expression Expression)
Plots a two-dimensional horizontal-bar chart.
override string[] DefaultArgumentNames
Default Argument names
Handles two-dimensional graphs.
Definition: Graph2D.cs:27
Base class for graphs.
Definition: Graph.cs:88
static readonly SKColor DefaultColor
Default color: Red
Definition: Graph.cs:127
Base class for multivariate funcions.
ScriptNode[] Arguments
Function arguments.
Base class for all nodes in a parsed script tree.
Definition: ScriptNode.cs:69
int Length
Length of expression covered by node.
Definition: ScriptNode.cs:101
Expression Expression
Expression of which the node is a part.
Definition: ScriptNode.cs:177
int Start
Start position in script expression.
Definition: ScriptNode.cs:92
Collection of variables.
Definition: Variables.cs:25
Basic interface for all types of elements.
Definition: IElement.cs:21
Basic interface for vectors.
Definition: IVector.cs:9
ArgumentType
Type of parameter used in a function definition or a lambda definition.
Definition: IFunction.cs:9