We can perform equality tests on the members of the HierarchicalDirection enum, but we can’t, I think, derive human-legible strings for them (for the Console etc) so at the moment, to find out which one we are looking at, it seems we would have to run 2-4 tests to find out ? (I may well have missed something)
Setting the direction property of Canvas.layout.Info does realign the axis of Automatic Layout, but not at the moment, as far as I can see, consistently in the direction that is suggested by the docs or the name of the enum key. These results seem unexpected to me (click the expansion triangles to see the result).
Docs: "Root of the hierarchy is at the top and tree extends downwards."
Docs: "Root of the hierarchy is at the right and tree extends leftwards."
Docs: "Root of the hierarchy is at the bottom and tree extends upwards."
Docs: "Root of the hierarchy is at the left and tree extends rightwards."
NOTE:
**Reading** the value of Canvas.layoutInfo.direction with something like:
['Top', 'Left', 'Right', 'Bottom']
.map(k => direction === HierarchicalDirection[k])
yields the same pattern of unexpected mappings:
Top -> ‘Bottom’
Left -> ‘Top’
Right -> ‘Left’
Bottom -> ‘Right’
Which suggests, perhaps, a 0 vs 1 indexing problem in the reading of the enum ? ( The value sequence is right, but the specific values are all “off by one” in the same direction).
and the ordering relationships between the enum elements are:
Left < Top < Right < Bottom
So assuming the tmp function above, we can correctly derive the name of a direction (for example, the current layout direction setting) with something like:
// directionName :: OG HierarchicalDirection -> String
const directionName = d =>
d < HierarchicalDirection[tmp('Right')] ? (
d < HierarchicalDirection[tmp('Top')] ? (
'Left'
) : 'Top'
) : d < HierarchicalDirection[tmp('Bottom')] ? (
'Right'
) : 'Bottom';
Another very minor but conceivably related puzzle in the canvas.layoutinfo enums:
There are four diagram types in the GUI, and the Layout. Just in case its of any significance in the light of the other issue above, I notice that their indexing suddenly goes discontinuous (apparently off by one) at the last moment, so: