-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow a way to set options for Clustering like setMinClusterSize #388
Comments
If you would like to upvote the priority of this issue, please comment below or react on the original post above with 👍 so we can see what is popular when we triage.@srenrd Thank you for opening this issue. 🙏
This is an automated message, feel free to ignore. |
Hi @srenrd . The following PR will allow using custom renderers. This will allow you to use setMinClusterSize. Please stay tuned! |
@Jasperav no i've yet to create a custom manager. Like you, it seems overkill that if you want to customize a single property you have to customize everything. |
@kikoso Can you please respond to this what the most easiest way is now with the linked PR? As far as I can see is that I have to write my complete renderer while I just want to customize 1 single property on the DefaultRenderer. |
Hi @Jasperav . Depending on the property you want to modify, a custom Renderer or a Manager could serve you. I understand it can feel like overkill, but on the other hand, exposing internal properties on the On the other hand, arguably a Compose API could benefit from having the Let me create a PR where we can discuss this. |
@kikoso any update on this? Is there any target to add such an option? |
@kikoso I submitted #473 for discussion around this issue. When using the default renderer, it made sense to me allow an optional Clustering(
items = items,
minClusterSize = 3,
// ...
) I'm not sure if this is what you were thinking or not... just trying to help things along. |
Hi @darronschall , One counterargument against this is that we are expanding the Clustering() interface with items that do not fully belong to the Clustering itself, but to the renderer. This in its own does not pose any risk, but the problem here is to draw a line. Is the I am tempted to say that the best solution would be to refactor the underlying Then, when this is implemented, we could do this on the clusterManager:
If this sounds good I can put a PR together to discuss it. |
@kikoso I suspect the common case is using Unfortunately, both I agree with your concerns on where to draw the customization line. I think the pain point here is that it's hard to get a handle on the default renderer to change it, and it's also hard to create and use a custom renderer. There isn't a combination of both The The All of that said, the workaround for this bug is really just piecing together the different parts of the library in perhaps a non-obvious-to-newcomers way. It's not a bug in the code, it's a "bug" in the current API design; it's possible to set For example, to change the existing the val clusterManager = rememberClusterManager<MyItem>()
val clusterRenderer = rememberClusterRenderer(
clusterContent = { cluster ->
CircleContent(
modifier = Modifier.size(40.dp),
text = "%,d".format(cluster.size),
color = Color.Blue,
)
},
clusterItemContent = null,
clusterManager = clusterManager,
) as? DefaultClusterRenderer
LaunchedEffect(clusterManager, clusterRenderer) {
clusterRenderer?.let {
clusterRenderer.minClusterSize = 2 // <--- here!
clusterManager?.renderer = clusterRenderer
clusterManager?.setOnClusterClickListener {
Log.d(TAG, "Cluster clicked! $it")
false
}
clusterManager?.setOnClusterItemClickListener {
Log.d(TAG, "Cluster item clicked! $it")
false
}
clusterManager?.setOnClusterItemInfoWindowClickListener {
Log.d(TAG, "Cluster item info window clicked! $it")
}
}
}
clusterManager?.let {
Clustering(
items = items,
clusterManager = clusterManager,
)
} ... that's a lot of effort just for that one I don't have a strong opinion on a path forward, but I lean towards making |
@kikoso What do you think about the approach I took in be54c55 instead? Rather than clutter I updated Clustering(
items = items,
// Optional: Handle clicks on clusters, cluster items, and cluster item info windows
onClusterClick = {
Log.d(TAG, "Cluster clicked! $it")
false
},
onClusterItemClick = {
Log.d(TAG, "Cluster item clicked! $it")
false
},
onClusterItemInfoWindowClick = {
Log.d(TAG, "Cluster item info window clicked! $it")
},
// Optional: Custom rendering for clusters
clusterContent = { cluster ->
CircleContent(
modifier = Modifier.size(40.dp),
text = "%,d".format(cluster.size),
color = Color.Blue,
)
},
// Optional: Custom rendering for non-clustered items
clusterItemContent = null,
onClusterManager = { clusterManager ->
(clusterManager.renderer as DefaultClusterRenderer).minClusterSize = 2
},
) 👍 / 👎? Was this more in line with what you had in mind? |
The fix from @darronschall looks pretty good 👍 Would we be able to prioritise this? |
I'm really missing a way to customize the MinClusterSize on the Clustering composable.
The text was updated successfully, but these errors were encountered: