Completed
Last Updated: 13 Nov 2015 12:20 by ADMIN
ADMIN
Danail Vasilev
Created on: 08 Dec 2014 08:23
Category: HtmlChart
Type: Bug Report
0
FIX XAxis labels of data-bound categorical series must not be parsed to numeric
When data-bound categorical series has zeros in the x-axis labels they are parsed and the zeros disappear. For example:
ASPX:

            <asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
            <telerik:RadHtmlChart runat="server" ID="Radhtmlchart1">
                <PlotArea>
                    <Series>
                        <telerik:ColumnSeries DataFieldY="Score1"></telerik:ColumnSeries>
                   </Series>

                   <XAxis DataLabelsField="Student">
                    </XAxis>
                </PlotArea>
            </telerik:RadHtmlChart>

C#:

    protected void Page_Load(object sender, EventArgs e)
    {
        Radhtmlchart1.DataSource = GetData();
        Radhtmlchart1.DataBind();
    }
    protected DataTable GetData()
    {
        DataTable table = new DataTable();

        table.Columns.Add("Student", typeof(string));
        table.Columns.Add("Score1", typeof(int));

        table.Rows.Add(new object[] { "0806014562", 40 });
        table.Rows.Add(new object[] { "0806014562", 50 });
        table.Rows.Add(new object[] { "0806014562", 70 });
        return table;
    }
Workarounds:
1) Use format string to add the desired missing zeros when parsed.

<LabelsAppearance DataFormatString="0{0}"></LabelsAppearance>

2) Add items programmatically

    protected void Page_Load(object sender, EventArgs e)
    {
        Radhtmlchart1.DataSource = GetData();
        Radhtmlchart1.DataBind();

        DataTable currDT = GetData();
        for (int i = 0; i < currDT.Rows.Count; i++)
        {
            AxisItem currItem = new AxisItem(currDT.Rows[i]["Student"].ToString());
            Radhtmlchart1.PlotArea.XAxis.Items.Add(currItem);
        }
    }
0 comments