I was looking at the great duarte.leao's JSFiddle demo here: http://jsfiddle.net/duarteleao/e2Qfd/ and I want to apply it to a horizontal stacked bar chart but I am unable to get it to work

I first started by applying it to a vertical chart as per the demo but even then I am getting an error processing component error.

This is the code I have in Pre Execution in CDE:

function f() {var eps = Dashboards.propertiesArrayToObject(cccOptions.extensionPoints);  

eps.plot_add = function() {
                return new pv.Label()
                    .data(function() {
                        // A Bar chart's visibleData is grouped 
                        // by Category > Series.
                        var cccContext = this.getContext();
                        // Return the category Data children.
                        return cccContext.panel.visibleData().childNodes;
                    .font('bold 12px sans-serif')
                    .left(function(catData) {
                        // Scales use the keys, not the values.
                        return this.getContext()
                    .text(function(catData) {
                        // Getting the sum of each category is easy.

                        // The name of the dimension to which the 
                        // "value" visual role is bound.
                        var valueDimName = this.getContext()

                        // catData's local dimension object
                        var valueDim = catData.dimensions(valueDimName);

                        // Sum the value dimension over all 
                        // Datums in catData.
                        var catSum = valueDim.sum();

                        // Now format it with the value 
                        // dimension's formatter.
                        return valueDim.format(catSum);
cccOptions.extensionPoints = Dashboards.objectToPropertiesArray(eps);

What changes would I need to make it work with a vertical stacked bar chart and if I simply change the orientation option in CDE would it still work?

BTW I am using Pentaho v5.4

Any help is appreciated