Add item to a Telerik Chart pie template

Asked

Viewed 79 times

4

I’m developing a chart using Telerik. In the graphic I need to show, in the template, some relevant information, such as formation, percentage and total. But I can only show two (training and percentage), in which case the Telerik comes by default, which is the field and the categoryField. Has the explodField also, but it only serves to highlight the part of the chart that was selected. Follow the code below:

    function createChart(data) {
    $("#divGraficoFinanceiro").kendoChart({
        theme: $(document).data("kendoSkin") || "default",
        seriesDefaults: {
            labels: {
                visible: true,
                background: "transparent",
                template: "Formação: #= category #: \n Percentual: #= value#% \n Total: #= total#"
            }
        },
        series: [{
            type: "pie",
            field: "percentage",
            categoryField: "source",
            explodeField: "explode"
            //adicionar o novo item => totalField: "total"

        }],
    });

How could you add a new item within the series: and show it in the seriesDefault: ?

1 answer

1


Well, I see that in the template you already have a variable with the total, I believe it is in javascript, so the only problem is in displaying it.
Telerik already has standard forms for this, in this case: #= var_telerik #, but when you want to display your own javascript variable, use: #: sua_var #. In this case your code would be:

template: "Formação : #= category# \n Percentual : ${value} % \n Total : #: total #"

You can test it will work!

  • 1

    It worked perfectly! Thank you

Browser other questions tagged

You are not signed in. Login or sign up in order to post.