@@ -23,35 +23,35 @@ public struct GraphRangeSlider<Data, ID>: View where Data: RandomAccessCollectio
2323 @Environment ( \. toggleRadius) private var toggleRadius : CGFloat
2424 @Environment ( \. sliderBarHeight) private var sliderBarHeight : CGFloat
2525 @Environment ( \. margin) private var margin : CGFloat
26+ @Environment ( \. isHiddenChart) private var isHiddenChart : Bool
2627
2728 public var body : some View {
28- Chart ( data, id: id) { data in
29- BarMark (
30- x: . value( PlottableKeys . x, String ( describing: data. x) ) ,
31- y: . value( PlottableKeys . y, data. y) ,
32- width: builder. barDimension. call ( data) ? . width ?? . automatic,
33- height: builder. barDimension. call ( data) ? . height ?? . automatic
34- )
35- . foregroundStyle (
36- by: . value(
37- PlottableKeys . status,
38- selectedData. contains ( data) ? Status . active: Status . inactive
39- )
40- )
41- }
42- . padding ( . horizontal, toggleRadius * 2 )
43- . padding ( . bottom, toggleRadius + sliderBarHeight / 2 + margin)
44- . chartXAxis ( . hidden)
45- . chartYAxis ( . hidden)
46- . chartLegend ( . hidden)
47- . chartForegroundStyleScale ( [
48- Status . active: activeColor,
49- Status . inactive: inactiveColor
50- ] )
51- . background (
52- Color . clear. viewSize { width = $0. width }
53- )
54- . overlay ( alignment: . bottom) {
29+ VStack ( spacing: margin) {
30+ if !isHiddenChart {
31+ Chart ( data, id: id) { data in
32+ BarMark (
33+ x: . value( PlottableKeys . x, String ( describing: data. x) ) ,
34+ y: . value( PlottableKeys . y, data. y) ,
35+ width: builder. barDimension. call ( data) ? . width ?? . automatic,
36+ height: builder. barDimension. call ( data) ? . height ?? . automatic
37+ )
38+ . foregroundStyle (
39+ by: . value(
40+ PlottableKeys . status,
41+ selectedData. contains ( data) ? Status . active: Status . inactive
42+ )
43+ )
44+ }
45+ . chartXAxis ( . hidden)
46+ . chartYAxis ( . hidden)
47+ . chartLegend ( . hidden)
48+ . chartForegroundStyleScale ( [
49+ Status . active: activeColor,
50+ Status . inactive: inactiveColor
51+ ] )
52+ . padding ( . horizontal, toggleRadius * 2 )
53+ }
54+
5555 if !positions. isEmpty {
5656 Slider (
5757 positions: positions,
@@ -62,6 +62,9 @@ public struct GraphRangeSlider<Data, ID>: View where Data: RandomAccessCollectio
6262 . frame ( height: toggleRadius * 2 )
6363 }
6464 }
65+ . background (
66+ Color . clear. viewSize { width = $0. width }
67+ )
6568 . onChange ( of: leftCurrentIndex) { _ in
6669 onChangedSelectedData ( )
6770 }
0 commit comments