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

Skip to content

fix issue related to bar functionality #410

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 1 commit into from
Oct 13, 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
fix issue related to bar functionality
  • Loading branch information
galvisgilberto committed Oct 13, 2021
commit 1c95daff7265fa44ab485ac735f2f652593551db
280 changes: 123 additions & 157 deletions plotly/plotlyfig_aux/handlegraphics/updateBar.m
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


Loading