Pen Settings



CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource


Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource


Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.


Auto Save

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.


                <div id="graph"></div>


                .g6-component-tooltip {
    background-color: rgba(255, 255, 255, 0.8);
    padding: 0px 10px 24px 10px;
    box-shadow: rgb(174, 174, 174) 0px 0px 10px;


                const data = {
  nodes: [
      id: "0",
      label: "Has Tooltip - node0",
      x: 100,
      y: 50,
      description: "This is node-0.",
      subdescription: "This is subdescription of node-0."
      id: "1",
      label: "No Tooltip - node1",
      x: 250,
      y: 50,
      description: "This is node-1.",
      subdescription: "This is subdescription of node-1.",
      type: "circle"
      id: "2",
      label: "Tooltip on Text - node2",
      x: 150,
      y: 210,
      description: "This is node-2.",
      subdescription: "This is subdescription of node-2.",
      type: "circle"
      id: "3",
      label: "Tooltip on KeyShape - node-3",
      x: 320,
      y: 210,
      description: "This is node-3.",
      subdescription: "This is subdescription of node-3."
  edges: [
      id: "e0",
      source: "0",
      target: "1",
      description: "This is edge from node 0 to node 1."
      id: "e1",
      source: "0",
      target: "2",
      description: "This is edge from node 0 to node 2."
      id: "e2",
      source: "0",
      target: "3",
      description: "This is edge from node 0 to node 3."
const tooltip = new G6.Tooltip({
  offsetX: 10,
  offsetY: 10,
  // the types of items that allow the tooltip show up
  // 允许出现 tooltip 的 item 类型
  itemTypes: ["node"],
  // custom the tooltip's content
  // 自定义 tooltip 内容
  getContent: (e) => {
    const outDiv = document.createElement("div"); = "fit-content";
    // = '0px 0px 20px 0px';
    outDiv.innerHTML = `
      <h4>Custom Content</h4>
        <li>Type: ${e.item.getType()}</li>
        <li>Label: ${e.item.getModel().label || e.item.getModel().id}</li>
    return outDiv;
  shouldBegin: (e) => {
    const node = e.item
    const model = node.getModel()
    if (model && model.type === 'circle') {
      return true
    return false

const graph = new G6.Graph({
  container: "graph",
  width: 500,
  height: 500,
  linkCenter: true,
  plugins: [tooltip],
  modes: {
    default: ["drag-node"]
  defaultNode: {
    size: [80, 40],
    type: "rect"