I just edited my question. Assuming X is compact,....
The statement is true even though the domain is compact.
I can tell you are doing physics. I am doing economics, sin function will never cross my mind.
Let me see if I understand what you're asking correctly. You want a function f:X->Y whose domain and range are compact, but whose graph isn't? If this is the case, then (unless you look at non-Hausdorff spaces) you won't be very lucky finding one that is continuous, so try to find that isn't continuous. (Another hint: Try a step function.)
We Value Quality
• Topics based on mainstream science
• Proper English grammar and spelling We Value Civility
• Positive and compassionate attitudes
• Patience while debating We Value Productivity
• Disciplined to remain on-topic
• Recognition of own weaknesses
• Solo and co-op problem solving