line and points in xychart

Showing 1-12 of 12 messages
line and points in xychart fernando cinquegrani 3/1/02 2:02 AM
in a xy chart what is the position (left, top)
of a single datapoint [cells(x, y)]?
how can i connect with a line (shape line)
two points not in succession?
thanks
                     .f
http://www.prodomosua.it


line and points in xychart fernando cinquegrani 3/1/02 5:22 AM
"fernando cinquegrani" <f.cinq...@libero.it> ha scritto nel messaggio
news:BkIf8.48524$fa5.1555685@twister2.libero.it...

> in a xy chart what is the position (left, top)
> of a single datapoint [cells(x, y)]?
> how can i connect with a line (shape line)
> two points not in succession?

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
>
>


line and points in xychart Tushar Mehta 3/4/02 3:23 PM
[This followup was posted to microsoft.public.excel.charting with an
email copy to fernando cinquegrani.
Please use the newsgroup for further discussion.]

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

line and points in xychart fernando cinquegrani 3/5/02 12:28 AM
Thanks, but...
i would fill the polygon defined by lines.
please, see cluster.exe or scatter.exe
in my excel page (hhtp://www.prodomosua.it/ppage02.html).
i select a range of datapoints, then compute
the convex hull (in italian: inviluppo convesso), then create
a new dataseries with lines. how can i fill this polygon?
Thanks
                   .f


"Tushar Mehta" <ng_p...@bigfoot.com> ha scritto nel messaggio
news:MPG.16edcbbe7e7d257598a541@msnews.microsoft.com...

line and points in xychart Tushar Mehta 3/5/02 6:42 AM
I couldn't tell from the examples on the web page what exactly you want
to do.  And, its been some time since I had to worry about constructing
a convex hull.  So, if what you want to do is create an object that
closes on itself, just plot the first data point once more as the last
data point.  This would have to be in a XY Scatter chart.  For example,
to create a rectangle, plot (x1,y1), (x1,y2), (x2, y2), (x2, y1), and
(x1,y1).
 
--
Regards,

Tushar Mehta
www.tushar-mehta.com
Microsoft MVP -- Excel
--

In <1l%g8.4319$uN5.1...@twister1.libero.it>, fernando cinquegrani

line and points in xychart fernando cinquegrani 3/5/02 11:39 AM
Thanks for your interest, but...
in my examples i create a new close polygon
(the convex hull) yet.
i want to fill this with a colour.
i think i have to draw the polygon as a shape.
i now draw this polygon as shape (not in examples),
and i fill it with a colour.
but for find the nodes of my polygon, i need the
position in chart of each point.
which is the position (left, top) of a generic point in a xychart?
the statement dataseries(a).points(b).left=...doesn't exist.
now i use the datalabel (not visible) center of this point.
this process is very slow and it is impossible to
update the chart in real time if i change the data.
any solution?
                               .f
(excuse me, but i dont speak english)


"Tushar Mehta" <ng_p...@bigfoot.com> ha scritto nel messaggio
news:MPG.16eea356275692c798a544@msnews.microsoft.com...

line and points in xychart Jon Peltier 3/5/02 11:59 AM
Fernando -

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...

line and points in xychart fernando cinquegrani 3/5/02 4:15 PM
perfect, jon! thanks for your help
                               .f


"Jon Peltier" <jonpe...@yahoo.com> ha scritto nel messaggio
news:utFn5#HxBHA.2620@tkmsftngp03...

line and points in xychart fernando cinquegrani 3/5/02 5:37 PM
Xnode = Xleft + (mySrs.XValues(Ipts) <<< - Xmin >>>) * Xwidth / (Xmax -
Xmin)
because the scale doesn't start by zero (MinimumScale).
thanks again
                   .f


"fernando cinquegrani" <f.cinq...@libero.it> ha scritto nel messaggio
news:Icdh8.9389$uN5.245296@twister1.libero.it...

line and points in xychart Jon Peltier 3/5/02 7:18 PM
Doh!!

Thanks for correcting this for me.

- Jon
_______

In article <rpeh8.8611$5z3.2...@twister2.libero.it>,
f.cinq...@libero.it says...

line and points in xychart fernando cinquegrani 3/9/02 5:58 AM
the statement
Set myShape = myBuilder.ConvertToShape
is frequently in error when the
chart is very little (points quite near).
do you know why?
how can i obviate?
                                 .f
http://www.prodomosua.it
p.s.:
1. the addin cluster.xla, where i use your suggestion, is on line
2. for a best performance of your code, define
    Dim Xnode as Single, ...

"Jon Peltier" <jonpe...@yahoo.com> ha scritto nel messaggio
news:uErS$0LxBHA.1644@tkmsftngp07...

line and points in xychart Jon Peltier 3/12/02 2:38 PM
Fernando -

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...