Skip to content

fix issue 241 #297

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Aug 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion plotly/plotlyfig.m
Original file line number Diff line number Diff line change
Expand Up @@ -945,7 +945,7 @@ function delete(obj)
if ~( ...
strcmpi(fieldname,'surface') || strcmpi(fieldname,'scatter3d') ...
|| strcmpi(fieldname,'mesh3d') || strcmpi(fieldname,'bar') ...
|| strcmpi(fieldname,'scatterpolar') ...
|| strcmpi(fieldname,'scatterpolar') || strcmpi(fieldname,'barpolar') ...
)
fprintf(['\nWhoops! ' exception.message(1:end-1) ' in ' fieldname '\n\n']);
end
Expand Down
281 changes: 135 additions & 146 deletions plotly/plotlyfig_aux/core/updateData.m
Original file line number Diff line number Diff line change
@@ -1,146 +1,135 @@
%----UPDATE PLOT DATA/STYLE----%

function obj = updateData(obj, dataIndex)

%-update plot based on plot call class-%
try

switch lower(obj.State.Plot(dataIndex).Class)

%--CORE PLOT OBJECTS--%
case 'image'
updateImage(obj, dataIndex);
case 'line'
updateLineseries(obj, dataIndex);
case 'histogram'
updateHistogram(obj, dataIndex);
case 'histogram2'
updateHistogram2(obj, dataIndex);
case 'patch'
% check for histogram
if isHistogram(obj,dataIndex)
updateHistogram(obj,dataIndex);
else
updatePatch(obj, dataIndex);
end
case 'rectangle'
updateRectangle(obj,dataIndex);
case 'surface'
updateSurfaceplot(obj,dataIndex);

%-GROUP PLOT OBJECTS-%
case 'area'
updateArea(obj, dataIndex);
case 'areaseries'
updateAreaseries(obj, dataIndex);
case 'bar'
updateBar(obj, dataIndex);
case 'barseries'
updateBarseries(obj, dataIndex);
case 'baseline'
updateBaseline(obj, dataIndex);
case {'contourgroup','contour'}
updateContourgroup(obj,dataIndex);
case 'errorbar'
updateErrorbar(obj,dataIndex);
case 'errorbarseries'
updateErrorbarseries(obj,dataIndex);
case 'lineseries'
updateLineseries(obj, dataIndex);
case 'quiver'
updateQuiver(obj, dataIndex);
case 'quivergroup'
updateQuivergroup(obj, dataIndex);
case 'scatter'
updateScatter(obj, dataIndex);
case 'scattergroup'
updateScattergroup(obj, dataIndex);
case 'stair'
updateStair(obj, dataIndex);
case 'stairseries'
updateStairseries(obj, dataIndex);
case 'stem'
updateStem(obj, dataIndex);
case 'stemseries'
updateStemseries(obj, dataIndex);
case 'surfaceplot'
updateSurfaceplot(obj,dataIndex);

%--Plotly supported MATLAB group plot objects--%
case {'hggroup','group'}
% check for boxplot
if isBoxplot(obj, dataIndex)
updateBoxplot(obj, dataIndex);
end
end

catch exception
if obj.UserData.Verbose
fprintf([exception.message '\nWe had trouble parsing the ' obj.State.Plot(dataIndex).Class ' object.\n',...
'This trace might not render properly.\n\n']);
end
end

%------------------------AXIS/DATA CLEAN UP-------------------------------%

%-AXIS INDEX-%
axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis);

%-CHECK FOR MULTIPLE AXES-%
[xsource, ysource] = findSourceAxis(obj,axIndex);

%-AXIS DATA-%
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);

%-------------------------------------------------------------------------%

% check for xaxis dates
if strcmpi(xaxis.type, 'date')
obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x);
end

% check for xaxis categories
if strcmpi(xaxis.type, 'category') && ...
~strcmp(obj.data{dataIndex}.type,'box')
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
end

% check for xaxis duration
if strcmpi(xaxis.type, 'duration')
obj.data{dataIndex}.x = convertDuration(obj.data{dataIndex}.x);
xaxis.type = 'category';
end

% check for xaxis duration with input format
if strcmpi(xaxis.type, 'duration - specified format')
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
xaxis.type = 'category';
end
%-------------------------------------------------------------------------%
% check for yaxis dates
if strcmpi(yaxis.type, 'date')
obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y);
end

% check for yaxis categories
if strcmpi(yaxis.type, 'category') && ...
~strcmp(obj.data{dataIndex}.type,'box')
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
end

% check for yaxis duration
if strcmpi(yaxis.type, 'duration')
obj.data{dataIndex}.y = convertDuration(obj.data{dataIndex}.y);
yaxis.type = 'category';
end

% check for yaxis duration with input format
if strcmpi(yaxis.type, 'duration - specified format')
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
yaxis.type = 'category';
end

%-------------------------------------------------------------------------%

end
%----UPDATE PLOT DATA/STYLE----%

function obj = updateData(obj, dataIndex)

%-update plot based on plot call class-%
try
switch lower(obj.State.Plot(dataIndex).Class)

%--CORE PLOT OBJECTS--%
case 'image'
updateImage(obj, dataIndex);
case 'line'
updateLineseries(obj, dataIndex);
case 'histogram'
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
updateHistogramPolar(obj, dataIndex);
else
updateHistogram(obj, dataIndex);
end
case 'histogram2'
updateHistogram2(obj, dataIndex);
case 'patch'
% check for histogram
if isHistogram(obj,dataIndex)
updateHistogram(obj,dataIndex);
else
updatePatch(obj, dataIndex);
end
case 'rectangle'
updateRectangle(obj,dataIndex);
case 'surface'
updateSurfaceplot(obj,dataIndex);

%-GROUP PLOT OBJECTS-%
case 'area'
updateArea(obj, dataIndex);
case 'areaseries'
updateAreaseries(obj, dataIndex);
case 'bar'
updateBar(obj, dataIndex);
case 'barseries'
updateBarseries(obj, dataIndex);
case 'baseline'
updateBaseline(obj, dataIndex);
case {'contourgroup','contour'}
updateContourgroup(obj,dataIndex);
case 'errorbar'
updateErrorbar(obj,dataIndex);
case 'errorbarseries'
updateErrorbarseries(obj,dataIndex);
case 'lineseries'
updateLineseries(obj, dataIndex);
case 'quiver'
updateQuiver(obj, dataIndex);
case 'quivergroup'
updateQuivergroup(obj, dataIndex);
case 'scatter'
if strcmpi(obj.State.Axis(dataIndex).Handle.Type, 'polaraxes')
updateScatterPolar(obj, dataIndex);
else
updateScatter(obj, dataIndex);
end
case 'scattergroup'
updateScattergroup(obj, dataIndex);
case 'stair'
updateStair(obj, dataIndex);
case 'stairseries'
updateStairseries(obj, dataIndex);
case 'stem'
updateStem(obj, dataIndex);
case 'stemseries'
updateStemseries(obj, dataIndex);
case 'surfaceplot'
updateSurfaceplot(obj,dataIndex);
case 'implicitfunctionline'
updateLineseries(obj, dataIndex);

%--Plotly supported MATLAB group plot objects--%
case {'hggroup','group'}
% check for boxplot
if isBoxplot(obj, dataIndex)
updateBoxplot(obj, dataIndex);
end
end

catch exception
if obj.UserData.Verbose
fprintf([exception.message '\nWe had trouble parsing the ' obj.State.Plot(dataIndex).Class ' object.\n',...
'This trace might not render properly.\n\n']);
end
end

%------------------------AXIS/DATA CLEAN UP-------------------------------%

try
%-AXIS INDEX-%
axIndex = obj.getAxisIndex(obj.State.Plot(dataIndex).AssociatedAxis);

%-CHECK FOR MULTIPLE AXES-%
[xsource, ysource] = findSourceAxis(obj,axIndex);

%-AXIS DATA-%
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);

%---------------------------------------------------------------------%

% check for xaxis dates
if strcmpi(xaxis.type, 'date')
obj.data{dataIndex}.x = convertDate(obj.data{dataIndex}.x);
end

% check for xaxis categories
if strcmpi(xaxis.type, 'category') && ...
~strcmp(obj.data{dataIndex}.type,'box')
obj.data{dataIndex}.x = get(obj.State.Plot(dataIndex).AssociatedAxis,'XTickLabel');
end

% check for yaxis dates
if strcmpi(yaxis.type, 'date')
obj.data{dataIndex}.y = convertDate(obj.data{dataIndex}.y);
end

% check for yaxis categories
if strcmpi(yaxis.type, 'category') && ...
~strcmp(obj.data{dataIndex}.type,'box')
obj.data{dataIndex}.y = get(obj.State.Plot(dataIndex).AssociatedAxis,'YTickLabel');
end
catch
% TODO to the future
end

%-------------------------------------------------------------------------%

end
Loading