最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

reactjs - AmCharts 5 Column Chart Apply Pattern Conditionally - Stack Overflow

programmeradmin3浏览0评论

I have a column chart in AmCharts 5 and i want to make some of the columns have a striped pattern based on some condition. I tried using template adapters but it doesn't seem to work.

series.columns.template.adapters.add("fillPattern", (pattern, target) => {
  const dataItem: any = target.dataItem;
  if (dataItem) {
    if (SOME_CONDITION) {
      return am5.LinePattern.new(root, {
        color: am5.color(COLORS.WHITE),
        rotation: 45,
        width: 200,
        height: 200,
      });
    }
  }
  // Return undefined for columns that shouldn't have a pattern
  return undefined;
});

In the documentation series.columns.template.set("fillPattern", somePattern) is used but this one add pattern to the whole series. I also don't want to have multiple series to set pattern for some of them. How can I achieve my goal?

发布评论

评论列表(0)

  1. 暂无评论