필터 지우기
필터 지우기

data display in app designer

조회 수: 3 (최근 30일)
William
William 2022년 5월 19일
답변: Ishu 2024년 8월 30일
I am trying to display data similar to something as showing in the pic.
initially I was thinking to use a table with the 3 colums as shown but then comes the issue of displaying the compliance and risk level as like a bar graph. How would I display the bar graph in the table or is there some other way to get this done.

답변 (1개)

Ishu
Ishu 2024년 8월 30일
Hi William,
To plot bar graph in App Designer you can make use of UIAxes along with UITable.
You can either plot the selected row from the UITable in the bar graph or you can plot all the rows from UITable.
1) Plotting the selected row.
Use "CellSelectionCallback" of the UITable to plot a bar graph when row is selected.
You can add the following code in "CellSelectionCallback"
function UITableCellSelection(app, event)
indices = event.Indices;
if ~isempty(indices)
selectedRow = indices(1);
compliance = app.UITable.Data{selectedRow, 2};
risk = app.UITable.Data{selectedRow, 3};
% Plot bar graph
bar(app.UIAxes, [compliance, risk]);
app.UIAxes.XTickLabel = {'Compliance', 'Risk'};
end
end
2) Plotting all rows.
Use "StartupFcn" callback of application to call a function that will plot the bar graph.
Refer to the example code below to plot al rows of UITable.
% In your app's StartupFcn or initialization code
function startupFcn(app)
% Sample data for the UITable
data = {
'Patient 1', 20, 30;
'Patient 2', 35, 45;
'Patient 3', 50, 60;
};
app.UITable.Data = data;
% Plot all rows in a bar chart
plotAllRowsBarChart(app, data);
end
% Function to plot all rows in a bar chart
function plotAllRowsBarChart(app, data)
% Extract numeric data
numData = cell2mat(data(:, 2:end));
bar(app.UIAxes, numData);
app.UIAxes.XTickLabel = data(:, 1);
end

카테고리

Help CenterFile Exchange에서 Migrate GUIDE Apps에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by