Skip to content

Infragistics Community Forum / Web / Ultimate UI for ASP.NET Web Forms / Line Chart Error: You must have at least one row and one numeric column

Line Chart Error: You must have at least one row and one numeric column

New Discussion
Travis
Travis asked on Jan 18, 2018 7:05 AM

What am I doing wrong?

DataTable dt = new DataTable();
dt.Columns.Add(“Value”);
dt.Columns.Add(“Date”);

DataRow row = dt.NewRow();

row[0] = “2”;
row[1] = DateTime.Today.AddDays(-1);

dt.Rows.Add(row);

row = dt.NewRow();

row[0] = “3”;
row[1] = DateTime.Today.AddDays(-2);

dt.Rows.Add(row);

row = dt.NewRow();

row[0] = “4”;
row[1] = DateTime.Today.AddDays(-3);

dt.Rows.Add(row);

myChart.DataSource = dt;
myChart.DataBind();

Sign In to post a reply

Replies

  • 0
    Travis
    Travis answered on Oct 22, 2008 5:22 PM

     Also tried this with NumericSeries per an example I found and I am receiving the same error.  What gives?

    • 0
      Max Rivlin [Infragistics]
      Max Rivlin [Infragistics] answered on Oct 22, 2008 9:43 PM

      This is likely to happen when you don't specify the column type. Try using
      dt.Columns.Add("Value", typeof(int));
      dt.Columns.Add("Date", typeof(DateTime));

      Also, in order for the line chart to display a date time axis, you need to set
      chart.LineChart.TreatDateTimeAsString = false;

      https://www.infragistics.com/help/aspnet/chart-display-data-on-a-time-scale-axis

      • 0
        Chuck
        Chuck answered on Oct 23, 2008 8:08 PM

        I'm getting this same error, when I use a Bar Chart and it is bound to a Collection derived from CollectionBase.

         Here's my code:

         

        public

        class ChartDataValue

        {

        public string origData;

        public int barHeight;public decimal origDataConverted;public ChartDataValue(string _origData, decimal _origDataConverted)

        {

        origData = _origData;

        origDataConverted = _origDataConverted;

        barHeight = 0;

        }

        }

        /// <summary>

        /// Custom collection

        /// </summary>

        public class ChartData : CollectionBase

        {

        /// <summary>

        /// Add a new item to the collection

        /// </summary>public virtual void Add(ChartDataValue toAdd)

        {

        this.List.Add(toAdd);

        }

        /// <summary>

        /// Gets or sets the element at the specified index.

        /// </summary>public ChartDataValue this[int index]

        {

        get

        {

        return this.List[index] as ChartDataValue;

        }

        }

        }

        public

        partial class _Default : System.Web.UI.Page

        {

        private ChartData BarData;protected void Page_Load(object sender, EventArgs e)

        {

        BarData = dl.LoadData(selectedItem);

        }

        protected void BindingtoClassesDerivedfromCollectionBase_Load(object sender, System.EventArgs e)

        {

        this.UltraChart1.Data.DataSource = BarData;

        UltraChart1.Data.DataBind();

        }

        }

         

        (from DataLayer)

         

        public ChartData LoadData(string practiceID)

        {

        // sql stuff intentionally removed here

        ChartData cd = new ChartData();

        string tempStr;for (int i = 0; i < 12; i++)

        {

        cd.Add(new ChartDataValue(GenerateMonthName(i), ParseDataValue(tempStr)));

        }

        return cd;

        }

         

        I have checked this with a breakpoint at runtime, and just before the call to DataBind(), my ChartData Collection contains 12 items, each of class ChartDataValue.  Inside each ChartDataValue, as expected, the MonthName appears in the origData, and the decimal value is in origDataConverted.

         

        All requirements in the documentation seem to be fulfilled, however it still just draws the red error message saying:

        You must have at least one row and one numeric column

      • 0
        [Infragistics] Vince McDonald
        [Infragistics] Vince McDonald answered on Oct 23, 2008 8:33 PM

        What happens if you use a List<ChartDataValue>, as opposed to a custom collection?

      • 0
        Chuck
        Chuck answered on Oct 23, 2008 9:16 PM

        I was just following the docs, and they say to derive from CollectionBase.

        OK, so I tried using List<ChartDataValue> and I think I'm getting closer.

        I get a different error message now:

        Server Error in '/' Application.


        Index was outside the bounds of the array.

        Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

        Exception Details: System.IndexOutOfRangeException: Index was outside the bounds of the array.

        Source Error:

        An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

        Stack Trace:

        [IndexOutOfRangeException: Index was outside the bounds of the array.]
           Infragistics.UltraChart.Data.IListToChartAdapter2.GetObjectValue(Int32 row, Int32 column) +70
           Infragistics.UltraChart.Data.IListToChartAdapter2.IsColumnString(Int32 column) +34
           Infragistics.UltraChart.Core.Layers.Layer.SetupDataFilter(DataAppearance dataApp) +216
           Infragistics.UltraChart.Core.Layers.Layer.SetupDataFilter() +73
           Infragistics.UltraChart.Core.Layers.ChartLayer.SetData(IChartData data) +52
           Infragistics.UltraChart.Core.ChartCore.SetDataIntoLayers(IChartData data) +116
           Infragistics.UltraChart.Core.ChartCore.SetupDataModel() +2008
           Infragistics.UltraChart.Core.ChartCore.DrawChart() +161
           Infragistics.WebUI.UltraWebChart.UltraChart.Render(HtmlTextWriter output) +16552
           System.Web.UI.Control.RenderControlInternal(HtmlTextWriter writer, ControlAdapter adapter) +25
        

        The BarData contains 12 items, each of which is fully initialized.

        Thanks for your continued help.

      • 0
        David Negley
        David Negley answered on Nov 4, 2008 6:47 PM

         the chart uses the public properties (not fields) on your data objects to determine the item labels and data values.  add these lines to your ChartDataValue class and both CollectionBase and List<T> scenarios should work fine.

            public decimal OrigDataConverted { get { return this.origDataConverted; } }
            public string OrigData { get { return this.origData; } }

      • 0
        Gcobani Mkontwana
        Gcobani Mkontwana answered on Jan 18, 2018 7:05 AM

        Hi Team

        I'm using ultrachart and want to display data on my data source, can any person help me with this control on showing sample on open edge not C# nor Visual Basic, purely Progress.

  • You must be logged in to reply to this topic.
Discussion created by
Favorites
Replies
Created On
Last Post
Discussion created by
Travis
Favorites
0
Replies
7
Created On
Jan 18, 2018
Last Post
8 years, 1 month ago

Suggested Discussions

Created by

Created on

Jan 18, 2018 7:05 AM

Last activity on

Feb 18, 2026 2:23 PM