[CLOSED] "Serie has no chart reference" error

  1. #1

    [CLOSED] "Serie has no chart reference" error

    Hello

    I try to set title to a chart column with this :

    Serie.SetTitle(i, SerieTitle(i))
    i, is the index of my serie, and SerieTitle(i) the title.

    I will try to make a complete example.

    I get this message :
    System.Exception: Series has no Chart reference
    In AbstractSeries.cs here :

      protected virtual void CallTemplate(string name, params object[] args)
            {
                if (this.SeriesID.IsEmpty())
                {
                    throw new Exception("You have to set series ID to call its methods");
                }
    
                var chart = this.Owner as Chart;
    
                if (chart == null)
                {
                    throw new Exception("Series has no Chart reference");
                }
    
                StringBuilder sb = new StringBuilder();
                var comma = false;
    
                if (args != null && args.Length > 0)
                {
                    foreach (object arg in args)
                    {
                        if (comma)
                        {
                            sb.Append(",");
                        }
                        comma = true;
                        sb.Append(JSON.Serialize(arg, JSON.ScriptConvertersInternal));
                    }
                }
    
                var template = "{0}.series.get(\"{1}\").{2}({3});";
    
                string script = template.FormatWith(chart.ClientID, this.SeriesID, name, sb.ToString());
    
                chart.AddScript(script);
            }
    Last edited by Daniil; May 29, 2012 at 6:45 PM. Reason: [CLOSED]
  2. #2
    The example :
    <%@ 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();
    
                this.Form.Controls.Add(BuildWindow1());  //construct window with chart build into
              }
     
         private object[] stoChartsValue
        {
            get
            {
                return new object[]
                {
                    new object[] {"2011/01/01",10,200,550},
                    new object[] {"2011/02/01",15,300,450},
                    new object[] {"2011/03/01",21,452,800},
                    new object[] {"2011/04/01",1,125,952},
                    new object[] {"2011/05/01",18,214,458},
                    new object[] {"2011/06/01",30,57,480},
                    new object[] {"2011/07/01",25,38,452},
                    new object[] {"2011/08/01",14,189,650},
                    new object[] {"2011/09/01",11,170,520},
                    new object[] {"2011/10/01",9,98,152},
                    new object[] {"2011/11/01",3,78,259},
                    new object[] {"2011/12/01",45,120,454}           
                };
            }
        }
     
     
         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 MySerie1 = new LineSeries();
                //LineSeries MySerie2 = new LineSeries();
                //LineSeries MySerie3 = new LineSeries();
                ColumnSeries MySerie1 = new ColumnSeries();
                           
                AxesX.Title = "Month";
                AxesX.Fields = new string[1];
                AxesX.Fields[0] = "Date";
                 
                AxesY.Minimum = 0;
                AxesY.Fields = new string[3];
                AxesY.Fields[0] = "Value1";
                AxesY.Fields[1] = "Value2";
                AxesY.Fields[2] = "Value3";
     
                MyAxes.Add(AxesX);
                MyAxes.Add(AxesY);
     
                MySerie1.SeriesID = "IdSerie1";
                MySerie1.Axis = Position.Left;
                MySerie1.XField = new string[1];
                MySerie1.XField[0] = "Date";
                MySerie1.YField = new string[3];
                MySerie1.YField[0] = "Value1";
                MySerie1.YField[1] = "Value2";
                MySerie1.YField[2] = "Value3";
                MySerie1.Stacked = true;
                MySerie1.SetTitle(0, "title 1");
                MySerie1.SetTitle(1, "title 2");
                MySerie1.SetTitle(2, "title 3");
                   
                MyChart.StoreID = "stoCharts";
                MyChart.Animate = false;
     
                MyChart.Legend = true;
                MyChart.Axes.Add(AxesX);
                MyChart.Axes.Add(AxesY);
             
                MyChart.Series.Add(MySerie1);
                //MyChart.Series.Add(MySerie2);
                //MyChart.Series.Add(MySerie3);
             
                MyChart.LegendConfig = new Ext.Net.ChartLegend();
                MyChart.LegendConfig.RefreshOnItemToggle = true;
             
                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="Value1" />
                                <ext:ModelField Name="Value2" />
                                <ext:ModelField Name="Value3" />
                            </Fields>
                        </ext:Model>
                    </Model>        
                </ext:Store>
     
                
                 
                  
     
             </form>
        </body>
     
    </html>
  3. #3
    Hi,

    Please replace:
    MySerie1.SetTitle(0, "title 1");
    MySerie1.SetTitle(1, "title 2");
    MySerie1.SetTitle(2, "title 3");
    with
    MySerie1.Title = "={['title1','title2', 'title3']}";
    We will add an array support soon. Thanks for the question.
  4. #4
    Works perfectly. Thanks
  5. #5
    After update from SVN please use the Titles property.
    MySeries.Titles = new string[] { "title 1", "title 2", "title 3" };
  6. #6
    Works well, thanks.

Similar Threads

  1. [CLOSED] How does "MaskCls" work for "AutoLoad" mask in panel control
    By leon_tang in forum 1.x Legacy Premium Help
    Replies: 5
    Last Post: Jul 19, 2012, 12:09 PM
  2. Replies: 1
    Last Post: Jun 26, 2012, 11:29 AM
  3. Replies: 5
    Last Post: May 02, 2012, 5:37 PM
  4. Replies: 4
    Last Post: Oct 11, 2011, 2:42 AM
  5. Replies: 2
    Last Post: Jun 26, 2011, 1:59 AM

Posting Permissions