P
PLP
I'm trying to "square" a chart...
I mean:
given 2 points (P1 and P2) with coordinates
P1(x1,y1) and P2(x2,y2), I want set the vertical (y) distance between P2 and
P1 equal to the horizontal distance between the points (on the monitor, in
pixels).
I start with a chart, and after drawing the chart (let's say with
..plotarea.width = k) I want resize it to fit my need.
From a matematichal point of view, the problem is very simple.
What I want is that:
(y2-y1)
-------- = 1
(x2-x1)
So (y2-y1) = (x2-x1).
Obviously you have to consider the value in pixel of both y2, y1 and x2,x1
pairs.
The distance in pixel is:
(y2-y1) =((y2actualvalue - y1actualvalue)* (.MaximumscaleY -
..MinimumscaleY))/.InsideHeight
I have to change the .plotarea.insidewidth, let's say from k to k'.
In excel vba language it should be something like this:
..PlotArea.InsideWidth = ((y2 -y1) * ActiveChart.PlotArea.InsideHeight *
(MaximumscaleX - MinimumscaleX)) / ((MaximumscaleY - MinimumscaleYs) *
(x2 -x1) )
(I know the formula is not correct, it's just to give you an idea; I wrote
the right formula in tha actual subroutine)
The problem is that I cannot change the .plotarea.insidewidth value but only
the .plotarea.widht value.
There is some relation between the .insidewidth and the .width value?
I tryed guessing width = .insidewidth + left but it does'nt work.....
Then I tryed with .insidewidth + 2 * left (maybe there is a right
also ), but it doesn't work again.
The best result I reached so far is using a Do while... loop with a little
change in the width of just one pixel for time, and then verifying the new
(y2-y1)/(x2-x1) ratio.
Is quite good, but non perfect....
Any ideas?
Tkx
Pierluigi
:
I mean:
given 2 points (P1 and P2) with coordinates
P1(x1,y1) and P2(x2,y2), I want set the vertical (y) distance between P2 and
P1 equal to the horizontal distance between the points (on the monitor, in
pixels).
I start with a chart, and after drawing the chart (let's say with
..plotarea.width = k) I want resize it to fit my need.
From a matematichal point of view, the problem is very simple.
What I want is that:
(y2-y1)
-------- = 1
(x2-x1)
So (y2-y1) = (x2-x1).
Obviously you have to consider the value in pixel of both y2, y1 and x2,x1
pairs.
The distance in pixel is:
(y2-y1) =((y2actualvalue - y1actualvalue)* (.MaximumscaleY -
..MinimumscaleY))/.InsideHeight
I have to change the .plotarea.insidewidth, let's say from k to k'.
In excel vba language it should be something like this:
..PlotArea.InsideWidth = ((y2 -y1) * ActiveChart.PlotArea.InsideHeight *
(MaximumscaleX - MinimumscaleX)) / ((MaximumscaleY - MinimumscaleYs) *
(x2 -x1) )
(I know the formula is not correct, it's just to give you an idea; I wrote
the right formula in tha actual subroutine)
The problem is that I cannot change the .plotarea.insidewidth value but only
the .plotarea.widht value.
There is some relation between the .insidewidth and the .width value?
I tryed guessing width = .insidewidth + left but it does'nt work.....
Then I tryed with .insidewidth + 2 * left (maybe there is a right
also ), but it doesn't work again.
The best result I reached so far is using a Do while... loop with a little
change in the width of just one pixel for time, and then verifying the new
(y2-y1)/(x2-x1) ratio.
Is quite good, but non perfect....
Any ideas?
Tkx
Pierluigi
: