fixed graph going outside of viewing window issue