Hi Team,
public class Service{
public string ServiceName{get;set;}
public string List {get;set;}
}
In which each service has a list of reports.Report structure is as below
public class Report{
public string ReportName{get;set;}
public int density{get;set;}
On X axis i wanted the service name that has list of report bars grouped together with the same colour of service, report bars are based on density value.
on xaxis service names should show up.
on report bars on the tooltip report name should be displayed
In simple words i wanted to display all the reports under services.But all services under a report should have the same colour and must be grouped.Also attached the screen shot of the requirement i need.
Tried the same way but it is not working as expected
Waiting for your help on this.Thanks in advance for all you do
Regards.
Sridhar
Hello Sridhar,
I am aware of the structure that you are currently using, but the hierarchical structure of your data source will not work correctly with the XamDataChart with the way that the chart is currently implemented.
From my understanding, you are trying to have the columns of the XamDataChart be represented by the Report objects that belong to your Services, and have the labels on the CategoryXAxis represent the service. For this to work with the current implementation of the chart, you will need to make sure that your data items are of the type Service, and that would not happen here, as your data items would currently be your reports, because the reports are what carry the ValueMemberPath for your ColumnSeries elements. In other words, binding your CategoryXAxis and your ColumnSeries elements to a collection of type "Service" here would not work in the XamDataChart with the current way that you have your service class set up.
This is why, in the sample project I had sent you, I had recommended that you utilize an external class or data table that has all of the information for the ValueMemberPaths and the services that those Report values belong to, because the XamDataChart has no way of parsing the hierarchy that is currently set up by your current "Service" class. That is what the SampleData class in the sample project I had sent you was meant to mimic. The issue here now becomes that since you are dynamically adding and removing your reports, you need a way to add a new ValueMemberPath dynamically to the data source so that you can add a new series representing that particular value path. Using a DataTable as a data source may help with this, as you could dynamically add columns to your data table programmatically for this purpose as you add reports to your service.
Regarding actually dynamically adding the ColumnSeries, the static series in the sample project were just there to show that this example works in the way that you wanted. The ColumnSeries can be created and added dynamically to the XamDataChart.Series collection if you wish to add more series to it. As an alternative, you can also use the SeriesBinder behavior for dynamic series creation that is discussed at the following forum thread: http://ko.infragistics.com/community/forums/t/97638.aspx.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer
Hello Andrew,
Thanks a lot for the example posted.But it doesnt meet my requirement completely.
The structure which you have defined is as follows:
public class SampleData
{
public string ServiceName { get; set; }
public string ReportName { get; set; }
public int Report1Density { get; set; }
public int Report2Density { get; set; }
public int Report3Density { get; set; }
But i wanted the report structure to be defined a level lower .
public class SampleData { public string ServiceName { get; set; } public List<Report> Reports { get; set; } }
public class Report { public string ReportName { get; set; } public int Density { get; set; } }
One more thing to mention is you have defined the series as static elements in the UI but in my requirement both the services and reports are dynamic
This is how you have mapped series as static elements:
<ig:XamDataChart.Series>
<ig:ColumnSeries XAxis="{Binding ElementName=xAxis}" YAxis="{Binding ElementName=yAxis}" ItemsSource="{Binding Data}"
ValueMemberPath="Report1Density" IsCustomCategoryStyleAllowed="True" AssigningCategoryStyle="ColumnSeries_AssigningCategoryStyle"
ToolTip="{StaticResource theTooltip}"/>
ValueMemberPath="Report2Density" IsCustomCategoryStyleAllowed="True" AssigningCategoryStyle="ColumnSeries_AssigningCategoryStyle"
ValueMemberPath="Report3Density" IsCustomCategoryStyleAllowed="True" AssigningCategoryStyle="ColumnSeries_AssigningCategoryStyle"
</ig:XamDataChart.Series>
But i wanted this part to be dynamic where i will provide density single column instead of static(Report3Density,Report3Density2,Report3Density1).The value member path needs to be dynamic
Thanks in advance for all you do.
Regards,
Sridhar.
Thank you for your post(s).
Unfortunately, this is not the way that the XamDataChart works with its ColumnSeries elements. The amount of ColumnSeries used for a particular category on the axis depends on the number of ColumnSeries elements that you have in your XamDataChart.Series collection, and for this to work, you would need a separate ValueMemberPath for each of the column series so that you could "group" by the services in your chart.
For your requirement to work, I would recommend having a separate class, or perhaps a DataTable with the number of value-properties (or columns) equal to the maximum number of reports in one of your services. Using this, you can have X number of ColumnSeries in your XamDataChart, where X is that number of value-properties or columns. For the "services" that don't have the maximum amount of reports, you can set the value for those reports to "0" or "null" if you use a nullable type, and the columns for that particular service will not show for the values that are null or 0, assuming you set the MinimumValue of your NumericYAxis to 0.
What this will do, is it will allow you to have multiple columns in your chart existing for each service in the chart. The issue now, is that each of these columns will be a different color for that particular service. This issue can be eliminated by handling the AssigningCategoryStyle event of the ColumnSeries. This allows you to color the columns of a column series individually, and to handle this event, you need to opt into it by setting the IsCustomCategoryStyleAllowed property of your ColumnSeries to "true" and then hook the event normally.
From the event arguments of this event, you can get the data item that a particular column represents, and color it according to the service that it represents in your application. The tooltip can also be set here, or on the ColumnSeries by setting the ToolTip property to a ContentControl of your creation.
I have attached a sample project that demonstrates how this can be done. I hope this helps you.
In the above mentioned structure the Service class is as follows.
Public class service
Public string service name{get;set;}
Public List<Report> Reports{get;set;}