4.3.0 • Published 2 months ago

chartjs-chart-pcp v4.3.0

Weekly downloads
25
License
MIT
Repository
github
Last release
2 months ago

Chart.js Parallel Coordinate Plots

NPM Package Github Actions

Chart.js module for charting parallel coordinate plots (PCPs). Adding new chart type: pcp.

Works only with Chart.js >= 3.0.0

MTCars

Open in CodePen

MTCars Tooltip

MTCars Tension

Open in CodePen

Install

npm install --save chart.js@next chartjs-chart-pcp@next

Usage

see Samples on Github

PCP

Data Structure

the data items are the regular data items along with their labels. For each attribute there is an dataset. e.g., in the following example there are three items (A, B, C) with three axes / features (f1, f2, f3).

const objs = [
  { label: 'A', f1: 5, f2: 3, f4: 3 },
  { label: 'B', f1: 2, f2: 1, f4: 8 },
  { label: 'C', f1: 10, f2: 6, f4: 2 },
];
const attrs = ['f1', 'f2', 'f3'];
const config = {
  type: 'pcp',
  data: {
    labels: objs.map((obj) => obj.label),
    datasets: attrs.map((attr) => ({
      label: attr,
      data: objs.map((obj) => obj[attr]),
    })),
  },
  options: {},
};

Styling of elements

Two new elements were added: lineSegment as a subclass of line for a line segment between two axes and linearAxis for representing the vertical axis as a wrapper around a linear scale.

interface ILineSegmentOptions {
  // all options from
  // https://www.chartjs.org/docs/latest/charts/line.html#line-styling

  /**
   * line tension > 0 (e.g., 0.3) to create bezier curves
   * @default 0
   */
  tension: number;
}
interface ILinearAxisOptions {
  // all options from
  // https://www.chartjs.org/docs/latest/axes/cartesian/linear.html#linear-cartesian-axis
  /**
   * width of the visible axis
   * @default 30
   */
  axisWidth: number;
}

Scaling

The Parallel Coordinates controller pcp uses a linear scale. There is also the logarithmicPcp that uses a logarithmic scale. Using chart.js hybrid charts, one can specify the type per dataset. e.g.,

const config = {
  type: 'pcp',
  data: {
    labels: ['1', '2', '3'],
    datasets: [
      {
        label: 'A',
        data: [1, 2, 3]
      },
      {
        type: 'logarithmicPcp',
        label: 'B',
        data: [1, 2, 10000]
      }
    })),
  },
  options: {},
};

Development Environment

npm i -g yarn
yarn set version 2
yarn
yarn pnpify --sdk

Building

yarn install
yarn build
4.3.0

2 months ago

4.2.8

4 months ago

4.2.7

7 months ago

4.2.6

7 months ago

4.2.3

10 months ago

4.2.5

8 months ago

4.2.4

8 months ago

4.2.2

10 months ago

4.2.1

10 months ago

4.2.0

1 year ago

4.1.0

1 year ago

4.0.1

1 year ago

4.1.1

1 year ago

3.10.0

2 years ago

4.0.0-alpha

2 years ago

4.0.0

1 year ago

3.9.0

2 years ago

3.8.0

2 years ago

3.7.1

2 years ago

3.7.0

2 years ago

3.6.0

3 years ago

3.5.0

3 years ago

3.1.0

3 years ago

3.0.1

3 years ago

3.0.0

3 years ago

3.0.0-beta.9

3 years ago

3.0.0-beta.7

3 years ago

3.0.0-beta.6

4 years ago

3.0.0-beta.4

4 years ago

3.0.0-beta.3

4 years ago

3.0.0-beta.1

4 years ago

3.0.0-alpha.20

4 years ago

3.0.0-alpha.2

4 years ago

3.0.0-alpha.1

4 years ago

1.0.0

4 years ago