Jan 17, 2014, 5:34 AM
[CLOSED] charts from code behind not showing via OnDirectClick method
I tried to load the chart from Page_Load with below code and it works,
and then I add a Button in the aspx file, and use OnDirectClick="LoadSimpleChart", but the chart didn't show up.
Paggy
and then I add a Button in the aspx file, and use OnDirectClick="LoadSimpleChart", but the chart didn't show up.
protected void Page_Load(object sender, EventArgs e)
{
//this.LoadSimpleChart();
}
<ext:Button ID="Button21" runat="server" Text="Load Chart" AutoDataBind="true"
Icon="Zoom" ToolTip="<%# @Resources.AmsResource.BUTTON_SEARCH %>" OnDirectClick="LoadSimpleChart" >
</ext:Button>
public void LoadSimpleChart()
{ // create sample data
System.Data.DataTable dt = new System.Data.DataTable();
Random ran = new Random();
System.Data.DataColumn dc = new System.Data.DataColumn("Name");
dc.DataType = System.Type.GetType("System.String");
dt.Columns.Add(dc);
dc = new System.Data.DataColumn("Data");
dc.DataType = System.Type.GetType("System.Int32");
dt.Columns.Add(dc);
System.Data.DataRow dr = dt.NewRow();
dr[0] = "January";
dr[1] = ran.Next(0, 100);
dt.Rows.Add(dr); dr = dt.NewRow();
dr[0] = "February";
dr[1] = ran.Next(0, 100);
dt.Rows.Add(dr); dr = dt.NewRow();
dr[0] = "March is just way too long for this";
dr[1] = ran.Next(0, 100);
dt.Rows.Add(dr);
//if (!X.IsAjaxRequest)
//{
Ext.Net.Panel pnl = new Ext.Net.Panel
{
Title = "Chart Test",
Layout = "FitLayout",
Width = 300,
Height = 500,
Items =
{
new Chart {
ID = "ChartTest",
Shadow = true,
Animate = true,
//LegendConfig = { Position = LegendPosition.Top },
LegendConfig = new ChartLegend() { Position = LegendPosition.Top },
Store = {
new Store {
DataSource = dt,
AutoDataBind = true,
Model = {
new Model {
Fields = {
new ModelField { Name = "Name" },
new ModelField { Name = "Data" }
}
}
}
}
},
Axes = {
new NumericAxis { Fields = new string[] { "Data" }, Title = "Number", Minimum = 0 },
new CategoryAxis { Position = Position.Bottom, Fields = new string[] { "Name" }, Title = "Name" }
},
Series = {
new ColumnSeries { Axis = Position.Left, XField = new string[] { "Name" }, YField = new string[] { "Data" } }
}
}
}
};
this._extFP.Controls.Add(pnl);
this._extFP.Reload();
//}
}
Best Regards,Paggy
Last edited by Daniil; Jan 17, 2014 at 11:19 AM.
Reason: [CLOSED]