Chart Basics

Basics

Introduction

A chart, also called a graph, is a visual way to show data. This data can describe physical entities, such as people, vehicles or servers, or abstract entities, such as countries or accounts. Charts are widely used as an analysis tool in many fields including cyber security, fraud detection, intelligence or law enforcement.

KeyLines charts use nodes, links and other items and features to visualise data and reveal relationships, patterns and anomalies.

Key features

The basic building blocks of a chart in KeyLines are nodes, representing concrete or abstract entities, and links, representing the connections between them.

Alongside these, KeyLines offers many more features that make charts interactive and fully customisable. These include for example:

  • Layouts that untangle complex relationships in the data and turn them into easily understandable visual patterns.
  • Node styling and link styling options that enrich nodes and links with more contextual information from the data.
  • Annotations that can visualise important insights and alerts and tell the story behind the dataset.
  • Combos and aggregate links which organise nodes and links to reduce visual clutter at a first glance.
  • Event logging that handles any user interaction with the chart or time bar.
  • Time bar that allows you to visualise, explore and filter data that evolves over time.

You can explore all of these features in our demos.

Creating charts

To create a chart, call the KeyLines.create() function that creates a KeyLines container for the chart component to sit inside:

async function startKeyLines() {    // async functions prevent long-running functions from blocking
  chart = await KeyLines.create({   // waits until chart is created before calling other functions
    type: 'chart',
    container: 'kl',
  });
  chart.load(data);
}

You must wait for KeyLines.create() to finish before calling other chart functions such as chart.load(). See Asynchronous JavaScript for more details.

You can display multiple charts on one page, as shown in the Path Analysis in Trees demo.

Loading data

KeyLines is database agnostic and works with data from any source, but it only accepts data in JSON format.

There are a few different ways how to load data into your chart. See Loading Data for more details.

Customising charts

a simple KeyLines chart showing examples of items and sub-items

Styling items

Chart items including nodes, links and annotations can be styled and enhanced with various sub-items for decoration or additional source of information.

You can add styling directly in the items array:

let data = {
  type: 'LinkChart',
  items: [
    {
      id: 'node1',
      type: 'node',
      c: 'green',                   // green node background
      t: { t: 'A simple label' },   // a label as a node sub-item
    }
  ],
};

Or if your data is already loaded into the chart, you can use chart.setProperties() or chart.animateProperties() to change the properties of items in the chart:

// updates the node background and label text
chart.setProperties({ id: 'n1', c: 'orange', t: { t: 'A different label' } });

For various examples, see:

Chart options

The chart options APIs can be used to change styling, display and interaction defaults of the chart as an element that integrates into an application.

You can set options in the KeyLines.create() function:

const options = { controlTheme: 'dark' };

chart = await KeyLines.create({
  ...
  options,
});

Or you can apply options by calling chart.options() function as a setter:

const options = { controlTheme: 'dark' };
chart.options(options);

For a full list, head to the chart options APIs, including for example:

Chart functions

The chart functions have many uses including adding and removing chart content, manipulating the view, running layouts and more.

These functions are called on the chart object created by KeyLines.create():

const chart = await KeyLines.create({ type: 'chart', container: 'kl' });  // creates a chart in 'kl' div
await chart.load(data);
await chart.layout();

For a full list, head to the chart functions APIs, including for example:

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.