I am trying to display a ColumnSeries with a LineSeries on a CategoryDateTimeXAxis-based XamDataChart. The ColumnSeries data points are meant to indicate an event and intensity value at a certain point in time, but when rendered, the ColumnSeries element widths expand to fill the screen which makes it impossible to see the time it occurred. How can I create a ColumnSeries (or other) that will draw a fixed-width bar (say 5 pixels) at a specific date/time on a CategoryDateTimeXAxis and not expand to fill the entire width of the graph?
I have tried Gap, Width and Thickness, but none of these work well with a CategoryDateTimeXAxis-based chart.
Thanks Rob, your example works but is more complicated than I was willing to implement (figuring out what the widths should be based on chart size, zoom, intervals, etc) so I took another approach which was overlaying a visible CategoryDateTimeXAxis of line series with a hidden CategoryXAxis that just contains the column series that have their DateTime.Ticks (long) values as the categories. I then found the greatest common divisor of all of the column series X values (DateTime in ticks) and used that number and an expected category "interval" to back-fill the series data with the "blank" interval values where needed. After that, I have to adjust the DateTime min/max values of the CategoryDateTimeXAxis by half of the GCD/interval value for all series to line up on the right time tick marks (columns stacked or side-by-side groups are centered on the relevant time value). A similar algorithm would be a good addition to include natively somewhere in the Infragistics WPF chart control set, but this implementation works outside of having that.
As a note, this causes an issue with the way I need the x-axis tick labels to display, but I'll post another question on that since it is a more general problem.
Hi Gary,
The ColumnSeries has no property that will allow you to control the width of the columns. This width is entirely controlled by the series rendering code and it's designed to fill the space evenly between all columns. For CategoryDateTimeXAxis this is a little different as the columns can be spaced unevenly across a date range.
With that being said, there's nothing stopping you from grabbing the Rectangle objects and adjusting their widths after the series has rendered itself. There is an event called RefreshCompleted which fires after the chart has rendered. You can go through the ColumnSeries.RootCanvas and grab the Rectangles, then adjust their widths to your desired amount. You will also need to change their position since their current position is determined by the width that the series thinks the column has. This is done by adjusting the RenderTransform of the Rectangle. It uses a TranslateTransform to position the columns.
Take a look at my attached sample. If you'd like to see this feature built into the product by default I recommend that you submit this as a product idea here: http://ideas.infragistics.com