File tree Expand file tree Collapse file tree
routes/docs/examples/Compound Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ ---
2+ ' layerchart ' : patch
3+ ---
4+
5+ fix(Bars): Fix inverted rect when rendered top-to-bottom or right-to-left. Fixes #540
Original file line number Diff line number Diff line change 136136 const rounded = $derived (
137137 roundedProp === ' edge'
138138 ? isVertical
139- ? resolvedValue >= 0
139+ ? resolvedValue >= 0 && ctx . yRange [ 0 ] > ctx . yRange [ 1 ] // not inverted (bottom to top)
140140 ? ' top'
141141 : ' bottom'
142- : resolvedValue >= 0
142+ : resolvedValue >= 0 && ctx . xRange [ 0 ] < ctx . xRange [ 1 ] // not inverted (left to right)
143143 ? ' right'
144144 : ' left'
145145 : roundedProp
Original file line number Diff line number Diff line change @@ -152,6 +152,11 @@ export function createDimensionGetter<TData>(
152152 bottom = yValue ;
153153 }
154154
155+ // If yRange is inverted (drawing from top), swap top and bottom
156+ if ( ctx . yRange [ 0 ] < ctx . yRange [ 1 ] ) {
157+ [ top , bottom ] = [ bottom , top ] ;
158+ }
159+
155160 const y = ctx . yScale ( top ) + insets . top ;
156161 const height = ctx . yScale ( bottom ) - ctx . yScale ( top ) - insets . bottom - insets . top ;
157162
Original file line number Diff line number Diff line change 247247 padding ={{ left : 32 , right : 32 , bottom : 20 }}
248248 props ={{
249249 bars : {
250- // TODO: Determine why non-rounded Rect within Bar is not working for inverted range
251- // rounded: 'none',
252- class : ' stroke-none fill-blue-500' ,
250+ rounded : ' none' ,
251+ class : ' _stroke-none fill-blue-500' ,
253252 },
254253 }}
255254 {renderContext }
You can’t perform that action at this time.
0 commit comments