Skip to content

Commit ac0aaa1

Browse files
Merge pull request #410 from plotly/fix_issue_related_to_bar_functionality
fix issue related to bar functionality
2 parents 620f32d + 1c95daf commit ac0aaa1

File tree

2 files changed

+230
-259
lines changed

2 files changed

+230
-259
lines changed
+123-157
Original file line numberDiff line numberDiff line change
@@ -1,163 +1,129 @@
11
function obj = updateBar(obj,barIndex)
22

3-
% x: ...[DONE]
4-
% y: ...[DONE]
5-
% name: ...[DONE]
6-
% orientation: ...[DONE]
7-
% text: ...[NOT SUPPORTED IN MATLAB]
8-
% error_y: ...[HANDLED BY ERRORBAR]
9-
% error_x: ...[HANDLED BY ERRORBAR]
10-
% opacity: ...[DONE]
11-
% xaxis: ...[DONE]
12-
% yaxis: ...[DONE]
13-
% showlegend: ...[DONE]
14-
% stream: ...[HANDLED BY PLOTLY STREAM]
15-
% visible: ...[DONE]
16-
% type: ...[DONE]
17-
% r: ...[NA]
18-
% t: ...[NA]
19-
% textfont: ...[NA]
20-
21-
% MARKER:
22-
% color: ...DONE]
23-
% size: ...[NA]
24-
% symbol: ...[NA]
25-
% opacity: ...[NA]
26-
% sizeref: ...[NA]
27-
% sizemode: ...[NA]
28-
% colorscale: ...[NA]
29-
% cauto: ...[NA]
30-
% cmin: ...[NA]
31-
% cmax: ...[NA]
32-
% outliercolor: ...[NA]
33-
% maxdisplayed: ...[NA]
34-
35-
% MARKER LINE:
36-
% color: ...[DONE]
37-
% width: ...[DONE]
38-
% dash: ...[NA]
39-
% opacity: ---[TODO]
40-
% shape: ...[NA]
41-
% smoothing: ...[NA]
42-
% outliercolor: ...[NA]
43-
% outlierwidth: ...[NA]
44-
45-
%-------------------------------------------------------------------------%
46-
47-
%-AXIS INDEX-%
48-
axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis);
49-
50-
%-BAR DATA STRUCTURE- %
51-
bar_data = obj.State.Plot(barIndex).Handle;
52-
53-
%-CHECK FOR MULTIPLE AXES-%
54-
[xsource, ysource] = findSourceAxis(obj, axIndex);
55-
56-
%-AXIS DATA-%
57-
eval(['xaxis = obj.layout.xaxis' num2str(xsource) ';']);
58-
eval(['yaxis = obj.layout.yaxis' num2str(ysource) ';']);
59-
60-
%-------------------------------------------------------------------------%
61-
62-
%-bar xaxis-%
63-
obj.data{barIndex}.xaxis = ['x' num2str(xsource)];
64-
65-
%-------------------------------------------------------------------------%
66-
67-
%-bar yaxis-%
68-
obj.data{barIndex}.yaxis = ['y' num2str(ysource)];
69-
70-
%-------------------------------------------------------------------------%
71-
72-
%-bar visible-%
73-
obj.data{barIndex}.visible = strcmp(bar_data.Visible,'on');
74-
75-
%-------------------------------------------------------------------------%
76-
77-
%-bar type-%
78-
obj.data{barIndex}.type = 'bar';
79-
80-
%-------------------------------------------------------------------------%
81-
82-
%-bar name-%
83-
obj.data{barIndex}.name = bar_data.DisplayName;
84-
85-
%-------------------------------------------------------------------------%
86-
87-
%-layout barmode-%
88-
switch bar_data.BarLayout
89-
case 'grouped'
90-
obj.layout.barmode = 'group';
91-
case 'stacked'
92-
obj.layout.barmode = 'relative';
93-
end
94-
95-
%-------------------------------------------------------------------------%
96-
97-
%-layout bargroupgap-%
98-
obj.layout.bargroupgap = 1-bar_data.BarWidth;
99-
100-
%---------------------------------------------------------------------%
101-
102-
%-layout bargap-%
103-
obj.layout.bargap = obj.PlotlyDefaults.Bargap;
104-
105-
%-------------------------------------------------------------------------%
106-
107-
%-bar orientation-%
108-
switch bar_data.Horizontal
109-
110-
case 'off'
111-
112-
%-bar orientation-%
113-
obj.data{barIndex}.orientation = 'v';
114-
115-
%-bar x data-%
116-
obj.data{barIndex}.x = bar_data.XData;
117-
118-
%-bar y data-%
119-
obj.data{barIndex}.y = bar_data.YData;
120-
121-
122-
case 'on'
123-
124-
%-bar orientation-%
125-
obj.data{barIndex}.orientation = 'h';
3+
% x: ...[DONE]
4+
% y: ...[DONE]
5+
% name: ...[DONE]
6+
% orientation: ...[DONE]
7+
% text: ...[NOT SUPPORTED IN MATLAB]
8+
% error_y: ...[HANDLED BY ERRORBAR]
9+
% error_x: ...[HANDLED BY ERRORBAR]
10+
% opacity: ...[DONE]
11+
% xaxis: ...[DONE]
12+
% yaxis: ...[DONE]
13+
% showlegend: ...[DONE]
14+
% stream: ...[HANDLED BY PLOTLY STREAM]
15+
% visible: ...[DONE]
16+
% type: ...[DONE]
17+
% r: ...[NA]
18+
% t: ...[NA]
19+
% textfont: ...[NA]
20+
21+
% MARKER:
22+
% color: ...DONE]
23+
% size: ...[NA]
24+
% symbol: ...[NA]
25+
% opacity: ...[NA]
26+
% sizeref: ...[NA]
27+
% sizemode: ...[NA]
28+
% colorscale: ...[NA]
29+
% cauto: ...[NA]
30+
% cmin: ...[NA]
31+
% cmax: ...[NA]
32+
% outliercolor: ...[NA]
33+
% maxdisplayed: ...[NA]
34+
35+
% MARKER LINE:
36+
% color: ...[DONE]
37+
% width: ...[DONE]
38+
% dash: ...[NA]
39+
% opacity: ---[TODO]
40+
% shape: ...[NA]
41+
% smoothing: ...[NA]
42+
% outliercolor: ...[NA]
43+
% outlierwidth: ...[NA]
44+
45+
%-------------------------------------------------------------------------%
46+
47+
%-AXIS INDEX-%
48+
axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis);
49+
50+
%-BAR DATA STRUCTURE- %
51+
barData = obj.State.Plot(barIndex).Handle;
52+
53+
%-CHECK FOR MULTIPLE AXES-%
54+
[xSource, ySource] = findSourceAxis(obj, axIndex);
55+
56+
%-------------------------------------------------------------------------%
57+
58+
%-associate axis-%
59+
obj.data{barIndex}.xaxis = sprintf('x%d', xSource);
60+
obj.data{barIndex}.yaxis = sprintf('y%d', ySource);
61+
62+
%-------------------------------------------------------------------------%
63+
64+
%-set trace-%
65+
obj.data{barIndex}.type = 'bar';
66+
obj.data{barIndex}.name = barData.DisplayName;
67+
obj.data{barIndex}.visible = strcmp(barData.Visible,'on');
68+
69+
%-------------------------------------------------------------------------%
70+
71+
%-set plot data-%
72+
switch barData.Horizontal
12673

127-
%-bar x data-%
128-
obj.data{barIndex}.x = bar_data.YData;
129-
130-
%-bar y data-%
131-
obj.data{barIndex}.y = bar_data.XData;
132-
end
133-
134-
%---------------------------------------------------------------------%
135-
136-
%-bar showlegend-%
137-
leg = get(bar_data.Annotation);
138-
legInfo = get(leg.LegendInformation);
139-
140-
switch legInfo.IconDisplayStyle
141-
case 'on'
142-
showleg = true;
143-
case 'off'
144-
showleg = false;
145-
end
146-
147-
obj.data{barIndex}.showlegend = showleg;
148-
149-
%-------------------------------------------------------------------------%
150-
151-
%-bar marker-%
152-
obj.data{barIndex}.marker = extractAreaFace(bar_data);
153-
154-
%-------------------------------------------------------------------------%
155-
156-
%-bar marker line-%
157-
markerline = extractAreaLine(bar_data);
158-
obj.data{barIndex}.marker.line = markerline;
159-
160-
%-------------------------------------------------------------------------%
74+
case 'off'
75+
obj.data{barIndex}.orientation = 'v';
76+
obj.data{barIndex}.x = barData.XData;
77+
obj.data{barIndex}.y = barData.YData;
78+
79+
case 'on'
80+
obj.data{barIndex}.orientation = 'h';
81+
obj.data{barIndex}.x = barData.YData;
82+
obj.data{barIndex}.y = barData.XData;
83+
end
84+
85+
%-------------------------------------------------------------------------%
86+
87+
%-trace settings-%
88+
markerline = extractAreaLine(barData);
89+
90+
obj.data{barIndex}.marker = extractAreaFace(barData);
91+
obj.data{barIndex}.marker.line = markerline;
92+
93+
%-------------------------------------------------------------------------%
94+
95+
%-layout settings-%
96+
obj.layout.bargroupgap = 1-barData.BarWidth;
97+
98+
try
99+
obj.layout.bargap = obj.layout.bargap + 0.0625;
100+
catch
101+
obj.layout.bargap = 0.0625;
102+
end
103+
104+
switch barData.BarLayout
105+
case 'grouped'
106+
obj.layout.barmode = 'group';
107+
case 'stacked'
108+
obj.layout.barmode = 'relative';
109+
end
110+
111+
%-------------------------------------------------------------------------%
112+
113+
%-bar showlegend-%
114+
leg = get(barData.Annotation);
115+
legInfo = get(leg.LegendInformation);
116+
117+
switch legInfo.IconDisplayStyle
118+
case 'on'
119+
showleg = true;
120+
case 'off'
121+
showleg = false;
122+
end
123+
124+
obj.data{barIndex}.showlegend = showleg;
125+
126+
%-------------------------------------------------------------------------%
161127
end
162128

163129

0 commit comments

Comments
 (0)