Aggregate value as text on bar chart

I’m using the transform property on a barchart to get sum/avg/count/… of a group. I’d like to display the calculated value on top of the barchart, but I can’t figure out how to access the value.

Code:

      _d.forEach(trace => {
          graph_data.push({
            y: trace.values,
            x: trace.dates.map(date => this.transformDate(date)),
            customdata: trace.info,
            type: 'bar',
            text: "i want to be the aggregate value",
            name: trace.info[0].naam,
            transforms: [{
              type: 'aggregate',
              groups: trace.dates.map(date => this.transformDate(date)),
              aggregations: [
                {target: 'y', func: aggregation, enabled: true}
              ]
            }]
          });
        });

Here’s one hacky way to access to aggregated data: https://codepen.io/etpinard/pen/YvqqgB?editors=0010

Use at your own risk though. We should think about providing a more “official” to access post-transform values. Thanks for writing in.

Thanks for the answer!

I think i’m just going to calculate the values myself then (as I’m already doing it that way to get some % based charts)