Skip to content

Commit

Permalink
Bottom insets for LabelPosition.Bottom and ask for super's insets in …
Browse files Browse the repository at this point in the history
…Marker.kt
  • Loading branch information
L-Andrade committed May 23, 2024
1 parent 46c56ad commit f56e3fd
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,14 +101,18 @@ internal fun rememberMarker(
horizontalDimensions: HorizontalDimensions,
) {
with(context) {
outInsets.top =
super.getInsets(context, outInsets, horizontalDimensions)
val shadowClipping =
(
CLIPPING_FREE_SHADOW_RADIUS_MULTIPLIER * LABEL_BACKGROUND_SHADOW_RADIUS_DP -
LABEL_BACKGROUND_SHADOW_DY_DP
)
.pixels
if (labelPosition == LabelPosition.AroundPoint) return
outInsets.top += label.getHeight(context) + labelBackgroundShape.tickSizeDp.pixels
when (labelPosition) {
LabelPosition.Top -> outInsets.top += shadowClipping
LabelPosition.Bottom -> outInsets.bottom += shadowClipping
LabelPosition.AroundPoint, LabelPosition.AbovePoint -> Unit
}
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,8 +191,17 @@ public open class DefaultCartesianMarker(
outInsets: Insets,
horizontalDimensions: HorizontalDimensions,
) {
if (labelPosition == LabelPosition.AroundPoint) return
with(context) { outInsets.top = label.getHeight(context) + label.tickSizeDp.pixels }
when (labelPosition) {
LabelPosition.Top, LabelPosition.AbovePoint -> with(context) {
outInsets.top = label.getHeight(context) + label.tickSizeDp.pixels
}

LabelPosition.Bottom -> with(context) {
outInsets.bottom = label.getHeight(context) + label.tickSizeDp.pixels
}

LabelPosition.AroundPoint -> Unit // Will be inside the chart
}
}

/** Specifies the position of a [DefaultCartesianMarker]’s label. */
Expand Down

0 comments on commit f56e3fd

Please sign in to comment.