I have two bar series. X axis is date-time. The series are set to be displayed adjacently (series.MultiBarMode = MultiBarMode.Clustered)
Everything is fine unless all X values are same. In this case the X scale collapses in one dot and the axis displays only seconds without date: "01". This happens when I use any MultiBarMode except MultiBarMode.Series.
The code is following:
public partial class Form1 : Form
{
public void ConfigureChart(DataView data, bool primary)
{
NChartControl chartControl = nChartControl1;
chartControl.DataBindingManager.RemoveAllBindings();
NChart chart = chartControl.Charts[0];
chart.Axis(StandardAxis.SecondaryY).Visible = true;
NBarSeries series = (NBarSeries)chart.Series.Add(SeriesType.Bar);
series.MultiBarMode = MultiBarMode.Clustered; //!!
series.DisplayOnAxis(StandardAxis.PrimaryY, primary);
series.DisplayOnAxis(StandardAxis.SecondaryY, !primary);
series.UseXValues = true;
chartControl.DataBindingManager.RemoveAllBindings();
NDateTimeScaleConfigurator xsc = new NDateTimeScaleConfigurator();
chart.Axis(StandardAxis.PrimaryX).ScaleConfigurator = xsc;
NOrdinalScaleConfigurator ysc = new NOrdinalScaleConfigurator();
chart.Axis(StandardAxis.PrimaryY).ScaleConfigurator = ysc;
NLinearScaleConfigurator yprimesc = new NLinearScaleConfigurator();
chart.Axis(StandardAxis.SecondaryY).ScaleConfigurator = yprimesc;
int index = chart.Series.IndexOf(series);
chartControl.DataBindingManager.AddBinding(0, index, "XValues", data, "x");
chartControl.DataBindingManager.AddBinding(0, index, "Values", data, "y");
chartControl.Refresh();
}
public Form1()
{
InitializeComponent();
DataTable t = new DataTable();
t.Columns.Add("x", typeof(DateTime));
t.Columns.Add("y", typeof(double));
t.Rows.Add(new DateTime(2000, 10, 10, 1, 1, 1), 10);
t.Rows.Add(new DateTime(2000, 10, 10, 1, 1, 1), -10);
t.Rows.Add(new DateTime(2000, 10, 10, 1, 1, 1), 10);
t.Rows.Add(new DateTime(2000, 10, 10, 1, 1, 1), -10);
t.Rows.Add(new DateTime(2000, 10, 10, 1, 1, 1), 0);
ConfigureChart(t.DefaultView, true);
ConfigureChart(t.DefaultView, false);
}
}
Am I doing something wrong? How to fix the axis label to display full date, not only seconds?
Thank you.
Mike Arkhipov