May 22, 2012, 1:23 PM
[CLOSED] Problem to draw a chart into a panel
Hello
I manage to draw my code behind generated charts directly into a window, but not into a panel...See code below :
Meanwhile, we can see the X axis anyway and it is not the point. The point is why I cannot manage to deal with the panel?
I manage to draw my code behind generated charts directly into a window, but not into a panel...See code below :
<%@ Page Language="C#" %>
<%@ Import Namespace="Ext.Net.Utilities"%>
<%@ Import Namespace="Panel=Ext.Net.Panel" %>
<%@ Import Namespace="Chart=Ext.Net.Chart" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>
<script runat="server">
protected void Page_Load(object sender,EventArgs e)
{
// Load the data into the Store and DataBind.
this.stoCharts.DataSource = this.stoChartsValue;
this.stoCharts.DataBind();
BuildWindow1().Render(this.Form); //construct window with chart build into
BuildWindow2().Render(this.Form); //construct window with chart into a panel in the window
}
private object[] stoChartsValue
{
get
{
return new object[]
{
new object[] {"2011/01/01",10},
new object[] {"2011/02/01",15},
new object[] {"2011/03/01",21},
new object[] {"2011/04/01",1},
new object[] {"2011/05/01",18},
new object[] {"2011/06/01",30},
new object[] {"2011/07/01",25},
new object[] {"2011/08/01",14},
new object[] {"2011/09/01",11},
new object[] {"2011/10/01",9},
new object[] {"2011/11/01",3},
new object[] {"2011/12/01",45}
};
}
}
private Window BuildWindow1()
{
return this.X().Window()
.ID("Window1")
.Title("My Window With Chart in it")
.Height(400)
.Width(300)
.X(0)
.Y(0)
.Layout("Fit")
.Add(BuildChart());
}
private Window BuildWindow2()
{
return this.X().Window()
.ID("Window2")
.Title("My Window with chart into panel")
.Height(400)
.Width(300)
.X(500)
.Y(500)
.Layout("Fit")
.Add(BuildPanel());
}
private Chart BuildChart()
{
Chart MyChart = new Chart();
AxisCollection MyAxes=new AxisCollection();
CategoryAxis AxesX =new CategoryAxis();
NumericAxis AxesY= new NumericAxis();
LineSeries MySerie=new LineSeries();
AxesX.Title = "Month";
AxesX.Fields = new string[1];
AxesX.Fields[0] = "Date";
AxesY.Minimum = 0;
AxesY.Fields = new string[1];
AxesY.Fields[0] = "Value";
MyAxes.Add(AxesX);
MyAxes.Add(AxesY);
MySerie.SeriesID = "IdSerie";
MySerie.Axis = Position.Left;
MySerie.XField = new string[1];
MySerie.XField[0] = "Date";
MySerie.YField = new string[1];
MySerie.YField[0] = "Value";
MySerie.Title = "Test";
MySerie.MarkerConfig = new SpriteAttributes();
MySerie.MarkerConfig.Fill = "#00ff00";
MySerie.MarkerConfig.Stroke = "#00ff00";
MySerie.MarkerConfig.Type = SpriteType.Circle;
MySerie.MarkerConfig.Size = 3;
MySerie.MarkerConfig.Radius = 3;
MySerie.Style = new SpriteAttributes();
MySerie.Style.Fill = "#00ff00";
MySerie.Style.Stroke = "#00ff00";
MySerie.Style.StrokeWidth = 0;
MyChart.StoreID = "stoCharts";
MyChart.Animate = true;
MyChart.Legend = true;
MyChart.Axes.Add(AxesX);
MyChart.Axes.Add(AxesY);
return MyChart;
}
private Panel BuildPanel()
{
return this.X().Panel()
.ID("panChart")
.Title("Chart")
.Padding(5)
.Add(BuildChart());
}
</script>
<!DOCTYPE html protected "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
<title>Test Chart into panel</title>
<ext:ResourcePlaceHolder ID="ResourcePlaceHolder1" runat="server" Mode="ScriptFiles" />
</head>
<body>
<form id="form1" runat="server">
<ext:ResourceManager ID="ResourceManager1" runat="server" RethrowAjaxExceptions="True">
</ext:ResourceManager>
<%-- Data stores--%>
<ext:Store ID="stoCharts" runat="server" AutoLoad="True">
<Reader>
<ext:ArrayReader />
</Reader>
<Model>
<ext:Model ID="Model2" runat="server">
<Fields>
<ext:ModelField Name="Date" />
<ext:ModelField Name="Value" />
</Fields>
</ext:Model>
</Model>
</ext:Store>
</form>
</body>
</html>
Side effect, my serie is not drawn into the window, didn't know why, in VB code it works see :Meanwhile, we can see the X axis anyway and it is not the point. The point is why I cannot manage to deal with the panel?
Last edited by Daniil; May 22, 2012 at 3:36 PM.
Reason: [CLOSED]