lichtbringer February 2016

How to display accumulated data in a line graph in wpf

I'm sure this is a beginner question but somehow I fail to come up with a solution.

I've got a database table which is mapped to a MVVM which among other columns has two named 'DTS' and 'Movement'.

DTS Movement

01.01.2016 12:00 +6.5

02.01.2016 20:00 -4

03.01.2016 13:45 +4.4

04.01.2016 13:45 +10

... ...

Now I want to visualize this information in a Line graph with the Syncfusion WPF Library. The X Axis should be the 'DTS'-Column but the Y Axis should be the sum of the values of the movement column up to the DTS.

For example

X: 01.01.2016 12:00 Y: 6.5

X: 02.01.2016 20:00 Y: 2.5 (6.5 - 4)

X: 03.01.2016 13:45 Y: 6.9 (6.5 - 4 +4.4)

X: 04.01.2016 13:45 Y: 16.9 (6.5 - 4 + 4.4 + 10)

...

Is there's an elegant way to solve this?

Best Regards

Markus

Answers


Sumathi Jayaraj February 2016

we can get the accumulated values by manipulating the movements and accumulated value which is bound to the y-axis value in syncfusion chart.

 private void CalculateYValue()
 {
    double temp = 0;
    for (int index=0;index<DataPoints.Count;index++)
    {
        temp += DataPoints[index].Movement;
        DataPoints[index].YValue += temp;
    }
}

Post Status

Asked in February 2016
Viewed 2,900 times
Voted 11
Answered 1 times

Search




Leave an answer