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

[Solved] Tooltip Template Format

3 Answers 118 Views
Chart
This is a migrated thread and some comments may be shown as answers.
This question is locked. New answers and comments are not allowed.
Rick Glos
Top achievements
Rank 1
Rick Glos asked on 04 Apr 2012, 03:54 PM
I have a relatively complex tooltip to add.  I'm attempting to convert what I have in WPF.  It looks like this:

Screenshot

Because I'm displaying multiple values, they don't all have the same format specifier.  One is a percent, another is a number, another is a number with 2 decimal positions.  ({0:P0}, {0:N0} and {0:N2})

Is there a way to do this within the Template?

@(Html.Telerik().Chart(Model.FairShareDataPoints)
        .Name("PhonesFairShare")
        .Theme("windows7")
        .Title("Fair Share")
        .Series(series =>
        {
            series.Line(s => s.Goal).Color("Red");
            series.Line(s => s.FairShare)
                .Color("Green")
                .Tooltip(x => x.Template("<table><tr><td>Fair Share Team Member:</td><td><#= value #></td></tr><tr><td>Time Period:</td><td><#= category #></td></tr></table><#= dataItem.TeamMemberPhoneCallsPresented #>")
                    .Visible(true)
                );
        })
        .CategoryAxis(axis => axis
            .Categories(s => s.TimePeriodCaption)
            .Labels(label => label.Rotation(45)))
        .ValueAxis(x => x.Numeric().Labels(l => l.Format("{0:P0}")))
        )

3 Answers, 1 is accepted

Sort by
0
Accepted
Iliana Dyankova
Telerik team
answered on 06 Apr 2012, 12:17 PM
Hello Rick,

In order to display multiple values with different format through template, you need to use the $.telerik.formatNumber utility method.
For example: 
.Series(series =>
    {
        series.Line(...).Color("Red");
        series.Line(...).Color("Green")
            .Tooltip(x => x.Template("<table><tr><td>Fair Share Team Member:</td><td><#= $.telerik.formatNumber(value,'{0:P0}') #></td><td><#= $.telerik.formatNumber(value,'{0:N2}') #></td><td><#= $.telerik.formatNumber(value,'{0:N0}') #></td></tr><tr><td>Time Period:</td><td><#= category #></td></tr></table><#= dataItem.TeamMemberPhoneCallsPresented #>")
                .Visible(true)
            );
    })

 

Kind regards,
Iliana Nikolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
0
Rick Glos
Top achievements
Rank 1
answered on 10 Apr 2012, 03:40 PM
Thank you that solved the problem.

Where would I find this information in the ASP.NET MVC documentation?  I didn't see anything.
0
Iliana Dyankova
Telerik team
answered on 11 Apr 2012, 09:42 AM
Hi Rick,

I am glad that everything works fine now.

Currently documentation on this topic is not available, but we are planning to add it in the near future. Please excuse us for the temporary inconvenience.

 

All the best,
Iliana Nikolova
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the Telerik Extensions for ASP.MET MVC, subscribe to their blog feed now.
Tags
Chart
Asked by
Rick Glos
Top achievements
Rank 1
Answers by
Iliana Dyankova
Telerik team
Rick Glos
Top achievements
Rank 1
Share this question
or