Is it possible to display a LineSeries X/Y graph that contains only one point? For two or more points, it works great, but one point is not shown even PointGeometry is set to some shape. At least in this variant, I would expect to see a single point for one-point series. Is there any way to enable it?
EDIT: I'm really sorry for the slow response, I wasn't at the computer. Sach's answer moved me, but I still have no solution. Look at my code - modification of Sach's sample. If I use my own data type and formatter for the axis, it only works with one point if it is specified in the constructor. If I create an empty serie, will the graph show up when I add at least two points? (see handler mouse down)
public partial class MainWindow : Window
{
LineSeries lineSeries;
public SeriesCollection SeriesCollection { get; set; }
public Func<double, string> XFormatter { get; set; }
public Func<double, string> YFormatter { get; set; }
public MainWindow()
{
InitializeComponent();
var dayConfig = Mappers.Xy<DateModel>()
.X(dayModel => (double)dayModel.DateTime.Ticks / TimeSpan.FromHours(1).Ticks)
.Y(dayModel => dayModel.Value);
lineSeries = new LineSeries()
{
//Values = new ChartValues<DateModel>{ new DateModel(DateTime.Now, 3) }, //this works
Values = new ChartValues<DateModel>(),
PointGeometry = DefaultGeometries.Circle
};
SeriesCollection = new SeriesCollection(dayConfig);
SeriesCollection.Add(lineSeries);
XFormatter = value => new System.DateTime((long)(value * TimeSpan.FromHours(1).Ticks)).ToString("HH:mm");
YFormatter = value => value.ToString("0.0000");
DataContext = this;
}
public class DateModel
{
public DateModel(DateTime timestamp, double value)
{
DateTime = timestamp;
Value = value;
}
public System.DateTime DateTime { get; set; }
public double Value { get; set; }
}
private void OnMouseDown(object sender, MouseButtonEventArgs e)
{
lineSeries.Values.Add(new DateModel(DateTime.Now, 3));
}
}