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

DataViz chart aggregate function inlcuding data from previous month

5 Answers 79 Views
Charts
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 02 Oct 2013, 08:24 PM
Hi,

I'm building a basic line chart in Kendo UI Dataviz and I'm having a
problem with the aggregation method. The goal is to group my sales data
by month and aggregate the Sum(Amount) which seems to work in my chart
but I'm experiencing a bug that causes data from the first day of
October to be included in the sum for September. Oct 2 shows in October
but Oct 1 is included in September's total.

The data is:

10/1/2013 12:00:00 AM, 22964.5000

10/2/2013 12:00:00 AM, 6762.9400

Html.Kendo().Chart(Model)
.Name("revenue")
.Title("Revenue Activity by Month")
.Legend(legend => legend
.Position(ChartLegendPosition.Bottom)
)
.Series(series =>
{
series.Area(s => s.TotalRevenue, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Total Revenue").Color("#73c100");
series.Line(s => s.RevenueSubscriber, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Subscriber Revenue");
series.Line(s => s.RevenueNonSubscriber, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Non-Subscriber Revenue");
})
.CategoryAxis(axis => axis.Date()
.BaseUnit(ChartAxisBaseUnit.Months)
)
.ValueAxis(axis => axis
.Numeric("revenue")
.Labels(labels => labels.Format("{0:C}"))
.Line(line => line.Visible(false))
)
.Tooltip(tooltip => tooltip
.Visible(true)
.Format("{0:C}")
)

What I receive is a chart with two points on the X Axis. The first
point is Sept 2013 and includes $22,964. The second point is Oct 2013
and includes $6,762.

Any ideas would be greatly appreciated.

5 Answers, 1 is accepted

Sort by
0
Hristo Germanov
Telerik team
answered on 03 Oct 2013, 08:19 AM
Hi Chris,

Could you please give me the chart's data because I need to observe the problem locally?

Regards,
Hristo Germanov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Chris
Top achievements
Rank 1
answered on 03 Oct 2013, 03:16 PM
I've attached a sample that will allow you to recreate the error. In the first chart there are two data points for Oct - 10/1 and 10/2. The 10/1 metrics gets included in Sept revenue and the 10/2 included in October revenue. When I move both October metrics to 10/2 they are both included in October like they should be.

Thanks,
Chris
0
Chris
Top achievements
Rank 1
answered on 03 Oct 2013, 03:18 PM
The forum page errored and did not include the attachment so I'm pasting it into this reply.
<%
        // in this example there are two revenue metrics for Oct. The metric for 10/1 is added to Sept, the metric for 10/2 is added to October
        var recs = new []
        {
            new { Date = DateTime.Parse("9/26/2013"), TotalRevenue = Decimal.Parse("276.5600"), RevenueSubscriber = Decimal.Parse("0.0000"), RevenueNonSubscriber = Decimal.Parse("276.5600") }
            , new { Date = DateTime.Parse("9/27/2013"), TotalRevenue = Decimal.Parse("3556.5313"), RevenueSubscriber = Decimal.Parse("0.0000"), RevenueNonSubscriber = Decimal.Parse("3556.5313") }
            , new { Date = DateTime.Parse("10/1/2013"), TotalRevenue = Decimal.Parse("23763.0400"), RevenueSubscriber = Decimal.Parse("23763.0400"), RevenueNonSubscriber = Decimal.Parse("0.0000") }
            , new { Date = DateTime.Parse("10/2/2013"), TotalRevenue = Decimal.Parse("21379.1400"), RevenueSubscriber = Decimal.Parse("21379.1400"), RevenueNonSubscriber = Decimal.Parse("0.0000") }
        };
    %>

    <%=
    Html.Kendo().Chart(recs)
        .Name("revenue")
        .Title("Revenue Activity by Month")
        .Legend(legend => legend
            .Position(ChartLegendPosition.Bottom)
        )
        .Series(series =>
                {
                    series.Area(s => s.TotalRevenue, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Total Revenue").Color("#73c100");
                    series.Line(s => s.RevenueSubscriber, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Subscriber Revenue");
                    series.Line(s => s.RevenueNonSubscriber, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Non-Subscriber Revenue");
                })
        .CategoryAxis(axis => axis.Date()
            .BaseUnit(ChartAxisBaseUnit.Months)
            )
        .ValueAxis(axis => axis
            .Numeric("revenue")
            .Labels(labels => labels.Format("{0:C}"))
            .Line(line => line.Visible(false))
        )
        .Tooltip(tooltip => tooltip
            .Visible(true)
            .Format("{0:C}")
        )
    %>
    <%
        // in this example I moved the both October revenue metrics to 10/2. the revenue showed up in October like it's supposed to
        recs = new []
        {
            new { Date = DateTime.Parse("9/26/2013"), TotalRevenue = Decimal.Parse("276.5600"), RevenueSubscriber = Decimal.Parse("0.0000"), RevenueNonSubscriber = Decimal.Parse("276.5600") }
            , new { Date = DateTime.Parse("9/27/2013"), TotalRevenue = Decimal.Parse("3556.5313"), RevenueSubscriber = Decimal.Parse("0.0000"), RevenueNonSubscriber = Decimal.Parse("3556.5313") }
            , new { Date = DateTime.Parse("10/2/2013"), TotalRevenue = Decimal.Parse("23763.0400"), RevenueSubscriber = Decimal.Parse("23763.0400"), RevenueNonSubscriber = Decimal.Parse("0.0000") }
            , new { Date = DateTime.Parse("10/2/2013"), TotalRevenue = Decimal.Parse("21379.1400"), RevenueSubscriber = Decimal.Parse("21379.1400"), RevenueNonSubscriber = Decimal.Parse("0.0000") }
        };
    %>
    <%=
    Html.Kendo().Chart(recs)
        .Name("revenue2")
        .Title("Revenue Activity by Month")
        .Legend(legend => legend
            .Position(ChartLegendPosition.Bottom)
        )
        .Series(series =>
                {
                    series.Area(s => s.TotalRevenue, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Total Revenue").Color("#73c100");
                    series.Line(s => s.RevenueSubscriber, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Subscriber Revenue");
                    series.Line(s => s.RevenueNonSubscriber, categoryExpression: model => model.Date).Aggregate(ChartSeriesAggregate.Sum).Name("Non-Subscriber Revenue");
                })
        .CategoryAxis(axis => axis.Date()
            .BaseUnit(ChartAxisBaseUnit.Months)
            )
        .ValueAxis(axis => axis
            .Numeric("revenue")
            .Labels(labels => labels.Format("{0:C}"))
            .Line(line => line.Visible(false))
        )
        .Tooltip(tooltip => tooltip
            .Visible(true)
            .Format("{0:C}")
        )
    %>
0
Hristo Germanov
Telerik team
answered on 04 Oct 2013, 12:01 PM
Hello Chris,

I tried to reproduce the problem - to no avail. I am sending my test project for your reference. Could you please examine it and try to reproduce the problem?

Regards,
Hristo Germanov
Telerik
Join us on our journey to create the world's most complete HTML 5 UI Framework - download Kendo UI now!
0
Chris
Top achievements
Rank 1
answered on 04 Oct 2013, 07:39 PM
I ran project and it worked. The only difference I could see between your project and mine was the library. I was using the 7.18 version. I undated project to use the newer library but the problem remains. This weekend I will further investigate and let you know what I find.
Chris
Tags
Charts
Asked by
Chris
Top achievements
Rank 1
Answers by
Hristo Germanov
Telerik team
Chris
Top achievements
Rank 1
Share this question
or