I am trying to change graph's edge arrow size in React application using react-sigma library. Arrow size is so small that it is very hard to see it without zooming in. It seems that changing minArrowSize attribute in SigmaContainer settings does not work anymore in v2, it only worked in v1.
I have seen this answer https://stackoverflow.com/a/74287630/23819306 that might be helpful but I am not sure how to implement it in my React application. It seems that library code is being edited but I am only importing that library in my code. How to implement changes to react-sigma library?
This is code of my main component if it helps:
import React, { useState } from 'react';
import { SigmaContainer } from "@react-sigma/core";
import data from '../../newData.json';
import MyGraph from '../MyGraph/MyGraph';
export default function GraphRepresentation() {
const [hoveredNode, setHoveredNode] = useState(null);
const [pathData, setPathData] = useState(null);
const [filters, setFilters] = useState({
paths: {},
nodes: {},
edges: {},
options: { explicitEdges: false, extraNodes: false, globalMode: true },
explicitEdges: {},
overlappingEdges: {}
});
return (
<SigmaContainer
style={{ height: "100vh", width: "100vw" }}
settings={{
defaultEdgeType: "arrow",
zIndex: true
}}
>
<MyGraph data={data} onGraphReady={(data) => {
setFilters(data.filters);
setPathData(data.pathData);
}} />
<Controls />
<Panels filters={filters} setFilters={setFilters} pathData={pathData} />
<Controllers hoveredNode={hoveredNode} setHoveredNode={setHoveredNode} filters={filters} />
</SigmaContainer>
);
};
To change the arrow size in the React application using the
react-sigmalibrary, you need to directly manipulate the Sigma.js instance to apply custom settings. Here's how you can do it:Extend Sigma.js with Custom Settings: You need to create a custom Sigma.js component that extends the functionality of
Sigma.jsand allows you to apply custom settings.Access Sigma.js Instance: Within this custom component, you can access the Sigma.js instance and apply custom settings such as arrow size.
Here's how you can implement these steps:
In this example:
MyCustomSigma.useRefto get a reference to the Sigma.js instance.useEffectto apply custom settings whenever the data changes.useEffect, we access the Sigma instance usinggetInstances()method.settings()method.Make sure to replace
'yourDataHere'with your actual graph data. This example assumes you're using React hooks for managing state. Adjust the code as per your application structure.