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

RadHTMLChart not displaying data

2 Answers 358 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
jk
Top achievements
Rank 1
jk asked on 31 Dec 2014, 03:53 PM
In case this helps someone else: I was having difficulty with my column RadHTMLChart. There were no exceptions but it wouldn't display the data. I was binding to a dataview and setting the DataFieldY and DataLabelsField to columns in that dataview. Long story short, it seems that there are certain reserved words that the chart has trouble with. In my case, my dataview had a column named "count" and a column named "Category". I changed my SQL query to give the column names the aliases of "ErrCount" and "CategoryName", changed the chart's DataFieldY and DataLabelsField properties to use these new column names, and then the chart displayed correctly.

While I have solved my problem, I'm wondering if there is documentation which lists reserved keywords so I don't run into this again?

2 Answers, 1 is accepted

Sort by
0
Danail Vasilev
Telerik team
answered on 05 Jan 2015, 08:59 AM
Hello,

I am not able to reproduce the mentioned issue with the code below:
ASPX:
<telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Width="600" Height="400">
    <PlotArea>
        <Series>
            <telerik:ColumnSeries DataFieldY="count">
            </telerik:ColumnSeries>
        </Series>
        <XAxis DataLabelsField="Category"></XAxis>
    </PlotArea>
</telerik:RadHtmlChart>
C#:
protected void Page_Load(object sender, EventArgs e)
{
    RadHtmlChart1.DataSource = GetData();
    RadHtmlChart1.DataBind();
}
 
protected DataTable GetData()
{
    DataTable tbl = new DataTable();
    tbl.Columns.Add(new DataColumn("count", typeof(decimal)));
    tbl.Columns.Add(new DataColumn("Category", typeof(string)));
 
    tbl.Rows.Add(new object[] { 100, "First" });
    tbl.Rows.Add(new object[] { 200, "Second" });
    return tbl;
}

Can you please try to reproduce the problem with this example and then tell me what changes you have made, so that I can proceed further with the investigation? Can you also tell us which version of Telerik UI you are using?

Regards,
Danail Vasilev
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Pratik
Top achievements
Rank 1
answered on 30 Jun 2016, 12:04 PM
I am facing same issue with the RadHTMLChart... I'm creating html chart dynamically from code behind.(Below attached). Code not showing any error but chart is not visible on web page

 

 

 
.ASPX
<telerik:RadHtmlChart ID="h1" runat="server" InvokeLoadData="AfterPageLoad" Width="100%"  CssClass="rdchart"
           Skin="Vista" Visible="true">
           
           <Legend>
               <Appearance Position="Top" Orientation="Horizontal" Visible="true">
               </Appearance>
           </Legend>
           <ChartTitle Text="POs raised in running 12 months">
               <Appearance>
                   <TextStyle FontFamily="Tahoma" FontSize="11pt" Bold="true" />
               </Appearance>
           </ChartTitle>
           <Zoom Enabled="true">
               <MouseWheel Enabled="true" />
           </Zoom>
       </telerik:RadHtmlChart>

aspx.cs

 

 
if (ds.Tables.Count>0)
        {
            DataTable dt = new DataTable();
            dt = ds.Tables[0];
 
           
               AxisY axisY = new AxisY();
                axisY.Name = "POCOUNT";
                axisY.NarrowRange = false;
                axisY.TitleAppearance.Text = "PO Count";
                axisY.TitleAppearance.TextStyle.FontSize = 14;
                axisY.TitleAppearance.TextStyle.FontFamily = "Tahoma";
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                ColumnSeries col = new ColumnSeries
                {
                    Name = dt.Rows[i][0].ToString()
                };
                int j = 1;
                CategorySeriesItem cs = new CategorySeriesItem();
                if (iWaveLibrary.ConvertToDecimal(dt.Rows[i][j].ToString())  > 0)
                {
 
                    cs.Y = iWaveLibrary.ConvertToDecimal(dt.Rows[i][j].ToString());
                }
                 
                col.SeriesItems.Add(cs);
                h1.PlotArea.Series.Add(col);
 
                LineSeries ls = new LineSeries();
 
                CategorySeriesItem csls = new CategorySeriesItem();
                if (iWaveLibrary.ConvertToDecimal(dt.Rows[i][2].ToString()) > 0)
                {
                    csls.Y = iWaveLibrary.ConvertToDecimal(dt.Rows[i][2].ToString());
                }
                ls.SeriesItems.Add(csls);
                ls.AxisName = "POCOUNT";
                ls.TooltipsAppearance.DataFormatString = "{0}";
                h1.PlotArea.Series.Add(ls);
                h1.DataBind();
 
            }
            for (int i = 0; i < dt.Rows.Count; i++)
            {
                AxisItem xAxisItem = new AxisItem(dt.Rows[i][0].ToString());
                if (!h1.PlotArea.XAxis.Items.Contains(xAxisItem))
                {
                    h1.PlotArea.XAxis.Items.Add(xAxisItem);
                }
            }
 
            h1.PlotArea.XAxis.AxisCrossingPoints.Add(0);
            h1.PlotArea.XAxis.AxisCrossingPoints.Add(dt.Rows.Count + 1);
            h1.PlotArea.YAxis.LabelsAppearance.DataFormatString = "N";
            h1.PlotArea.CommonTooltipsAppearance.DataFormatString = "N";
             
 
            h1.Visible = true;
            h1.InvokeLoadData = Telerik.Web.UI.HtmlChart.LoadDataInvocation.OnPageLoad;
            h1.PlotArea.YAxis.MinorGridLines.Visible = false;
            h1.PlotArea.XAxis.MinorGridLines.Visible = false;
            h1.PlotArea.XAxis.MajorGridLines.Visible = false;

Tags
Chart (HTML5)
Asked by
jk
Top achievements
Rank 1
Answers by
Danail Vasilev
Telerik team
Pratik
Top achievements
Rank 1
Share this question
or