Ticket T805650
Visible to All Users

How to change the bubble chart size at runtime

created 6 years ago

Hi

I need to display a bunch of symbols on a GIS map . The size of each symbol denotes some value (for example the population of a city). I am using the BubbleChartDataAdapter and it seems to do exactly that.
My problem is that the values are changing over time, but I cannot find a way to update the adapter in order to reflect the change in the symbol's size

Is it possible in general to update the bubbles at runtime or do I have to do something custom?

Here is a very crude example where I try to change the bubble's size when I click on a symbol (working project also attached)

C#
using DevExpress.XtraMap; namespace bubble { public partial class Form1 : DevExpress.XtraEditors.XtraForm { private MyClass[] MyData; public Form1() { InitializeComponent(); bubbles.Data = CreateData(); // bubbles is a VectorItemsLayer mapControl1.MapItemClick += MapControl1OnMapItemClick; } private void MapControl1OnMapItemClick(object sender, MapItemClickEventArgs e) { // trying to edit the source object, not working var obj = bubbles.GetItemSourceObject(e.Item) as MyClass; if (obj != null) { obj.Size += 5; } // changin the bubble's size directly doesnt work either var mb = e.Item as MapBubble; mb.Size += 5; } private IMapDataAdapter CreateData() { MyData = new MyClass[4]; MyData[0] = new MyClass { Lat = 36.475, Lon = 70.14, Size = 5 }; MyData[1] = new MyClass { Lat = 36.475, Lon = -73.059, Size = 10 }; MyData[2] = new MyClass { Lat = -15.877, Lon = -73.059, Size = 15 }; MyData[3] = new MyClass { Lat = -15.877, Lon = 70.14, Size = 20 }; var adapter = new BubbleChartDataAdapter { DataSource = MyData, ItemMaxSize = 50, ItemMinSize = 10, ValueMember = "Size", LatitudeMember = "Lat", LongitudeMember = "Lon" }; return adapter; } } class MyClass { public double Lat { get; set; } public double Lon { get; set; } public double Size { get; set; } } }

Answers approved by DevExpress Support

created 6 years ago

Hi,

To resolve this issue, reset the BubbleChartDataAdapter.DataSource property to recreate the Bubble Chart layout after modifying the data source collection.

C#
private void MapControl1OnMapItemClick(object sender, MapItemClickEventArgs e) { var obj = bubbles.GetItemSourceObject(e.Item) as MyClass; if (obj != null) { obj.Size += 5; } BubbleChartDataAdapter adapt = (BubbleChartDataAdapter)bubbles.Data; adapt.DataSource = null; adapt.DataSource = MyData;

Alternatively, change the MyData object type to BindingList<MyClass> and implement the INotifyPropertyChanged interface at your data source object level (MyClass).

    Comments (1)
    GK GK
    George Kalatzantonakis 1 6 years ago

      The INotifyPropertyChanged  solution works, thank you

      Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

      Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.