@reltio/components 1.4.2246 → 1.4.2248
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/cjs/index.d.ts +0 -1
- package/cjs/index.js +5 -7
- package/index.d.ts +0 -1
- package/index.js +0 -1
- package/package.json +2 -2
- package/UpSetChart/UpSetChart.d.ts +0 -9
- package/UpSetChart/UpSetChart.js +0 -40
- package/UpSetChart/UpSetChart.test.d.ts +0 -1
- package/UpSetChart/UpSetChart.test.js +0 -193
- package/UpSetChart/components/IntersectionsChart/IntersectionsChart.d.ts +0 -15
- package/UpSetChart/components/IntersectionsChart/IntersectionsChart.js +0 -39
- package/UpSetChart/components/IntersectionsChart/index.d.ts +0 -1
- package/UpSetChart/components/IntersectionsChart/index.js +0 -1
- package/UpSetChart/components/IntersectionsChart/styles.d.ts +0 -1
- package/UpSetChart/components/IntersectionsChart/styles.js +0 -29
- package/UpSetChart/components/IntersectionsChartAxis/IntersectionsChartAxis.d.ts +0 -10
- package/UpSetChart/components/IntersectionsChartAxis/IntersectionsChartAxis.js +0 -34
- package/UpSetChart/components/IntersectionsChartAxis/index.d.ts +0 -1
- package/UpSetChart/components/IntersectionsChartAxis/index.js +0 -1
- package/UpSetChart/components/IntersectionsChartAxis/styles.d.ts +0 -1
- package/UpSetChart/components/IntersectionsChartAxis/styles.js +0 -29
- package/UpSetChart/components/IntersectionsMatrix/IntersectionsMatrix.d.ts +0 -13
- package/UpSetChart/components/IntersectionsMatrix/IntersectionsMatrix.js +0 -26
- package/UpSetChart/components/IntersectionsMatrix/index.d.ts +0 -1
- package/UpSetChart/components/IntersectionsMatrix/index.js +0 -1
- package/UpSetChart/components/IntersectionsMatrix/styles.d.ts +0 -1
- package/UpSetChart/components/IntersectionsMatrix/styles.js +0 -24
- package/UpSetChart/components/SetsChart/SetsChart.d.ts +0 -15
- package/UpSetChart/components/SetsChart/SetsChart.js +0 -31
- package/UpSetChart/components/SetsChart/index.d.ts +0 -1
- package/UpSetChart/components/SetsChart/index.js +0 -1
- package/UpSetChart/components/SetsChart/styles.d.ts +0 -1
- package/UpSetChart/components/SetsChart/styles.js +0 -40
- package/UpSetChart/components/SetsChartAxis/SetsChartAxis.d.ts +0 -6
- package/UpSetChart/components/SetsChartAxis/SetsChartAxis.js +0 -13
- package/UpSetChart/components/SetsChartAxis/index.d.ts +0 -1
- package/UpSetChart/components/SetsChartAxis/index.js +0 -1
- package/UpSetChart/components/SetsChartAxis/styles.d.ts +0 -1
- package/UpSetChart/components/SetsChartAxis/styles.js +0 -14
- package/UpSetChart/constants.d.ts +0 -17
- package/UpSetChart/constants.js +0 -20
- package/UpSetChart/gameOfThrones.test-data.d.ts +0 -4
- package/UpSetChart/gameOfThrones.test-data.js +0 -23
- package/UpSetChart/helpers.d.ts +0 -20
- package/UpSetChart/helpers.js +0 -120
- package/UpSetChart/index.d.ts +0 -1
- package/UpSetChart/index.js +0 -1
- package/UpSetChart/styles.d.ts +0 -4
- package/UpSetChart/styles.js +0 -15
- package/UpSetChart/types.d.ts +0 -16
- package/UpSetChart/types.js +0 -1
- package/UpSetChart/useUpSetChartSizes.d.ts +0 -20
- package/UpSetChart/useUpSetChartSizes.js +0 -30
- package/cjs/UpSetChart/UpSetChart.d.ts +0 -9
- package/cjs/UpSetChart/UpSetChart.js +0 -70
- package/cjs/UpSetChart/UpSetChart.test.d.ts +0 -1
- package/cjs/UpSetChart/UpSetChart.test.js +0 -198
- package/cjs/UpSetChart/components/IntersectionsChart/IntersectionsChart.d.ts +0 -15
- package/cjs/UpSetChart/components/IntersectionsChart/IntersectionsChart.js +0 -66
- package/cjs/UpSetChart/components/IntersectionsChart/index.d.ts +0 -1
- package/cjs/UpSetChart/components/IntersectionsChart/index.js +0 -5
- package/cjs/UpSetChart/components/IntersectionsChart/styles.d.ts +0 -1
- package/cjs/UpSetChart/components/IntersectionsChart/styles.js +0 -32
- package/cjs/UpSetChart/components/IntersectionsChartAxis/IntersectionsChartAxis.d.ts +0 -10
- package/cjs/UpSetChart/components/IntersectionsChartAxis/IntersectionsChartAxis.js +0 -64
- package/cjs/UpSetChart/components/IntersectionsChartAxis/index.d.ts +0 -1
- package/cjs/UpSetChart/components/IntersectionsChartAxis/index.js +0 -5
- package/cjs/UpSetChart/components/IntersectionsChartAxis/styles.d.ts +0 -1
- package/cjs/UpSetChart/components/IntersectionsChartAxis/styles.js +0 -32
- package/cjs/UpSetChart/components/IntersectionsMatrix/IntersectionsMatrix.d.ts +0 -13
- package/cjs/UpSetChart/components/IntersectionsMatrix/IntersectionsMatrix.js +0 -56
- package/cjs/UpSetChart/components/IntersectionsMatrix/index.d.ts +0 -1
- package/cjs/UpSetChart/components/IntersectionsMatrix/index.js +0 -5
- package/cjs/UpSetChart/components/IntersectionsMatrix/styles.d.ts +0 -1
- package/cjs/UpSetChart/components/IntersectionsMatrix/styles.js +0 -27
- package/cjs/UpSetChart/components/SetsChart/SetsChart.d.ts +0 -15
- package/cjs/UpSetChart/components/SetsChart/SetsChart.js +0 -58
- package/cjs/UpSetChart/components/SetsChart/index.d.ts +0 -1
- package/cjs/UpSetChart/components/SetsChart/index.js +0 -5
- package/cjs/UpSetChart/components/SetsChart/styles.d.ts +0 -1
- package/cjs/UpSetChart/components/SetsChart/styles.js +0 -43
- package/cjs/UpSetChart/components/SetsChartAxis/SetsChartAxis.d.ts +0 -6
- package/cjs/UpSetChart/components/SetsChartAxis/SetsChartAxis.js +0 -20
- package/cjs/UpSetChart/components/SetsChartAxis/index.d.ts +0 -1
- package/cjs/UpSetChart/components/SetsChartAxis/index.js +0 -5
- package/cjs/UpSetChart/components/SetsChartAxis/styles.d.ts +0 -1
- package/cjs/UpSetChart/components/SetsChartAxis/styles.js +0 -17
- package/cjs/UpSetChart/constants.d.ts +0 -17
- package/cjs/UpSetChart/constants.js +0 -23
- package/cjs/UpSetChart/gameOfThrones.test-data.d.ts +0 -4
- package/cjs/UpSetChart/gameOfThrones.test-data.js +0 -26
- package/cjs/UpSetChart/helpers.d.ts +0 -20
- package/cjs/UpSetChart/helpers.js +0 -127
- package/cjs/UpSetChart/index.d.ts +0 -1
- package/cjs/UpSetChart/index.js +0 -5
- package/cjs/UpSetChart/styles.d.ts +0 -4
- package/cjs/UpSetChart/styles.js +0 -18
- package/cjs/UpSetChart/types.d.ts +0 -16
- package/cjs/UpSetChart/types.js +0 -2
- package/cjs/UpSetChart/useUpSetChartSizes.d.ts +0 -20
- package/cjs/UpSetChart/useUpSetChartSizes.js +0 -34
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
2
|
-
import { scaleLinear } from 'd3-scale';
|
|
3
|
-
import { SetsChartAxis } from '../SetsChartAxis';
|
|
4
|
-
import { GAP_BEFORE_LEFT_BAR, SET_BAR_HEIGHT, TEXT_GAP } from '../../constants';
|
|
5
|
-
import { useStyles } from './styles';
|
|
6
|
-
export var SetsChart = function (_a) {
|
|
7
|
-
var sets = _a.sets, width = _a.width, yScale = _a.yScale, transform = _a.transform, labels = _a.labels, hoveredElements = _a.hoveredElements, hoverAreaWidth = _a.hoverAreaWidth, onSetHover = _a.onSetHover;
|
|
8
|
-
var styles = useStyles();
|
|
9
|
-
var containerRef = React.useRef(null);
|
|
10
|
-
var xScale = useMemo(function () {
|
|
11
|
-
var maxSetSize = sets.length > 0 ? Math.max.apply(Math, sets.map(function (set) { return set.size; })) : 0;
|
|
12
|
-
return scaleLinear().domain([0, maxSetSize]).range([0, width]);
|
|
13
|
-
}, [width, sets]);
|
|
14
|
-
return (React.createElement("g", { ref: containerRef, transform: transform },
|
|
15
|
-
React.createElement(SetsChartAxis, { width: width }),
|
|
16
|
-
sets.map(function (set, i) {
|
|
17
|
-
var name = set.name, size = set.size, elements = set.elements;
|
|
18
|
-
var label = labels[i];
|
|
19
|
-
var height = yScale.bandwidth();
|
|
20
|
-
var y = yScale(name) + height / 2 - SET_BAR_HEIGHT / 2;
|
|
21
|
-
var lineY = yScale(name) + height;
|
|
22
|
-
var barSize = hoveredElements ? elements.filter(function (el) { return hoveredElements.includes(el); }).length : size;
|
|
23
|
-
return (React.createElement("g", { key: "set-group-".concat(i) },
|
|
24
|
-
React.createElement("rect", { className: styles.setsBarBackground, x: 0, y: y, width: width, height: SET_BAR_HEIGHT }),
|
|
25
|
-
React.createElement("rect", { className: styles.setsBarDimmed, x: width - xScale(size), y: y, width: xScale(size), height: SET_BAR_HEIGHT }),
|
|
26
|
-
React.createElement("rect", { className: styles.setsBar, x: width - xScale(barSize), y: y, width: xScale(barSize), height: SET_BAR_HEIGHT }),
|
|
27
|
-
i !== sets.length - 1 && (React.createElement("line", { className: styles.gridLine, x1: 0, x2: hoverAreaWidth, y1: lineY, y2: lineY })),
|
|
28
|
-
React.createElement("text", { className: styles.setsLabel, x: width + TEXT_GAP, y: yScale(name) + height / 2 }, label),
|
|
29
|
-
React.createElement("rect", { className: styles.hoverBar, "data-reltio-id": "set-hover-area", x: -GAP_BEFORE_LEFT_BAR + 1, y: yScale(name), width: hoverAreaWidth - 2, height: height, onMouseEnter: function () { return onSetHover(set); }, onMouseLeave: function () { return onSetHover(null); } })));
|
|
30
|
-
})));
|
|
31
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SetsChart } from './SetsChart';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SetsChart } from './SetsChart';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"setsBarBackground" | "setsBarDimmed" | "setsBar" | "hoverBar" | "setsLabel" | "gridLine">;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from '@mui/styles';
|
|
2
|
-
import { DIMMED_COLOR, PRIMARY_COLOR, SET_LABEL_SIZE, TEXT_COLOR } from '../../constants';
|
|
3
|
-
export var useStyles = makeStyles(function () { return ({
|
|
4
|
-
setsBarBackground: {
|
|
5
|
-
fill: PRIMARY_COLOR,
|
|
6
|
-
opacity: 0.08,
|
|
7
|
-
transition: 'x ease-in-out 0.3s, width ease-in-out 0.3s'
|
|
8
|
-
},
|
|
9
|
-
setsBarDimmed: {
|
|
10
|
-
fill: DIMMED_COLOR,
|
|
11
|
-
transition: 'x ease-in-out 0.3s, width ease-in-out 0.3s'
|
|
12
|
-
},
|
|
13
|
-
setsBar: {
|
|
14
|
-
fill: PRIMARY_COLOR,
|
|
15
|
-
transition: 'x ease-in-out 0.3s, width ease-in-out 0.3s'
|
|
16
|
-
},
|
|
17
|
-
hoverBar: {
|
|
18
|
-
fill: 'transparent',
|
|
19
|
-
strokeWidth: '1px',
|
|
20
|
-
cursor: 'pointer',
|
|
21
|
-
stroke: PRIMARY_COLOR,
|
|
22
|
-
opacity: 0,
|
|
23
|
-
transition: 'opacity ease-in-out 0.3s',
|
|
24
|
-
'&:hover': {
|
|
25
|
-
opacity: 1
|
|
26
|
-
}
|
|
27
|
-
},
|
|
28
|
-
setsLabel: {
|
|
29
|
-
fontSize: SET_LABEL_SIZE,
|
|
30
|
-
fill: TEXT_COLOR,
|
|
31
|
-
textAnchor: 'start',
|
|
32
|
-
dominantBaseline: 'middle',
|
|
33
|
-
transition: 'all ease-in-out 0.3s'
|
|
34
|
-
},
|
|
35
|
-
gridLine: {
|
|
36
|
-
stroke: '#000000',
|
|
37
|
-
opacity: 0.04,
|
|
38
|
-
strokeWidth: '1px'
|
|
39
|
-
}
|
|
40
|
-
}); });
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { useStyles } from './styles';
|
|
3
|
-
export var SetsChartAxis = function (_a) {
|
|
4
|
-
var width = _a.width;
|
|
5
|
-
var styles = useStyles();
|
|
6
|
-
return (React.createElement("g", null,
|
|
7
|
-
React.createElement("g", { transform: "translate(0,0)" },
|
|
8
|
-
React.createElement("line", { y2: -6, className: styles.axisTick }),
|
|
9
|
-
React.createElement("text", { x: 0, y: -9, className: styles.axisTickLabel }, "100%")),
|
|
10
|
-
React.createElement("g", { transform: "translate(".concat(width, ",0)") },
|
|
11
|
-
React.createElement("line", { y2: -6, className: styles.axisTick }),
|
|
12
|
-
React.createElement("text", { x: 0, y: -9, className: styles.axisTickLabel }, "0%"))));
|
|
13
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SetsChartAxis } from './SetsChartAxis';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { SetsChartAxis } from './SetsChartAxis';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const useStyles: (props?: any) => import("@mui/styles").ClassNameMap<"axisTick" | "axisTickLabel">;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from '@mui/styles';
|
|
2
|
-
export var useStyles = makeStyles(function () { return ({
|
|
3
|
-
axisTick: {
|
|
4
|
-
stroke: '#000000',
|
|
5
|
-
strokeWidth: '1px',
|
|
6
|
-
opacity: 0.54
|
|
7
|
-
},
|
|
8
|
-
axisTickLabel: {
|
|
9
|
-
fontSize: '10px',
|
|
10
|
-
fill: '#000000',
|
|
11
|
-
opacity: 0.54,
|
|
12
|
-
textAnchor: 'middle'
|
|
13
|
-
}
|
|
14
|
-
}); });
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const PRIMARY_COLOR = "#000066";
|
|
2
|
-
export declare const DIMMED_COLOR = "#CCCCE0";
|
|
3
|
-
export declare const TEXT_COLOR = "rgba(0, 0, 0, 0.87)";
|
|
4
|
-
export declare const TOP_GAP = 24;
|
|
5
|
-
export declare const TEXT_GAP = 16;
|
|
6
|
-
export declare const GAP_BETWEEN_TABLE_AND_CHART = 8;
|
|
7
|
-
export declare const GAP_BEFORE_LEFT_BAR = 12;
|
|
8
|
-
export declare const AXIS_TICK_LABEL_SIZE = "12px";
|
|
9
|
-
export declare const SET_LABEL_SIZE = "13px";
|
|
10
|
-
export declare const SET_BAR_HEIGHT = 12;
|
|
11
|
-
export declare const MATRIX_ROW_HEIGHT = 29;
|
|
12
|
-
export declare const MIN_MATRIX_COLUMN_WIDTH = 28;
|
|
13
|
-
export declare const MIN_INTERSECTION_CHART_HEIGHT = 120;
|
|
14
|
-
export declare const MIN_SETS_CHART_WIDTH = 100;
|
|
15
|
-
export declare const MAX_SETS_CHART_WIDTH = 200;
|
|
16
|
-
export declare const MAX_CHARACTERS = 20;
|
|
17
|
-
export declare const MIN_CHARACTERS = 8;
|
package/UpSetChart/constants.js
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
// Colors
|
|
2
|
-
export var PRIMARY_COLOR = '#000066';
|
|
3
|
-
export var DIMMED_COLOR = '#CCCCE0';
|
|
4
|
-
export var TEXT_COLOR = 'rgba(0, 0, 0, 0.87)';
|
|
5
|
-
// Gaps
|
|
6
|
-
export var TOP_GAP = 24;
|
|
7
|
-
export var TEXT_GAP = 16;
|
|
8
|
-
export var GAP_BETWEEN_TABLE_AND_CHART = 8;
|
|
9
|
-
export var GAP_BEFORE_LEFT_BAR = 12;
|
|
10
|
-
// Sizes
|
|
11
|
-
export var AXIS_TICK_LABEL_SIZE = '12px';
|
|
12
|
-
export var SET_LABEL_SIZE = '13px';
|
|
13
|
-
export var SET_BAR_HEIGHT = 12;
|
|
14
|
-
export var MATRIX_ROW_HEIGHT = 29;
|
|
15
|
-
export var MIN_MATRIX_COLUMN_WIDTH = 28;
|
|
16
|
-
export var MIN_INTERSECTION_CHART_HEIGHT = 120;
|
|
17
|
-
export var MIN_SETS_CHART_WIDTH = 100;
|
|
18
|
-
export var MAX_SETS_CHART_WIDTH = 200;
|
|
19
|
-
export var MAX_CHARACTERS = 20;
|
|
20
|
-
export var MIN_CHARACTERS = 8;
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export var gameOfThronesData = [
|
|
2
|
-
{ name: 'Alton Lannister', sets: ['was killed', 'Lannister', 'male'] },
|
|
3
|
-
{ name: 'Arya Stark', sets: ['Stark', 'female'] },
|
|
4
|
-
{ name: 'Bran Stark', sets: ['royal', 'Stark', 'male'] },
|
|
5
|
-
{ name: 'Benjen Stark', sets: ['was killed', 'Stark', 'male'] },
|
|
6
|
-
{ name: 'Brandon Stark', sets: ['was killed', 'Stark'] },
|
|
7
|
-
{ name: 'Catelyn Stark', sets: ['was killed', 'Stark', 'female'] },
|
|
8
|
-
{ name: 'Cersei Lannister', sets: ['royal', 'was killed', 'Lannister', 'female'] },
|
|
9
|
-
{ name: 'Eddard Stark', sets: ['was killed', 'Stark', 'male'] },
|
|
10
|
-
{ name: 'Jaime Lannister', sets: ['was killed', 'Lannister', 'male'] },
|
|
11
|
-
{ name: 'Jon Snow', sets: ['royal', 'was killed', 'Stark', 'male'] },
|
|
12
|
-
{ name: 'Kevan Lannister', sets: ['was killed', 'Lannister', 'male'] },
|
|
13
|
-
{ name: 'Lancel Lannister', sets: ['was killed', 'Lannister', 'male'] },
|
|
14
|
-
{ name: 'Lyanna Stark', sets: ['was killed', 'Stark', 'female'] },
|
|
15
|
-
{ name: 'Martyn Lannister', sets: ['was killed', 'Lannister', 'male'] },
|
|
16
|
-
{ name: 'Rickard Stark', sets: ['was killed', 'Stark', 'male'] },
|
|
17
|
-
{ name: 'Rickon Stark', sets: ['was killed', 'Stark', 'male'] },
|
|
18
|
-
{ name: 'Robb Stark', sets: ['royal', 'was killed', 'Stark', 'male'] },
|
|
19
|
-
{ name: 'Sansa Stark', sets: ['royal', 'Stark', 'female'] },
|
|
20
|
-
{ name: 'Tyrion Lannister', sets: ['Lannister', 'male'] },
|
|
21
|
-
{ name: 'Tywin Lannister', sets: ['was killed', 'Lannister', 'male'] },
|
|
22
|
-
{ name: 'Willem Lannister', sets: ['was killed', 'Lannister', 'male'] }
|
|
23
|
-
];
|
package/UpSetChart/helpers.d.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { ScaleBand } from 'd3-scale';
|
|
2
|
-
import { DataSet, Intersection, UpSetChartData } from './types';
|
|
3
|
-
export declare const findIntersections: (data: UpSetChartData) => {
|
|
4
|
-
intersections: Intersection[];
|
|
5
|
-
sets: DataSet[];
|
|
6
|
-
};
|
|
7
|
-
export declare const getMatrixData: (xScale: ScaleBand<string>, yScale: ScaleBand<string>, intersections: Intersection[], sets: DataSet[]) => {
|
|
8
|
-
circles: {
|
|
9
|
-
cx: number;
|
|
10
|
-
cy: number;
|
|
11
|
-
isPresent: boolean;
|
|
12
|
-
intersectionIndex: number;
|
|
13
|
-
}[];
|
|
14
|
-
lines: any[];
|
|
15
|
-
};
|
|
16
|
-
export declare const truncateLabels: (sets: DataSet[], maxLabelsWidth: number) => {
|
|
17
|
-
labels: string[];
|
|
18
|
-
maxWidth: number;
|
|
19
|
-
};
|
|
20
|
-
export declare const calculateTicksWidth: (ticks: number[]) => number;
|
package/UpSetChart/helpers.js
DELETED
|
@@ -1,120 +0,0 @@
|
|
|
1
|
-
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
2
|
-
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
3
|
-
if (ar || !(i in from)) {
|
|
4
|
-
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
5
|
-
ar[i] = from[i];
|
|
6
|
-
}
|
|
7
|
-
}
|
|
8
|
-
return to.concat(ar || Array.prototype.slice.call(from));
|
|
9
|
-
};
|
|
10
|
-
import { AXIS_TICK_LABEL_SIZE, MAX_CHARACTERS, MIN_CHARACTERS, SET_LABEL_SIZE } from './constants';
|
|
11
|
-
export var findIntersections = function (data) {
|
|
12
|
-
var setsCombinations = {};
|
|
13
|
-
var individualSets = {};
|
|
14
|
-
data.forEach(function (_a) {
|
|
15
|
-
var name = _a.name, sets = _a.sets;
|
|
16
|
-
sets.forEach(function (set) {
|
|
17
|
-
if (!individualSets[set]) {
|
|
18
|
-
individualSets[set] = [];
|
|
19
|
-
}
|
|
20
|
-
individualSets[set].push(name);
|
|
21
|
-
});
|
|
22
|
-
var generateCombinations = function (subset, index) {
|
|
23
|
-
if (index === sets.length) {
|
|
24
|
-
if (subset.length > 0) {
|
|
25
|
-
var key = subset.sort().join(',');
|
|
26
|
-
if (!setsCombinations[key]) {
|
|
27
|
-
setsCombinations[key] = [];
|
|
28
|
-
}
|
|
29
|
-
setsCombinations[key].push(name);
|
|
30
|
-
}
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
generateCombinations(subset, index + 1);
|
|
34
|
-
generateCombinations(__spreadArray(__spreadArray([], subset, true), [sets[index]], false), index + 1);
|
|
35
|
-
};
|
|
36
|
-
generateCombinations([], 0);
|
|
37
|
-
});
|
|
38
|
-
var intersections = Object.entries(setsCombinations)
|
|
39
|
-
.map(function (_a, index) {
|
|
40
|
-
var key = _a[0], elements = _a[1];
|
|
41
|
-
return ({
|
|
42
|
-
index: index,
|
|
43
|
-
sets: key.split(','),
|
|
44
|
-
size: elements.length,
|
|
45
|
-
elements: elements
|
|
46
|
-
});
|
|
47
|
-
})
|
|
48
|
-
.sort(function (a, b) { return b.size - a.size; });
|
|
49
|
-
var sets = Object.entries(individualSets).map(function (_a, index) {
|
|
50
|
-
var name = _a[0], elements = _a[1];
|
|
51
|
-
return ({
|
|
52
|
-
index: index,
|
|
53
|
-
name: name,
|
|
54
|
-
size: elements.length,
|
|
55
|
-
elements: elements
|
|
56
|
-
});
|
|
57
|
-
});
|
|
58
|
-
return { intersections: intersections, sets: sets };
|
|
59
|
-
};
|
|
60
|
-
export var getMatrixData = function (xScale, yScale, intersections, sets) {
|
|
61
|
-
var circles = intersections.flatMap(function (intersection, i) {
|
|
62
|
-
return sets.map(function (set) { return ({
|
|
63
|
-
cx: xScale(String(i)) + xScale.bandwidth() / 2,
|
|
64
|
-
cy: yScale(set.name) + yScale.bandwidth() / 2,
|
|
65
|
-
isPresent: intersection.sets.includes(set.name),
|
|
66
|
-
intersectionIndex: intersection.index
|
|
67
|
-
}); });
|
|
68
|
-
});
|
|
69
|
-
var lines = intersections.reduce(function (acc, intersection, i) {
|
|
70
|
-
var activeSetIndices = intersection.sets
|
|
71
|
-
.map(function (name) { return sets.findIndex(function (set) { return set.name === name; }); })
|
|
72
|
-
.filter(function (i) { return i >= 0; })
|
|
73
|
-
.sort(function (a, b) { return a - b; });
|
|
74
|
-
if (activeSetIndices.length > 1) {
|
|
75
|
-
var firstIdx = activeSetIndices[0];
|
|
76
|
-
var lastIdx = activeSetIndices[activeSetIndices.length - 1];
|
|
77
|
-
var x = xScale(String(i)) + xScale.bandwidth() / 2;
|
|
78
|
-
var y1 = yScale(sets[firstIdx].name) + yScale.bandwidth() / 2;
|
|
79
|
-
var y2 = yScale(sets[lastIdx].name) + yScale.bandwidth() / 2;
|
|
80
|
-
return __spreadArray(__spreadArray([], acc, true), [{ x: x, y1: y1, y2: y2, intersectionIndex: intersection.index }], false);
|
|
81
|
-
}
|
|
82
|
-
return acc;
|
|
83
|
-
}, []);
|
|
84
|
-
return { circles: circles, lines: lines };
|
|
85
|
-
};
|
|
86
|
-
export var truncateLabels = function (sets, maxLabelsWidth) {
|
|
87
|
-
var newTruncatedLabels = [];
|
|
88
|
-
var maxWidth = 0;
|
|
89
|
-
var tempSvgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
90
|
-
document.body.appendChild(tempSvgElement);
|
|
91
|
-
var tempTextElement = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
92
|
-
tempTextElement.setAttribute('font-size', SET_LABEL_SIZE);
|
|
93
|
-
tempSvgElement.appendChild(tempTextElement);
|
|
94
|
-
sets.forEach(function (_a) {
|
|
95
|
-
var name = _a.name;
|
|
96
|
-
var truncatedText = name.length > MAX_CHARACTERS ? name.slice(0, MAX_CHARACTERS) + '...' : name;
|
|
97
|
-
tempTextElement.textContent = truncatedText;
|
|
98
|
-
while (tempTextElement.getBBox().width > maxLabelsWidth && truncatedText.length > MIN_CHARACTERS) {
|
|
99
|
-
truncatedText = truncatedText.slice(0, -4) + '...';
|
|
100
|
-
tempTextElement.textContent = truncatedText;
|
|
101
|
-
}
|
|
102
|
-
newTruncatedLabels.push(truncatedText);
|
|
103
|
-
maxWidth = Math.max(maxWidth, tempTextElement.getBBox().width);
|
|
104
|
-
});
|
|
105
|
-
document.body.removeChild(tempSvgElement);
|
|
106
|
-
return { labels: newTruncatedLabels, maxWidth: maxWidth };
|
|
107
|
-
};
|
|
108
|
-
export var calculateTicksWidth = function (ticks) {
|
|
109
|
-
var tempSvgElement = document.createElementNS('http://www.w3.org/2000/svg', 'svg');
|
|
110
|
-
var tempTextElement = document.createElementNS('http://www.w3.org/2000/svg', 'text');
|
|
111
|
-
tempTextElement.setAttribute('font-size', AXIS_TICK_LABEL_SIZE);
|
|
112
|
-
tempSvgElement.appendChild(tempTextElement);
|
|
113
|
-
document.body.appendChild(tempSvgElement);
|
|
114
|
-
var maxWidth = ticks.reduce(function (maxWidth, tick) {
|
|
115
|
-
tempTextElement.textContent = String(tick);
|
|
116
|
-
return Math.max(maxWidth, tempTextElement.getBBox().width);
|
|
117
|
-
}, 0);
|
|
118
|
-
document.body.removeChild(tempSvgElement);
|
|
119
|
-
return maxWidth;
|
|
120
|
-
};
|
package/UpSetChart/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { UpSetChart } from './UpSetChart';
|
package/UpSetChart/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { UpSetChart } from './UpSetChart';
|
package/UpSetChart/styles.d.ts
DELETED
package/UpSetChart/styles.js
DELETED
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { makeStyles } from '@mui/styles';
|
|
2
|
-
export var useStyles = makeStyles(function () { return ({
|
|
3
|
-
wrapper: function (_a) {
|
|
4
|
-
var width = _a.width, height = _a.height;
|
|
5
|
-
return ({
|
|
6
|
-
width: width,
|
|
7
|
-
height: height,
|
|
8
|
-
display: 'flex',
|
|
9
|
-
overflow: 'auto'
|
|
10
|
-
});
|
|
11
|
-
},
|
|
12
|
-
svg: {
|
|
13
|
-
flexShrink: '0'
|
|
14
|
-
}
|
|
15
|
-
}); });
|
package/UpSetChart/types.d.ts
DELETED
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
export type UpSetChartData = {
|
|
2
|
-
name: string;
|
|
3
|
-
sets: string[];
|
|
4
|
-
}[];
|
|
5
|
-
export type Intersection = {
|
|
6
|
-
index: number;
|
|
7
|
-
sets: string[];
|
|
8
|
-
size: number;
|
|
9
|
-
elements: string[];
|
|
10
|
-
};
|
|
11
|
-
export type DataSet = {
|
|
12
|
-
index: number;
|
|
13
|
-
name: string;
|
|
14
|
-
size: number;
|
|
15
|
-
elements: string[];
|
|
16
|
-
};
|
package/UpSetChart/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { DataSet, Intersection } from './types';
|
|
2
|
-
type Props = {
|
|
3
|
-
width: number;
|
|
4
|
-
height: number;
|
|
5
|
-
intersections: Intersection[];
|
|
6
|
-
sets: DataSet[];
|
|
7
|
-
};
|
|
8
|
-
export declare const useUpSetChartSizes: ({ width, height, intersections, sets }: Props) => {
|
|
9
|
-
labels: string[];
|
|
10
|
-
svgWidth: number;
|
|
11
|
-
svgHeight: number;
|
|
12
|
-
intersectionsChartWidth: number;
|
|
13
|
-
intersectionsChartHeight: number;
|
|
14
|
-
matrixY: number;
|
|
15
|
-
matrixHeight: number;
|
|
16
|
-
maxLabelsWidth: number;
|
|
17
|
-
leftPadding: number;
|
|
18
|
-
setsChartWidth: number;
|
|
19
|
-
};
|
|
20
|
-
export {};
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
import { GAP_BEFORE_LEFT_BAR, GAP_BETWEEN_TABLE_AND_CHART, MATRIX_ROW_HEIGHT, MAX_SETS_CHART_WIDTH, MIN_INTERSECTION_CHART_HEIGHT, MIN_MATRIX_COLUMN_WIDTH, MIN_SETS_CHART_WIDTH, TEXT_GAP, TOP_GAP } from './constants';
|
|
2
|
-
import { truncateLabels } from './helpers';
|
|
3
|
-
export var useUpSetChartSizes = function (_a) {
|
|
4
|
-
var width = _a.width, height = _a.height, intersections = _a.intersections, sets = _a.sets;
|
|
5
|
-
var minMatrixWidth = intersections.length * MIN_MATRIX_COLUMN_WIDTH * 1.2;
|
|
6
|
-
var matrixHeight = sets.length * MATRIX_ROW_HEIGHT;
|
|
7
|
-
var availableLabelsWidth = width - minMatrixWidth - TEXT_GAP * 2 - GAP_BEFORE_LEFT_BAR - MIN_SETS_CHART_WIDTH;
|
|
8
|
-
var _b = truncateLabels(sets, availableLabelsWidth), labels = _b.labels, labelsWidth = _b.maxWidth;
|
|
9
|
-
var availableSetsChartWidth = width - minMatrixWidth - TEXT_GAP * 2 - GAP_BEFORE_LEFT_BAR - labelsWidth;
|
|
10
|
-
var setsChartWidth = Math.min(Math.max(availableSetsChartWidth, MIN_SETS_CHART_WIDTH), MAX_SETS_CHART_WIDTH);
|
|
11
|
-
var maxLabelsWidth = width - minMatrixWidth - TEXT_GAP * 2 - GAP_BEFORE_LEFT_BAR - setsChartWidth;
|
|
12
|
-
var leftPadding = setsChartWidth + labelsWidth + TEXT_GAP * 2 + GAP_BEFORE_LEFT_BAR;
|
|
13
|
-
var intersectionsChartWidth = Math.max(minMatrixWidth, width - leftPadding);
|
|
14
|
-
var intersectionsChartHeight = Math.max(MIN_INTERSECTION_CHART_HEIGHT, height - TOP_GAP - matrixHeight - GAP_BETWEEN_TABLE_AND_CHART);
|
|
15
|
-
var svgWidth = leftPadding + intersectionsChartWidth;
|
|
16
|
-
var svgHeight = intersectionsChartHeight + matrixHeight + TOP_GAP + GAP_BETWEEN_TABLE_AND_CHART;
|
|
17
|
-
var matrixY = svgHeight - matrixHeight - 1;
|
|
18
|
-
return {
|
|
19
|
-
labels: labels,
|
|
20
|
-
svgWidth: svgWidth,
|
|
21
|
-
svgHeight: svgHeight,
|
|
22
|
-
intersectionsChartWidth: intersectionsChartWidth,
|
|
23
|
-
intersectionsChartHeight: intersectionsChartHeight,
|
|
24
|
-
matrixY: matrixY,
|
|
25
|
-
matrixHeight: matrixHeight,
|
|
26
|
-
maxLabelsWidth: maxLabelsWidth,
|
|
27
|
-
leftPadding: leftPadding,
|
|
28
|
-
setsChartWidth: setsChartWidth
|
|
29
|
-
};
|
|
30
|
-
};
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
-
if (k2 === undefined) k2 = k;
|
|
4
|
-
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
-
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
-
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
-
}
|
|
8
|
-
Object.defineProperty(o, k2, desc);
|
|
9
|
-
}) : (function(o, m, k, k2) {
|
|
10
|
-
if (k2 === undefined) k2 = k;
|
|
11
|
-
o[k2] = m[k];
|
|
12
|
-
}));
|
|
13
|
-
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
|
|
14
|
-
Object.defineProperty(o, "default", { enumerable: true, value: v });
|
|
15
|
-
}) : function(o, v) {
|
|
16
|
-
o["default"] = v;
|
|
17
|
-
});
|
|
18
|
-
var __importStar = (this && this.__importStar) || function (mod) {
|
|
19
|
-
if (mod && mod.__esModule) return mod;
|
|
20
|
-
var result = {};
|
|
21
|
-
if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
|
-
__setModuleDefault(result, mod);
|
|
23
|
-
return result;
|
|
24
|
-
};
|
|
25
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
26
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
27
|
-
};
|
|
28
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
29
|
-
exports.UpSetChart = void 0;
|
|
30
|
-
var react_1 = __importStar(require("react"));
|
|
31
|
-
var d3_scale_1 = require("d3-scale");
|
|
32
|
-
var Tooltip_1 = __importDefault(require("@mui/material/Tooltip"));
|
|
33
|
-
var SetsChart_1 = require("./components/SetsChart");
|
|
34
|
-
var IntersectionsMatrix_1 = require("./components/IntersectionsMatrix");
|
|
35
|
-
var IntersectionsChart_1 = require("./components/IntersectionsChart");
|
|
36
|
-
var useUpSetChartSizes_1 = require("./useUpSetChartSizes");
|
|
37
|
-
var constants_1 = require("./constants");
|
|
38
|
-
var helpers_1 = require("./helpers");
|
|
39
|
-
var styles_1 = require("./styles");
|
|
40
|
-
var UpSetChart = function (_a) {
|
|
41
|
-
var data = _a.data, width = _a.width, height = _a.height;
|
|
42
|
-
var styles = (0, styles_1.useStyles)({ width: width, height: height });
|
|
43
|
-
var containerRef = (0, react_1.useRef)(null);
|
|
44
|
-
var _b = (0, react_1.useState)(null), hoveredSet = _b[0], setHoveredSet = _b[1];
|
|
45
|
-
var _c = (0, react_1.useState)(null), hoveredIntersection = _c[0], setHoveredIntersection = _c[1];
|
|
46
|
-
var _d = (0, react_1.useState)([width, height]), _e = _d[0], availableWidth = _e[0], availableHeight = _e[1], setAvailableSize = _d[1];
|
|
47
|
-
var _f = (0, react_1.useMemo)(function () { return (0, helpers_1.findIntersections)(data); }, [data]), intersections = _f.intersections, sets = _f.sets;
|
|
48
|
-
var hoveredElements = (hoveredIntersection === null || hoveredIntersection === void 0 ? void 0 : hoveredIntersection.elements) || (hoveredSet === null || hoveredSet === void 0 ? void 0 : hoveredSet.elements);
|
|
49
|
-
var tooltipTitle = hoveredIntersection === null || hoveredIntersection === void 0 ? void 0 : hoveredIntersection.sets.join(' ∩ ');
|
|
50
|
-
var _g = (0, useUpSetChartSizes_1.useUpSetChartSizes)({ width: availableWidth, height: availableHeight, intersections: intersections, sets: sets }), labels = _g.labels, svgWidth = _g.svgWidth, svgHeight = _g.svgHeight, intersectionsChartWidth = _g.intersectionsChartWidth, intersectionsChartHeight = _g.intersectionsChartHeight, matrixY = _g.matrixY, matrixHeight = _g.matrixHeight, setsChartWidth = _g.setsChartWidth, leftPadding = _g.leftPadding;
|
|
51
|
-
var matrixXScale = (0, react_1.useMemo)(function () {
|
|
52
|
-
var domain = intersections.map(function (_, i) { return String(i); });
|
|
53
|
-
return (0, d3_scale_1.scaleBand)([0, intersectionsChartWidth]).domain(domain).paddingInner(0.2);
|
|
54
|
-
}, [intersections, intersectionsChartWidth]);
|
|
55
|
-
var matrixYScale = (0, react_1.useMemo)(function () {
|
|
56
|
-
var domain = sets.map(function (set) { return set.name; });
|
|
57
|
-
return (0, d3_scale_1.scaleBand)([0, matrixHeight]).domain(domain);
|
|
58
|
-
}, [sets, matrixHeight]);
|
|
59
|
-
(0, react_1.useEffect)(function () {
|
|
60
|
-
var _a = containerRef.current || {}, clientWidth = _a.clientWidth, clientHeight = _a.clientHeight;
|
|
61
|
-
setAvailableSize([clientWidth || width, clientHeight || height]);
|
|
62
|
-
}, [width, height]);
|
|
63
|
-
return (react_1.default.createElement("div", { ref: containerRef, className: styles.wrapper },
|
|
64
|
-
react_1.default.createElement(Tooltip_1.default, { title: tooltipTitle, followCursor: true },
|
|
65
|
-
react_1.default.createElement("svg", { className: styles.svg, width: svgWidth, height: svgHeight },
|
|
66
|
-
react_1.default.createElement(IntersectionsMatrix_1.IntersectionsMatrix, { xScale: matrixXScale, yScale: matrixYScale, intersections: intersections, sets: sets, transform: "translate(".concat(leftPadding, ",").concat(matrixY, ")"), hoveredIntersection: hoveredIntersection }),
|
|
67
|
-
react_1.default.createElement(SetsChart_1.SetsChart, { yScale: matrixYScale, width: setsChartWidth, sets: sets, labels: labels, hoveredElements: hoveredElements, hoverAreaWidth: svgWidth, transform: "translate(".concat(constants_1.GAP_BEFORE_LEFT_BAR, ",").concat(matrixY, ")"), onSetHover: setHoveredSet }),
|
|
68
|
-
react_1.default.createElement(IntersectionsChart_1.IntersectionsChart, { xScale: matrixXScale, width: intersectionsChartWidth, height: intersectionsChartHeight, intersections: intersections, highlightedElements: hoveredElements, transform: "translate(".concat(leftPadding, ",").concat(constants_1.TOP_GAP, ")"), matrixHeight: matrixHeight, onIntersectionHover: setHoveredIntersection })))));
|
|
69
|
-
};
|
|
70
|
-
exports.UpSetChart = UpSetChart;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|