function [x,y,z,n] = getTargetXYData(hThis,orient)
% GETTARGETXYDATA Create vectors of Target XData and YData
%
% Thanks to <a href="http://www.mathworks.com/matlabcentral/profile/authors/3354683-yaroslav">Yaroslav Don</a> for his assistance in updating cursorbar for
% MATLAB Graphics and for his contribution of new functionality.
% Copyright 2003-2016 The MathWorks, Inc.
% set inputs
if nargin<2 || isempty(orient)
orient = hThis.Orientation;
end
hTarget = hThis.Target;
x = [];
y = [];
z = [];
n = [];
% set data
if isTargetAxes(hThis)
return
else
if isa(hTarget,'matlab.graphics.chart.primitive.Histogram')
xDataName = 'BinEdges';
yDataName = 'Values';
else
xDataName = 'XData';
yDataName = 'YData';
end
%
if numel(hTarget) == 1
xData = {get(hTarget,xDataName)};
yData = {get(hTarget,yDataName)};
else % should all be lines
xData = get(hTarget, xDataName);
yData = get(hTarget, yDataName);
end
%
if isa(hTarget,'matlab.graphics.chart.primitive.Histogram')
xData = cellfun(@(x)x(2:end)-diff(x)/2, xData, 'UniformOutput', 0); % transform to BinCenters
end
end
% check if CData exists
try
try
zData = {hTarget.ZData};
catch
zData = {hTarget.CData};
end
isZData = sum(cellfun('prodofsize',zData))>0;
%
if isZData && ~isequal( cellfun(@numel,xData), cellfun(@numel,zData) )