Kendo Pie Chart Sum, Count, Avg

3 posts, 1 answers
  1. Gokhan
    Gokhan avatar
    15 posts
    Member since:
    Jan 2014

    Posted 17 Oct 2014 Link to this post

    I have a problem with Kendo Pie chart about "Aggregate" functions(count, sum, average).Everyting works with Bar or Column chart but when i try to show pie chart i can't use count, sum, average functions of Kendo Pie Chart's.

    I can show my values invidually but i can't group my values(like euro, dolar, lira)How can i group my values and show them with Pie chart?

    Here is my model:
    public decimal MoneyValue{ get; set; }
    public string MoneyName{ get; set; }

    My values are coming like that with Pie Chart.:
    Euro - 10
    Dolar- 100
    Dolar - 50
    Euro -15
    Dolar - 50
    Lira - 45

    I need to show values like that:
    Euro - Count: 2 Total:25 Avg: 12,5
    Dolar - Count: 3 Total: 200 Avg: 66,6
    Lira Count: 1 Total: 200 Avg: 200

    View Code


    View Code@(Html.Kendo().Chart(Model)
    .Name("chart")
    .Title(title => title
    .Text(@ViewBag.a)
    .Position(ChartTitlePosition.Top))
    .Legend(legend => legend
    .Visible(false)
    .Position(ChartLegendPosition.Top))
    .Series(series =>
    {
    series.Pie(model => model.MoneyValue, categoryExpression: model => model.MoneyName);
    // .Aggregate(ChartSeriesAggregate.Count)
    //.Labels(labels => labels.Visible(true).Position(ChartBarLabelsPosition.Center));

    //here i get the error. It shows there is no .Aggregate function so i can't group my values.

    })


    .Theme("metro")
    .Tooltip(tooltip => tooltip
    .Visible(true)
    .Template("#= category #: #= value #"))
    .Events(ev => ev.DataBound("onDB"))

    )

    Kendo Count - Sum - Average functions:(i've no problem with them, they work correctly.)<div class="configuration-horizontal">

    <div class="config-section">
    <center>
    <span class="configHead">Grafik </span>
    </center>
    <ul class="options">

    <td>
    <input id="aggregateSum" name="aggregate" type="radio" value="sum" autocomplete="off" />

    Sum

    </td>
    <td>
    <input id="aggregateAvg" name="aggregate" type="radio" value="avg"
    autocomplete="off" />

    Avg

    </td>
    <td>
    <input id="aggregateCount" name="aggregate" type="radio" value="count" checked="checked" autocomplete="off" />

    Count

    </td>
    </ul>

    </div>
    </div>
    <script>
    $(".configuration-horizontal").bind("change", refresh);

    function refresh() {
    var chart = $("#chart").data("kendoChart"),
    series = chart.options.series,
    categoryAxis = chart.options.categoryAxis,
    baseUnitInputs = $("input:radio[name=baseUnit]"),
    aggregateInputs = $("input:radio[name=aggregate]");

    for (var i = 0, length = series.length; i < length; i++) {
    series[i].aggregate = aggregateInputs.filter(":checked").val();
    }

    categoryAxis.baseUnit = baseUnitInputs.filter(":checked").val();

    chart.refresh();
    }
    </script>
  2. Answer
    Hristo Germanov
    Admin
    Hristo Germanov avatar
    703 posts

    Posted 17 Oct 2014 Link to this post

    Hello Gokhan,

    Currently the Kendo UI Chart doesn't support aggregates for Pie series. I would suggest to submit your request in Kendo's UserVoice so other members of the community can evaluate, comment on and vote for it. 

    Regards,
    Hristo Germanov
    Telerik
     

    Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

     
  3. UI for ASP.NET MVC is VS 2017 Ready
  4. Gokhan
    Gokhan avatar
    15 posts
    Member since:
    Jan 2014

    Posted 17 Oct 2014 in reply to Hristo Germanov Link to this post

    Thank you. I will.
Back to Top