Neuron®
The Neuron® is the basis for the creation of open and secure federated networks for smart societies.
Loading...
Searching...
No Matches
VerticalBars.cs
1using System.Collections.Generic;
5
7{
15 {
16 private static readonly ArgumentType[] argumentTypes3Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector, ArgumentType.Scalar };
17 private static readonly ArgumentType[] argumentTypes2Parameters = new ArgumentType[] { ArgumentType.Vector, ArgumentType.Vector };
18
28 : base(new ScriptNode[] { Labels, Values }, argumentTypes2Parameters, Start, Length, Expression)
29 {
30 }
31
42 : base(new ScriptNode[] { Labels, Values, Color }, argumentTypes3Parameters, Start, Length, Expression)
43 {
44 }
45
49 public override string FunctionName => nameof(VerticalBars);
50
54 public override string[] DefaultArgumentNames
55 {
56 get { return new string[] { "labels", "values", "color" }; }
57 }
58
66 {
67 if (!(Arguments[0] is IVector Labels))
68 throw new ScriptRuntimeException("Expected vector for Labels argument.", this);
69
70 if (!(Arguments[1] is IVector Values))
71 throw new ScriptRuntimeException("Expected vector for Values argument.", this);
72
73 int Dimension = Labels.Dimension;
74 if (Values.Dimension != Dimension)
75 throw new ScriptRuntimeException("Vector size mismatch.", this);
76
77 IElement Color = Arguments.Length <= 2 ? null : Arguments[2];
78
79 return new Graph2D(Variables, Labels, Values, new VerticalBarsPainter(), false, true, this,
80 Color?.AssociatedObjectValue ?? Graph.DefaultColor);
81 }
82 }
83}
Class managing a script expression.
Definition: Expression.cs:39
Plots a two-dimensional vertical-bar chart.
Definition: VerticalBars.cs:15
VerticalBars(ScriptNode Labels, ScriptNode Values, ScriptNode Color, int Start, int Length, Expression Expression)
Plots a two-dimensional vertical-bar chart.
Definition: VerticalBars.cs:41
VerticalBars(ScriptNode Labels, ScriptNode Values, int Start, int Length, Expression Expression)
Plots a two-dimensional vertical-bar chart.
Definition: VerticalBars.cs:27
override string[] DefaultArgumentNames
Default Argument names
Definition: VerticalBars.cs:55
override string FunctionName
Name of the function
Definition: VerticalBars.cs:49
override IElement Evaluate(IElement[] Arguments, Variables Variables)
Evaluates the function.
Definition: VerticalBars.cs:65
Plots a two-dimensional vertical-bar chart.
Handles two-dimensional graphs.
Definition: Graph2D.cs:26
Base class for graphs.
Definition: Graph.cs:79
static readonly SKColor DefaultColor
Default color: Red
Definition: Graph.cs:118
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:20
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