Can the graph of a continuous real function $f:\mathbb{R}\to\mathbb{R}$ be a totally disconnected subset of $\mathbb{R}^2$?
Certainly there can be many disconnected points (in $\mathbb{R}^2$), like the point $(0,0)$ in the graph of:
$ f(x)= \begin{cases} x\sin\frac{1}{x}&\text{if}\, x\neq 0\\ 0&\text{if}\, x=0\\ \end{cases} $
And perhaps it isn't necessary for the graph of $f$ to be connected either side of these "disconnected points".
Whether or not there is a real function $f$ and dense subset $X$ of $\mathbb{R}$ so that $\{\ (x,f(x)): x\in X\}$ is a totally disconnected subset of $\mathbb{R}^2,\ $ I am not sure. Perhaps this is not possible?
The graph of any continuous function $f:X\to Y$ is homeomorphic to $X$ via $x\mapsto \big(x,f(x)\big)$ (see this). In particular any continuous function $\mathbb{R}\to\mathbb{R}$ has a (path)connected graph.
It is unclear why you think that your particular $f$ has a disconnected graph. It certainly is even path connected.