Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Chart > String data is not displaying in X-axis of Bar Chart
RadControls for ASP.NET are no longer supported (see this page for reference). In case you have inquiries about the Telerik ASP.NET AJAX controls, post them in the pertinent ASP.NET AJAX forums.

Not answered String data is not displaying in X-axis of Bar Chart

Feed from this thread
  • annu avatar

    Posted on May 13, 2011 (permalink)

    I am creating the Bar chart where in X-axis I am assigning "MeterNumber" which is of type String. But in my line chart it displays 0 where
    the Meter Number is string.
    I am attaching the screenshots, in legend you can see for MeterNumber Meter555, Meter556 , in the x-axis it is displaying 0.

    Below is the code:

    <telerik:RadChart ID="RadChart1" runat="server" Width="710px" OnItemDataBound="RadChart1_ItemDataBound">
                        <Series>
                            <telerik:ChartSeries Type="Bar">
                              <Appearance LegendDisplayMode="ItemLabels">
                                </Appearance>
                            </telerik:ChartSeries>
                        </Series>
                        <Legend>
                            <Appearance GroupNameFormat="#VALUE" >
                            </Appearance>
                        </Legend>
                        <ChartTitle>
                            <TextBlock Text="Energy consumption">
                            </TextBlock>
                        </ChartTitle>
         </telerik:RadChart>

    Code behind:
    public partial class BarChart_Sample : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            List<RT_prcGetReadingBasedOnMeterType_POCResult> readingList = new Model().GetReadingBasedOnMeterType(null);
            RadChart1.DataSource = readingList;
            RadChart1.Series[0].DataYColumn = "MeterReading";
            RadChart1.PlotArea.XAxis.DataLabelsColumn = "MeterNumber";
            RadChart1.PlotArea.XAxis.Appearance.TextAppearance.TextProperties.Font
             = new System.Drawing.Font("Ariel", 8);
            RadChart1.DataBind();
        }
        public void RadChart1_ItemDataBound(object sender, Telerik.Charting.ChartItemDataBoundEventArgs e)
        {
            e.SeriesItem.Name = ((DataRowView)e.DataItem)["MeterNumber"].ToString();
        }
    }

    The Procedure are:

     public List<RT_prcGetReadingBasedOnMeterType_POCResult> GetReadingBasedOnMeterType(string meterType)
            {
                try
                {
                    List<RT_prcGetReadingBasedOnMeterType_POCResult> list = DBContext.RT_prcGetReadingBasedOnMeterType_POC(meterType).ToList();
                    return list;
                }
                catch (Exception ex)
                {
                    throw ex;
                }

            }


    Attached files

  • Evgenia Evgenia admin's avatar

    Posted on May 18, 2011 (permalink)

    Hello annu,

    I'm not able to reproduce the problematic behavior you are facing with our XAxis Labels. The project attached is made with Q1 2009 binaries and demonstrates how a strings made from concatenated letters and numbers are correctly set as Axis Labels. If the issue still persists please download the latest binaries of our control and give it a try or send us a sample runnable zipped project where this issue occurs so that we will be able to investigate it and help you.

    Greetings,
    Evgenia
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get now >>

    Attached files

  • annu avatar

    Posted on May 18, 2011 (permalink)

    Thanx for reply. It is working properly if we set the predefined data in XAxis.
    But I have to set the XAxis value from the database as shown below:

                                 RadChart1.PlotArea.XAxis.DataLabelsColumn = "MeterName";
    Here the "MeterName" is the attribute name of a table and it is the type of nvarchar.
    If I add the DataLabelColumn as MeterName in XAxis it displays 0.
    Please resolve the issues, the value in XAxis is displaying properly if we set the int type column of the table
    but it displays 0 when we set the nvarchar type column.

Back to Top

Skip Navigation LinksHome / Community & Support / Developer Productivity Tools Forums / ASP.NET > Chart > String data is not displaying in X-axis of Bar Chart