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

Formatting Dates Not Working As Expected

1 Answer 118 Views
Chart (HTML5)
This is a migrated thread and some comments may be shown as answers.
Tyler
Top achievements
Rank 1
Tyler asked on 30 Aug 2016, 06:42 PM

Hey all.

I have a stored procedure that returns two columns: [dates] and [total]. I have bound a RadHtmlChart to this data as a Line Series. Currently, my tooltip is showing the [Total] properly, however I'd also like it to display the date.

Doing #=dataItem.dates# returns something along the lines of "Mon Aug 27 2016 12:00:000 Eastern Standard Time", which I would desperately need formatted. I'd prefer "08/29/16" and have tried to achieve it using the following:

#= kendo.format(\'{0:MM/dd/yy}\', dates) #

but this results in the tooltips not working at all, which I assume is indicative of a syntax error. Can anyone assist?

<telerik:RadHtmlChart runat="server" ID="RadHtmlChart1" Layout="stock" DataSourceID="report">
            <PlotArea>
                <Series>
                    <telerik:LineSeries DataFieldY="Total" Name="Combined Total">
                        <LineAppearance LineStyle="Smooth" />
                        <LabelsAppearance Visible="false"></LabelsAppearance>
                        <TooltipsAppearance>
                            <ClientTemplate>
                            <strong>Combined: </strong>#=dataItem.Total#
                            </ClientTemplate>
                        </TooltipsAppearance>
                    </telerik:LineSeries>
                </Series>
                <XAxis DataLabelsField="dates" Type="Date" BaseUnit="days" BaseUnitStep="1" EnableBaseUnitStepAuto="true">
                    <TitleAppearance Text="Date"></TitleAppearance>
                    <MajorGridLines Visible="true" />
                    <MinorGridLines Visible="false" />
                </XAxis>
                <YAxis>
                    <TitleAppearance Text="Declines"></TitleAppearance>
                    <LabelsAppearance DataFormatString="{0}">
                    </LabelsAppearance>
                </YAxis>
            </PlotArea>
        </telerik:RadHtmlChart>

1 Answer, 1 is accepted

Sort by
0
Ianko
Telerik team
answered on 02 Sep 2016, 07:11 AM

Hello Tyler,

 

You can check out this article here: http://docs.telerik.com/devtools/aspnet-ajax/controls/htmlchart/appearance-and-styling/format-dates

 

What you are using, although, is the client template of the chart. Which can be formatting with the kendo.toString method. You can check the Kendo documentation for that: http://docs.telerik.com/kendo-ui/framework/globalization/dateformatting. And you can read this forum thread for more details and examples about the syntax to use: http://www.telerik.com/forums/template-syntax-conditional-statements

 

Regards,
Ianko
Telerik by Progress
Do you need help with upgrading your ASP.NET AJAX, WPF or WinForms projects? Check the Telerik API Analyzer and share your thoughts.
Tags
Chart (HTML5)
Asked by
Tyler
Top achievements
Rank 1
Answers by
Ianko
Telerik team
Share this question
or