Search

Link Gallery

Styles

Explore link styles with arrowheads, labels, glyphs and more.

Link Gallery
View live example →

Click on a link to see its styling data in the overlay.

You can customize the appearance of links with arrowheads, labels, glyphs and more.

See also

import React, { useState } from "react";
import { createRoot } from "react-dom/client";

import isEmpty from "lodash/isEmpty";
import { Chart, FontLoader } from "regraph";

import { data, dataPositions } from "./data";

import "@ci/theme/rg/css/properties.css";

export const Demo = () => <LinkGallery items={data()} positions={dataPositions} />;

function LinkGallery(props) {
  const { items, positions } = props;
  const [selection, setSelection] = useState({});

  const handleChartChange = (change) => {
    if (change.selection) {
      // change.selection includes details about the selected item
      // so we use this to show the properties used
      setSelection({ ...change.selection });
    }
  };

  return (
    <div style={{ width: "100%", height: "100%" }}>
      <FontLoader
        config={{
          google: { families: ["Material Icons"] },
        }}
      >
        <Chart
          items={items}
          positions={positions}
          onChange={handleChartChange}
          options={{ navigation: false, overview: false }}
          animation={{ animate: true, time: 450 }}
        />
      </FontLoader>
      {isEmpty(selection) ? (
        <pre className="properties empty">Select a link to view its properties</pre>
      ) : (
        <pre className="properties">{JSON.stringify(selection, null, 2)}</pre>
      )}
    </div>
  );
}

const root = createRoot(document.getElementById("regraph"));
root.render(<Demo />);
const primaryColor = "#2dcda8";
const darkColor = "#00423e";
const lightColor = "#8cedd0";
const primaryTransparent = "#2dcda850";
const accentColor = "#22BF6D";
const greyColor = "#2e3842";
const backgroundColor = "#FFF";
const transparentColor = "rgba(255,255,255,0)";

function data() {
  return {
    "1_n1": {
      color: primaryColor,
    },
    "1_n2": {
      color: primaryColor,
    },
    "1_l1": {
      id1: "1_n1",
      id2: "1_n2",
      color: greyColor,
      width: 2,
    },
    "2_n1": {
      color: primaryColor,
    },
    "2_n2": {
      color: primaryColor,
    },
    "2_l2": {
      id1: "2_n2",
      id2: "2_n1",
      color: greyColor,
      lineStyle: "dashed",
      width: 4,
    },
    "3_n1": {
      color: primaryColor,
    },
    "3_n2": {
      color: primaryColor,
    },
    "3_l1": {
      id1: "3_n1",
      id2: "3_n2",
      color: greyColor,
      lineStyle: "dotted",
      width: 4,
    },
    "4_n1": {
      color: primaryColor,
    },
    "4_n2": {
      color: primaryColor,
    },
    "4_l1": {
      id1: "4_n1",
      id2: "4_n2",
      end2: { arrow: true },
      color: greyColor,
    },
    "5_n1": {
      color: primaryColor,
    },
    "5_n2": {
      color: primaryColor,
    },
    "5_l1": {
      id1: "5_n1",
      id2: "5_n2",
      end1: { arrow: true },
      end2: { arrow: true },
      color: greyColor,
    },
    "6_n1": {
      color: primaryColor,
    },
    "6_n2": {
      color: primaryColor,
    },
    "6_l1": {
      id1: "6_n1",
      id2: "6_n2",
      end1: {
        arrow: false,
        glyphs: [
          {
            color: accentColor,
          },
        ],
      },
      end2: {
        arrow: false,
        glyphs: [
          {
            color: accentColor,
            border: {
              width: 1,
              color: darkColor,
            },
            fontIcon: {
              text: "\u{e645}",
              fontFamily: "Material Icons",
            },
          },
        ],
      },
      color: greyColor,
      glyphs: [
        {
          label: { text: "1" },
          color: greyColor,
          border: { color: accentColor, width: 1 },
        },
      ],
    },
    "7_n1": {
      color: primaryColor,
    },
    "7_n2": {
      color: primaryColor,
    },
    "7_l1": {
      id1: "7_n1",
      id2: "7_n2",
      end1: { arrow: true, backOff: 0.25 },
      end2: { arrow: true, backOff: 0.25 },
      color: greyColor,
    },
    "8_n1": {
      color: primaryColor,
    },
    "8_n2": {
      color: primaryColor,
    },
    "8_l1": {
      id1: "8_n1",
      id2: "8_n2",
      end1: { arrow: true },
      end2: { arrow: true },
      width: 4,
      color: greyColor,
    },
    "9_n1": {
      color: primaryColor,
    },
    "9_n2": {
      color: primaryColor,
    },
    "9_l1": {
      id1: "9_n1",
      id2: "9_n2",
      end1: { arrow: true },
      end2: { arrow: true },
      color: accentColor,
    },
    "9_l2": {
      id1: "9_n1",
      id2: "9_n2",
      end1: { arrow: true },
      end2: { arrow: true, color: "rgb(244,83,3)" },
      color: primaryColor,
    },
    "10_n1": {
      color: primaryColor,
    },
    "10_n2": {
      color: primaryColor,
    },
    "10_l1": {
      id1: "10_n1",
      id2: "10_n2",
      end2: { arrow: true },
      flow: { velocity: 3 },
      color: greyColor,
    },
    "10_l2": {
      id1: "10_n2",
      id2: "10_n1",
      end2: { arrow: true },
      flow: { velocity: 1 },
      color: greyColor,
    },
    "11_n1": {
      color: primaryColor,
    },
    "11_l1": {
      id1: "11_n1",
      id2: "11_n1",
      end2: { arrow: true },
      color: greyColor,
    },
    "12_n1": {
      color: primaryColor,
    },
    "12_n2": {
      color: primaryColor,
    },
    "12_n3": {
      color: primaryColor,
    },
    "12_n4": {
      color: primaryColor,
    },
    "12_l1": {
      id1: "12_n1",
      id2: "12_n2",
      end2: { arrow: true },
      color: lightColor,
      width: 2,
      label: {
        text: "Label",
        bold: true,
        backgroundColor: lightColor,
        color: darkColor,
      },
    },
    "12_l2": {
      id1: "12_n1",
      id2: "12_n3",
      end2: { arrow: true },
      color: lightColor,
      width: 6,
      label: {
        text: "Label",
        bold: true,
        backgroundColor: lightColor,
        color: darkColor,
        fontSize: 24,
        border: { color: darkColor, width: 1 },
        padding: "2 2 -3 2",
      },
    },
    "12_l3": {
      id1: "12_n1",
      id2: "12_n4",
      end1: {
        label: {
          text: "End 1",
          backgroundColor: darkColor,
          border: { radius: 10 },
          padding: "2 5 -1 5",
        },
      },
      end2: {
        arrow: true,
        label: {
          text: "End 2",
          fontFamily: "cursive",
          fontSize: 14,
          border: { color: lightColor, radius: 2, width: 1 },
          backgroundColor,
        },
      },
      color: lightColor,
      width: 2,
      label: {
        text: "Label",
        bold: true,
        border: { radius: 4 },
        color: primaryColor,
        fontFamily: "monospace",
      },
    },
    "13_n1": {
      label: { text: "1" },
      color: primaryColor,
    },
    "13_n3": {
      label: { text: "3" },
      color: lightColor,
      size: 0.8,
    },
    "13_n4": {
      label: { text: "4" },
      color: lightColor,
      size: 0.8,
    },
    "13_n2": {
      label: { text: "2" },
      color: backgroundColor,
      border: {
        color: lightColor,
        lineStyle: "dashed",
      },
      size: 0.8,
    },
    "13_n5": {
      label: { text: "5" },
      color: backgroundColor,
      border: {
        color: lightColor,
        lineStyle: "dashed",
      },
      size: 0.8,
    },
    "13_n7": {
      label: { text: "7" },
      color: lightColor,
      size: 0.8,
    },
    "13_n6": {
      label: { text: "6" },
      color: lightColor,
      size: 0.8,
    },
    "13_l8": {
      id1: "13_n2",
      id2: "13_n3",
      color: primaryTransparent,
      width: 2,
    },
    "13_l9": {
      id1: "13_n2",
      id2: "13_n7",
      color: primaryTransparent,
      width: 2,
    },
    "13_l11": {
      id1: "13_n7",
      id2: "13_n6",
      color: primaryTransparent,
      width: 2,
    },
    "13_l13": {
      id1: "13_n6",
      id2: "13_n5",
      color: primaryTransparent,
      width: 2,
    },
    "13_l15": {
      id1: "13_n5",
      id2: "13_n4",
      color: primaryTransparent,
      width: 2,
    },
    "13_l17": {
      id1: "13_n4",
      id2: "13_n3",
      color: primaryTransparent,
      width: 2,
    },
    "13_l12": {
      id1: "13_n7",
      id2: "13_n5",
      color: primaryTransparent,
      width: 2,
    },
    "13_l16": {
      id1: "13_n5",
      id2: "13_n3",
      color: primaryTransparent,
      width: 2,
    },
    "13_l19": {
      id1: "13_n7",
      id2: "13_n3",
      color: primaryTransparent,
      width: 2,
    },
    "13_l14": {
      id1: "13_n6",
      id2: "13_n4",
      color: primaryTransparent,
      width: 2,
    },
    "13_l10": {
      id1: "13_n2",
      id2: "13_n6",
      color: primaryTransparent,
      width: 2,
    },
    "13_l18": {
      id1: "13_n4",
      id2: "13_n2",
      color: primaryTransparent,
      width: 2,
    },
    "13_l1": {
      id1: "13_n5",
      id2: "13_n1",
      color: lightColor,
      end2: { arrow: true },
      lineStyle: "dashed",
      width: 2,
    },
    "13_l5": {
      id1: "13_n7",
      id2: "13_n1",
      color: primaryTransparent,
      width: 2,
    },
    "13_l7": {
      id1: "13_n6",
      id2: "13_n1",
      color: primaryColor,
      end1: { arrow: true },
      width: 6,
    },
    "13_l6": {
      id1: "13_n2",
      id2: "13_n1",
      color: lightColor,
      end2: { arrow: true },
      lineStyle: "dashed",
      width: 2,
    },
    "13_l2": {
      id1: "13_n4",
      id2: "13_n1",
      color: primaryTransparent,
      width: 2,
    },
    "13_l3": {
      id1: "13_n3",
      id2: "13_n1",
      color: primaryColor,
      end1: { arrow: true },
      width: 6,
    },
  };
}

const dataPositions = {
  "1_n1": {
    x: -300,
    y: -225,
  },
  "1_n2": {
    x: -150,
    y: -225,
  },
  "2_n1": {
    x: -300,
    y: -125,
  },
  "2_n2": {
    x: -150,
    y: -125,
  },
  "3_n1": {
    x: -300,
    y: -25,
  },
  "3_n2": {
    x: -150,
    y: -25,
  },
  "4_n1": {
    x: -300,
    y: 75,
  },
  "4_n2": {
    x: -150,
    y: 75,
  },
  "5_n1": {
    x: -300,
    y: 175,
  },
  "5_n2": {
    x: -150,
    y: 175,
  },
  "6_n1": {
    x: -50,
    y: -225,
  },
  "6_n2": {
    x: 100,
    y: -225,
  },
  "7_n1": {
    x: -50,
    y: -125,
  },
  "7_n2": {
    x: 100,
    y: -125,
  },
  "8_n1": {
    x: -50,
    y: -25,
  },
  "8_n2": {
    x: 100,
    y: -25,
  },
  "9_n1": {
    x: -50,
    y: 75,
  },
  "9_n2": {
    x: 100,
    y: 75,
  },
  "10_n1": {
    x: -50,
    y: 175,
  },
  "10_n2": {
    x: 100,
    y: 175,
  },
  "11_n1": {
    x: 200,
    y: -225,
  },
  "12_n1": {
    x: 200,
    y: -125,
  },
  "12_n2": {
    x: 400,
    y: -225,
  },
  "12_n3": {
    x: 400,
    y: -125,
  },
  "12_n4": {
    x: 400,
    y: -25,
  },
  "13_n1": {
    x: 300,
    y: 125,
  },
  "13_n3": {
    x: 300,
    y: 25,
  },
  "13_n4": {
    x: 400,
    y: 75,
  },
  "13_n2": {
    x: 200,
    y: 75,
  },
  "13_n5": {
    x: 400,
    y: 175,
  },
  "13_n7": {
    x: 200,
    y: 175,
  },
  "13_n6": {
    x: 300,
    y: 225,
  },
};

export { data, dataPositions };
<!doctype html>
<html>
  <body>
    <div id="regraph" style="height: 100vh"></div>
    <script type="module" src="./code.jsx"></script>
  </body>
</html>

Terms of use

These terms do not alter or supersede any existing agreements between you (or your employer) and us.

By accessing or using any Content you agree to be bound by these Terms of Use. Please review these terms carefully before using the website.

The contents of this website, including but not limited to any text, code samples, API references, schemas, interactive tools, and other materials (collectively, the 'Content'), are made available for informational and internal evaluation purposes only. All intellectual property rights in the Content are reserved. No licence is granted to use the Content for any commercial purpose, or to copy, distribute, modify, reverse-engineer, or incorporate any part of the Content into any product or service, without our prior written consent.

This Content is provided “as is” and “as available,” without any representations, warranties, or guarantees of any kind, whether express or implied, including but not limited to implied warranties of merchantability, fitness for a particular purpose, non-infringement, or accuracy. To the fullest extent permitted by applicable law, we expressly exclude and disclaim all implied warranties, conditions, and other terms that might otherwise be implied.

We disclaim all liability for any loss or damage, whether direct, indirect, incidental, consequential, or otherwise, arising from any reliance placed on the Content or from your use of it, to the fullest extent permitted by applicable law. By continuing to access or use the Content, you acknowledge and agree to these terms.