As the variable is constantly increasing or decreasing , is there such a way that i can write the program to plot the graph of this 'x' variable against time(ms).
The main purpose is for me to plot a graph so that i can observe the acceleration and deceleration of the robot so that I can tune the PID.
If you have a collection (in the form of an array or an STL container) of coordinates (time, speed) then simply use that information to output a graph on screen. It will be no different from graphing any other pair of coordinates and I bet you can find examples on the Net. But even if you find nothing specific for C++, you can read about graphing or charting for other languages because the algorithm will be similar.
For example, you need to calculate the proper scale to use, decide whether or not your graph will auto-scale depending on the data (highly recommended), and how to actually draw the curve, which in reality is quite simple: Connect the coordinates with line segments.
I'm not sure about plotting in C++, but if you don't have to use C++, maybe you can try some less 'strict' language for the plotting part. For Python, as an example, using the package 'matplotlib' will make it really easy. The data transfer can be a little tricky, but you can always transfer with data files.