defining length by percent complete

Started by CHARLESPDANA, January 15, 2016, 07:24:30 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

CHARLESPDANA

Hello!
I am trying to grow a line with multiple vertices based on percent complete from external data.
For example drawing roads on a map as they are being built.
I was trying to make it a data bar, but the articles I've found for custom data bars don't have the images that the text refers to.
Any support in pointing me to articles that are relevant would be greatly appreciated.
Thanks.
Charlie.

JuneTheSecond

#1
Visio accepts "%" as a proper unit.
Set shape data as a numerical data with unit, and set width as  "GUARD(100 mm*Prop.Row_1/100%)" in shapesheet.
Best Regards,

Junichi Yoda
http://june.minibird.jp/

CHARLESPDANA

That works great for a straight horizontal line. but what if I have an "L" shaped road or a "Z" shape. Can I have the segments grow incrementally and in order?

Yacine

#3
This is a very interesting problem.

There may be 2 solutions.

1) Line Colour Gradients
Available in V2013 (probably also V2010)
Define 2 Fill Gradient stops. The first having the desired colour and 0% transparency.
The second being bound to the first one by ("GUARD(LineGradientStops.GradientStopPosition)") and with 100% transparency. This way you get a sharp transition between show/ no show.
The first gradient stop will now be bound to a custom property translating the degree of completion ("prop.completion").
The CONS:
- Only linear gradients work, and not perfectly when the line shows convolutions.
- Path gradients have been implemented to start at the center of the path - towards the ends - why on earth did someone think of such a behavior ??? ?.
So you'll probably need to adjust the angle of the linear gradient.
- custom line type won't work. (Drawing roads)

2) Using single line segments instead of one shape with different vertices in one geometry section
You could draw your path using individual line segments, then use my "Shape Scripter" to make their visibility depend on the first shape.
http://visguy.com/vgforum/index.php?topic=6914.msg28863#msg28863
CONS:
- you asked for a single shape - here you need several ones.
- the transition is shape-wise - not continuous
- you need to use my tool.

3) Have macro to modify the geometry section in such a way that the individual vertices show or not depending on "prop.completion" --> complicated.

HTH,
Y.

Yacine

CHARLESPDANA

Yacine,
Can you elaborate a little on the line gradient idea?
I've been playing with it and still cant get the hard line between colors I'm using red and black.
I'm also having a difficult time finding any information or tutorials on line gradients.
But it does seem like a promising avenue.
Thanks

Yacine

Hi Charles,
There's not much about the gradient solution.
1) Make sure to have 2 gradient stops, link them by a formula see (attached picture)
2) Differentiate them by either the colour or the transparency
3) have the first one follow a custom property (cf picture)

Have a look at the shapesheet of the enclosed drawing.
Yacine

wapperdude

Just throwing out an idea...

V2010 has shapesheet fcns pathlength and pointalongpath.  I think point a long path gives a %.  Between the two, ought to get the info you need, i.e., where on the line the completion point is.

Don't know about gradient or even two tone coloring a line...I don't even think a custom line pattern would provide sufficient control.  A possibility would be something like Yacine suggests, a partial line segment, overlaid on top, with its color showing completed progress...but that becomes difficult with meandering lines.

It may be you just settle for a point that shows how far the completion has progressed.

Wapperdude
Visio 2019 Pro

Yacine

Spent several hours thinking on how to use the path functions. got stuck.
I did also experiment with line patterns and fillings. same :(

What about a "super" shape having "enough" (10,20, ... ?) vertices implemented as follows:
- N control points. Visible if prop.completion <= control point X - respectively in edit mode to amount chosen.
- LineTo formulas in the geometry section built in a way, that "IF (controls.rowX.visibile, controls.rowX, rowX-1)"
- A prop.EditMode would allow to show either the whole line without considering prop.completion or a part of it when being in "display" mode.
- a macro would prepare this shape, but only once, such as to have the shape working without VBA.
- Editing the shape would then be a matter of 1) chosing the number of vertices, then 2) moving them around.
- a global reset function would trigger a setf/getref formula to get all the control points aligned

This solution would have the great benefit of:
- using one shape
- no VBA
- line patterns with no restrictions
CONS
- probably a more difficult way of editing a path.

The rest is (probably) only diligence.
Yacine

wapperdude

Phew!  That's a lot of work!  Think I'd rather trace over the line, up to the completion point.  Add connected segments as needed. 
Visio 2019 Pro

CHARLESPDANA

Yacine,
Thanks for the image,  now I  see what I was missing.
I think it'll work perfectly.
I'm not back to my desk for a week and a half, but will let you know how it goes.
I shouldn't have more than 10 vertices. But am interested in trying to decipher your second post.
Thanks again
Charlie

Yacine

#10
Hi Charlie and Wayne,
At the end it wasn't that "Phew!" at all.
First I set up a shape with only two vertices to see how the formulas would need to work.
I repeated the steps, while recording them, took the code, cleaned it and put it in loops.



Option Explicit
Public Sub MakeSuper()
    If ActiveWindow.Selection.Count <> 1 Then Exit Sub
    Dim shp As Shape
    Dim i As Integer
    Const N = 40
   
    Set shp = ActiveWindow.Selection(1)
    Dim UndoScopeID1 As Long
    UndoScopeID1 = Application.BeginUndoScope("MakeSuper")
    With shp
        'Add PROP.COMPLETION
        If Not .SectionExists(visSectionProp, False) Then
            .AddSection visSectionProp
        End If
        .AddNamedRow visSectionProp, "Completion", visTagDefault
        'Add CONTROLS
        If Not .SectionExists(visSectionControls, False) Then
            .AddSection visSectionControls
        End If
        For i = 1 To N
            .AddRow visSectionControls, visRowLast, visTagDefault
            .CellsSRC(visSectionControls, i - 1, visCtlX).FormulaForceU = "Width*0+" & i & " mm"
            .CellsSRC(visSectionControls, i - 1, visCtlY).FormulaForceU = "Height*0"
            .CellsSRC(visSectionControls, i - 1, visCtlXCon).FormulaForceU = "IF(Prop.Completion<" & i & ",7,2)"
            .CellsSRC(visSectionControls, i - 1, visCtlYCon).FormulaForceU = "2"
        Next i
        'Add GEOMETRY
        Dim newGeom As Integer
        newGeom = visSectionFirstComponent + 1
        .AddSection newGeom
            .AddRow newGeom, visRowComponent, visTagComponent
        .CellsSRC(newGeom, 0, 0).FormulaForceU = "TRUE"
   
    '        .AddRow newGeom, visRowVertex, visTagLineTo
            .AddRow newGeom, visRowVertex, visTagMoveTo
   
        For i = 1 To N
            .AddRow newGeom, visRowLast, visTagLineTo
            .CellsSRC(11, visRowLast, 0).FormulaU = "IF(Prop.Completion<" & i & ",Geometry2.X" & i & ",Controls.Row_" & i & ")"
            .CellsSRC(11, visRowLast, 1).FormulaU = "IF(Prop.Completion<" & i & ",Geometry2.Y" & i & ",Controls.Row_" & i & ".Y)"
        Next i
    End With
    Application.EndUndoScope UndoScopeID1, True


End Sub

I then added a last control point to which I bound the value of prop.completion, so I could modify the value easier.


The shape was now growing depending on the X coordinate of the last control point - but no 2 colors.
To realize this last requirement, I just duplicated the shape and changed its format.
The full path, will stay in the background and the completion value of the foreground shape can be modified to show the whole picture.


I enjoyed very much this challenge. Let me know how you got along.


One last point: I did not implement the reset function. I'll leave it up to you. The principle is the same.


Cheers,
Yacine


PS: vsd enclosed, please check
Yacine