MaroPolo
MaroPolo

Reputation: 31

Highcharts JS - share legend color between pie charts

I've two pie charts and i want to share their color of the legend items. The problem is that one pie has more elements in the legend as the other and their starts with different color.

I my case i can have very different legend items in two pie charts, but there are some equal and they should get the same color.

series: [{
            name: "Brands",
            colorByPoint: true,
            data: [{
                name: "Microsoft Internet Explorer",
                y: 56.33
            }, {
                name: "Chrome",
                y: 24.03,
                sliced: true,
                selected: true
            }, {
                name: "Firefox",
                y: 10.38
            }, {
                name: "Safari",
                y: 4.77
            }, {
                name: "Opera",
                y: 0.91
            }, {
                name: "Proprietary or Undetectable",
                y: 0.2
            }]
        }]

series: [{
            name: "Brands",
            colorByPoint: true,
            data: [{
                name: "Chrome",
                y: 24.03,
                sliced: true,
                selected: true
            }, {
                name: "Firefox",
                y: 20.38
            }, {
                name: "Safari",
                y: 4.77
            }, {
                name: "Opera",
                y: 0.91
            }, {
                name: "Proprietary or Undetectable",
                y: 0.2
            }]
        }]

jsfiddle example here

Upvotes: 1

Views: 333

Answers (1)

Kacper Madej
Kacper Madej

Reputation: 7886

Color can be set per data point - slice. You could set them to be the same in both series for corresponding data points.

Example: http://jsfiddle.net/m2v2vyj2/1/

            }, {
                name: "Chrome",
                y: 24.03,
                color: '#c80'
            }, {

Upvotes: 1

Related Questions