This is a simulation of AC powered RC circuit.
It can be used to study phase between voltage of capacitor$VR$, voltage of resistor $VR$and voltage of AC power supply $Vs$.
[img]http://www.phy.ntnu.edu.tw/ntnujava/index.php?action=dlattach;topic=2147.0;attach=4055;image[/img]
$V_{AC}=V_C+V_R$,

$I(t)=\frac{V_R}{R}=\frac{V_{AC}-V_C}{R}=\frac{V_{AC}-Q/C}{R}$

$V_C(t)=\frac{Q}{C}$

$Q(t)=\int I\, dt$
The current $I$ and voltage $V_C$ are 90 degree out of phase.

The voltage $V_C$ in capacitor is proportional to charge $Q$,
However, change $Q$ need to be charged by  current $I$. ($Q=\int I\,dt$).
So current $I$ is leading charge $Q$ (90 degree earlier).
And voltage in resistor $V_R$ is proportional to current $I$.
Voltage in R ($V_R$)is leading Voltage in capacitor($V_C$)

The following simulation assume, $V_{AC}=V_o \sin\,(\omega\,t+\phi)$

$V_R=I\,R,\qquad V_C=\frac{Q}{C}=\frac{1}{C}\,\int I dt$