Max,Min X-Coordinate

I need to customize code in my vba project for creating charts and thus adjusting the x,y coordinates to fit the chart accordingly into the excel sheet.

for example say if the y coordinate value is exceeding the maximum value , if y=80 and the input is 85 then that difference of 5 will be squeezed in the design. How can I overcome this.
Who is Participating?
Let's see.

Your chart will have a maximum height, and a maximum y value. The maximum height is a data you know (as you define how much space you will use on your view), while your maximum y value will depend in each load of the graph.

So... to make your values fit always on your defined height, you'll need to assign a correspondence between the space and the max values.

When you retrieve data you'd get the maximum y value on the dataset, then, through a simply mathematical rule, you can obtain the size of a unit on your graph:
total height --> maximum y
x --> single unit

x = (totalHeight * singleUnit) / maximum y

Once you know the maximum y value on your dataset you can recalculate the size of your graphs unit and redraw it.
Moizsaif123Author Commented:
I got a clear picture of the work needed. I have attached an image where the coordinates marked as (1,10) and (2,9) so the line is so short and now i want the space between the spaces where iv marked with arrows in the jpeg to not appear or to be filled.

so to fill the space the max,min of the y axis needs to be set as 10,9 so the line will be longer as well as the x-axis.

I need code to implement now the requirement is this. can I get an example of some code.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.