This repository has been archived by the owner on Jul 13, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 65
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add basic rangeslider * add snap * add center shift to rangeslider * fix crossover logic * make sliderrange dynamically changeable * fix dynamic sliderrange * comment * rename to intervalslider * fix duplicated functions * return real values from `set_close_to!` * update docs * update docs * add intervalslider page * add IntervalSlider to basic MakieLayout test * resolution fixed
- Loading branch information
1 parent
fb04c2a
commit 5573064
Showing
9 changed files
with
423 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
# IntervalSlider | ||
|
||
The interval slider selects an interval (low, high) from the supplied attribute `range`. | ||
The (approximate) start values can be set with `startvalues`. | ||
|
||
The currently selected interval is in the attribute `interval` and is a Tuple of `(low, high)`. | ||
Don't change this value manually, but use the function `set_close_to!(intslider, v1, v2)`. | ||
This is necessary to ensure the values are actually present in the `range` attribute. | ||
|
||
You can click anywhere outside of the currently selected range and the closer interval edge will jump to the point. | ||
You can then drag the edge around. | ||
When hovering over the slider, the larger button indicates the edge that will react. | ||
|
||
If the mouse hovers over the central area of the interval and both buttons are enlarged, clicking and dragging shifts the interval around as a whole. | ||
|
||
You can double-click the slider to reset it to the values present in `startvalues`. | ||
If `startvalues === AbstractPlotting.automatic`, the full interval will be selected (this is the default). | ||
|
||
If you set the attribute `snap = false`, the slider will move continously while dragging and only jump to the closest available values when releasing the mouse. | ||
|
||
|
||
```@example | ||
using CairoMakie | ||
AbstractPlotting.inline!(true) # hide | ||
CairoMakie.activate!() # hide | ||
f = Figure(resolution = (800, 800)) | ||
Axis(f[1, 1], limits = (0, 1, 0, 1)) | ||
rs_h = IntervalSlider(f[2, 1], range = LinRange(0, 1, 1000), | ||
startvalues = (0.2, 0.8)) | ||
rs_v = IntervalSlider(f[1, 2], range = LinRange(0, 1, 1000), | ||
startvalues = (0.4, 0.9), horizontal = false) | ||
Label(f[3, 1], @lift(string(round.($(rs_h.interval), digits = 2))), | ||
tellwidth = false) | ||
Label(f[1, 3], @lift(string(round.($(rs_v.interval), digits = 2))), | ||
tellheight = false, rotation = pi/2) | ||
points = rand(Point2f0, 300) | ||
# color points differently if they are within the two intervals | ||
colors = lift(rs_h.interval, rs_v.interval) do h_int, v_int | ||
map(points) do p | ||
(h_int[1] < p[1] < h_int[2]) && (v_int[1] < p[2] < v_int[2]) | ||
end | ||
end | ||
scatter!(points, color = colors, colormap = [:black, :orange], strokewidth = 0) | ||
f | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.