Author Topic: xy-curve - calculating with visio  (Read 15563 times)

0 Members and 1 Guest are viewing this topic.


  • Hero Member
  • *****
  • Posts: 2708
xy-curve - calculating with visio
« on: May 08, 2009, 01:30:13 AM »
Hi folks,
as part of a bigger project I'm trying to get a shape to behave as y=f(x) with arbitrary curves - x being the input and y the output.
The curve shall be not just a function that you could put as formula in a shape sheet, but a collection of points. this would allow binary outputs as well. Fourier was not really an option, because too few understand them.

My solution:
I put in TheText() the collection of points separeted by semicolons. (prepared in Excel)
Then a makro writes in a new geometry section all the points et voila: you got the curve.

Now the hard part: I could not  find any function  like in excel to get the index of the nearest value of geometry1.x to my input value in order to evaluate the y-component.
So, brute force solution:
calculate for every x in the geometry section the distance to input: abs(scratch.x1=controls.input-geometry1.x1)
then get the min of these calculations and for each of these calculations set a decision formula
if min(distance)=xi then setf(...output...)

This solution - whilst working - is so miserable, that I welcome every visio "frea..." - I mean "Master" out there to present a better one.
The race is open.

PS: there's of course still a lot of work to be done: convert the output to the actual value instead of a ratio of height, triangulation of the value, a macro to get the input value from another shape... also please don't comment the dirty code - it's been made quick and dirty.
« Last Edit: May 08, 2009, 02:31:46 AM by Yacine »


  • Hero Member
  • *****
  • Posts: 1517
Re: xy-curve - calculating with visio
« Reply #1 on: May 08, 2009, 07:48:49 AM »
You might want to look at the points functions in VBA.   I know you can defined any arbitrary shape in a single geometry section and have control over precision/coarseness as to meeting those points exactly or get close cause the subsequent point takes you in another direction (like curved corners).   I believe there is an analog that gives you a set of points  based on precision for a given shape in a given geometry.

As far as distance from some reference, I think there is a macro on visio cafe that does that and shows some of the pitfalls if not down right (boundary conditions that give you the wrong answer).

BTW, so you know....doing curves as a set of points in visio is probably not the best way to go since the
precision/coarness tradeoff makes the curve look pretty crude.

You may want to look at points function anyway and use that as the general approach.
Ie input your function, create a start point and end point, determine if linear or curved, then decide
to create points array or use an ellipse arc or NURBS approach (either requires alot more math to determine the control points...but after refreshing yourself on analytic geometry...probably can derive from the input function).         

Visio Guy

  • Administrator
  • Hero Member
  • *****
  • Posts: 1718
  • Smart Graphics for Visual People...n' Stuff
    • Visio Guy
Re: xy-curve - calculating with visio
« Reply #2 on: May 08, 2009, 03:05:18 PM »
Servus Yacine,

You might investigate the PolyLineTo (geometry) row type, with the corresponding PolyLine function. This allows you to "blast" a list of x,y points into a single ShapeSheet cell to get a many-vertexed shape.

This could also double as the data-storage for your numerical solution, although you won't be able to get at the individual points from ShapeSheet functions.

But the same list of points could be used in a BOUND function to constrain the x-position of the control-handle to only the data that you input into the shape. Then, you could use INDEX and LOOKUP functions to get the y-value for a given x value.

Are your x-values always at a constant dx interval? If so, then you could know that you are at the ith point, and look up the ith y-value, if that makes any sense.

The ShapeSheet is a spreadsheet, so you will probably have to have lots of rows and lists of lots of points. Your solution so far actually works fairly well. It might not be pretty inside, but it seems to work fairly smoothly! :)

For articles, tips and free content, see the Visio Guy Website at
Get my Visio Book! Using Microsoft Visio 2010


  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3826
  • Ideas Visio-lized into solutions
Re: xy-curve - calculating with visio
« Reply #3 on: May 08, 2009, 05:57:00 PM »
It looks like you already test the x value of the control point and find the suitable y value.  Perhaps in your scratch table, you could do a simple linear interpolation when the control x-value is between two known plot values.  You have all the points you need, and the graph is based upon linear steps between points anyway.

Just a thought.   ???

Visio 2019 Pro


  • Hero Member
  • *****
  • Posts: 1027
    • Visio Shapes, Stencils and Sample Drawings
Re: xy-curve - calculating with visio
« Reply #4 on: May 09, 2009, 02:56:10 AM »
Hi, Yacine.

Your work is really creative and has strong impact to me.
Your work inspired me to make such kind of shapes.
However, they are not so sofisticated as your work.
« Last Edit: May 09, 2009, 04:04:19 AM by JuneTheSecond »
Best Regards,

Junichi Yoda


  • Hero Member
  • *****
  • Posts: 2708
Re: xy-curve - calculating with visio
« Reply #5 on: May 09, 2009, 07:01:10 AM »
these words from you make me very proud, but are not justified.
I read all the publications I could find from you in the web and you are the one who got me in the joy of shapesheets.
Specially your isometric shapes and the calculation shapes... my deepest respect.

Visio Guy,
you on the other hand, are the most prolific visio blogger around ;) and a constant source of inspiration.

But now enough praise affusion!
Your recommendations were really great. I got the curve already drawn. The good thing is that you don't need a macro anymore. You can write the points in the polyline with SETF. I hope to be able to present the final result in some hours :).

accuracy is not "yet" a matter, but as soon as it becomes, I'd look for the nearest neighbour and make a triangulation. thanks

cheers, Yacine.
« Last Edit: May 04, 2010, 06:39:50 PM by Yacine »