Let me show a simple code below.
.aspx
<telerik:RadChart ID="RadChart3" runat="server" Width="1000" />
.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
DataTable chartdata = new DataTable();
chartdata.Columns.Add("date", typeof(DateTime));
chartdata.Columns.Add("value", typeof(double));
List<string> dates = new List<string>();
dates.Add("2010-06-01 02:44:35.753");
dates.Add("2010-06-01 02:45:54.753");
dates.Add("2010-06-01 02:47:13.543");
dates.Add("2010-06-01 02:48:32.600");
dates.Add("2010-06-01 02:49:51.730");
dates.Add("2010-06-01 02:51:10.640");
List<double> values = new List<double>();
values.Add(120);
values.Add(130);
values.Add(140);
values.Add(150);
values.Add(160);
values.Add(170);
int k = 0;
foreach (string strdate in dates)
{
DataRow cdr = chartdata.NewRow();
cdr[0] = DateTime.Parse(strdate);
cdr[1] = values[k];
chartdata.Rows.Add(cdr);
k++;
}
ChartSeries series = RadChart3.CreateSeries("value", Color.DarkBlue, Color.Empty, ChartSeriesType.Bar);
foreach (DataRowView drv in chartdata.DefaultView)
{
ChartSeriesItem item = new ChartSeriesItem();
item.XValue = DateTime.Parse(drv["date"].ToString()).ToOADate();
item.YValue = Math.Round(double.Parse(drv["value"].ToString()), 1);
series.Items.Add(item);
}
RadChart3.AutoLayout = true;
RadChart3.Series.Add(series);
RadChart3.Appearance.BarWidthPercent = 1;
RadChart3.PlotArea.XAxis.AutoScale = false;
RadChart3.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;
RadChart3.PlotArea.XAxis.AddRange(DateTime.Parse("2010-06-01 02:42:00").ToOADate(), DateTime.Parse("2010-06-01 02:52:00").ToOADate(), (double)1 / 1440);
RadChart3.PlotArea.YAxis.AutoScale = true;
}
And the chart is expected to show six bars.
Actually, however, the chart shows only 2 bars, because they are overlapped.
How can I solve this problem?
Thank you.
-Alex.
.aspx
<telerik:RadChart ID="RadChart3" runat="server" Width="1000" />
.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
DataTable chartdata = new DataTable();
chartdata.Columns.Add("date", typeof(DateTime));
chartdata.Columns.Add("value", typeof(double));
List<string> dates = new List<string>();
dates.Add("2010-06-01 02:44:35.753");
dates.Add("2010-06-01 02:45:54.753");
dates.Add("2010-06-01 02:47:13.543");
dates.Add("2010-06-01 02:48:32.600");
dates.Add("2010-06-01 02:49:51.730");
dates.Add("2010-06-01 02:51:10.640");
List<double> values = new List<double>();
values.Add(120);
values.Add(130);
values.Add(140);
values.Add(150);
values.Add(160);
values.Add(170);
int k = 0;
foreach (string strdate in dates)
{
DataRow cdr = chartdata.NewRow();
cdr[0] = DateTime.Parse(strdate);
cdr[1] = values[k];
chartdata.Rows.Add(cdr);
k++;
}
ChartSeries series = RadChart3.CreateSeries("value", Color.DarkBlue, Color.Empty, ChartSeriesType.Bar);
foreach (DataRowView drv in chartdata.DefaultView)
{
ChartSeriesItem item = new ChartSeriesItem();
item.XValue = DateTime.Parse(drv["date"].ToString()).ToOADate();
item.YValue = Math.Round(double.Parse(drv["value"].ToString()), 1);
series.Items.Add(item);
}
RadChart3.AutoLayout = true;
RadChart3.Series.Add(series);
RadChart3.Appearance.BarWidthPercent = 1;
RadChart3.PlotArea.XAxis.AutoScale = false;
RadChart3.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Charting.Styles.ChartValueFormat.ShortTime;
RadChart3.PlotArea.XAxis.AddRange(DateTime.Parse("2010-06-01 02:42:00").ToOADate(), DateTime.Parse("2010-06-01 02:52:00").ToOADate(), (double)1 / 1440);
RadChart3.PlotArea.YAxis.AutoScale = true;
}
And the chart is expected to show six bars.
Actually, however, the chart shows only 2 bars, because they are overlapped.
How can I solve this problem?
Thank you.
-Alex.