Completed
Last Updated: 30 May 2016 05:46 by ADMIN
ADMIN
Stamo Gochev
Created on: 16 May 2016 06:36
Category: UI for ASP.NET AJAX
Type: Bug Report
0
The default chart labels' ClientTemplate should not be serialized
When the labels' template is not defined, there is an explicit serialization like:

template:"#= dataItem.<data_bound_property> #"

which is in a collision with the DataFormatString property.

Sample code:

ASPX:
<telerik:RadHtmlChart runat="server" ID="Chart">
<PlotArea>
    <Series>
        <telerik:ColumnSeries DataFieldY="Total" Name="Total">
            <LabelsAppearance DataField="Total" DataFormatString="$#,##0.00">
            </LabelsAppearance>
        </telerik:ColumnSeries>
    </Series>
</PlotArea>
</telerik:RadHtmlChart>

C#:
protected void Page_Load(object sender, EventArgs e)
{
    Chart.DataSource = GetData();
    Chart.DataBind();
}

    
private DataTable GetData()
{
    DataTable table = new DataTable();
    table.Columns.Add(new DataColumn("Total", typeof(long)));
    table.Rows.Add(new object[] { 10000000 });
    table.Rows.Add(new object[] { 10000000 });
    table.Rows.Add(new object[] { 10000000 });
    return table;
}

The workaround is to set the ClientTemplate and remove the DataFormatString property or override the template on the client-side:

        <script type="text/javascript">
            function pageLoad() {
                var chart = $find("Chart");
                var widget = chart.get_kendoWidget();

                widget.options.series[0].labels.template = null;

                chart.repaint();
            }
        </script>
0 comments