Profile Picture

Problem with bar chart in Clustered mode with DateTime scale

Posted By Mike Arkhipov 14 Years Ago

Problem with bar chart in Clustered mode with DateTime scale

Author
Message
Mike Arkhipov
Posted 14 Years Ago
View Quick Profile
Forum Newbie

Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)Forum Newbie (7 reputation)

Group: Forum Members
Last Active: 14 Years Ago
Posts: 7, Visits: 1
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


Attachments
clustered mode.png (40 views, 43.00 KB)



Similar Topics


Reading This Topic