Skip to content
Snippets Groups Projects
Commit d33beff9 authored by Vink, S.A. (Sjoerd)'s avatar Vink, S.A. (Sjoerd)
Browse files

feat(visManager): matrix settings

parent 033f283a
No related branches found
No related tags found
2 merge requests!135geo intergation,!129Feat/visManager
Pipeline #131565 passed
...@@ -22,9 +22,9 @@ import { NLPopup } from './MatrixPopup'; ...@@ -22,9 +22,9 @@ import { NLPopup } from './MatrixPopup';
import { Actions, Interpolations } from 'pixi-actions'; import { Actions, Interpolations } from 'pixi-actions';
import Color from 'color'; import Color from 'color';
import { SettingTypes } from '../../../configuration/settings';
import { createColumn } from './ColumnGraphicsComponent'; import { createColumn } from './ColumnGraphicsComponent';
import { ReorderingManager } from './ReorderingManager'; import { ReorderingManager } from './ReorderingManager';
import { VisualizationConfiguration } from '../../../types';
type Props = { type Props = {
// onClick: (node: NodeType, pos: IPointData) => void; // onClick: (node: NodeType, pos: IPointData) => void;
...@@ -34,7 +34,7 @@ type Props = { ...@@ -34,7 +34,7 @@ type Props = {
currentShortestPathEdges?: LinkType[]; currentShortestPathEdges?: LinkType[];
highlightedLinks?: LinkType[]; highlightedLinks?: LinkType[];
graph?: GraphQueryResult; graph?: GraphQueryResult;
localConfig: SettingTypes; configuration: VisualizationConfiguration;
}; };
const app = new Application({ background: 0xffffff, antialias: true, autoDensity: true, eventMode: 'auto' }); const app = new Application({ background: 0xffffff, antialias: true, autoDensity: true, eventMode: 'auto' });
...@@ -122,7 +122,7 @@ export const MatrixPixi = (props: Props) => { ...@@ -122,7 +122,7 @@ export const MatrixPixi = (props: Props) => {
if (props.graph && ref.current && ref.current.children.length > 0) { if (props.graph && ref.current && ref.current.children.length > 0) {
setup(); setup();
} }
}, [props.localConfig]); }, [props.configuration]);
// TODO implement search results // TODO implement search results
// useEffect(() => { // useEffect(() => {
...@@ -145,7 +145,7 @@ export const MatrixPixi = (props: Props) => { ...@@ -145,7 +145,7 @@ export const MatrixPixi = (props: Props) => {
function onButtonDown(event: FederatedPointerEvent) { function onButtonDown(event: FederatedPointerEvent) {
console.log( console.log(
event.currentTarget event.currentTarget,
// graph.nodes.find((node) => node.id === event.currentTarget.name) // graph.nodes.find((node) => node.id === event.currentTarget.name)
); );
} }
...@@ -231,7 +231,7 @@ export const MatrixPixi = (props: Props) => { ...@@ -231,7 +231,7 @@ export const MatrixPixi = (props: Props) => {
if (columnTextPositions.length !== columnPositions.length) if (columnTextPositions.length !== columnPositions.length)
throw new Error( throw new Error(
'columnTextPositions and columnPositions have different length ' + columnTextPositions.length + ' / ' + columnPositions.length 'columnTextPositions and columnPositions have different length ' + columnTextPositions.length + ' / ' + columnPositions.length,
); );
for (let i = 0; i < columns.length; i++) { for (let i = 0; i < columns.length; i++) {
...@@ -257,7 +257,7 @@ export const MatrixPixi = (props: Props) => { ...@@ -257,7 +257,7 @@ export const MatrixPixi = (props: Props) => {
rowOrder: string[], rowOrder: string[],
colorScale: any, colorScale: any,
cellWidth: number, cellWidth: number,
cellHeight: number cellHeight: number,
) => { ) => {
const rows = rowsContainer.children; const rows = rowsContainer.children;
let rowPositions: Point[] = []; let rowPositions: Point[] = [];
...@@ -306,11 +306,14 @@ export const MatrixPixi = (props: Props) => { ...@@ -306,11 +306,14 @@ export const MatrixPixi = (props: Props) => {
viewport.current.addChild(columnsContainer); viewport.current.addChild(columnsContainer);
viewport.current.addChild(rowsContainer); viewport.current.addChild(rowsContainer);
const groupByType = props.graph.nodes.reduce((group: any, node: Node) => { const groupByType = props.graph.nodes.reduce(
if (!group[node.label]) group[node.label] = []; (group: any, node: Node) => {
group[node.label].push(node); if (!group[node.label]) group[node.label] = [];
return group; group[node.label].push(node);
}, {} as { [key: string]: Node[] }); return group;
},
{} as { [key: string]: Node[] },
);
// order groupByType by size // order groupByType by size
const ordered = Object.entries(groupByType).sort((a: any[], b: any[]) => b[1].length - a[1].length); const ordered = Object.entries(groupByType).sort((a: any[], b: any[]) => b[1].length - a[1].length);
...@@ -350,7 +353,7 @@ export const MatrixPixi = (props: Props) => { ...@@ -350,7 +353,7 @@ export const MatrixPixi = (props: Props) => {
// console.log('currentColumnOrder', columnOrder); // console.log('currentColumnOrder', columnOrder);
setupVisualizationEncodingMapping(props.localConfig); setupVisualizationEncodingMapping(props.configuration);
setupColumns(props.graph.edges, columnOrder, rowOrder); setupColumns(props.graph.edges, columnOrder, rowOrder);
setupColumnLegend(columnOrder); setupColumnLegend(columnOrder);
...@@ -369,7 +372,7 @@ export const MatrixPixi = (props: Props) => { ...@@ -369,7 +372,7 @@ export const MatrixPixi = (props: Props) => {
isSetup.current = true; isSetup.current = true;
}; };
const setupVisualizationEncodingMapping = (localConfig: SettingTypes) => { const setupVisualizationEncodingMapping = (configuration: VisualizationConfiguration) => {
if (!props.graph) throw new Error('Graph is undefined; cannot setup matrix'); if (!props.graph) throw new Error('Graph is undefined; cannot setup matrix');
const visMapping = []; // TODO type const visMapping = []; // TODO type
...@@ -381,7 +384,7 @@ export const MatrixPixi = (props: Props) => { ...@@ -381,7 +384,7 @@ export const MatrixPixi = (props: Props) => {
const adjacenyScale = d3.scaleLinear([colorNeutral, tailwindColors.entity.DEFAULT]); const adjacenyScale = d3.scaleLinear([colorNeutral, tailwindColors.entity.DEFAULT]);
visMapping.push({ visMapping.push({
attribute: 'adjacency', attribute: 'adjacency',
encoding: localConfig.marks, encoding: configuration.marks,
colorScale: adjacenyScale, colorScale: adjacenyScale,
renderFunction: function (i: number, color: ColorSource, gfxContext: Graphics) { renderFunction: function (i: number, color: ColorSource, gfxContext: Graphics) {
gfxContext.beginFill(color, 1); gfxContext.beginFill(color, 1);
......
...@@ -6,14 +6,17 @@ import { MatrixPixi } from './components/MatrixPixi'; ...@@ -6,14 +6,17 @@ import { MatrixPixi } from './components/MatrixPixi';
import { VisualizationPropTypes, VISComponentType } from '../../types'; import { VisualizationPropTypes, VISComponentType } from '../../types';
import Input from '@graphpolaris/shared/lib/components/inputs'; import Input from '@graphpolaris/shared/lib/components/inputs';
import { GraphMetaData } from '@graphpolaris/shared/lib/data-access/statistics'; import { GraphMetaData } from '@graphpolaris/shared/lib/data-access/statistics';
import { SettingsContainer, SettingsHeader } from '@graphpolaris/shared/lib/vis/configuration'; import { SettingsContainer } from '@graphpolaris/shared/lib/vis/configuration';
import { dataColors, tailwindColors } from 'config';
export interface MatrixVisProps { export interface MatrixVisProps {
marks: string; marks: string;
color: string;
} }
const configuration: MatrixVisProps = { const configuration: MatrixVisProps = {
marks: 'rect', marks: 'rect',
color: 'blue',
}; };
export const MatrixVis = React.memo(({ data, ml, configuration }: VisualizationPropTypes) => { export const MatrixVis = React.memo(({ data, ml, configuration }: VisualizationPropTypes) => {
...@@ -31,7 +34,7 @@ export const MatrixVis = React.memo(({ data, ml, configuration }: VisualizationP ...@@ -31,7 +34,7 @@ export const MatrixVis = React.memo(({ data, ml, configuration }: VisualizationP
return ( return (
<> <>
<div className="h-full w-full overflow-hidden" ref={ref}> <div className="h-full w-full overflow-hidden" ref={ref}>
<MatrixPixi graph={graph} highlightNodes={highlightNodes} highlightedLinks={highlightedLinks} localConfig={configuration} /> <MatrixPixi graph={graph} highlightNodes={highlightNodes} highlightedLinks={highlightedLinks} configuration={configuration} />
</div> </div>
</> </>
); );
...@@ -55,6 +58,14 @@ const MatrixSettings = ({ ...@@ -55,6 +58,14 @@ const MatrixSettings = ({
options={['rect', 'circle']} options={['rect', 'circle']}
onChange={(val) => updateSettings({ marks: val })} onChange={(val) => updateSettings({ marks: val })}
/> />
<Input
type="dropdown"
label="Color"
value={configuration.color}
options={['blue', 'green']}
onChange={(val) => updateSettings({ color: val })}
/>
</SettingsContainer> </SettingsContainer>
); );
}; };
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment