This is a migrated thread and some comments may be shown as answers.

Javascript: Unterminated String Constant

6 Answers 47 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Roland Klug
Top achievements
Rank 1
Roland Klug asked on 26 Oct 2016, 12:30 PM

Hello,

I'm trying to get a working RadHtmlChart. But as soon as i'm using a LinQ-DataSource, i'm getting an Javascript-Exception "0x800a03f7: Unterminated String Constant" and the Chart is empty

Here's the Code of the .aspx:

<telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="800px" Height="500px">
          <PlotArea>
             <Series>
                <telerik:ColumnSeries DataFieldY="PriceVk">
                </telerik:ColumnSeries>
              </Series>
            <XAxis DataLabelsField="Name"></XAxis>
       </PlotArea>
</telerik:RadHtmlChart>

 

And this is the Code Behind:

protected void Page_Load(object sender, EventArgs e)
        {
            var context = new StuffrulerDataContext(this.Connection);
            var data = context.StuffItems.Where(i => i.PriceVk > 0).Take(5).ToList();
            this.RadHtmlChart1.DataSource = data;
           // this.RadHtmlChart1.DataSource = GetData();
            this.RadHtmlChart1.DataBind();
 
        }
 
        protected DataTable GetData()
        {
            DataTable tbl = new DataTable();
            tbl.Columns.Add(new DataColumn("PriceVk", typeof(decimal)));
            tbl.Columns.Add(new DataColumn("Name", typeof(string)));
 
            tbl.Rows.Add(new object[] { 100, "First" });
            tbl.Rows.Add(new object[] { 200, "Second" });
            return tbl;
        }

 

When I'm using GetData() as Source, it works fine.

 

6 Answers, 1 is accepted

Sort by
0
Slav
Telerik team
answered on 31 Oct 2016, 09:24 AM

Hello Roland,

I tried reproducing the issue you mentioned in the following demo, because the data source for your example is not included: http://demos.telerik.com/aspnet-ajax/htmlchart/examples/databinding/linqdatasource/defaultcs.aspx

The data appears to be loading on the demo so the error might be related to the data you are using. If the issue can be reproduced in the demo, let me know how to change it so that I can debug it locally.

If not, please send a fully runnable sample that isolates the problem at hand. This will allow me to reproduce it on my end and determine what happens.


Regards,
Slav
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Roland Klug
Top achievements
Rank 1
answered on 02 Nov 2016, 08:48 AM

Hello Slav,

i found the Problem. When i juse this as DataSource:

var data = context.StuffItems.Select(i => new { i.PriceVk, i.Name }).Where(i => i.PriceVk > 0)

 

it works fine. As soon as i delete the Select-Part it stops working.

I thought i was able to bind the whole DataSource and select the wanted Fields in the .aspx or in Code Behind using 

RadHtmlChart1.PlotArea.XAxis.DataLabelsField = "Name";

 

but it looks like this is not possible.

0
Slav
Telerik team
answered on 07 Nov 2016, 09:17 AM

Hello Roland,

It is possible that this is a result of setting the data in the RadHtmlChart directly without using a LinqDataSource (which is the the expected setup in such scenarios).

Nevertheless, when I try the same with the HtmlChart - LinqDataSource demo (http://demos.telerik.com/aspnet-ajax/htmlchart/examples/databinding/linqdatasource/defaultcs.aspx) and more specifically, to bind the data like this

protected void Page_Load(object sender, System.EventArgs e)
{
    NorthwindReadOnlyEntities northwindContext = new NorthwindReadOnlyEntities();
    RadHtmlChart1.DataSource = northwindContext.Products.Where(p => p.UnitsOnOrder > 0).Where(p => p.UnitsInStock > 0).Take(5);
}
it still loads them correctly.

You can try using a LinqDataSource in order to data bind the chart control. If the same issue occurs with the data source control, you can isolate the problematic behavior in a fully runnable sample. This will allow me to debug it locally and determine why the chart cannot detect the data source field with the particular data source on your end.

 

 

Regards,
Slav
Telerik by Progress
Check out the new UI for ASP.NET Core, the most complete UI suite for ASP.NET Core development on the market, with 60+ tried-and-tested widgets, based on Kendo UI.
0
Roland Klug
Top achievements
Rank 1
answered on 23 Nov 2016, 10:55 AM

Hello Slav,

i switched to a SQL-DataSource and got it working so far. But i've got a Problem when there are a lot of Results.

With 150 Results (select TOP 150...) it works, but with 200 it stops working with the same Error Message (Javascript-Exception 0x800a03f7). When i set this Source for a RadGrid it works without any Problem.

Is there a restriction for the amount of Results? If yes, how high is it?

0
Slav
Telerik team
answered on 28 Nov 2016, 09:19 AM

Hello Roland,

There should not be issues with loading such amount of data in RadHtmlChart. Could you please try isolating the problem at hand in a fully runnable sample that includes the data you use? It will allow me to reproduce the issue locally and determine why it occurs.

You can also use the attached sample to extract the data and send in, which can help me reproduce it.

Another resource you can check is the following documentation article, which can help you optimize the performance in case the issue is performance related: http://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/troubleshooting/performance-optimizations

Regards,
Slav
Telerik by Progress
Telerik UI for ASP.NET AJAX is ready for Visual Studio 2017 RC! Learn more.
0
Roland Klug
Top achievements
Rank 1
answered on 07 Dec 2016, 09:05 AM

Hello Slav,

i've found the Problem now. It was a quotation mark in one of the records. Thank you for your help.

Tags
Chart (HTML5)
Asked by
Roland Klug
Top achievements
Rank 1
Answers by
Slav
Telerik team
Roland Klug
Top achievements
Rank 1
Share this question
or