resize graph depending on available space