Hello,
I have tried every single example found to set my XAxis values but none of them seems to work for me.
I'm populating a Line chart manually with a List of objects and it works just fine. I am also setting the XAxis ValueFormat to ShortDate and whatever I do, this includes clearing the collection of ChartAxisItems and adding with my own, I only get dates in the range of 1899/01/01...1900/01/01 etc etc even when I'm explicitly adding items with dates like "2010-01-01...2010-06-01" in OADate format.
I tried to set the Min and Max values of my XAxis to 01/01/2010 to 01/07/2010 but it doesn't produce any effect.
Here's some code because I know you'll ask:
NeedDataSource Event:
and in the attached file is the result of this code...
P.S.: For the record, I'm using the latest version of Q1 2010 (Version=4.0.10.423)
I have tried every single example found to set my XAxis values but none of them seems to work for me.
I'm populating a Line chart manually with a List of objects and it works just fine. I am also setting the XAxis ValueFormat to ShortDate and whatever I do, this includes clearing the collection of ChartAxisItems and adding with my own, I only get dates in the range of 1899/01/01...1900/01/01 etc etc even when I'm explicitly adding items with dates like "2010-01-01...2010-06-01" in OADate format.
I tried to set the Min and Max values of my XAxis to 01/01/2010 to 01/07/2010 but it doesn't produce any effect.
Here's some code because I know you'll ask:
NeedDataSource Event:
chart1.PlotArea.XAxis.Appearance.ValueFormat = Telerik.Reporting.Charting.Styles.ChartValueFormat.ShortDate; |
List<Issue> issues = new List<Issue>(); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-01-2010")}); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-01-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-01-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-02-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-02-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-03-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-04-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-04-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-04-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-04-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-04-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-05-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-05-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-05-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-06-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-06-2010") }); |
issues.Add(new Issue() { CategoryName = "Teste1", DueDate = DateTime.Parse("01-06-2010") }); |
var cats = issues.GroupBy(x => x.CategoryName); |
List<string> Categorias = new List<string>(); |
chart1.Series.Clear(); |
chart1.PlotArea.XAxis.MinValue = DateTime.Parse("01-01-2010").ToOADate(); |
chart1.PlotArea.XAxis.MaxValue = DateTime.Parse("01-07-2010").ToOADate(); |
foreach (var cat in cats) |
{ |
Categorias.Add(cat.Key); |
} |
foreach (string categoria in Categorias) |
{ |
var issuesissuesPerCat = issues.Where(x => x.CategoryName == categoria); |
var groupedIssues = issuesPerCat.GroupBy(x => x.DueDate.ToString("dd/MM/yyyy")); |
ChartSeries series = new ChartSeries(); |
series.Type = ChartSeriesType.Line; |
foreach (var issue in groupedIssues) |
{ |
ChartSeriesItem csitem = new ChartSeriesItem(); |
csitem.YValue = issue.Count(); |
series.Items.Add(csitem); |
chart1.PlotArea.XAxis.AddItem(issue.Key); |
} |
chart1.Series.Add(series); |
} |
and in the attached file is the result of this code...
P.S.: For the record, I'm using the latest version of Q1 2010 (Version=4.0.10.423)