Hello,
I am using codebehind to add items to the chart because I can't make it group the items the way I want it to when using a LINQ query. I attempted to use your "Dynamic Databinding" example on the website to try and help me accomplish what I need to but found it utterly confusing (would be nice if you would comment your examples).
Anyway, my chart has 2 series - 1 for open orders and 1 for in progress. The chart works fine in the aspect of displaying bars however I would like to see the customer names below the bars on the X axis and I can't for the life of me figure out how to do this. I tried using ChartAxisItem and adding to the collection but it doesn't do anything.
Please help.
My grid aspx code:
My codebehind code which adds the values to the chart:
I am using codebehind to add items to the chart because I can't make it group the items the way I want it to when using a LINQ query. I attempted to use your "Dynamic Databinding" example on the website to try and help me accomplish what I need to but found it utterly confusing (would be nice if you would comment your examples).
Anyway, my chart has 2 series - 1 for open orders and 1 for in progress. The chart works fine in the aspect of displaying bars however I would like to see the customer names below the bars on the X axis and I can't for the life of me figure out how to do this. I tried using ChartAxisItem and adding to the collection but it doesn't do anything.
Please help.
My grid aspx code:
<telerik:RadChart ID="rcOrders" runat="server" Skin="LightBlue" |
Width="710px" SeriesOrientation="Vertical" AutoLayout="false"> |
<Series> |
<telerik:ChartSeries Name="Open"> |
</telerik:ChartSeries> |
</Series> |
<Series> |
<telerik:ChartSeries Name="WIP"> |
</telerik:ChartSeries> |
</Series> |
<PlotArea> |
<XAxis> |
<AxisLabel> |
<Appearance RotationAngle="270"> |
</Appearance> |
</AxisLabel> |
</XAxis> |
<YAxis> |
<AxisLabel> |
<Appearance RotationAngle="0"> |
</Appearance> |
</AxisLabel> |
</YAxis> |
<YAxis2> |
<AxisLabel> |
<Appearance RotationAngle="0"> |
</Appearance> |
</AxisLabel> |
</YAxis2> |
</PlotArea> |
<ChartTitle TextBlock-Visible="false"></ChartTitle> |
</telerik:RadChart> |
My codebehind code which adds the values to the chart:
var orderStatusesByCompanyQuery = from o in database.Orders |
join c in database.Companies on o.CompanyId equals c.CompanyId |
join os in database.OrderStatuses on o.StatusId equals os.StatusId |
where o.Active == true && c.Active == true && os.Active == true && os.StatusId != 3 |
group o |
by new { CompanyId = o.CompanyId, CompanyName = c.ShortDisplayName, StatusId = os.StatusId, StatusDisplayName = os.ShortDisplayName } |
into grouping |
orderby grouping.Key.CompanyName |
select new |
{ |
CompanyId = grouping.Key.CompanyId, |
CompanyName = grouping.Key.CompanyName, |
StatusId = grouping.Key.StatusId, |
StatusDisplayName = grouping.Key.StatusDisplayName, |
StatusCount = grouping.Count() |
}; |
foreach (var orderStatusByCompany in orderStatusesByCompanyQuery) |
{ |
// adding this ChartAxisItem does nothing |
ChartAxisItem chartAxisItem = new ChartAxisItem(); |
chartAxisItem.Value = orderStatusByCompany.CompanyId; |
chartAxisItem.TextBlock.Text = orderStatusByCompany.CompanyName; |
rcOrders.PlotArea.XAxis.Items.Add(chartAxisItem); |
ChartSeriesItem chartSeriesItem = new ChartSeriesItem(); |
chartSeriesItem.Label.TextBlock.Text = orderStatusByCompany.StatusCount.ToString(); |
chartSeriesItem.XValue = orderStatusByCompany.CompanyId; |
chartSeriesItem.XValue2 = orderStatusByCompany.StatusId; |
chartSeriesItem.YValue = orderStatusByCompany.StatusCount; |
rcOrders.Series.GetByName(orderStatusByCompany.StatusDisplayName).Items.Add(chartSeriesItem); |
} |