version 2.0.0-alpha.19 custom marker value formatter issue #696
-
Hi, Is there a way to fix this? This is how I call my CustomMarkerLabelFormatter. (what is the purpose of the label here? it would be ideal if we can pass custom labels to the marker from here. )
This is my custom class. I am not sure how to draw that background shape here. :(
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
Hello! Drawing is performed by The first approach is to keep using @@ -80,6 +80,7 @@
return remember(label, labelPosition, indicator, showIndicator, guideline) {
object : DefaultCartesianMarker(
label = label,
+ valueFormatter = /* ... */,
labelPosition = labelPosition,
indicator = if (showIndicator) indicator else null,
indicatorSizeDp = 36f, The second approach is to modify your existing code so that, like Finally, I’m not sure I understand what you’re referring to when you say that “it would be ideal if we could pass custom labels” from rememberDefaultCartesianMarker(
label = /* ... */,
valueFormatter = { context, targets -> /* ... */ },
// ...
) If |
Beta Was this translation helpful? Give feedback.
-
Hi @patrickmichalik , Thanks a lot for the detailed reply. I went with the first approach and everything looks ok now. about my comment, well I understand it better now and I agree with you that having a valueFormatter gives more flexibility, but still, when someone needs to add a custom label (especially for stacked charts) they need to follow a similar approach as in my Hope you understand this time and just don't bother about it too much. you guys are doing an awesome job already. 👍 Thanks again! |
Beta Was this translation helpful? Give feedback.
Hello!
CartesianMarkerValueFormatter
s don’t draw anything, and neither didMarkerLabelFormatter
s. The only responsibility of implementations of these interfaces is formatting values for display, hence theCharSequence
return type.Drawing is performed by
TextComponent
. A distinction should be made between the label text and theTextComponent
that draws the label. The purpose of thelabel
parameter ofrememberDefaultCartesianMarker
is to let you pass aTextComponent
and customize such properties as the font, the text size, and—most importantly here—the background. Indeed, as can be seen here, therememberMarker
function from the sample app, which you were previously using, creates aTextCo…