其设置文档中提到的Sigma样式文件是什么?

发布于 2025-01-21 11:20:10 字数 729 浏览 1 评论 0 原文

这是我第一次在React中制作图形,因此我遵循指南和文档。我没有图形学,sigma.js或 reactigma (我知道如何知道如何知道使用正常反应)。

设置文档说:

在您的应用程序中导入React Sigma样式文件。示例:导入“@react-sigma/core/lib/react-sigma.min.css”

什么是样式文件? CSS?我该怎么做?我找不到任何文档。 Is it something basic from a previous library?

Step I cant figure out

Honestly我发现很难学习Sigma.js并将其插入我的React网站。我找不到任何指南。有吗?我只想从一个简单的图表开始,然后从那里学习。

This is my first time making graphs in React so I'm following the guide and documentation. I have no prior experience with graphology, sigma.js or react-sigma (I know how to use normal React).

The setup documentation says:

Import the React Sigma style file in your application. Example : import "@react-sigma/core/lib/react-sigma.min.css"

What are style files? CSS? How can I make one? I can't find any documentation. Is it something basic from a previous library?

Step I cant figure out

Honestly I'm finding it very hard to learn sigma.js and insert it in my react website. I can't find any guides. Are there any? I just want to start with a simple graph and learn from there.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

夏末染殇 2025-01-28 11:20:10

The documentation refers specifically to their own CSS file which must be imported in a React app like they are showing in the example:

import "@react-sigma/core/lib/react-sigma.min.css";

Disclaimer: depending on your React app setup, the way to import a CSS file might differ.


The example in the documentation was broken when I wrote this answer.我打开关于react-sigma repo 的问题,从那时起就解决了。

当我尝试使用时,缺少一些依赖性,需要进行一些更改。

npm install @react-sigma/core sigma graphology graphology-types lodash 
import { useEffect } from "react";
import Graph from "graphology";
import { SigmaContainer, useLoadGraph } from "@react-sigma/core";

// Import the style file here
import "@react-sigma/core/lib/react-sigma.min.css";

export const LoadGraph = () => {
  // first change to their example
  const loadGraph = useLoadGraph();

  // also wrapped their graph instantiation side-effect with useEffect
  useEffect(() => {
    const graph = new Graph();

    graph.addNode("first", {
      // Required position
      x: 1,
      y: 1,

      size: 15,
      label: "My first node",
      color: "#FA4F40"
    });

    // Calling the function that was missing from the example
    loadGraph(graph);
  }, [loadGraph]);

  // Returning null to get a valid component
  return null;
};

export const DisplayGraph = () => {
  return (
    <SigmaContainer style={{ height: "500px", width: "500px" }}>
      <LoadGraph />
    </SigmaContainer>
  );
};

Note that I used TypeScript for the example, which gives insightful error messages since react-sigma< /em>提供自己的类型。

然后很明显, useloadgraph 挂钩未正确使用,因为它不接受任何参数,并且返回一个函数接受 graph 参数。可以用 api文档)。

我还认为 lodash 开发人员控制台中的错误缺少。


请参阅文档迄今为止。

The documentation refers specifically to their own CSS file which must be imported in a React app like they are showing in the example:

import "@react-sigma/core/lib/react-sigma.min.css";

Disclaimer: depending on your React app setup, the way to import a CSS file might differ.


The example in the documentation was broken when I wrote this answer. I opened an issue on the react-sigma repo and it was fixed since then.

When I tried it, some dependencies were missing and some changes were needed.

npm install @react-sigma/core sigma graphology graphology-types lodash 
import { useEffect } from "react";
import Graph from "graphology";
import { SigmaContainer, useLoadGraph } from "@react-sigma/core";

// Import the style file here
import "@react-sigma/core/lib/react-sigma.min.css";

export const LoadGraph = () => {
  // first change to their example
  const loadGraph = useLoadGraph();

  // also wrapped their graph instantiation side-effect with useEffect
  useEffect(() => {
    const graph = new Graph();

    graph.addNode("first", {
      // Required position
      x: 1,
      y: 1,

      size: 15,
      label: "My first node",
      color: "#FA4F40"
    });

    // Calling the function that was missing from the example
    loadGraph(graph);
  }, [loadGraph]);

  // Returning null to get a valid component
  return null;
};

export const DisplayGraph = () => {
  return (
    <SigmaContainer style={{ height: "500px", width: "500px" }}>
      <LoadGraph />
    </SigmaContainer>
  );
};

Edit react-sigma-example

Note that I used TypeScript for the example, which gives insightful error messages since react-sigma provides its own types.

Then it was clear that the useLoadGraph hook wasn't used properly since it doesn't accept any parameter and it returns a function accepting a graph parameter. This can be confirmed with the API documentation.

I also figured that lodash was missing from errors in the developer console.


Please refer to the documentation as it's now up-to-date.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文