chartjs-chart-pcp v4.3.0
Chart.js Parallel Coordinate Plots
Chart.js module for charting parallel coordinate plots (PCPs). Adding new chart type: pcp
.
Works only with Chart.js >= 3.0.0
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
2 months ago
4 months ago
7 months ago
7 months ago
10 months ago
8 months ago
8 months ago
10 months ago
10 months ago
1 year ago
1 year ago
1 year ago
1 year ago
2 years ago
2 years ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago