now i do this in connecting centers of
vertical centered and horizontal centered
datalabels (mydatalabel.position.left,
mydatalabel.position.top).
it is possible to simplify this?
> thanks
> .f
> http://www.prodomosua.it
>
>
I would suggest that you not use shapes to connect data points on a
chart. Instead, create a new series with just two data points in it.
The two data points will be the data points that you want to connect.
--
Regards,
Tushar Mehta
www.tushar-mehta.com
Microsoft MVP -- Excel
--
In <BkIf8.48524$fa5.1...@twister2.libero.it>, fernando cinquegrani
<f.cinq...@libero.it> wrote
"Tushar Mehta" <ng_p...@bigfoot.com> ha scritto nel messaggio
news:MPG.16edcbbe7...@msnews.microsoft.com...
Tushar Mehta
www.tushar-mehta.com
Microsoft MVP -- Excel
--
In <1l%g8.4319$uN5.1...@twister1.libero.it>, fernando cinquegrani
"Tushar Mehta" <ng_p...@bigfoot.com> ha scritto nel messaggio
news:MPG.16eea3562...@msnews.microsoft.com...
No problem, I think I know what you want. To just draw a closed shape, you
can use Tushar's suggestion, which will connect the points which you define
for the nodes of the closed shape.
Since you want to fill in the shape with some other color, however, you really
need a shape. And the coordinates of the shape have to be converted from
chart X,Y values to screen-pixel-points (or whatever mysterious units those
are). I was intrigued, so I recorded a macro whil I drew a shape, then I
fiddled with it as shown.
This works for an XY Scatter chart (I assume it will crap out for a line
chart), and it will draw a shape using the points of series 1 in the active
chart. It converts from XY to screen coordinates, starts the shape with the
last point of the series, then draws to the first point, the second, and
around to the last (so you do not need to repeat the first/last point).
''' START THE CODE ---------------------------------------
Sub DrawAShape()
Dim myCht As Chart
Dim mySrs As Series
Dim Npts As Integer, Ipts As Integer
Dim myBuilder As FreeformBuilder
Dim myShape As Shape
Dim Xnode As Double, Ynode As Double
Dim Xmin As Double, Xmax As Double
Dim Ymin As Double, Ymax As Double
Dim Xleft As Double, Ytop As Double
Dim Xwidth As Double, Yheight As Double
Set myCht = ActiveChart
Xleft = myCht.PlotArea.InsideLeft
Xwidth = myCht.PlotArea.InsideWidth
Ytop = myCht.PlotArea.InsideTop
Yheight = myCht.PlotArea.InsideHeight
Xmin = myCht.Axes(1).MinimumScale
Xmax = myCht.Axes(1).MaximumScale
Ymin = myCht.Axes(2).MinimumScale
Ymax = myCht.Axes(2).MaximumScale
Set mySrs = myCht.SeriesCollection(1)
Npts = mySrs.Points.Count
Xnode = Xleft + mySrs.XValues(Npts) * Xwidth / (Xmax - Xmin)
Ynode = Ytop + (Ymax - mySrs.Values(Npts)) * Yheight / (Ymax - Ymin)
Set myBuilder = myCht.Shapes.BuildFreeform(msoEditingAuto, Xnode, Ynode)
For Ipts = 1 To Npts
Xnode = Xleft + mySrs.XValues(Ipts) * Xwidth / (Xmax - Xmin)
Ynode = Ytop + (Ymax - mySrs.Values(Ipts)) * Yheight / (Ymax - Ymin)
myBuilder.AddNodes msoSegmentLine, msoEditingAuto, Xnode, Ynode
Next
Set myShape = myBuilder.ConvertToShape
With myShape
' USE YOUR FAVORITE COLORS HERE
.Fill.ForeColor.SchemeColor = 13 ' YELLOW
.Line.ForeColor.SchemeColor = 12 ' BLUE
End With
End Sub
''' END THE CODE -----------------------------------------
Good luck,
- Jon
_______
In article <2a9h8.6501$5z3.1...@twister2.libero.it>, f.cinq...@libero.it
says...
"Jon Peltier" <jonpe...@yahoo.com> ha scritto nel messaggio
news:utFn5#HxBHA.2620@tkmsftngp03...
"fernando cinquegrani" <f.cinq...@libero.it> ha scritto nel messaggio
news:Icdh8.9389$uN5.2...@twister1.libero.it...
Thanks for correcting this for me.
- Jon
_______
In article <rpeh8.8611$5z3.2...@twister2.libero.it>,
f.cinq...@libero.it says...
"Jon Peltier" <jonpe...@yahoo.com> ha scritto nel messaggio
news:uErS$0LxBHA.1644@tkmsftngp07...
When you draw a shape manually, if you make a point very close to another
point, the shape closes up for you. It may be that the ConvertToShape method
has been done already, and you are causing it to error by trying to repeat the
method. I would look into parameters of AddNodes (what does msoEditingAuto
really mean, for instance), and whether myBuilder is already converted to a
shape.
- Jon
_______
In article <Vxoi8.11775$tC3.3...@twister1.libero.it>,
f.cinq...@libero.it says...