G2Plot icon indicating copy to clipboard operation
G2Plot copied to clipboard

🤔 [QUESTION]Sankey图如何设置node的文字填充颜色?

Open sakuraine opened this issue 1 year ago • 0 comments

🐛 Question description [Please make everyone to understand it]

💻 Link to minimal reproduction

Please provide a link by forking these links g2plot or GitHub repo. What is a minimal reproduction, and why is it required?

import { Sankey } from "@antv/g2plot";

const DATA = [
  { source: "首次打开", target: "首页 UV", value: 160 },
  { source: "结果页", target: "首页 UV", value: 40 },
  { source: "验证页", target: "首页 UV", value: 10 },
  { source: "我的", target: "首页 UV", value: 10 },
  { source: "朋友", target: "首页 UV", value: 8 },
  { source: "其他来源", target: "首页 UV", value: 27 },
  { source: "首页 UV", target: "理财", value: 30 },
  { source: "首页 UV", target: "扫一扫", value: 40 },
  { source: "首页 UV", target: "服务", value: 35 },
  { source: "首页 UV", target: "蚂蚁森林", value: 25 },
  { source: "首页 UV", target: "跳失", value: 10 },
  { source: "首页 UV", target: "借呗", value: 30 },
  { source: "首页 UV", target: "花呗", value: 40 },
  { source: "首页 UV", target: "其他流向", value: 45 },
];

const sankey = new Sankey("container", {
  data: DATA,
  sourceField: "source",
  targetField: "target",
  weightField: "value",
  nodeWidthRatio: 0.008,
  nodePaddingRatio: 0.03,
  label: {
    style: {
      fill: "red",
    },
  },
});

sankey.render();

按照文档设置label并不会改变节点标题的文字

🏞 Expected result

image

🚑 Any additional [like screenshots]

  • G2Plot Version: 2.4.32
  • Platform: MacOS Chrome Web

sakuraine avatar Jan 15 '25 10:01 sakuraine