Completed
Last Updated: 14 Feb 2014 07:32 by ADMIN
ADMIN
Danail Vasilev
Created on: 28 Nov 2013 14:32
Category: HtmlChart
Type: Bug Report
1
FIX DateTime parsing of the data source when the XAxis type is category in RadHtmlChart
If the type of the XAxis is category the field from the data source used for the XAxis must not be tried to be parsed to DateTime format.

For the time being the issue can be workaround as follows:

-Either set an appropriate DataFormatString for the XAxis labels. For example:

        <telerik:RadHtmlChart ID="ColumnChart" runat="server" Width="600" Height="400">
            <PlotArea>
                <Series>
                    <telerik:ColumnSeries DataFieldY="yValues">
                    </telerik:ColumnSeries>
                </Series>
                <XAxis DataLabelsField="xLabels" Type="category">
                    <LabelsAppearance DataFormatString="d - MM"></LabelsAppearance>
                </XAxis>
            </PlotArea>
        </telerik:RadHtmlChart>

- OR add the XAxis items manually from the data source:

ASPX:

        <telerik:RadHtmlChart ID="ColumnChart" runat="server" Width="600" Height="400">
            <PlotArea>
                <Series>
                    <telerik:ColumnSeries DataFieldY="yValues">
                    </telerik:ColumnSeries>
                </Series>
                <XAxis DataLabelsField="xLabels" Type="category">
                    <LabelsAppearance></LabelsAppearance>
                </XAxis>
            </PlotArea>
        </telerik:RadHtmlChart>
C#:

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

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

    protected DataTable GetData()
    {
        DataTable dt = new DataTable();
        dt.Columns.Add("yValues");
        dt.Columns.Add("xLabels");

        dt.Rows.Add(10, "1 - 10");
        dt.Rows.Add(30, "2 - 11");
        dt.Rows.Add(20, "3 - 12");

        return dt;
    }

2 comments
ADMIN
Danail Vasilev
Posted on: 14 Feb 2014 07:32
The issue will be fixed for Q1 2014.
Robert Veach
Posted on: 04 Dec 2013 14:09
This would be very useful.  I don't think that every value should be checked to see if it is a date and then formatted as a date.  For instance, ranges ( 1- 10, 11 -20, 21 -30, 31 - 40 ) end up with the first two values showing as dates and the rest normally which makes no sense.  Taking out automatic formatting makes sense since the format can be controlled by the developer if needed.