Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Changing .InsideHeight in PlotArea

Status
Not open for further replies.

AGlazer

Programmer
Sep 15, 2002
38
0
0
US
Hey, guys.

I have two graphs that represent similar data for different organizations. I apply a custom graph type to the graphs and 95% of the time this works fine; I also stabalize the major unit, max & min on the axes, so they are the same for both grapsh Every once in a while, though, one .PlotArea.InsideHeight is larger than the other one (generally because of issues with displaying the labels). Since these graphs are being compared together, I need the .PlotArea.InsideHeight to be the same height -- but I can't set it in Excel, as it's a read only variable. The code below was what someone here in the office came up with to fix it, but it doesn't seem to work right. Any ideas?

With nChart
'other random code is here
sgl1 = .PlotArea.InsideHeight
End With

With cbChart
'other random code is here
sgl2 = .PlotArea.InsideHeight
End With

If Abs(sgl1 - sgl2) > 2 Then
If sgl2 > sgl1 Then
cbChart.PlotArea.Height = cbChart.PlotArea.Height - (sgl2 - sgl1)
Else:
nChart.PlotArea.Height = nChart.PlotArea.Height - (sgl1 - sgl2)
End If
End If

Thanks!
 
Sorry, should have been more descriptive.

The code itself runs, but it doesn't actually fix the problem -- the two graphs don't end up with the same InsideHeight size, which is what it was originally designed to do.
 
Why not just set the Plot.Height in each to the same value?
Code:
        If Abs(sgl1 - sgl2) > 2 Then
            If sgl2 > sgl1 Then
                cbChart.PlotArea.Height = cbChart.PlotArea.Height 
            Else
                nChart.PlotArea.Height = nChart.PlotArea.Height 
            End If
        End If


Skip,
Skip@TheOfficeExperts.com
 
oops...
Code:
        If Abs(sgl1 - sgl2) > 2 Then
            If sgl2 > sgl1 Then
                cbChart.PlotArea.Height = nChart.PlotArea.Height 
            Else
                nChart.PlotArea.Height = cbChart.PlotArea.Height 
            End If
        End If

Skip,
Skip@TheOfficeExperts.com
 
Skip,

Thanks. PlotArea.Height is exactly the same for both -- it's the inside height (the part of the graph that has data, but not labels) that's different. I need that part to be the same, so we were trying to "fix" the inside height by alterint ght PlotArea.Height for both graphs.

Basically, Graph A looks like this:

_
| |
| |
l
a
b
e
l

while graph B looks like this

_
| |
| |
| |
| |
lb
ae
l

They both are the same height, but the inside height is different.

That help?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top