This paper proposes Synthetic-on-Graph (SoG), a novel synthetic data generation framework for continuous pretraining on small, specialized datasets. Unlike existing methods that focus solely on document content, SoG enhances the diversity and depth of synthetic data by considering knowledge associations between documents. SoG extracts entities and concepts from the original dataset, constructs a context graph representing inter-document associations, and performs knowledge-related sampling using a graph exploration strategy. Furthermore, it integrates Chain-of-Thought (CoT) and Contrastive Clarifying (CC) strategies to enhance the quality of the synthetic data and enhance its inference and discriminative capabilities. Experimental results demonstrate that SoG outperforms state-of-the-art (SOTA) methods in multi-hop QA and domain-specific QA, and demonstrates competitive performance in long-text context understanding. These results demonstrate SoG's superior generalization capabilities.