Skip to content

Commit

Permalink
Merge pull request #11 from receptron/cytoscapeType
Browse files Browse the repository at this point in the history
Cytoscape type
  • Loading branch information
snakajima authored May 2, 2024
2 parents 11930d9 + 253e3e9 commit 744aa3a
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions src/views/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ import cytoscape, {
// EventObject,
Core,
NodeSingular,
NodeDefinition,
EdgeDefinition,
} from "cytoscape";
import fcose from "cytoscape-fcose";
Expand Down Expand Up @@ -202,7 +204,7 @@ const graph_data2: GraphData = {
};
const cytoscapeFromGraph = (graph_data: GraphData) => {
const elements = Object.keys(graph_data.nodes).reduce((tmp: Record<string, any>, nodeId) => {
const elements = Object.keys(graph_data.nodes).reduce((tmp: { nodes: NodeDefinition[], edges: EdgeDefinition[], map: Record<string, NodeDefinition>}, nodeId) => {
const node: NodeData = graph_data.nodes[nodeId];
const cyNode = {
data: {
Expand Down Expand Up @@ -245,7 +247,7 @@ const cytoscapeFromGraph = (graph_data: GraphData) => {
return { elements };
}
export const sleepTestAgent: AgentFunction<{ duration?: number; value?: Record<string, any> }> = async (context) => {
export const sleepTestAgent: AgentFunction<{ duration?: number}> = async (context) => {
const { params, inputs } = context;
await sleep(params?.duration ?? 500);
return inputs[0];
Expand Down Expand Up @@ -301,7 +303,7 @@ export default defineComponent({
const storePositions = () => {
console.log("storePositions");
if (cy) {
cy.nodes().forEach((cynode:any) => {
cy.nodes().forEach((cynode: NodeDefinition) => {

Check failure on line 306 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

Argument of type '(cynode: NodeDefinition) => void' is not assignable to parameter of type '(ele: NodeSingular, i: number, eles: NodeCollection) => boolean | void'.
const id = cynode.id();

Check failure on line 307 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

Property 'id' does not exist on type 'NodeDefinition'.
const pos = cynode.position();

Check failure on line 308 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

Cannot invoke an object which is possibly 'undefined'.

Check failure on line 308 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

'cynode.position' is possibly 'undefined'.

Check failure on line 308 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

This expression is not callable.
const node = cytoData.value.elements.map[id];
Expand All @@ -314,7 +316,7 @@ export default defineComponent({
try {
cy = cytoscape({
container: cyRef.value,
style: cyStyle as any,
style: cyStyle,

Check failure on line 319 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

Type '({ selector: string; style: { "background-color": string; label: string; shape: (ele: NodeSingular) => "rectangle" | "roundrectangle"; width: (ele: NodeSingular) => string; ... 12 more ...; "line-style"?: undefined; }; } | { ...; } | { ...; } | { ...; })[]' is not assignable to type 'Stylesheet[] | Promise<Stylesheet[]> | undefined'.
layout: {
name: "cose",
fit: true,
Expand All @@ -336,8 +338,8 @@ export default defineComponent({
const updateGraphData = async () => {
if (cy) {
cy.elements().remove();
cy.add(cytoData.value.elements as any);
const name = cytoData.value.elements.nodes.reduce((name: string, node: Record<string, any>) => {
cy.add(cytoData.value.elements);
const name = cytoData.value.elements.nodes.reduce((name: string, node: Record<string, NodeDefinition>) => {

Check failure on line 342 in src/views/Home.vue

View workflow job for this annotation

GitHub Actions / build (20.x)

No overload matches this call.
if (node.position) {
return "preset";
}
Expand Down

0 comments on commit 744aa3a

Please sign in to comment.