I have a RadGrid that draws its data from a SP that is effectively the hours user load on a system by day sorted newest to oldest.
Date,0000,0100,0200,...2200,2300
2/10/2010, 12,45,65,....32,10
2/9/2010, 9,56,123,....65,23
I set the Page Size to 7 to effectively show me the last 7 days of data in the grid. I ahve created a RadChart above the grid and would like it to display each of the 7 days on the chart with the X-Axis being the Hour of the Day, and the legend reflecting the data.
aspx page
codebehind page
1) How do I get the RADChart to chart the data so that I have 7 series (one for each day displayed on the radgrid), and allow the 24 fields to be charted in the series.
2) Handle going to the next page and refreshing the RadChart to the RadGrid Display
I have been trying (with very little luck) for far too many hours to lick this, any help would be greatly appreciated..
Thanks
Harry Anderson
harry.k.anderson@wellsfargo.com
Date,0000,0100,0200,...2200,2300
2/10/2010, 12,45,65,....32,10
2/9/2010, 9,56,123,....65,23
I set the Page Size to 7 to effectively show me the last 7 days of data in the grid. I ahve created a RadChart above the grid and would like it to display each of the 7 days on the chart with the X-Axis being the Hour of the Day, and the legend reflecting the data.
aspx page
<asp:Content ID="Content2" runat="Server" ContentPlaceHolderID="Main"> |
<telerik:RadScriptManager ID="RadScriptManager1" runat="server"> |
</telerik:RadScriptManager> |
<script type="text/javascript" language="javascript"> |
function onRequestStart(sender, args) { |
if (args.get_eventTarget().indexOf("imgbtn_xls") >= 0 || |
args.get_eventTarget().indexOf("imgbtn_doc") >= 0) { |
args.set_enableAjax(false); |
} |
} |
</script> |
<telerik:RadAjaxManager ID="RadAjaxManager1" runat="server"> |
<AjaxSettings> |
<telerik:AjaxSetting AjaxControlID="ReportGrid"> |
<UpdatedControls> |
<telerik:AjaxUpdatedControl ControlID="ReportGrid" /> |
</UpdatedControls> |
</telerik:AjaxSetting> |
</AjaxSettings> |
</telerik:RadAjaxManager> |
<div class="boxlist" style="width: 1020px; left: -2px; top: 5px;"> |
<table width="100%"> |
<tr> |
<th class="shaded" width="100%" colspan="2"> |
<%=(string)Session["myPageName"] %> |
</th> |
</tr> |
<tr> |
<td> |
</td> |
<th style="text-align: right;"> |
<input type="button" value="Admin Home" onclick="location.href='Admin_Home.aspx'" /> |
</th> |
</tr> |
</table> |
<table width="100%"> |
<tr> |
<th> |
Page Hits by Day |
</th> |
</tr> |
<tr> |
<td> |
<telerik:RadChart ID="RadChart1" runat="server" Height="350px" Width="1010px" Skin="default" |
Legend-Visible="false" |
ChartTitle-TextBlock-Text="Page Statistics by Day (7 day view)" DefaultType="Line"> |
<Legend Visible="False"> |
<Appearance Visible="False"></Appearance> |
</Legend> |
</telerik:RadChart> |
</td> |
</tr> |
<tr> |
<td style="text-align: right;"> |
<table> |
<tr> |
<td> |
<asp:ImageButton ID="imgbtn_xls" runat="server" AlternateText="Export to Excel" ImageUrl="~/images/xls.png" |
OnClick="imgbtn_xls_Click" /> |
</td> |
<td> |
<asp:ImageButton ID="imgbtn_doc" runat="server" AlternateText="Export to Word" ImageUrl="~/images/doc.png" |
OnClick="imgbtn_doc_Click" /> |
</td> |
</tr> |
</table> |
</td> |
</tr> |
<tr> |
<td> |
<telerik:RadGrid ID="grdApplicationStatistics" runat="server" ExportSettings-IgnorePaging="true" |
HeaderStyle-Font-Bold="true" Font-Names="tahoma" PageSize="7" AllowPaging="true" |
Width="1010px" Skin="Default" EnableEmbeddedSkins="false" OnPageIndexChanged="grdApplicationStatistics_PageIndexChanged"> |
<ExportSettings IgnorePaging="true" FileName="PageStatsbyDay" OpenInNewWindow="true" |
ExportOnlyData="false"> |
</ExportSettings><PagerStyle Mode="NextPrev" /> |
<ClientSettings EnableRowHoverStyle="true"> |
<Resizing AllowRowResize="True" EnableRealTimeResize="True" ResizeGridOnColumnResize="True" |
AllowColumnResize="True"></Resizing> |
<Selecting AllowRowSelect="true" /> |
</ClientSettings> |
<MasterTableView PageSize="7"> |
</MasterTableView> |
</telerik:RadGrid> |
</td> |
</tr> |
</table> |
</div> |
</asp:Content> |
codebehind page
using System; |
using System.Collections; |
using System.ComponentModel; |
using System.Data; |
using System.Drawing; |
using System.Configuration; |
using System.Web; |
using System.Web.SessionState; |
using System.Web.UI; |
using System.Web.UI.WebControls; |
using System.Web.UI.HtmlControls; |
using Telerik.Web.UI; |
using Telerik.Charting; |
namespace XXXXXXXXXX.XXXXXX{ |
/// <summary> |
/// Summary description for Stats. |
/// </summary> |
public partial class PTOPageStatsbyDay : PTOBasePage |
{ |
protected void Page_Load(object sender, System.EventArgs e) |
{ |
Session["myPageName"] = "PTO Page Stats by Day"; |
this.Master._pageLabel = (string)Session["myPageName"]; |
Session["HelpPage"] = ""; |
//label_myPageName.Text = (string)Session["myPageName"]; |
if (!IsPostBack) |
{ |
User user = (User)Session["USER"]; |
//Insure that the user has proper credentials for this page. |
if (!user.Sys_Role.Equals("S")) |
{ |
Response.Redirect((String)ConfigurationManager.AppSettings["SYS_NOAUTH_PAGE"]); |
Application["i"] = null; |
} |
getData(); |
} |
grdApplicationStatistics.MasterTableView.RenderColumns[1].Display = false; |
} |
protected void getData() |
{ |
DataAccess da = new DataAccess(); |
DateTime dt = DateTime.Now; |
// Get year, month, and day |
int year = dt.Year; |
DataSet ds = da.Report_PageStatisticsbyDay(year); |
grdApplicationStatistics.DataSource = ds; |
grdApplicationStatistics.DataBind(); |
RadChart1.DataSource = ds; |
int curIndex = grdApplicationStatistics.CurrentPageIndex; |
int myStart = (curIndex-1)*grdApplicationStatistics.PageSize; |
int myEnd = (curIndex) * grdApplicationStatistics.PageSize; |
int myCntr = 0; |
foreach (ChartSeries series in RadChart1.Series) |
{ |
series.Appearance.LabelAppearance.Visible = false; |
series.Visible = false; |
if (myCntr >=myStart && myCntr<=myEnd) |
series.Visible = true; |
} |
myCntr++; |
RadChart1.DataBind(); |
} |
protected void grdApplicationStatistics_PageIndexChanged(object source, Telerik.Web.UI.GridPageChangedEventArgs e) |
{ |
getData(); |
} |
protected void imgbtn_xls_Click(object sender, System.EventArgs e) |
{ |
grdApplicationStatistics.AllowPaging = false; |
grdApplicationStatistics.ExportSettings.IgnorePaging = true; |
getData(); |
grdApplicationStatistics.MasterTableView.ExportToExcel(); |
} |
protected void imgbtn_doc_Click(object sender, System.EventArgs e) |
{ |
grdApplicationStatistics.AllowPaging = false; |
grdApplicationStatistics.ExportSettings.IgnorePaging = true; |
getData(); |
grdApplicationStatistics.MasterTableView.ExportToWord(); |
} |
#region Web Form Designer generated code |
override protected void OnInit(EventArgs e) |
{ |
// |
// CODEGEN: This call is required by the ASP.NET Web Form Designer. |
// |
InitializeComponent(); |
base.OnInit(e); |
} |
/// <summary> |
/// Required method for Designer support - do not modify |
/// the contents of this method with the code editor. |
/// </summary> |
private void InitializeComponent() |
{ |
} |
#endregion |
} |
} |
1) How do I get the RADChart to chart the data so that I have 7 series (one for each day displayed on the radgrid), and allow the 24 fields to be charted in the series.
2) Handle going to the next page and refreshing the RadChart to the RadGrid Display
I have been trying (with very little luck) for far too many hours to lick this, any help would be greatly appreciated..
Thanks
Harry Anderson
harry.k.anderson@wellsfargo.com