Hello
I have a XamDataChart with an OlapXAxis.
By default the columns will adjust their width to fit all available space. This looks wierd when only showing few columns, so I need a way to set a max width on the columns. I've read about the Gap property on the CategotyXAxis, but I am not able to find it on OlapXAxis.
Can you assist me?
Hello logimatic,
I have been investigating into this, and it appears that the Gap property does not exist on the OlapXAxis, and at the moment, there is no built in way to determine the width of the columns of a ColumnSeries using an OlapXAxis.
I have been crafting a workaround to this, in that you can get your ColumnSeries from the Series collection of the XamDataChart. The ColumnSeries has a RootCanvas property, which returns the drawing Canvas. Inside of this Canvas' Children collection exist the Rectangles that make up the "columns" of your series. You can set the Width of these.
Where this becomes tricky is that this will offset these rectangles from center. Each Rectangle has a TranslateTransform attached to its RenderTransform property, though, and if you increment this TranslateTransform's X value by a factor of ((original width of rectangle - desired width of rectangle) / 2), you can re-center these columns. This gets further trickier, though, in that the rectangles will try to resize when the chart is resized or when it zooms. To avoid this, I would recommend making this resize again in the SizeChanged event of the rectangles, as this will allow you to check the new size and resize them if the new size is not your desired one.
All of this sizing can happen in the ResultChanged event of the Olap data source that you are using with your OlapXAxis, but I would recommend using a Dispatcher.BeginInvoke action in order to ensure that the columns are all drawn before trying to perform this sizing.
I have attached a sample project to demonstrate the above.
If you would like to see the Gap property or another sizing method included in a future version of the OlapXAxis and XamDataChart, I would recommend suggesting a new product idea for this feature at http://ideas.infragistics.com. This product ideas site places you in direct communication with our product management teams who plan and prioritize upcoming features and development based on community and user feedback.
Please let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate Developer