Abstract We define vertex-colourings for edge-partitioned digraphs, which unify the theory of $P$-partitions and proper vertex-colourings of graphs. We use our vertex-colourings to define generalized chromatic functions, which merge the chromatic symmetric and quasisymmetric functions of graphs and generating functions of $P$-partitions. Moreover, numerous classical bases of symmetric and quasisymmetric functions, both in commuting and noncommuting variables, can be realized as special cases of our generalized chromatic functions. We also establish product and coproduct formulas for our functions. Additionally, we construct the new Hopf algebra of $r$-quasisymmetric functions in noncommuting variables, and apply our functions to confirm its Hopf structure, and establish natural bases for it.