is there an easy way in the codehind to acces the Text in the picture that is the category on the X axis of the Olap Axis. in the attached sample it would be the text: Ford, Audi
thanks
Hello,
Thank you for your post. I have been looking into your question and you can use two approaches. The first is to get the OlapLabelControl elements and the second is to use the Result of the FlatDataSouce and to access the Member corresponding to the labels of the OlapXAxis.
For the first approach, you can use function similar to the following:
private T GetChildFromType<T>(DependencyObject parent) where T : DependencyObject
{
T result = null;
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(parent); i++)
if (VisualTreeHelper.GetChild(parent, i) is T)
return VisualTreeHelper.GetChild(parent, i) as T;
}
else
result = GetChildFromType<T>(VisualTreeHelper.GetChild(parent, i));
if (result != null)
break;
return result;
To get the OlapLabelPanelHorizontal, which is a child of the XamDataChart and holds the OlapLabelControls. After getting the panel, you can iterate through its Children collection for get each individual OlapLabelControl:
OlapLabelPanelHorizontal labelPanel = GetChildFromType<OlapLabelPanelHorizontal>(DataChart);
if (labelPanel != null)
foreach (OlapLabelControl label in labelPanel.Children)
//Do something.
For the second approach. You can use the FlatDataSouce.Result.ColumnAxis.Tuples (or RowAxis, based on what is the value of OlapAxisSource property of the OlapXAxis). To get the text of the label, you can get the first Member of each Tuple and get its Caption property:
FlatDataSource flat = Resources["OlapFlatDataSource"] as FlatDataSource;
foreach (var tpl in flat.Result.ColumnAxis.Tuples)
Member member = tpl.Members[0] as Member;
//member.Caption
I am attaching a sample application that shows how you can implement this approach.
Please let me know if you need any further assistance on the matter.
Sincerely,
Krasimir, MCPD
Developer Support Supervisor - XAML
Infragistics
https://www.infragistics.com/support
the sample works great. i think i may have described my issue incorectly. what i am to do is figue out if a series belongs to a certain category when its created. i am current testing code in
olapXAxis_SeriesCreating
I am using the code that is on the sampe site to create the tool tips , i would like the call something like this in there but be able to determine if the series that is being created belongs to that Cateory. is this possible?
I have been looking into your requirement and I can say that the Series creating event fires for each series that is created. In the Samples browser three Series are created for Sold New, Sold Old and Sold Total Items. Also here:
https://www.infragistics.com/samples/silverlight/data-chart/#/olap-axis
it is shown how to add ToolTip, but in the event handler you are not able to determine the group, because the Series adds Column in each group. Please let us know if you have further questions on this matter
so bascially there is no way to do this?
i an trying to color one group one color and the next group no matter how many cols all the same color but a diff color from group one
is there a different event i could use?
Thank you for your reply and the clarification on the appearance that you are trying to achieve. By default the different colors of the rectangles in the OlapXAxis are based on the different series, which are generate by the measures that are added to the ItemsSource.
If you wish to color the rectangles by the root level of the hierarchy (“Audi”, “Ford”,…), what I can suggest is creating an attached behavior that is handling the LayoutUpdated event of the Rectangles used in the OlapXAxis and there, using the DataContext of the Rectangles, you can access the OlapAxisCell, from which you can get the ultimate parent of the current rectangle and color the rectangles as you described. I have modified the sample application that I have originally provided you with, to show how you can implement this approach.
Please note, that you should use the latest service release of version 13.1, in order to be able to use this approach, since in the previous versions, there were an issue that results in the Item property of the DataContext of the Rectangles to be null.
it looks like that would work but i think it is not working with 13.2. i do not have 13.1 installed so i can not test with it. using 13.2.20132.1000
DataContext context = (AssociatedObject as Rectangle).DataContext as DataContext;
if (context.Item != null)
the 'Item' is null every time. i am assuming it should have a value?
Thank you for your reply. As I have mentioned, there were an issue in the OlapXAxis, that resulted in Item to be always null and this issue is fixed in the latest service releases of version 13.1 and also in 13.2. I can suggest installing the latest service release of version 13.2 and test the application with it.
I am just checking if you require any further assistance on the matter.
i guess this didnt get fixed in 14.2 either?
This isn't fixed in 15.2 either. It is still null.