Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 5376988

Browse files
Refactor updateArea
1 parent 5e9252e commit 5376988

File tree

2 files changed

+22
-30
lines changed

2 files changed

+22
-30
lines changed

plotly/plotlyfig_aux/core/updateData.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103
updateImplicitFunctionSurface(obj,dataIndex);
104104
%-GROUP PLOT OBJECTS-%
105105
case "area"
106-
updateArea(obj, dataIndex);
106+
obj.data{dataIndex} = updateArea(obj, dataIndex);
107107
case "areaseries"
108108
updateAreaseries(obj, dataIndex);
109109
case "animatedline"

plotly/plotlyfig_aux/handlegraphics/updateArea.m

Lines changed: 21 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function updateArea(obj,areaIndex)
1+
function data = updateArea(obj,areaIndex)
22
% x: ...[DONE]
33
% y: ...[DONE]
44
% r: ...[NOT SUPPORTED IN MATLAB]
@@ -75,50 +75,42 @@ function updateArea(obj,areaIndex)
7575
[xsource, ysource] = findSourceAxis(obj,axIndex);
7676
end
7777

78-
obj.data{areaIndex}.xaxis = "x" + xsource;
79-
obj.data{areaIndex}.yaxis = "y" + ysource;
80-
obj.data{areaIndex}.type = "scatter";
81-
obj.data{areaIndex}.x = area_data.XData;
78+
data.xaxis = "x" + xsource;
79+
data.yaxis = "y" + ysource;
80+
data.type = "scatter";
81+
data.x = area_data.XData;
8282

83-
%-area y-%
8483
prevAreaIndex = find(cellfun(@(x) isfield(x,"fill") ...
85-
&& isequal({x.xaxis x.yaxis},{obj.data{areaIndex}.xaxis ...
86-
obj.data{areaIndex}.yaxis}),obj.data(1:areaIndex-1)),1,"last");
84+
&& isequal({x.xaxis x.yaxis},{data.xaxis ...
85+
data.yaxis}),obj.data(1:areaIndex-1)),1,"last");
8786
if ~isempty(prevAreaIndex)
88-
obj.data{areaIndex}.y = obj.data{prevAreaIndex}.y + area_data.YData;
87+
data.y = obj.data{prevAreaIndex}.y + area_data.YData;
8988
else
90-
obj.data{areaIndex}.y = area_data.YData;
89+
data.y = area_data.YData;
9190
end
9291

93-
obj.data{areaIndex}.name = area_data.DisplayName;
94-
obj.data{areaIndex}.visible = strcmp(area_data.Visible, "on");
92+
data.name = area_data.DisplayName;
93+
data.visible = area_data.Visible == "on";
9594

96-
%-area fill-%
9795
if ~isempty(prevAreaIndex)
98-
obj.data{areaIndex}.fill = "tonexty";
96+
data.fill = "tonexty";
9997
else % first area plot
100-
obj.data{areaIndex}.fill = "tozeroy";
98+
data.fill = "tozeroy";
10199
end
102100

103-
%-AREA MODE-%
104-
if isprop(area_data, "LineStyle") ...
105-
&& isequal(area_data.LineStyle, "none")
106-
obj.data{areaIndex}.mode = "none";
101+
if isprop(area_data, "LineStyle") && area_data.LineStyle == "none"
102+
data.mode = "none";
107103
else
108-
obj.data{areaIndex}.mode = "lines";
104+
data.mode = "lines";
109105
end
110106

111-
obj.data{areaIndex}.line = extractAreaLine(area_data);
112-
fill = extractAreaFace(area_data);
113-
obj.data{areaIndex}.fillcolor = fill.color;
107+
data.line = extractAreaLine(area_data);
108+
data.fillcolor = extractAreaFace(area_data).color;
114109

115-
leg = area_data.Annotation;
116-
legInfo = leg.LegendInformation;
117-
switch legInfo.IconDisplayStyle
110+
switch area_data.Annotation.LegendInformation.IconDisplayStyle
118111
case "on"
119-
showleg = true;
112+
data.showlegend = true;
120113
case "off"
121-
showleg = false;
114+
data.showlegend = false;
122115
end
123-
obj.data{areaIndex}.showlegend = showleg;
124116
end

0 commit comments

Comments
 (0)