echarts [Feature] 桑基图是否支持legend?

z4iuyo4d  于 5个月前  发布在  Echarts
关注(0)|答案(2)|浏览(110)

What problem does this feature solve?

目前在桑基图中增加legend的情况下是不起作用的

option = {
  series: {
    type: "sankey",
    layout: "none",
    emphasis: {
      focus: "adjacency",
    },
    legend: {
      data: ["1", "2", "3"],
      backgroundColor: "#ccc",
    },
    data: [
      {
        name: "a",
        category: "1",
      },
      {
        name: "b",
        category: "1",
      },
      {
        name: "a1",
        category: "2",
      },
      {
        name: "a2",
        category: "1",
      },
      {
        name: "b1",
        category: "3",
      },
      {
        name: "c",
        category: "1",
      },
    ],
    links: [
      {
        source: "a",
        target: "a1",
        value: 5,
      },
      {
        source: "a",
        target: "a2",
        value: 3,
      },
      {
        source: "b",
        target: "b1",
        value: 8,
      },
      {
        source: "a",
        target: "b1",
        value: 3,
      },
      {
        source: "b1",
        target: "a1",
        value: 1,
      },
      {
        source: "b1",
        target: "c",
        value: 2,
      },
    ],
    category: [{ name: "1" }, { name: "2" }, { name: "3" }],
  },
};

What does the proposed API look like?

想要让桑基图也可以支持标签过滤,显示关联关系,类似 https://echarts.apache.org/examples/zh/editor.html?c=graph 中的图,可以根据标签筛选显示节点。

kqqjbcuj

kqqjbcuj1#

@luhuiaaaluhui It seems you are not using English, I've helped translate the content automatically. To make your issue understood by more people and get helped, we'd like to suggest using English next time. 🤗
TRANSLATED

BODY

What problem does this feature solve?

Currently, adding legend to the Sankey diagram does not work.
`option = {
series: {
type: "sankey",
layout: "none",
emphasis: {
focus: "adjacency",
},
legend: {
data: ["1", "2", "3"],
backgroundColor: "#ccc",
},

data: [
  {
    name: "a",
    category: "1",
  },
  {
    name: "b",
    category: "1",
  },
  {
    name: "a1",
    category: "2",
  },
  {
    name: "a2",
    category: "1",
  },
  {
    name: "b1",
    category: "3",
  },
  {
    name: "c",
    category: "1",
  },
],
links: [
  {
    source: "a",
    target: "a1",
    value: 5,
  },
  {
    source: "a",
    target: "a2",
    value: 3,
  },
  {
    source: "b",
    target: "b1",
    value: 8,
  },
  {
    source: "a",
    target: "b1",
    value: 3,
  },
  {
    source: "b1",
    target: "a1",
    value: 1,
  },
  {
    source: "b1",
    target: "c",
    value: 2,
  },
],
category: [{ name: "1" }, { name: "2" }, { name: "3" }],

},
};`

What does the proposed API look like?

I want the Sankey diagram to also support tag filtering and display relationships, similar to [https://echarts.apache.org/examples/zh/editor.html?c=graph]( https://echarts.apache.org /examples/zh/editor.html?c=graph), you can filter and display nodes based on labels.

ybzsozfc

ybzsozfc2#

visualMap would have been the solution here, but looks like it does not work with sankey. Like:

visualMap: {
    categories: ['1', '2', '3'],
    dimension: 'category'  // does not work with nodes data
  },

Another solution could be to use toggleSelect on edge category - Demo .

相关问题