Can we change the color of the line of the graph based on a third variable in the graph?

While the x axis will show the time, the y axis will be showing the measured value coming at that time. In addition to these, if another data comes in that timestamp, can we change the color of the line according to the value of this variable?