Git Product home page Git Product logo

Comments (2)

MinorN avatar MinorN commented on July 18, 2024

已经完成了,但是出现了第二个问题,我想要在上面显示文字,但是显示不出来,怀疑是层级问题

 const nodeWithLine = G6.registerNode(
        "custom-line-circle",
        {
          draw: (cfg, group) => {
            let r = cfg.size / 2;

            const keyShape = group.addShape("circle", {
              attrs: {
                zIndex: 1,
                r: r + 10,
                fill: null,
                stroke: cfg.fill || "red",
              },
              name: "outer-circle",
              draggable: true,
            });
            group.addShape("circle", {
              attrs: {
                zIndex: 1,
                r: r,
                fill: cfg.fill || "red",
                stroke: null,
              },
              name: "inner-circle",
              draggable: true,
            });

            if (cfg.label) {
              const label = group.addShape("text", {
                attr: {
                  zIndex: 2,
                  x: 0,
                  y: 0,
                  textAlign: "center",
                  textBaseline: "middle",
                  text: cfg.label,
                  fill: "#fff",
                },
                name: "text-shape",
                draggable: true,
              });
            }

            return keyShape;
          },
          // afterDraw(cfg, group) {
          //   let r = cfg.size / 2;
          //   if (isNaN(r)) {
          //     r = cfg.size[0] / 2;
          //   }
          //   // 第一个背景圆
          //   const back = group.addShape("circle", {
          //     attrs: {
          //       x: 0,
          //       y: 0,
          //       r: r + 5,
          //       fill: null,
          //       stroke: "red",
          //     },

          //     // must be assigned in G6 3.3 and later versions. it can be any value you want
          //     name: "circle-shape1",
          //   });
          // },
          setState(name, value, item) {
            const shape = item.get("keyShape");
            const r = item.getModel().size / 2;
            if (name === "hover") {
              if (value) {
                shape.animate(
                  {
                    r: r + 5,
                  },
                  {
                    repeat: false,
                    duration: 500,
                    easing: "easeLinear",
                    delay: 0, // 无延迟
                  }
                );
              } else {
                shape.animate(
                  {
                    r: r + 10,
                  },
                  {
                    repeat: false,
                    duration: 500,
                    easing: "easeLinear",
                    delay: 0, // 无延迟
                  }
                );
              }
            }
          },
        },
        "circle"
      );

from g6.

MinorN avatar MinorN commented on July 18, 2024

已经解决了

from g6.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.