" a is undefined " javaScript error in Line Chart

  1. #1

    " a is undefined " javaScript error in Line Chart

    Hi All.
    I make line Chart and after I add it in Items collection of a window and returning it as a result for my CreateLineChart Direct method Call.
    The Code is here.
    Any help or recommendation is appreciated in advance.

    public static Window CreateLineChart(string chartID, string XAxeTitle, string YAxeTitle, string XAxeField, string YAxeField, int chartWidth, int chartHeight, string dataLoadURL, string entityID)
            {
                var dt = new DataTable();
                SqlConnection cn = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["KSPDBS"].ConnectionString);
                SqlDataAdapter da = new SqlDataAdapter("Select * from ViwPDEntityItemLanguageTitles where EntityID=" + entityID + " Order By PresentationSequenceNo", cn);
                da.Fill(dt);
    
                var myStore = CreateStore(dt, "s1", "ID", dataLoadURL, null, "ID", 20, true);
    
                Chart myChart = new Chart()
                {
                    ID = "Chrt1",
                    StyleSpec = "background:#fff;",
                    Animate = true,
                    Shadow = true,
                    StandardTheme = StandardChartTheme.Category1,
                    LegendConfig = new ChartLegend()
                    {
                        Position = LegendPosition.Right,
                    }
                };
    
                NumericAxis myNumAxe = new NumericAxis()
                {
                    Fields = new[] { YAxeField },
                    Title = YAxeTitle,
                    Minimum = 0,
                    MinorTickSteps = 1,
                    GridConfig = new AxisGrid()
                    {
                        Odd = new SpriteAttributes()
                        {
                            Opacity = 1,
                            Fill = "#ddd",
                            Stroke = "#bbb",
                            StrokeWidth = 0.5
                        }
                    }
                };
    
                myChart.Axes.Add(myNumAxe);
    
    
    
                CategoryAxis ctgryAxe = new CategoryAxis()
                {
                    Position = Position.Bottom,
                    Fields = new[] { XAxeField},
                    Title = XAxeTitle,
                };
    
                myChart.Axes.Add(ctgryAxe);
    
                var linSer1 = new LineSeries()
                {
                    Axis = Position.Left,
                    XField = new[] { XAxeField},
                    YField = new[] { YAxeField  },
                    HighlightConfig = new SpriteAttributes()
                    {
                        Size = 7,
                        Radius = 7
                    },
                    MarkerConfig = new SpriteAttributes()
                    {
                        Type = SpriteType.Cross,
                        Size = 4,
                        Radius = 4,
                        StrokeWidth = 0
                    }
                };
                var linSer2 = new LineSeries()
                {
                    Axis = Position.Left,
                    XField = new[] { XAxeField },
                    YField = new[] { YAxeField  },
                    HighlightConfig = new SpriteAttributes()
                    {
                        Size = 7,
                        Radius = 7
                    },
                    MarkerConfig = new SpriteAttributes()
                    {
                        Type = SpriteType.Cross,
                        Size = 4,
                        Radius = 4,
                        StrokeWidth = 0
                    },
                    Smooth = 3
                };
    
                myChart.Series.Add(linSer1);
                myChart.Series.Add(linSer2);
                myChart.Height = chartHeight - 50;
                myChart.Width = chartWidth - 50;
    
                Window myWin = new Window()
                {
                    ID = "w11",
                    Width = chartWidth,
                    Height = chartHeight,
                    Layout = "fit"
                };
    
                myChart.Render();
                myWin.Items.Add(myChart);
    
                return myWin;
            }
    Last edited by Daniil; Nov 05, 2013 at 12:33 PM. Reason: Please use [CODE] tags
  2. #2
    Hello!

    Please, don't forget to use CODE tag.

    About your problem, try to switch ScriptMode to Development and trace the error.

    <ext:ResourceManager ID="ResourceManager1" runat="server" ScriptMode="Development" />
    Probably, you add the window to the wrong container.

Similar Threads

  1. [CLOSED] "Serie has no chart reference" error
    By feanor91 in forum 2.x Legacy Premium Help
    Replies: 5
    Last Post: May 30, 2012, 8:27 AM
  2. Replies: 8
    Last Post: May 30, 2011, 6:55 PM
  3. Replies: 9
    Last Post: Apr 25, 2011, 9:23 PM
  4. Replies: 12
    Last Post: Apr 13, 2011, 4:28 PM
  5. Replies: 11
    Last Post: Mar 30, 2011, 3:21 PM

Posting Permissions