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.
shoaib30
  • 877
  • 11
  • 24
  • Does this answer your question? [Highchart Rectangle Border Radius](https://stackoverflow.com/questions/24736167/highchart-rectangle-border-radius) – adampweb Feb 24 '22 at 11:48
  • @AdamP. The question is regarding rectangles created within the chart. The properties don't apply to the entire chart itself. – shoaib30 Feb 24 '22 at 19:27

1 Answers1

5

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.

Barbara Laird
  • 12,599
  • 2
  • 44
  • 57
  • 1
    This works, I applied it to `.highcharts-treemap-series` to keep it specific to treemaps only. Thank you! – shoaib30 Feb 25 '22 at 04:48