Highchart 树形图 - 圆角边缘

发布于 2025-01-09 18:45:59 字数 2068 浏览 0 评论 0原文

我需要创建一个带有圆角的树状图,如图所示

带圆角的树图

我尝试过:

任何有关如何实现这一目标的指示都值得赞赏。这是树形图的 jsfiddle 供参考。

以下是我尝试过的选项

const options = {
        chart: {
            borderRadius: 20,
        },
        credits: {
          enabled: false,
        },
        tooltip: {
          enabled: false,
        },

        plotOptions: {
          treemap: {
            // borderRadiusBottomRight: 25,
            // borderRadiusBottomLeft: 25,
            borderWidth: 2,
            borderRadius: 5,
            borderColor: "#FFFFFF",
          
            },
          },
        series: [
          {
            type: "treemap",
            data: [{
                    id: 'A',
                    name: 'Apples',
                    color: "#EC2500",
                    value: 10,
                }, {
                    id: 'B',
                    name: 'Bananas',
                    color: "#ECE100",
                    value: 15,
                }, {
                    id: 'C',
                    name: 'Oranges',
                    color: '#EC9800',
                    value: 20,
                }],
          },
        ],
        title: {
          text: "",
        },
      },
    };

注意:

  1. 图表中不需要图例或标题,如果可能的话,绘图可以扩展到边缘
  2. 所有其他图表都是用 highcharts 制作的,更喜欢使用相同的树图而不是使用不同的库为了它。
  3. 无需向下钻取。

I need to create a treemap with round corners as shown in the image

Treemap with round corners

I have tried:

  • Changing plotOptions.treemap.borderRadius set the radius for each box instead of the entire plot.

  • Using chart.borderRadius has no impact on the graph, I believe it is so because the plot itself is not going till the edge of the chart.

  • The rounded-corners library by highcharts does not work with treemaps. It is working well with bar charts

Any direction on how to achieve this is appreciated. Here's a jsfiddle of treemap for reference.

Here are options I have tried

const options = {
        chart: {
            borderRadius: 20,
        },
        credits: {
          enabled: false,
        },
        tooltip: {
          enabled: false,
        },

        plotOptions: {
          treemap: {
            // borderRadiusBottomRight: 25,
            // borderRadiusBottomLeft: 25,
            borderWidth: 2,
            borderRadius: 5,
            borderColor: "#FFFFFF",
          
            },
          },
        series: [
          {
            type: "treemap",
            data: [{
                    id: 'A',
                    name: 'Apples',
                    color: "#EC2500",
                    value: 10,
                }, {
                    id: 'B',
                    name: 'Bananas',
                    color: "#ECE100",
                    value: 15,
                }, {
                    id: 'C',
                    name: 'Oranges',
                    color: '#EC9800',
                    value: 20,
                }],
          },
        ],
        title: {
          text: "",
        },
      },
    };

Note:

  1. Legend or title is not required in the chart, the plot can be extended to the edges if possible
  2. All other charts are made with highcharts, would prefer doing the treemap with the same instead of using a different library for it.
  3. No drill-down is required.

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

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

发布评论

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

评论(1

欢你一世 2025-01-16 18:45:59

您可以将 clip-path 添加到 highcharts-series 类。

.highcharts-series {
  clip-path: inset(0% 0% 0% 0% round 15px);
}

https://jsfiddle.net/mqo78ah2/

您必须使 css 更加具体,以便您不要更改您的其他图表。

You can add a clip-path to the highcharts-series class.

.highcharts-series {
  clip-path: inset(0% 0% 0% 0% round 15px);
}

https://jsfiddle.net/mqo78ah2/

You'll have to make the css more specific, so that you don't change your other charts.

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