Get data for current zoom view if X and Y axis values contains string values

Referring to the code in this post Get data for current zoomed in view How can we do the same for bar chart in the following codepen . Is there a way to get the data from current zoom view when x or y contains string values?