-
Notifications
You must be signed in to change notification settings - Fork 168
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #410 from plotly/fix_issue_related_to_bar_function…
…ality fix issue related to bar functionality
- Loading branch information
Showing
2 changed files
with
230 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,163 +1,129 @@ | ||
function obj = updateBar(obj,barIndex) | ||
|
||
% x: ...[DONE] | ||
% y: ...[DONE] | ||
% name: ...[DONE] | ||
% orientation: ...[DONE] | ||
% text: ...[NOT SUPPORTED IN MATLAB] | ||
% error_y: ...[HANDLED BY ERRORBAR] | ||
% error_x: ...[HANDLED BY ERRORBAR] | ||
% opacity: ...[DONE] | ||
% xaxis: ...[DONE] | ||
% yaxis: ...[DONE] | ||
% showlegend: ...[DONE] | ||
% stream: ...[HANDLED BY PLOTLY STREAM] | ||
% visible: ...[DONE] | ||
% type: ...[DONE] | ||
% r: ...[NA] | ||
% t: ...[NA] | ||
% textfont: ...[NA] | ||
|
||
% MARKER: | ||
% color: ...DONE] | ||
% size: ...[NA] | ||
% symbol: ...[NA] | ||
% opacity: ...[NA] | ||
% sizeref: ...[NA] | ||
% sizemode: ...[NA] | ||
% colorscale: ...[NA] | ||
% cauto: ...[NA] | ||
% cmin: ...[NA] | ||
% cmax: ...[NA] | ||
% outliercolor: ...[NA] | ||
% maxdisplayed: ...[NA] | ||
|
||
% MARKER LINE: | ||
% color: ...[DONE] | ||
% width: ...[DONE] | ||
% dash: ...[NA] | ||
% opacity: ---[TODO] | ||
% shape: ...[NA] | ||
% smoothing: ...[NA] | ||
% outliercolor: ...[NA] | ||
% outlierwidth: ...[NA] | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-AXIS INDEX-% | ||
axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis); | ||
|
||
%-BAR DATA STRUCTURE- % | ||
bar_data = obj.State.Plot(barIndex).Handle; | ||
|
||
%-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) ';']); | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar xaxis-% | ||
obj.data{barIndex}.xaxis = ['x' num2str(xsource)]; | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar yaxis-% | ||
obj.data{barIndex}.yaxis = ['y' num2str(ysource)]; | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar visible-% | ||
obj.data{barIndex}.visible = strcmp(bar_data.Visible,'on'); | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar type-% | ||
obj.data{barIndex}.type = 'bar'; | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar name-% | ||
obj.data{barIndex}.name = bar_data.DisplayName; | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-layout barmode-% | ||
switch bar_data.BarLayout | ||
case 'grouped' | ||
obj.layout.barmode = 'group'; | ||
case 'stacked' | ||
obj.layout.barmode = 'relative'; | ||
end | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-layout bargroupgap-% | ||
obj.layout.bargroupgap = 1-bar_data.BarWidth; | ||
|
||
%---------------------------------------------------------------------% | ||
|
||
%-layout bargap-% | ||
obj.layout.bargap = obj.PlotlyDefaults.Bargap; | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar orientation-% | ||
switch bar_data.Horizontal | ||
|
||
case 'off' | ||
|
||
%-bar orientation-% | ||
obj.data{barIndex}.orientation = 'v'; | ||
|
||
%-bar x data-% | ||
obj.data{barIndex}.x = bar_data.XData; | ||
|
||
%-bar y data-% | ||
obj.data{barIndex}.y = bar_data.YData; | ||
|
||
|
||
case 'on' | ||
|
||
%-bar orientation-% | ||
obj.data{barIndex}.orientation = 'h'; | ||
% x: ...[DONE] | ||
% y: ...[DONE] | ||
% name: ...[DONE] | ||
% orientation: ...[DONE] | ||
% text: ...[NOT SUPPORTED IN MATLAB] | ||
% error_y: ...[HANDLED BY ERRORBAR] | ||
% error_x: ...[HANDLED BY ERRORBAR] | ||
% opacity: ...[DONE] | ||
% xaxis: ...[DONE] | ||
% yaxis: ...[DONE] | ||
% showlegend: ...[DONE] | ||
% stream: ...[HANDLED BY PLOTLY STREAM] | ||
% visible: ...[DONE] | ||
% type: ...[DONE] | ||
% r: ...[NA] | ||
% t: ...[NA] | ||
% textfont: ...[NA] | ||
|
||
% MARKER: | ||
% color: ...DONE] | ||
% size: ...[NA] | ||
% symbol: ...[NA] | ||
% opacity: ...[NA] | ||
% sizeref: ...[NA] | ||
% sizemode: ...[NA] | ||
% colorscale: ...[NA] | ||
% cauto: ...[NA] | ||
% cmin: ...[NA] | ||
% cmax: ...[NA] | ||
% outliercolor: ...[NA] | ||
% maxdisplayed: ...[NA] | ||
|
||
% MARKER LINE: | ||
% color: ...[DONE] | ||
% width: ...[DONE] | ||
% dash: ...[NA] | ||
% opacity: ---[TODO] | ||
% shape: ...[NA] | ||
% smoothing: ...[NA] | ||
% outliercolor: ...[NA] | ||
% outlierwidth: ...[NA] | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-AXIS INDEX-% | ||
axIndex = obj.getAxisIndex(obj.State.Plot(barIndex).AssociatedAxis); | ||
|
||
%-BAR DATA STRUCTURE- % | ||
barData = obj.State.Plot(barIndex).Handle; | ||
|
||
%-CHECK FOR MULTIPLE AXES-% | ||
[xSource, ySource] = findSourceAxis(obj, axIndex); | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-associate axis-% | ||
obj.data{barIndex}.xaxis = sprintf('x%d', xSource); | ||
obj.data{barIndex}.yaxis = sprintf('y%d', ySource); | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-set trace-% | ||
obj.data{barIndex}.type = 'bar'; | ||
obj.data{barIndex}.name = barData.DisplayName; | ||
obj.data{barIndex}.visible = strcmp(barData.Visible,'on'); | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-set plot data-% | ||
switch barData.Horizontal | ||
|
||
%-bar x data-% | ||
obj.data{barIndex}.x = bar_data.YData; | ||
|
||
%-bar y data-% | ||
obj.data{barIndex}.y = bar_data.XData; | ||
end | ||
|
||
%---------------------------------------------------------------------% | ||
|
||
%-bar showlegend-% | ||
leg = get(bar_data.Annotation); | ||
legInfo = get(leg.LegendInformation); | ||
|
||
switch legInfo.IconDisplayStyle | ||
case 'on' | ||
showleg = true; | ||
case 'off' | ||
showleg = false; | ||
end | ||
|
||
obj.data{barIndex}.showlegend = showleg; | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar marker-% | ||
obj.data{barIndex}.marker = extractAreaFace(bar_data); | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar marker line-% | ||
markerline = extractAreaLine(bar_data); | ||
obj.data{barIndex}.marker.line = markerline; | ||
|
||
%-------------------------------------------------------------------------% | ||
case 'off' | ||
obj.data{barIndex}.orientation = 'v'; | ||
obj.data{barIndex}.x = barData.XData; | ||
obj.data{barIndex}.y = barData.YData; | ||
|
||
case 'on' | ||
obj.data{barIndex}.orientation = 'h'; | ||
obj.data{barIndex}.x = barData.YData; | ||
obj.data{barIndex}.y = barData.XData; | ||
end | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-trace settings-% | ||
markerline = extractAreaLine(barData); | ||
|
||
obj.data{barIndex}.marker = extractAreaFace(barData); | ||
obj.data{barIndex}.marker.line = markerline; | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-layout settings-% | ||
obj.layout.bargroupgap = 1-barData.BarWidth; | ||
|
||
try | ||
obj.layout.bargap = obj.layout.bargap + 0.0625; | ||
catch | ||
obj.layout.bargap = 0.0625; | ||
end | ||
|
||
switch barData.BarLayout | ||
case 'grouped' | ||
obj.layout.barmode = 'group'; | ||
case 'stacked' | ||
obj.layout.barmode = 'relative'; | ||
end | ||
|
||
%-------------------------------------------------------------------------% | ||
|
||
%-bar showlegend-% | ||
leg = get(barData.Annotation); | ||
legInfo = get(leg.LegendInformation); | ||
|
||
switch legInfo.IconDisplayStyle | ||
case 'on' | ||
showleg = true; | ||
case 'off' | ||
showleg = false; | ||
end | ||
|
||
obj.data{barIndex}.showlegend = showleg; | ||
|
||
%-------------------------------------------------------------------------% | ||
end | ||
|
||
|
Oops, something went wrong.