Difference between revisions of "Axis class"
Nguyenduyan (talk | contribs) |
|||
(13 intermediate revisions by 2 users not shown) | |||
Line 2: | Line 2: | ||
|Name=<nowiki>Axis</nowiki> | |Name=<nowiki>Axis</nowiki> | ||
|Description=<nowiki>Represents an axis in a data cache specification.</nowiki> | |Description=<nowiki>Represents an axis in a data cache specification.</nowiki> | ||
− | |Constructors= | + | |InheritsFrom=Array|Constructors= |
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=QcsColumn|Name=<nowiki>column</nowiki>|Description=<nowiki>Column</nowiki>}} | ||
+ | |Description=<nowiki>Create new axis based on the defaults for the dcs column</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Axis|Name=<nowiki>axis</nowiki>|Description=<nowiki>Existing axis to duplicate</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>New name</nowiki>}} | ||
+ | |Description=<nowiki>Create new axis based on existing axis in the same axisset</nowiki>}} | ||
{{CGscriptConstructors_Template|Parameters= | {{CGscriptConstructors_Template|Parameters= | ||
{{CGscriptParameters_Template|Type=DataCacheSpecification|Name=<nowiki>dataCache</nowiki>|Description=<nowiki>Validate against this data cache</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Initial name</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>text</nowiki>|Description=<nowiki>Initial text</nowiki>}} | {{CGscriptParameters_Template|Type=DataCacheSpecification|Name=<nowiki>dataCache</nowiki>|Description=<nowiki>Validate against this data cache</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>Initial name</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>text</nowiki>|Description=<nowiki>Initial text</nowiki>}} | ||
|Description=<nowiki>Create new axis</nowiki>}} | |Description=<nowiki>Create new axis</nowiki>}} | ||
+ | {{CGscriptConstructors_Template|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Axis|Name=<nowiki>axis</nowiki>|Description=<nowiki>Existing axis to duplicate</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=string|Name=<nowiki>name</nowiki>|Description=<nowiki>New name</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=DataCacheSpecification|Name=<nowiki>dataCache</nowiki>|Description=<nowiki>Validate against this data cache</nowiki>}} | ||
+ | |Description=<nowiki>Create new axis based on existing axis</nowiki>}} | ||
|Methods= | |Methods= | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>AddAccessGroup</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>groupResourceId</nowiki>|Description=<nowiki>Group to give access</nowiki>}} | ||
+ | |Description=<nowiki>Add a new group that has access to this option.</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>AddOption</nowiki>|Parameters= | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>AddOption</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=AxisOption|Name=<nowiki>option</nowiki>|Description=<nowiki>Option to add</nowiki>}} | {{CGscriptParameters_Template|Type=AxisOption|Name=<nowiki>option</nowiki>|Description=<nowiki>Option to add</nowiki>}} | ||
Line 15: | Line 27: | ||
|Description=<nowiki>Add a new tag. Return false if already added</nowiki>}} | |Description=<nowiki>Add a new tag. Return false if already added</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>AddToAxisSet</nowiki>|Description=<nowiki>Add this axis to the axis set of the given data cache. Return false if Name already exists</nowiki>}} | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>AddToAxisSet</nowiki>|Description=<nowiki>Add this axis to the axis set of the given data cache. Return false if Name already exists</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Any</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>predicate</nowiki>|Description=<nowiki>A function that takes 1 parameter of the types in the array, and return true/false</nowiki>}} | ||
+ | |Description=<nowiki>Return true if the array contains the element using the given function.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>Contains</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=object|Name=<nowiki>element</nowiki>|Description=<nowiki>Element to check for</nowiki>}} | ||
+ | |Description=<nowiki>Return true if the array contains the element using the normal equal operator.</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>CountOptions</nowiki>|Description=<nowiki>Number of current options</nowiki>}} | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>CountOptions</nowiki>|Description=<nowiki>Number of current options</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Except</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=array|Name=<nowiki>elements</nowiki>|Description=<nowiki>Elements to remove</nowiki>}} | ||
+ | |Description=<nowiki>Return all elements that does not exist in the other collection.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ExpressionForOption</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>lowerIdx</nowiki>|Description=<nowiki>Option to create expression for</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=AxisOption|Name=<nowiki>parent</nowiki>|Description=<nowiki>Needed if BaseExpression contains PARENTVALUE</nowiki>}} | ||
+ | |Description=<nowiki>Get the full numerator expression for a given option with an optional parent option</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>First</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A function to test each element for a condition.</nowiki>}} | ||
+ | |Description=<nowiki>Returns the first element in a sequence that satisfies a specified condition.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>FirstOrDefault</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A function to test each element for a condition.</nowiki>}} | ||
+ | |Description=<nowiki>Returns the first element in a sequence that satisfies a specified condition or empty if not found.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>Frequency</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=number|Name=<nowiki>number</nowiki>|Description=<nowiki>The number to search for</nowiki>}} | ||
+ | |Description=<nowiki>Counts the number of times a given Number object exists in the Array. Can only use if all the elements are of type Number</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>this[] { get; }</nowiki>|Parameters= | {{CGscriptMethods_Template|ReturnType=object|Name=<nowiki>this[] { get; }</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>}} | ||
|Description=<nowiki>Backward-compatible indexer</nowiki>}} | |Description=<nowiki>Backward-compatible indexer</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>HasAccessGroup</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>groupResourceId</nowiki>|Description=<nowiki>AccessGroup to work on</nowiki>}} | ||
+ | |Description=<nowiki>Return true if group is added</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>HasTag</nowiki>|Parameters= | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>HasTag</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>tag</nowiki>|Description=<nowiki>Tag to work on</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>tag</nowiki>|Description=<nowiki>Tag to work on</nowiki>}} | ||
|Description=<nowiki>Return true if tag is added</nowiki>}} | |Description=<nowiki>Return true if tag is added</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=int|Name=<nowiki>IndexOf</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=object|Name=<nowiki>element</nowiki>|Description=<nowiki>Element to search for</nowiki>}} | ||
+ | |Description=<nowiki>Return index of the given element, or -1.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsCharacterArray</nowiki>|Inherited=array|Description=<nowiki>check if array is an array of characters</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsNumericArray</nowiki>|Inherited=array|Description=<nowiki>check if array is an array of integer numbers</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>IsStringArray</nowiki>|Inherited=array|Description=<nowiki>check if array is an array of string</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Array of ints|Name=<nowiki>ListAccessGroups</nowiki>|Description=<nowiki>Return list of all added AccessGroups</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=Array of strings|Name=<nowiki>ListTags</nowiki>|Description=<nowiki>Return list of all added tags</nowiki>}} | {{CGscriptMethods_Template|ReturnType=Array of strings|Name=<nowiki>ListTags</nowiki>|Description=<nowiki>Return list of all added tags</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>OrderBy</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>comparer</nowiki>|Description=<nowiki>Function that compares two objects of the same type. Must return a signed integer that indicates the relative values of first param A and second param B. Value Less than 0 : A is less than B.Value 0 : A equals B.Value Greater than 0 : A is greater than B.It can also be a function that takes 1 parameter and returns a string or number.</nowiki>}} | ||
+ | |Description=<nowiki>Sorts the elements of a sequence in ascending order by using a specified comparer.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Randomize</nowiki>|Inherited=array|Description=<nowiki>Randomize the order of the elements in the current array.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>RemoveAccessGroup</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>groupResourceId</nowiki>|Description=<nowiki>AccessGroup to work on</nowiki>}} | ||
+ | |Description=<nowiki>Remove a group.</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>RemoveOption</nowiki>|Parameters= | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>RemoveOption</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=AxisOption|Name=<nowiki>option</nowiki>|Description=<nowiki>Option to remove</nowiki>}} | {{CGscriptParameters_Template|Type=AxisOption|Name=<nowiki>option</nowiki>|Description=<nowiki>Option to remove</nowiki>}} | ||
Line 32: | Line 82: | ||
{{CGscriptParameters_Template|Type=string|Name=<nowiki>tag</nowiki>|Description=<nowiki>Tag to work on</nowiki>}} | {{CGscriptParameters_Template|Type=string|Name=<nowiki>tag</nowiki>|Description=<nowiki>Tag to work on</nowiki>}} | ||
|Description=<nowiki>Remove a tag. Return false if not added</nowiki>}} | |Description=<nowiki>Remove a tag. Return false if not added</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Reverse</nowiki>|Inherited=array|Description=<nowiki>Returns an array with all the elements in the opposite order.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Select</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A transform function to apply to each element.</nowiki>}} | ||
+ | |Description=<nowiki>Projects each element of a sequence into a new form.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>SelectMany</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>selector</nowiki>|Description=<nowiki>A transform function to get each sub array.</nowiki>}} | ||
+ | |Description=<nowiki>Projects each array element of a sequence into a new form.</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>this[] { set; }</nowiki>|Parameters= | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>this[] { set; }</nowiki>|Parameters= | ||
{{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to set</nowiki>}} | {{CGscriptParameters_Template|Type=int|Name=<nowiki>index</nowiki>|Description=<nowiki>Index</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=object|Name=<nowiki>value</nowiki>|Description=<nowiki>Value to set</nowiki>}} | ||
|Description=<nowiki>Backward-compatible indexer</nowiki>}} | |Description=<nowiki>Backward-compatible indexer</nowiki>}} | ||
− | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Description=<nowiki>The string representation of the object.</nowiki>}} | + | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Skip</nowiki>|Inherited=array|Parameters= |
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>n</nowiki>|Description=<nowiki>How many elements to skip</nowiki>}} | ||
+ | |Description=<nowiki>Get all but the n first elements.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Take</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=int|Name=<nowiki>n</nowiki>|Description=<nowiki>How many elements to take</nowiki>}} | ||
+ | |Description=<nowiki>Get the n first elements.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Dictionary|Name=<nowiki>ToDictionary</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>keySelector</nowiki>|Description=<nowiki>A transform function to get the key of each element.</nowiki>}} | ||
+ | |Description=<nowiki>Return a dictionary with the elements of the array.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=Dictionary|Name=<nowiki>ToDictionary</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>keySelector</nowiki>|Description=<nowiki>A transform function to get the key of each element.</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Function|Name=<nowiki>valueSelector</nowiki>|Description=<nowiki>A transform function to get the value of each element.</nowiki>}} | ||
+ | |Description=<nowiki>Return a dictionary with the elements of the array.</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=string|Name=<nowiki>ToString</nowiki>|Inherited=Array|Description=<nowiki>The string representation of the object.</nowiki>}} | ||
{{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>UpdateAxisInAxisSet</nowiki>|Description=<nowiki>Update this axis in the axis set of the given data cache. Return false if Name does not exist already</nowiki>}} | {{CGscriptMethods_Template|ReturnType=bool|Name=<nowiki>UpdateAxisInAxisSet</nowiki>|Description=<nowiki>Update this axis in the axis set of the given data cache. Return false if Name does not exist already</nowiki>}} | ||
+ | {{CGscriptMethods_Template|ReturnType=array|Name=<nowiki>Where</nowiki>|Inherited=array|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Function|Name=<nowiki>predicate</nowiki>|Description=<nowiki>A function that takes 1 parameter of the types in the array, and an optional 2nd parameter that is the index and return true/false</nowiki>}} | ||
+ | |Description=<nowiki>Filters a sequence of values based on a predicate.</nowiki>}} | ||
|Properties= | |Properties= | ||
+ | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Average</nowiki>|HasGetter=1|Inherited=array|Description=<nowiki>Average of the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>BaseExpression</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Base Expression (nominator) that combined with the axis options value makes a complete expression. (Use col == %VALUE% to replace value, use %VALUE(Question) == val% to replace sub question, use PARENTVALUE instead of VALUE to access the value being crossed along with)</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=Color|Name=<nowiki>Color</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Color for this axis</nowiki>}} | {{CGscriptProperties_Template|ReturnType=Color|Name=<nowiki>Color</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Color for this axis</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>HasAccess</nowiki>|HasGetter=1|Description=<nowiki>Get if current logged in user has access (Voluntary access control, doesn't check inheritance, if no groups defined this returns true)</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=LocalizedString|Name=<nowiki>LocalizedTexts</nowiki>|HasGetter=1|Description=<nowiki>Get/set localized Text (description)</nowiki>}} | {{CGscriptProperties_Template|ReturnType=LocalizedString|Name=<nowiki>LocalizedTexts</nowiki>|HasGetter=1|Description=<nowiki>Get/set localized Text (description)</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=LocalizedString|Name=<nowiki>LocalizedTitles</nowiki>|HasGetter=1|Description=<nowiki>Get/set localized Titles</nowiki>}} | {{CGscriptProperties_Template|ReturnType=LocalizedString|Name=<nowiki>LocalizedTitles</nowiki>|HasGetter=1|Description=<nowiki>Get/set localized Titles</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>MathBase</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Math base (dcs column used to calculate statitics on)</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>MathBase</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Math base (dcs column used to calculate statitics on)</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>MathBaseModifier</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Math base modifier (filter for statistics calculations)</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>MathBaseModifier</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Math base modifier (filter for statistics calculations)</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Max</nowiki>|HasGetter=1|Inherited=array|Description=<nowiki>Largest of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} | ||
+ | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Min</nowiki>|HasGetter=1|Inherited=array|Description=<nowiki>Smallest of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Name (unique id)</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Name</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Name (unique id)</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>ObjectTypeName</nowiki>|HasGetter=1|Description=<nowiki>The name of the type of object.</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=array|Name=<nowiki>Options</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set options</nowiki>}} | {{CGscriptProperties_Template|ReturnType=array|Name=<nowiki>Options</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set options</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>PctBase</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Percentage base (denominator) for all options</nowiki>}} | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>PctBase</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set Percentage base (denominator) for all options</nowiki>}} | ||
− | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Text</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set | + | {{CGscriptProperties_Template|ReturnType=number|Name=<nowiki>Sum</nowiki>|HasGetter=1|Inherited=array|Description=<nowiki>Sum of all the objects in the Array object. Can only use if all the elements are of type Number</nowiki>}} |
− | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Description=<nowiki>Get information about this class.</nowiki>}} | + | {{CGscriptProperties_Template|ReturnType=string|Name=<nowiki>Text</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set default language text (description)</nowiki>}} |
+ | {{CGscriptProperties_Template|ReturnType=TypeInformation|Name=<nowiki>TypeInformation</nowiki>|HasGetter=1|Inherited=object|Description=<nowiki>Get information about this class.</nowiki>}} | ||
{{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Weight</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set if used for weight</nowiki>}} | {{CGscriptProperties_Template|ReturnType=bool|Name=<nowiki>Weight</nowiki>|HasGetter=1|HasSetter=1|Description=<nowiki>Get/set if used for weight</nowiki>}} | ||
+ | |StaticMethods= | ||
+ | {{CGscriptMethods_Template|ReturnType=Empty|Name=<nowiki>Axis_swap</nowiki>|Parameters= | ||
+ | {{CGscriptParameters_Template|Type=Axis|Name=<nowiki>a</nowiki>|Description=<nowiki>Swap position of a with b</nowiki>|Comma=,}}{{CGscriptParameters_Template|Type=Axis|Name=<nowiki>b</nowiki>|Description=<nowiki>Swap position of b with a</nowiki>}} | ||
+ | |Description=<nowiki>Swap 2 axis in the axis set</nowiki>}} | ||
}} | }} | ||
+ | |||
+ | (See more at: [[Axis_swap]]) | ||
+ | === <span style="color:#DF8621">'''Examples'''</span> === | ||
+ | <span style="color:#DF8621"> Create new axis based on the defaults for the dcs column </span> | ||
+ | <source lang="javascript"> | ||
+ | DataCacheSpecification dcs = new DataCacheSpecification(15639258); | ||
+ | array aQcsQuestionColumns = dcs.CreateAllColumnsForQuestion("Q4",0); | ||
+ | for(number i= 0; i < aQcsQuestionColumns.Count; i++){ | ||
+ | aQcsQuestionColumns[i].Save(); | ||
+ | Axis axis = new Axis(aQcsQuestionColumns[i]); | ||
+ | axis.AddToAxisSet(); | ||
+ | } | ||
+ | dcs.Save(); | ||
+ | </source> | ||
+ | <span style="color:#DF8621"> Create new axis based on existing axis in the same axisset </span> | ||
+ | <source lang="javascript"> | ||
+ | DCS_use(15639259); | ||
+ | Axis axis1 = AxisSet_getAxis("Age"); | ||
+ | Axis axis2 = new Axis (axis1, "AgeNew"); | ||
+ | axis2.AddToAxisSet(); | ||
+ | DCS_save(); | ||
+ | </source> | ||
+ | <span style="color:#DF8621"> Create new axis </span> | ||
+ | <source lang="javascript"> | ||
+ | DataCacheSpecification dcs = new DataCacheSpecification(15636760); | ||
+ | Axis axis = new Axis (dcs, "Gender", "Your Gender"); | ||
+ | axis.MathBase = "Gender"; | ||
+ | axis.PctBase = "Gender!=empty"; | ||
+ | axis.AddOption(new AxisOption(dcs, "Male", "Gender == [1]")); | ||
+ | axis.AddOption(new AxisOption(dcs, "Female", "Gender == [2]")); | ||
+ | axis.AddToAxisSet(); | ||
+ | dcs.Save(); | ||
+ | print(Catglobe.Json.Encode(axis)); | ||
+ | //{"id":"Gender","title":{},"desc":{"":"Your Gender"},"mathbase":"Gender","mathbasemod":"","pctbase":"Gender!=empty","color":"#00000000","options":[{"title":{"":"Male"},"expression":"Gender == [1]","pctbase":"","color":"#00000000","tags":[]},{"title":{"":"Female"},"expression":"Gender == [2]","pctbase":"","color":"#00000000","tags":[]}],"tags":[]} | ||
+ | </source> | ||
+ | |||
+ | <span style="color:#DF8621"> Create new axis based on existing axis </span> | ||
+ | <source lang="javascript"> | ||
+ | DCS_use(15639273); | ||
+ | Axis axis1 = AxisSet_getAxis("Gender"); | ||
+ | |||
+ | DataCacheSpecification dcs = new DataCacheSpecification (15639258); | ||
+ | Axis axis2 = new Axis(axis1, "GenderCopyFrom15639273", dcs); | ||
+ | axis2.AddToAxisSet(); | ||
+ | dcs.Save(); | ||
+ | </source> | ||
+ | |||
+ | <span style="color:#DF8621"> Remove options </span> | ||
+ | <source lang="javascript"> | ||
+ | DCS_use(15636575); | ||
+ | Axis axis = AxisSet_getAxis("Gender"); | ||
+ | array options = axis.Options; | ||
+ | for(number i=0; i<options.Count; i++) | ||
+ | { | ||
+ | AxisOption option = options[i]; | ||
+ | axis.RemoveOption(option); | ||
+ | } | ||
+ | AxisSet_save(); | ||
+ | </source> | ||
+ | <span style="color:#DF8621"> Set Title and Description for Axis </span> | ||
+ | <source lang="javascript"> | ||
+ | DCS_use(15636575); | ||
+ | Axis axis = AxisSet_getAxis("Gender"); | ||
+ | //set Titles | ||
+ | axis.LocalizedTitles.SetTranslation("en-GB", "Title En text"); | ||
+ | axis.LocalizedTitles.SetTranslation("da-DK", "title Da text"); | ||
+ | //set Texts | ||
+ | axis.LocalizedTexts.SetTranslation("en-GB", "Description En text"); | ||
+ | axis.LocalizedTexts.SetTranslation("da-DK", "Description Da text"); | ||
+ | AxisSet_save(); | ||
+ | print(Catglobe.Json.Encode(axis));//{"id":"Gender","title":{"en-GB":"Title En text","da-DK":"title Da text"},"desc":{"":"123","en-GB":"Description En text","da-DK":"Description Da text"},"mathbase":"Gender","mathbasemod":"","pctbase":"Gender != empty","color":"#00000000","options":[{"title":{"":"Male"},"expression":"","pctbase":"","color":"#00000000","tags":[],"accessGroups":[]},{"title":{"":"Female"},"expression":"","pctbase":"","color":"#00000000","tags":[],"accessGroups":[]}],"tags":[],"accessGroups":[]} | ||
+ | </source> |
Latest revision as of 07:36, 2 July 2020
Axis
Represents an axis in a data cache specification.
Parent class
Inherits from Array
Constructors
- (QcsColumn column "Column") - Create new axis based on the defaults for the dcs column
- (Axis axis "Existing axis to duplicate", string name "New name") - Create new axis based on existing axis in the same axisset
- (DataCacheSpecification dataCache "Validate against this data cache", string name "Initial name", string text "Initial text") - Create new axis
- (Axis axis "Existing axis to duplicate", string name "New name", DataCacheSpecification dataCache "Validate against this data cache") - Create new axis based on existing axis
Methods
- Empty AddAccessGroup(int groupResourceId "Group to give access") - Add a new group that has access to this option.
- int AddOption(AxisOption option "Option to add") - Add an option to current list
- Empty AddOrUpdateAxisInAxisSet() - Add or Update this axis in the axis set of the given data cache
- bool AddTag(string tag "Tag to work on") - Add a new tag. Return false if already added
- bool AddToAxisSet() - Add this axis to the axis set of the given data cache. Return false if Name already exists
- (From array) bool Any(Function predicate "A function that takes 1 parameter of the types in the array, and return true/false") - Return true if the array contains the element using the given function.
- (From array) bool Contains(object element "Element to check for") - Return true if the array contains the element using the normal equal operator.
- int CountOptions() - Number of current options
- (From array) array Except(array elements "Elements to remove") - Return all elements that does not exist in the other collection.
- string ExpressionForOption(int lowerIdx "Option to create expression for", AxisOption parent "Needed if BaseExpression contains PARENTVALUE") - Get the full numerator expression for a given option with an optional parent option
- (From array) object First(Function selector "A function to test each element for a condition.") - Returns the first element in a sequence that satisfies a specified condition.
- (From array) object FirstOrDefault(Function selector "A function to test each element for a condition.") - Returns the first element in a sequence that satisfies a specified condition or empty if not found.
- (From array) int Frequency(number number "The number to search for") - Counts the number of times a given Number object exists in the Array. Can only use if all the elements are of type Number
- object this[] { get; }(int index "Index") - Backward-compatible indexer
- bool HasAccessGroup(int groupResourceId "AccessGroup to work on") - Return true if group is added
- bool HasTag(string tag "Tag to work on") - Return true if tag is added
- (From array) int IndexOf(object element "Element to search for") - Return index of the given element, or -1.
- (From array) bool IsCharacterArray() - check if array is an array of characters
- (From array) bool IsNumericArray() - check if array is an array of integer numbers
- (From array) bool IsStringArray() - check if array is an array of string
- Array of int ListAccessGroups() - Return list of all added AccessGroups
- Array of string ListTags() - Return list of all added tags
- (From array) array OrderBy(Function comparer "Function that compares two objects of the same type. Must return a signed integer that indicates the relative values of first param A and second param B. Value Less than 0 : A is less than B.Value 0 : A equals B.Value Greater than 0 : A is greater than B.It can also be a function that takes 1 parameter and returns a string or number.") - Sorts the elements of a sequence in ascending order by using a specified comparer.
- (From array) Empty Randomize() - Randomize the order of the elements in the current array.
- Empty RemoveAccessGroup(int groupResourceId "AccessGroup to work on") - Remove a group.
- Empty RemoveOption(AxisOption option "Option to remove") - Remove option
- bool RemoveOption(int index "Index of option in the list") - Remove option
- bool RemoveTag(string tag "Tag to work on") - Remove a tag. Return false if not added
- (From array) array Reverse() - Returns an array with all the elements in the opposite order.
- (From array) array Select(Function selector "A transform function to apply to each element.") - Projects each element of a sequence into a new form.
- (From array) array SelectMany(Function selector "A transform function to get each sub array.") - Projects each array element of a sequence into a new form.
- Empty this[] { set; }(int index "Index", object value "Value to set") - Backward-compatible indexer
- (From array) array Skip(int n "How many elements to skip") - Get all but the n first elements.
- (From array) array Take(int n "How many elements to take") - Get the n first elements.
- (From array) Dictionary ToDictionary(Function keySelector "A transform function to get the key of each element.") - Return a dictionary with the elements of the array.
- (From array) Dictionary ToDictionary(Function keySelector "A transform function to get the key of each element.", Function valueSelector "A transform function to get the value of each element.") - Return a dictionary with the elements of the array.
- (From Array) string ToString() - The string representation of the object.
- bool UpdateAxisInAxisSet() - Update this axis in the axis set of the given data cache. Return false if Name does not exist already
- (From array) array Where(Function predicate "A function that takes 1 parameter of the types in the array, and an optional 2nd parameter that is the index and return true/false") - Filters a sequence of values based on a predicate.
Properties
- (From array) number Average { get; } - Average of the objects in the Array object. Can only use if all the elements are of type Number
- string BaseExpression { get; set; } - Get/set Base Expression (nominator) that combined with the axis options value makes a complete expression. (Use col == %VALUE% to replace value, use %VALUE(Question) == val% to replace sub question, use PARENTVALUE instead of VALUE to access the value being crossed along with)
- Color Color { get; set; } - Get/set Color for this axis
- bool HasAccess { get; } - Get if current logged in user has access (Voluntary access control, doesn't check inheritance, if no groups defined this returns true)
- LocalizedString LocalizedTexts { get; } - Get/set localized Text (description)
- LocalizedString LocalizedTitles { get; } - Get/set localized Titles
- string MathBase { get; set; } - Get/set Math base (dcs column used to calculate statitics on)
- string MathBaseModifier { get; set; } - Get/set Math base modifier (filter for statistics calculations)
- (From array) number Max { get; } - Largest of all the objects in the Array object. Can only use if all the elements are of type Number
- (From array) number Min { get; } - Smallest of all the objects in the Array object. Can only use if all the elements are of type Number
- string Name { get; set; } - Get/set Name (unique id)
- string ObjectTypeName { get; } - The name of the type of object.
- array Options { get; set; } - Get/set options
- string PctBase { get; set; } - Get/set Percentage base (denominator) for all options
- (From array) number Sum { get; } - Sum of all the objects in the Array object. Can only use if all the elements are of type Number
- string Text { get; set; } - Get/set default language text (description)
- (From object) TypeInformation TypeInformation { get; } - Get information about this class.
- bool Weight { get; set; } - Get/set if used for weight
Static Methods
- Empty Axis_swap(Axis a "Swap position of a with b", Axis b "Swap position of b with a") - Swap 2 axis in the axis set
(See more at: Axis_swap)
Examples
Create new axis based on the defaults for the dcs column
DataCacheSpecification dcs = new DataCacheSpecification(15639258);
array aQcsQuestionColumns = dcs.CreateAllColumnsForQuestion("Q4",0);
for(number i= 0; i < aQcsQuestionColumns.Count; i++){
aQcsQuestionColumns[i].Save();
Axis axis = new Axis(aQcsQuestionColumns[i]);
axis.AddToAxisSet();
}
dcs.Save();
Create new axis based on existing axis in the same axisset
DCS_use(15639259);
Axis axis1 = AxisSet_getAxis("Age");
Axis axis2 = new Axis (axis1, "AgeNew");
axis2.AddToAxisSet();
DCS_save();
Create new axis
DataCacheSpecification dcs = new DataCacheSpecification(15636760);
Axis axis = new Axis (dcs, "Gender", "Your Gender");
axis.MathBase = "Gender";
axis.PctBase = "Gender!=empty";
axis.AddOption(new AxisOption(dcs, "Male", "Gender == [1]"));
axis.AddOption(new AxisOption(dcs, "Female", "Gender == [2]"));
axis.AddToAxisSet();
dcs.Save();
print(Catglobe.Json.Encode(axis));
//{"id":"Gender","title":{},"desc":{"":"Your Gender"},"mathbase":"Gender","mathbasemod":"","pctbase":"Gender!=empty","color":"#00000000","options":[{"title":{"":"Male"},"expression":"Gender == [1]","pctbase":"","color":"#00000000","tags":[]},{"title":{"":"Female"},"expression":"Gender == [2]","pctbase":"","color":"#00000000","tags":[]}],"tags":[]}
Create new axis based on existing axis
DCS_use(15639273);
Axis axis1 = AxisSet_getAxis("Gender");
DataCacheSpecification dcs = new DataCacheSpecification (15639258);
Axis axis2 = new Axis(axis1, "GenderCopyFrom15639273", dcs);
axis2.AddToAxisSet();
dcs.Save();
Remove options
DCS_use(15636575);
Axis axis = AxisSet_getAxis("Gender");
array options = axis.Options;
for(number i=0; i<options.Count; i++)
{
AxisOption option = options[i];
axis.RemoveOption(option);
}
AxisSet_save();
Set Title and Description for Axis
DCS_use(15636575);
Axis axis = AxisSet_getAxis("Gender");
//set Titles
axis.LocalizedTitles.SetTranslation("en-GB", "Title En text");
axis.LocalizedTitles.SetTranslation("da-DK", "title Da text");
//set Texts
axis.LocalizedTexts.SetTranslation("en-GB", "Description En text");
axis.LocalizedTexts.SetTranslation("da-DK", "Description Da text");
AxisSet_save();
print(Catglobe.Json.Encode(axis));//{"id":"Gender","title":{"en-GB":"Title En text","da-DK":"title Da text"},"desc":{"":"123","en-GB":"Description En text","da-DK":"Description Da text"},"mathbase":"Gender","mathbasemod":"","pctbase":"Gender != empty","color":"#00000000","options":[{"title":{"":"Male"},"expression":"","pctbase":"","color":"#00000000","tags":[],"accessGroups":[]},{"title":{"":"Female"},"expression":"","pctbase":"","color":"#00000000","tags":[],"accessGroups":[]}],"tags":[],"accessGroups":[]}