Home Forums WPF controls Xceed DataGrid for WPF StatFunction – Sum on TimeSpan? Customize?

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #25987 |

    I’m cannot get Sums or Averages StatFunctions to work on TimeSpan columns.

    The Minimum and Maximum StatFunctions work OK for TimeSpan Columns.

    Has anyone had a similar experience or know of a work-around I could try?

    Is it possible to define your own custom StatFunction?

    Thanks,
    Rich

    Imported from legacy forums. Posted by Richard (had 3374 views)

    Xceed Support
    Member
    Post count: 5658

    Hi Rich,

    I haven’t tried StatFunctions on a TimeSpan value; however, you can create your own. Take a look at the CountIfFunction in the StatFunctions sample, it will show you how to go about creating your own 🙂

    Imported from legacy forums. Posted by Jenny [Xceed] (had 293 views)

    User (Old forums)
    Member
    Post count: 23064

    Hi Jenny,

    I’ve looked around for the sample but haven’t found it yet.

    I’ve checked ms-help://Xceed.Wpf.DataGrid/Documentation/Statistical%20Functions.html and other places without success.

    Where should I go to find it ?

    Thanks,
    Rich

    Imported from legacy forums. Posted by Richard (had 474 views)

    Xceed Support
    Member
    Post count: 5658

    C:\Xceed Component Samples\Xceed DataGrid for WPF 1.3\Samples\CSharp\StatFunctions\CountIfFunction.cs 🙂

    Imported from legacy forums. Posted by Jenny [Xceed] (had 190 views)

    User (Old forums)
    Member
    Post count: 23064

    Before seeing your response I created this derivation of SumFuntion and it works fine.

    This is really powerful stuff! Thanks! Just Fantastic! 🙂

    Writing Xceed WPF DataGrid StatFunctions is my new favorite thing to do… .yeah I haven’t had enough sleep 🙂

    <b>TimeSpan Sum StatFunction</b>

    public class TimeSpanSumStatFunction : SumFunction
    {
    private TimeSpan m_sum = new TimeSpan();
    protected TimeSpan Sum
    {
    get { return m_sum; }
    }

    protected override void Reset()
    {
    m_sum = new TimeSpan();
    }

    protected override void Accumulate(object[] values)
    {
    foreach (object obj in values)
    {
    m_sum = Sum.Add((TimeSpan)obj);
    }
    }

    protected override void AccumulateChildResult(StatResult childResult)
    {
    m_sum = m_sum.Add((TimeSpan)childResult.Value);
    }

    protected override StatResult GetResult()
    {
    return new StatResult(m_sum);
    }

    }

    Imported from legacy forums. Posted by Richard (had 4970 views)

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.