Or should I write this as differentiate respect to x only in my example.

$\displaystyle r^2=x^2+y^2\;\Rightarrow\;\frac{dr}{dx}=\frac {x}{r}+\frac{y}{r}\frac{dy}{dx}$

$\displaystyle x=r\cos\theta\;\Rightarrow dx=dr\cos\theta\;\Rightarrow\;\frac{dr}{dx}=\frac{ 1}{\cos\theta}=\frac{r}{x}$

$\displaystyle \Rightarrow\;\frac{r}{x}=\frac {x}{r}+\frac{y}{r}\frac{dy}{dx}$

$\displaystyle \Rightarrow\;\frac{dy}{dx}=\left(\frac{r}{x}-\frac{x}{r}\right)\frac{r}{y}$

$\displaystyle y=r\sin\theta$ and $\displaystyle x=r\cos\theta$

$\displaystyle \Rightarrow\;\frac{dy}{dx}=\left(\frac{r}{x}-\frac{x}{r}\right)\frac{r}{y} = \frac{r^2}{r^2 \cos\theta \sin\theta}-\frac{\cos\theta}{\sin\theta}=\tan\theta$