Skip to content

Can I change direction to be horizontal? #15

Answered by s0l0ist
kadiemq asked this question in Q&A
Discussion options

You must be logged in to vote

Hi @kadiemq,

Yes! You'll likely want to set the rank_dir to LR and maybe change the label_pos setting on any edges to suit your needs.

import {
  DirectedGraph,
  LabelPos,
  RankDir,
} from "@vizdom/vizdom-ts-node"

const graph = new DirectedGraph({
  layout: {
    rank_dir: RankDir.LR, // or RankDir.RL
  },
});

const v0 = graph.new_vertex({
  render: {
    label: "Hello",
  },
});
const v1 = graph.new_vertex({
  render: {
    label: "World!",
  },
});

// Add an edge between the vertices
graph.new_edge(v0, v1, {
  render: {
    label: "Foo Bar",
  },
 layout: {
    label_pos: LabelPos.R,
  },
});

Which will produce a graph that looks like this:

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by s0l0ist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants