[CLOSED] Problem to draw a chart into a panel

  1. #1

    [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 :

    <%@ 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 :

    Click image for larger version. 

Name:	chart.png 
Views:	103 
Size:	43.7 KB 
ID:	4273

    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]
  2. #2
    Hi,

    Please add
    .Layout("Fit")
    for the Panel as well.
  3. #3
    Your right it works. thanks
  4. #4
    Hello

    Please could you explain why series is not shown? I think I have found a bug in vertical axis when several series are drawn but to show it I need to draw the series.

    Whne I will be able to show it, I will make a new thread.
  5. #5
    Do you mean this LineSeries?
    LineSeries MySerie = new LineSeries();
    Well, I can't see where you add it to the Chart. So, please add:
    MyChart.Series.Add(MySerie);
    Also I would recommend to replace
    BuildWindow1().Render(this.Form);
    with
    this.Form.Controls.Add(BuildWindow1());
    as the Render method is designed to be used during an ajax request.
  6. #6
    Damn it! You'r right...Works better if serie is added to chart...OK, I construct my example and report in a new thread if behavior is the same that the one I experiment with VB.

Similar Threads

  1. Problem with Ext.Net Chart - Column
    By OCaglayan in forum 2.x Help
    Replies: 1
    Last Post: Jul 31, 2012, 12:43 PM
  2. This is a bug?Chart problem···
    By jiaxiang8756 in forum 2.x Help
    Replies: 4
    Last Post: Jul 17, 2012, 7:14 PM
  3. [CLOSED] Problem with chart controls and coolite
    By Pablo_Azevedo in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jan 12, 2012, 4:12 PM
  4. [CLOSED] Chart ReRender after Panel Resize
    By ljankowski in forum 1.x Legacy Premium Help
    Replies: 23
    Last Post: Jan 12, 2012, 4:09 PM
  5. [CLOSED] Draw div
    By 78fede78 in forum 1.x Legacy Premium Help
    Replies: 6
    Last Post: Nov 11, 2010, 6:58 PM

Posting Permissions