Toggle menu
876
3.8K
30.2K
279.1K
Catglobe Wiki
Toggle preferences menu
Toggle personal menu
Not logged in
Your IP address will be publicly visible if you make any edits.

Axis class: Difference between revisions

From Catglobe Wiki
No edit summary
No edit summary
Line 123: Line 123:
|Description=<nowiki>Swap 2 axis in the axis set</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">'''Examples'''</span> ===
<span style="color:#DF8621"> New Axis </span>
<span style="color:#DF8621"> New Axis </span>

Revision as of 09:44, 10 August 2018

Axis



Represents an axis in a data cache specification.

Constructors

  • (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
  • 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
  • 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
  • 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.
  • 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.
  • 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
  • bool IsCharacterArray() - check if array is an array of characters
  • bool IsNumericArray() - check if array is an array of integer numbers
  • bool IsStringArray() - check if array is an array of string
  • Array of number ListAccessGroups() - Return list of all added AccessGroups
  • Array of string ListTags() - Return list of all added tags
  • 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.
  • 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
  • array Select(Function selector "A transform function to apply to each element.") - Projects each element of a sequence into a new form.
  • 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
  • array Skip(int n "How many elements to skip") - Get all but the n first elements.
  • array Take(int n "How many elements to take") - Get the n first elements.
  • Dictionary ToDictionary(Function keySelector "A transform function to get the key of each element.") - Return a dictionary with the elements of the 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.
  • 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
  • array Where(Function predicate "A function that takes 1 parameter of the types in the array and return true/false") - Filters a sequence of values based on a predicate.

Properties

  • 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, user %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)
  • number Max { get; } - Largest of all the objects in the Array object. Can only use if all the elements are of type Number
  • 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
  • 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)
  • 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

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":[]}

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":[]}