Difference between revisions of "Slider"
(Domain) |
|||
Line 10: | Line 10: | ||
== Slider( val...'', domain, styles, ..., resultIndex, returnRef'' )== | == Slider( val...'', domain, styles, ..., resultIndex, returnRef'' )== | ||
− | :<code>Slider(0.5)</code> → [[image:slider(0.5).png]] | + | A slider can have one or more thumbs: |
− | + | :{| border="0" | |
− | + | ! Expression !! !! Control's appearance !! !! Result after evaluation | |
− | + | |- | |
+ | | <code>Slider(0.5)</code> || → || [[image:slider(0.5).png]] || → || <code>0.5</code> | ||
+ | |- | ||
+ | |<code>Slider(0.5, 0.75)</code> || → || [[image:slider(0.5,0.75).png]] || → || <code>[0.5, 0.75]</code> | ||
+ | |- | ||
+ | |<code>Slider(0.1, 0.5, 0.75)</code> || → || [[image:slider(0.1,0.5,0.75).png]] || → || <code>[0.1, 0.5, 0.75]</code> | ||
+ | |} | ||
− | + | The number of values specified determines the number of thumbs. Notice that it defaults to a <code>[[Continuous]](0,1)</code> scale. | |
− | + | == Creating your first user slider input == | |
− | + | # Enter [[Edit mode]] | |
+ | # [[Tutorial%3A_Create_a_model#Creating_variable_nodes|Drag a new Variable or Decision node to the diagram]] | ||
+ | #* Title it, say <code>Probability of Rain</code> | ||
+ | # Press [[image:ToolbarExprButton.png]] to edit its Definition | ||
+ | # Enter: <code>Slider(0.5)</code> [[image:GreenCheck.png]] | ||
+ | # Select '''Make User Input Node''' on the [[Object menu]] | ||
+ | # [[Tutorial%3A_Create_a_model#Moving_nodes|Drag the user input node]] to your desired location. | ||
− | |||
− | + | The user input node appears as | |
+ | <center>[[image:Probability of rain slider.png]]</center> | ||
− | + | When displayed with labels below, <code>Slider(0.5, styles:'LabelsBelow')</code> displays as | |
+ | <center>[[image:Probability of rain slider with labels below.png]]</center> | ||
− | When the domain is not specified | + | == Domain == |
− | + | The domain determines the space of values that can be selected by the slider. When no domain is specified, the slider defaults to <code>[[Continuous]](0,1)</code>, which allows any value between 0 and 1 to be selected. | |
− | + | ||
+ | There are two ways to specify the domain for the slider -- you can either use the Domain attribute or the «domain» parameter. | ||
+ | |||
+ | === Using the [[Domain attribute]] === | ||
+ | To change the [[Domain attribute]] from the [[Attribute panel]], select '''Domain''' on the [[Attribute panel|Attribute menu]]. [[image:Domain on Attribute Choice.png|top]]. | ||
+ | |||
+ | The Domain-type pulldown has these options: [[image:DomainPulldown5.png|top]]. | ||
+ | |||
+ | Select [[Continuous]] if you want a continuous slider and specify the lower and upper bounds. | ||
+ | |||
+ | A discrete slider restricts the thumb(s) to a finite set of positions. You can select either [[Integer]], '''Explicit Values''', or '''Copy from Index'''. You can also compute the domain using '''Expression'''. Here we illustrate the use of '''Explicit Values'''. | ||
+ | :[[image:Explicit Values for Domain.png]] | ||
+ | |||
+ | :<code>Slider('Bad', styles:'LabelsBelow')</code> → [[image:Slider from explicit values.png]] | ||
+ | |||
+ | Using the [[Domain attribute]] is often (but not always) preferable to using the «domain» parameter since it is more readily available once your UI is displaying the control. | ||
+ | |||
+ | === Using the «domain» parameter === | ||
+ | As an alternative to using the [[Domain attribute]], your can specify the domain directly as a parameter. If both are specified, the parameter is used. When you pass the domain as a parameter, you ''must'' use a [[Function calls and parameters|name-parameter calling convention]]. The following examples illustrate how the «domain» parameter is specified. | ||
+ | |||
+ | *<code>Slider( 'Good', domain:[[Discrete]]('Horrible', 'Bad', 'Neutral', 'Good', 'Excellent') )</code> | ||
+ | *<code>Slider( 'Good', domain:['Horrible', 'Bad', 'Neutral', 'Good', 'Excellent'] )</code> | ||
+ | *<code>Slider( 'D', domain: 'A'..'G' )</code> | ||
+ | *<code>Slider( 23, 54, domain:[[Continuous]](0, 100) )</code> | ||
+ | *<code>Slider( 4, domain:[[Integer]](1,5) )</code> | ||
+ | *<code>Slider( 'Medium', domain:LMH)</code> <font color="green">{ where LMH is an index name }</font> | ||
+ | |||
+ | == Return value == | ||
A slider with one thumb returns its first parameter. E.g., Slider(0.7) returns 0.7. | A slider with one thumb returns its first parameter. E.g., Slider(0.7) returns 0.7. | ||
Line 35: | Line 75: | ||
A slider with two or more thumbs returns a list of the values, e.g., Slider(0.3, 0.7) returns the list [0.3, 0.7]. In some places, this is a problem. For example, if you have 2 or more interval sliders in the same table, each becomes a separate implicit index, which is not allowed. There are two alternatives -- you can either supply a «resultIndex», or you can have it return a reference to the selections by setting «returnRef» to true. | A slider with two or more thumbs returns a list of the values, e.g., Slider(0.3, 0.7) returns the list [0.3, 0.7]. In some places, this is a problem. For example, if you have 2 or more interval sliders in the same table, each becomes a separate implicit index, which is not allowed. There are two alternatives -- you can either supply a «resultIndex», or you can have it return a reference to the selections by setting «returnRef» to true. | ||
− | + | == Ordering == | |
When a slider has 2 or more thumbs, the default is to constrain the ordering of the thumbs so that the left thumb cannot move past the right thumb. You can change this by including 'Unordered' in the «styles» parameter. | When a slider has 2 or more thumbs, the default is to constrain the ordering of the thumbs so that the left thumb cannot move past the right thumb. You can change this by including 'Unordered' in the «styles» parameter. | ||
− | + | == Appearance == | |
− | There are many style and color options available that alter the appearance sliders. In most cases, you'll want to adopt a consistent color and style scheme for all sliders in your model. To control these model-wide defaults, make sure no node is selected, then use the menus to navigate to | + | There are many style and color options available that alter the appearance sliders. In most cases, you'll want to adopt a consistent color and style scheme for all sliders in your model. |
+ | |||
+ | === Model-wide defaults === | ||
+ | To control these model-wide defaults, make sure no node is selected, then use the menus to navigate to | ||
Definition / System variables / Settings / Slider style defaults / Edit table | Definition / System variables / Settings / Slider style defaults / Edit table | ||
Line 61: | Line 104: | ||
You can specify multiple colors in the «thumbColor» parameter if you want each thumb in the same slider to have a different color, e.g., | You can specify multiple colors in the «thumbColor» parameter if you want each thumb in the same slider to have a different color, e.g., | ||
Slider(0.25,0.5,0.75,thumbColor:'green','yellow','red') | Slider(0.25,0.5,0.75,thumbColor:'green','yellow','red') | ||
− | |||
− | |||
== See Also == | == See Also == |
Revision as of 20:46, 21 October 2022
New to Analytica 6.3
Use this function to create a slider control in a user input node or in an edit table cell.
A slider control has a horizontal track with one or more movable thumbs that are used to select a value, an interval, or multiple values. A slider can be continuous or discrete -- a discrete slider limits the thumb to a finite set of positions. Its Domain specifies the space of selectable values and thus determines whether it is continuous or discrete. A slider can also optionally include labels with tick marks.
Slider( val..., domain, styles, ..., resultIndex, returnRef )
A slider can have one or more thumbs:
Expression Control's appearance Result after evaluation Slider(0.5)
→ → 0.5
Slider(0.5, 0.75)
→ → [0.5, 0.75]
Slider(0.1, 0.5, 0.75)
→ → [0.1, 0.5, 0.75]
The number of values specified determines the number of thumbs. Notice that it defaults to a Continuous(0,1)
scale.
Creating your first user slider input
- Enter Edit mode
- Drag a new Variable or Decision node to the diagram
- Title it, say
Probability of Rain
- Title it, say
- Press
to edit its Definition
- Enter:
Slider(0.5)
- Select Make User Input Node on the Object menu
- Drag the user input node to your desired location.
The user input node appears as

When displayed with labels below, Slider(0.5, styles:'LabelsBelow')
displays as

Domain
The domain determines the space of values that can be selected by the slider. When no domain is specified, the slider defaults to Continuous(0,1)
, which allows any value between 0 and 1 to be selected.
There are two ways to specify the domain for the slider -- you can either use the Domain attribute or the «domain» parameter.
Using the Domain attribute
To change the Domain attribute from the Attribute panel, select Domain on the Attribute menu. .
The Domain-type pulldown has these options: .
Select Continuous if you want a continuous slider and specify the lower and upper bounds.
A discrete slider restricts the thumb(s) to a finite set of positions. You can select either Integer, Explicit Values, or Copy from Index. You can also compute the domain using Expression. Here we illustrate the use of Explicit Values.
Using the Domain attribute is often (but not always) preferable to using the «domain» parameter since it is more readily available once your UI is displaying the control.
Using the «domain» parameter
As an alternative to using the Domain attribute, your can specify the domain directly as a parameter. If both are specified, the parameter is used. When you pass the domain as a parameter, you must use a name-parameter calling convention. The following examples illustrate how the «domain» parameter is specified.
Slider( 'Good', domain:Discrete('Horrible', 'Bad', 'Neutral', 'Good', 'Excellent') )
Slider( 'Good', domain:['Horrible', 'Bad', 'Neutral', 'Good', 'Excellent'] )
Slider( 'D', domain: 'A'..'G' )
Slider( 23, 54, domain:Continuous(0, 100) )
Slider( 4, domain:Integer(1,5) )
Slider( 'Medium', domain:LMH)
{ where LMH is an index name }
Return value
A slider with one thumb returns its first parameter. E.g., Slider(0.7) returns 0.7.
A slider with two or more thumbs returns a list of the values, e.g., Slider(0.3, 0.7) returns the list [0.3, 0.7]. In some places, this is a problem. For example, if you have 2 or more interval sliders in the same table, each becomes a separate implicit index, which is not allowed. There are two alternatives -- you can either supply a «resultIndex», or you can have it return a reference to the selections by setting «returnRef» to true.
Ordering
When a slider has 2 or more thumbs, the default is to constrain the ordering of the thumbs so that the left thumb cannot move past the right thumb. You can change this by including 'Unordered' in the «styles» parameter.
Appearance
There are many style and color options available that alter the appearance sliders. In most cases, you'll want to adopt a consistent color and style scheme for all sliders in your model.
Model-wide defaults
To control these model-wide defaults, make sure no node is selected, then use the menus to navigate to
Definition / System variables / Settings / Slider style defaults / Edit table
Each individual slider can override these model-wide defaults by specifying styles in the «styles» parameter, or by specifying any of the color parameters, or the «trackHeight» parameter.
The «styles» parameter accepts these options: 'Needle', 'Circle', 'Rectangle', 'Diamond', 'Block', 'Line', 'NoThumb': The thumb shape 'RoundedEnds', 'FlatEnds': The track shape 'LabelsNone','LabelsBelow','LabelsAtEnds': Whether and where labels apppear 'ShowSelect','HideSelect': Whether the area to the left of a single thumb, or between 2 thumbs, uses «selectColor» 'Ordered', 'Unordered': Whether multiple thumbs can cross over each other
For example: Slider( 1, styles:'ShowSelect','Line','FlatEnds','LabelsAtEnds' )
Colors are specified either via a color integer using the 0xrrggbb or 0xaarrggbb notation, or by naming the color, e.g., Slider( 1, TrackColor: 0xff0000, ThumbColor:'Pink' )
You can specify multiple colors in the «thumbColor» parameter if you want each thumb in the same slider to have a different color, e.g., Slider(0.25,0.5,0.75,thumbColor:'green','yellow','red')
Enable comment auto-refresher