@jmitchell.br, @mario60: Had a similar problem, solved in a similar way. On a second pass, added code for dealing with hiding one or more yField(s) in GUI by clicking on the respective Legend items.
In that case, the series.items array will only contain the visible items, so using the computed yField's index in the array with all yFields will always result in one of the first yFields, which is not always correct (e.g. if series.yField = ['one', 'two', 'three'] and the user clicks the first item in Legend and thus hides 'one', your code will always return the yField 'one' or ' two', instead of 'two' or 'three').
To address this I built a second array with only the visible yFields, and used the computed index in that array instead of the original series.yField array. (To determine which yField(s) are visible, I used the series' visibleInLegend method).
In 4.1 Beta 3 I see that there is an item.yField property (always String, indicating the current yField, not the array of yFields) which makes all these computations unnecessary. It also seems to work well when hiding yFields via click in the Legend. (In fact I think that the 4.0.x code will no longer work in 4.1 because 'storeItem' appears to no longer have a 'store' property but instead a 'stores' array property).