How to show guidelines only for labels on Horizontal axis #768
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 3 replies
-
In my code, I solved it using getXstep. @Composable
fun ECGChart(
modifier: Modifier,
dataList: List<Float>,
) {
val cartesianChartModel =
CartesianChartModel(LineCartesianLayerModel.build { series(dataList) })
Column(
modifier = modifier,
) {
CartesianChartHost(
chart = rememberCartesianChart(
rememberLineCartesianLayer(
lines = listOf(
rememberLineSpec(
shader = DynamicShader.color(Color(0xFF65A7BE)),
thickness = 1.dp,
backgroundShader = null,
),
),
),
startAxis = rememberStartAxis(),
bottomAxis = rememberBottomAxis(
guideline = null,
itemPlacer =
remember {
AxisItemPlacer.Horizontal.default(
addExtremeLabelPadding = true,
)
},
),
),
getXStep = { 100f },
model = cartesianChartModel,
zoomState = rememberVicoZoomState(zoomEnabled = false),
scrollState = rememberVicoScrollState(
scrollEnabled = true,
initialScroll = Scroll.Absolute.End
),
marker = rememberDefaultCartesianMarker(
label = rememberTextComponent(
textSize = 10.sp,
typeface = NotosanskrTypography.bodySmall.toGraphicsTypeFace(),
),
),
horizontalLayout = HorizontalLayout.FullWidth(),
)
}
}
|
Beta Was this translation helpful? Give feedback.
-
Hello, @anshu7vyas! Thanks for the kind words. Applying CartesianChartHost(horizontalLayout = HorizontalLayout.fullWidth(), /* ... */)
If you have any questions, let me know. Thanks for your input, @npced16! |
Beta Was this translation helpful? Give feedback.
Hello, @anshu7vyas! Thanks for the kind words. Applying
HorizontalLayout.FullWidth
should do the trick:HorizontalLayout.FullWidth
is used in @npced16’s code snippet, and this is the key point. BothgetXStep
andAxisItemPlacer.Horizontal.default
’sspacing
andoffset
parameters affect what labels are added, but it’sHorizontalLayout
that defines (among other things) how ticks and guidelines are positioned relative to the labels. This is described here.If you have any questions, let me know. Thanks for your input, @npced16!