How To: Add Data Series Values in Pie Chart Legend

I needed to includea pie chart inside of a table and I also wanted to include the data pointvalues in the chart legend instead of as labels coming off the chart itself.See the screenshot below for the end result. This is a quick write up on how Iaccomplished it. Putting the chart in the table is straightforward using a webblock but wanted to document how to include the data point values in the legendin case somebody else comes across this need. 

 

 

Create a web block with a Pie Chart and input parameters for your data point values.

 

 

 

Set the data pointvalues inside of your table on the parent screen. In this case my aggregate forthe table includes a count for who is going, not going, and maybe so I'mpassing those aggregate values into the web block.

 

 

In web block createa DataPointList and DataPoint local variables. In the Preparation assign thevalues for each DataPoint and append it to the list. 

 

 

Create a ChartFormatlocal variable and set the ShowDataPointValues = True in an Assign widget. Alsocreate an AdvancedFormat local variable and set the HighchartsJSON value to theJSON string below. The key is in setting showInLegend to true in the dataLablessection and then formatting the legend to include the datapoint value whichcomes from the this.y value in the format string.

 

"plotOptions:
{
    pie: {
        dataLabels:
        {
            showInLegend: true
        }
    }
},
legend: {        
            labelFormatter: function(){
                return this.name + ' (' +this.y + ')';
            }
        }"

 

 


Thanks for sharing Roy!