Hi,
I have two scatter series that represents points and another scatter series that draws the polygons based on some condition to connect these scatter points.
I built a bubble series to be displayed on some of the scatter points.
The issue that I ran into is:
- If I display either bubble series or scatter polygon series along with scatter , either one of the them is displayed.
If I keep bubble series with scatter series(polygons), then polygons are not drawn.
Here is the code:
<ig:XamDataChart Grid.Row="2" x:Name="chart" RefreshCompleted="chart_RefreshCompleted" HorizontalZoomable="True" VerticalZoomable="True" Margin="5,5,5,5" > <ig:XamDataChart.Axes> <ig:NumericXAxis x:Name="xAxis" MinimumValue="{Binding minXvalue}" MaximumValue="{Binding maxXvalue}" MajorStroke="Transparent" Label="{}{0:00}" /> <ig:NumericYAxis x:Name="yAxis" MinimumValue="{Binding minYvalue}" MaximumValue="{Binding maxYvalue}" MajorStroke="Transparent" Label="{}{0:00}" /> </ig:XamDataChart.Axes> <ig:XamDataChart.Series> <ig:BubbleSeries XMemberPath="Xlocation" YMemberPath="Ylocation" RadiusMemberPath="BubbleValue" FillMemberPath="BubbleValue" MarkerType="Circle" ShowDefaultTooltip="True" MarkerBrush="Black" XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ItemsSource="{Binding ComplianceProducerDataGrid}"> <ig:BubbleSeries.RadiusScale> <ig:SizeScale IsLogarithmic="False" MinimumValue="35" MaximumValue="70" /> </ig:BubbleSeries.RadiusScale> </ig:BubbleSeries>
<ig:ScatterSeries XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" MarkerType="Circle" Brush="SteelBlue" MarkerBrush="Green" ShowDefaultTooltip="True" ItemsSource="{Binding Data}" XMemberPath="XValue" YMemberPath="YValue"></ig:ScatterSeries>
<ig:ScatterSeries XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" MarkerType="Hexagon" Brush="SteelBlue" MarkerBrush="Blue" ShowDefaultTooltip="True" ItemsSource="{Binding Data_Inj}" XMemberPath="XValue" YMemberPath="YValue"></ig:ScatterSeries> <ig:ScatterSeries XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ItemsSource="{Binding ConnectData}" XMemberPath="XValue" YMemberPath="YValue"/>
</ig:XamDataChart.Series> </ig:XamDataChart>
Image1 (No Polygons): As you can see I don't see polygons
Image 2( Polygons but no Bubbles): I had to comment out bubble series in XAML to be able to see the polygons!
Thanks for looking into this Andrew.
Why is it necessary to add call to "Getbubbledata()" in the constructor itself?
In my scenario, user first picks the bubble variable via a combobox, then clicks on "connect shapes" button; the bubble data is populated after user picks the variable in UI. I believe adding a call to "getbubbledata()" in the constructor will not work in this scenario. That's why I set the call to "Getbubbledata" in the "private void connectShapes_Click(object sender, RoutedEventArgs e)".
do you think the bubble series will work with polygons only when it is called in constructor? I am confused.
Again, your version only works when call is made in the constructor.
Jay
Hello Jay,
I apologize, I didn't originally see the call to getBubbleData() in your button click. After removal of the getBubbleData() method call from the ViewModel constructor, I am now able to see the behavior you are seeing. This is still an issue with the sample project, though, and not the XamDataChart.
The reason for this is due to the instantiation of the DataBubble ObservableCollection<BubbleData> property, and the fact that it currently does not implement the INotifyPropertyChanged interface. In the getBubbleData() method call, you are setting this property to a new instance of ObservableCollection<BubbleData> at runtime due to the button click. Since you are not implementing INotifyPropertyChanged in this case, your UI will not be notified that anything has changed with that DataBubble collection, and so the BubbleSeries never updates.
As an alternative to implementing the INotifyPropertyChanged interface, you can also remove the instantiation of the DataBubble collection from your GetBubbleData() method, and instantiate it in the ViewModel's constructor. This doesn't necessarily mean you need to populate it there, but since it will already be instantiated, and since the ObservableCollection class implements INotifyCollectionChanged, this will allow you to see the changes to the data source when you do populate it via your button click.
I have attached a modified version of your sample project to demonstrate the above. I hope this helps.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Thanks Andrew for the explanation and the sample.
You mentioned that "Your UI will not be notified that anything has changed with that DataBubble collection, and so the BubbleSeries never updates" - But, if I comment out "polygon series" in XAML, the bubbles are displayed (even if I don't implement INotifyPropertyChanged to bubbledata collection/class). How does UI gets notified then? So, UI is not being notified when it is not commented out. Looks like polygon series collection is somehow affecting bubble series collection.
I noticed that you added the " ObservableModel" to "public class ViewModel". In my case, the public class viewmodel must be defined as :
public class Pattern_FillPluginModel : Analysis<Pattern_FillPluginModel> . In order to use INotifyChanged, I made the following changes to the observable collection and associated classes:
ObservableCollection<SampleData> _Data = new ObservableCollection<SampleData>(); public ObservableCollection<SampleData> Data // GET ALL DATA Points (completions) on the map { get { return _Data; } set { _Data = value; base.OnPropertyChanged("StringList"); } }
ObservableCollection<SampleData> _ConnectData = new ObservableCollection<SampleData>();
public ObservableCollection<SampleData> ConnectData { get { return _ConnectData; } set { _ConnectData = value; base.OnPropertyChanged("StringList"); }
} // For Pattern filling
ObservableCollection<BubbleData> _BubbleData = new ObservableCollection<BubbleData>(); public ObservableCollection<BubbleData> BubbleData { get { return _BubbleData; } set { _BubbleData = value; base.OnPropertyChanged("StringList");} }
CLASSES:
public class SampleData : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } public string wellname { get; set; } public string sectorname { get; set; } public double XValue { get; set; } public double YValue { get; set; } public string Shape { get; set; } }
public class BubbleData : INotifyPropertyChanged { public event PropertyChangedEventHandler PropertyChanged; private void NotifyPropertyChanged([CallerMemberName] String propertyName = "") { if (PropertyChanged != null) PropertyChanged(this, new PropertyChangedEventArgs(propertyName)); } public string Name { get; set; } public double Xlocation { get;set;} public double Ylocation { get; set; } public double BubbleValue { get; set; } }
But it did not work in my case! :(
With the previously attached sample project, I am unable to see the BubbleSeries show up if I remove the "Polygon Series" and click the button that instantiates and populates the BubbleData collection if the INotifyPropertyChanged interface implementation is removed from the BubbleSeries. Would it be possible for you to please provide a modified version of the sample project I sent you that shows the BubbleSeries working without the INotifyPropertyChanged interface? Perhaps you are instantiating the BubbleData collection in the constructor of your ViewModel in that case?
With your most recent code-sample, I see you are calling the OnPropertyChanged method for your BubbleData collection property, but you are passing in the string "StringList." This will look for a property named "StringList" to tell your UI that "StringList" has updated, in which case, your UI will still have no idea that BubbleData has updated. I would recommend that you make a call to OnPropertyChanged("BubbleData") in order to get the UI to be notified that your BubbleData collection has been instantiated in this case.
Thanks Andrew. It worked after i made the above change. I have another question but i will post separate question for that.
Cheers,