Having ColumnSeries and a LineSeries within the same plot (CategoryAxis problem)

Mar 21, 2013 at 2:17 PM
Edited Mar 21, 2013 at 2:20 PM
Hi!
First of all I want to thank you for this great project, it saved me a lot of work already, its features are great!

I have run into a problem recently and I need some help: I have to show a ColumnSeries and a LineSeries on the same plot. The x-axis has to be time, and with the LineSeries out of the picture it works fine:
public class PlotData
{
        public DateTime TimeOnX { get; set; }
        public double DataOnY { get; set; }
        public string LabelOnX { get { return this.TimeOnX.ToString("yyyy.mm.dd"); } }
}
var plot = new PlotModel();
plot.Axes.Add(new CategoryAxis { ItemsSource = PlotDataItems, LabelField = "LabelOnX" });
plot.Axes.Add(new LinearAxis(AxisPosition.Left) { MinimumPadding = 0, AbsoluteMinimum = 0 });
plot.Series.Add(new ColumnSeries { ItemsSource = PlotDataItems, ValueField = "DataOnY" });
After adding LineSeries (plot.Series.Add(new LineSeries { ItemsSource = PlotDataItems, DataFieldX = "TimeOnX", DataFieldY = "DataOnY" });) I get a perfecly vertical line (every value is assigned to the "category of nothing").
Then I figured out I have to set the ItemsSource of the CategoryAxis a collection of DateTime instead of PlotData:
plot.Axes.Add(new CategoryAxis { ItemsSource = PlotDataItems.Select(x => x.TimeOnX), Labels = PlotDataItems.Select(x => x.LabelOnX).ToList() });
As it turns out, LabelField property cannot be null, however I want to use the DateTime object itself, not its properties. (I am not quite sure how it supposed to work exactly, I could not find any details.)

Sorry, if I have overlooked something important.

Thank You,
Zsolt