How to calculate power from this diagram?
You are making this way too complicated.

From inspection you can see that during the first half of the period shown, you have a steady voltage of 500 mV.  The power is then just the average of the current times this voltage, which is 250 mW.  From inspection again you can see that the second half of the period is the same as the first half with the signs of the voltage and current flipped.  This obviously yields the same power again, 250 mW.

The instantaneous power is a triangle wave with peaks at 0 and 500 mW, and average of 250 mW (unless I'm misunderstanding what that diagram is showing).

Added:

I forgot to mention about calculating reative power.

One way to get that is to derive the power factor.  The power factor is usually described as the cosine of the phase angle between the current and voltage assuming both are sines.  However, it also has a more general definition that is more appropriate in this case.  You can think of the power factor as the ratio of true power to the product of RMS current and voltage.

In this case, the RMS voltage is obvious, which is 500 mV.  From inspection you can see that the current is symmetric and repeating, so you only have to solve for the RMS current of a ramp from 1 to 0.  From symmetry we can see that this must be the same as a ramp from 0 to 1, which will make the equation a little easier.

In other words, find the RMS current of I(t) = t from 0 to 1.  To do that, first square the function, which is then t^2.  The average of that from 0 to 1 is 1/3, and then the square root of that is 0.577.  So the RMS voltage is 500 mV, the RMS current is 577 mA, and the product of the two is 289 mW.  From above the real power is only 250 mW, so the power factor is 250mW/289mW = 0.866.  The reactive power is

sqrt(289mW^2 - 250mW^2) = 144 mW

Again, there is no need to make this complicated.