Hi
I am using Infragistics 11.2 xamchart control.The propblem I am facing is
In my model i have something like this
public
double
XValue
{
get
return
m_xValue;
}
set
m_xValue =
value
;
OnPropertyChanged(
"XValue"
);
public double
YValue
m_yValue;
m_yValue =
"YValue"
public string
Label
m_label;
m_label =
"Label"
In my view model i have
ObservableCollection<Model
> _MyProperty;
public IEnumerable<Model
> MyPropertyA
get { return _MyProperty.Where<Model>(s => s.Label == "A"
); }
> MyPropertyB
get { return _MyProperty.Where<Model>(s => s.Label == "B"
ViewModel()
_MyProperty=
new ObservableCollection<Model
>
new Model{YValue=1000,XValue=.1,Label = "A"
},
new Model{YValue=1000,XValue=.1,Label = "B"
new Model{YValue=2000,XValue=.2,Label = "A"
new Model{YValue=4000,XValue=.2,Label = "B"
new Model{YValue=3000,XValue=.3,Label = "A"
new Model{YValue=6000,XValue=.3,Label = "B"
new Model{YValue=4000,XValue=.4,Label = "A"
new Model{YValue=9000,XValue=.4,Label = "B"
};
Now in xaml i am binding the series like this
<igCA:XamChart.Series
<igCA:Series ChartType="ScatterLine" DataSource="{Binding MyPropertyA}" DataMapping="ValueX=XValue; ValueY=YValue" Label="{Binding Label
}" >
<igCA:Series.Marker
<igCA:Marker Foreground="{Binding Fill}"></igCA:Marker
</igCA:Series.Marker
</igCA:Series
<igCA:Series ChartType="ScatterLine" DataSource="{Binding MyPropertyB}" DataMapping="ValueX=XValue;ValueY=YValue" Label="{Binding Label
}">
<igCA:Marker Foreground="{Binding Fill}" ></igCA:Marker
</igCA:XamChart.Series
The chart gets plotted fine but the problem is that in the legend instead of A and B item 0 and item 1 is coming .Please help what can i do about it.
Also if i have suppose 4 series and each gets generated only when user gives some input for them through a grid or something, is it possible to show the legend for only the series that have been generated.
Thanks in advance
Hello,
Thank you for your post. I have been looking into it and if I understand correctly, the issue that you are having is that the text for the items in the Legend is not “A” for the first series and “B” for the second. The reason for the text in the legend to not display those values is that you are setting the Label property of the Series to Binding with path Label and since your view model (which is the DataContext for the Window and the Series) the XamChart is displaying the default values in the Legend. I assume that you wish to display the Label of the items in the corresponding collection that is used as DataSource for the Series. To do that you can bind the Label property of the series to the Label property of the first item of the DataSource.
Regarding the functionality that you have described, for not showing item in the Legend, if the series does not contain data, I can suggest using XamDataChart, instead of the XamChart. The Series in the XamDataChart, provides a property called LegendItemVisibility, that can be used in order to show or hide the legend item for a series. You can bind the LegendItemVisibility property of the Series, to the Count of property of the ItemsSource and using a converter to return Visible if the count is bigger than 0 and Collapsed if it is not. The XamDataGrid is providing more accurate control over its elements and also better performance and since the XamChart control is already retired (you can read more detailed information here: http://es.infragistics.com/community/blogs/jason_beres/archive/2011/11/10/important-product-changes-and-control-retirements-in-2011-2.aspx), I can suggest using XamDataChart. I have create a sample application for you, that demonstrates how you can implement the approach I have mentioned.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hi,
Thanks for the reply now i am using xamdatachart but the problem is I am generating series only when the user gives value to a certain control.If no value is there the legend shows the text as series title.What i am trying to do is that if no data is there for the series there should be nothing for it in legend not even the default text(series title).
Hello Manuj,
Thank you for your reply. I have been reading through it and I am not completely sure what is the exact scenario that you are having. Would you please provide me with more detailed description on how and when the series are generated and if possible, would you please modify the sample application that I have attached with my previous reply, in order to demonstrates how you are generating the series, in order to be able to research, how the items in the Legend can be hidden, more accurately?
Looking forward to hearing from you.
I am just checking if you require any further assistance on the matter.