Cluster Location limitation and Bounds bug

3 posts, 0 answers
  1. Magnus
    Magnus avatar
    11 posts
    Member since:
    May 2015

    Posted 28 Feb 2018 Link to this post

    It seems like there's a limitation to Cluster locations and a bug regarding its Bounds. I noticed that the location of a Cluster is always at the location of the first item added to it. I would expect that it actually would be at the center of all added items. Looking at the ClusterData.Add method it seems like it would be easy to update the Cluster-location there since the bounds are updated each time a new item is added. I tried solving it by overriding the DefaultClusterGenerator like the code below, but then I noticed that the calculation for the Bounds are actually wrong in the ClusterData.Add method. The last Math.Min should be a Math.Max. In the end I had to calculate the Bounds myself, and then update the Cluster Location.

     

    public class ClusterGenerator : DefaultClusterGenerator
     
    {
        public override ClusterData CreateCluster(Location center, object item)
        {
            var clusterData = base.CreateCluster(center, item);
            clusterData.AutoCalculateBounds = true;
     
            clusterData.PropertyChanged += this.ClusterDataOnPropertyChanged;
            return clusterData;
        }
        private void ClusterDataOnPropertyChanged(object sender, PropertyChangedEventArgs args)
        {
            // Check if an item has been added or removed
            if (args.PropertyName == nameof(ClusterData.Count))
            {
                var clusterData = sender as ClusterData;
                if (!clusterData.Bounds.IsEmpty)
                {
                    clusterData.Location = clusterData.Bounds.Center;
                }
            }
        }
    }
  2. Dinko
    Admin
    Dinko avatar
    899 posts

    Posted 05 Mar 2018 Link to this post

    Hello Magnus,

    Thank you for the provided code snippet.

    I am currently investigating this behavior. I will contact you again as soon as I have more information about your case.

    Regards,
    Dinko
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Petar Mladenov
    Admin
    Petar Mladenov avatar
    3086 posts

    Posted 06 Mar 2018 Link to this post

    Hello Magnus,

    We understand your requirement for the center of the cluster. This is a valid request and you can submit it in our feedback portal. To be honest, we need to evaluate the performance and the behavior of the cluster if we change the way its Location is calculated. As for the Bounds, we managed to isolate the issue and a fix for it will be available in the in the build next week. We logged it in our portal and increased your telerik account points as thanks for your cooperation.

    Regards,
    Petar Mladenov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
Back to Top