Graphs in reports in a matlab WebApp

조회 수: 11 (최근 30일)
Roberto M Sanchez
Roberto M Sanchez 2019년 11월 8일
댓글: Torsten Zschieschang 2022년 9월 15일
I have a Matlab webApp launched in a Matlab webApp Server that performs a calculation and show a graph to the user (a patch in an uiAxes object). Now I want to offer a button to the user to print a report including some information and a uiAxes capture. Considering that:
  • axes or figures are not supported in webApps then you need to use uiaxes and uifigures
  • saveas() is not supported with uiaxes or uifigures
  • getframe() is not supported with uifigures or uiaxes
  • uiaxes or uifigures are not supported by mlreportgen.report.*
¿Is it possible to include graphs in a report from a web application?.
Thanks and regards
Roberto
  댓글 수: 1
Torsten Zschieschang
Torsten Zschieschang 2022년 9월 15일
I have currently a similar problem to save a snapshot as a mixture of uiaxes and information stored in panels or somewhere in the uifigure.
The snapshot functionality of uiaxes should be transformed also to panels! This could help to organize a snap region of a graph and the related information.
Best regards
Torsten

댓글을 달려면 로그인하십시오.

채택된 답변

Mary Abbott
Mary Abbott 2019년 11월 8일
Unfortunately, there is currently no completely programmatic way to include snapshots of uiaxes in a report from a web application, for the reasons you already listed.
With version R2019a and later, you can use the figure toolbar to download a snapshot of the axes. The toolbar appears in the top right corner of the axes when you hover your mouse over the axes. To save the figure, mouse over the left-most toolbar icon and select the save icon that appears.
From there, you can use the uigetfile function to prompt the user to specify the saved snapshot image file and then insert the image into the report.
% (In callback to create report)
imgPath = uigetfile("*.png", "Select the axes snapshot image file");
if ~isempty(imgPath)
% Create DOM Image
imgRptr = mlreportgen.dom.Image(imgPath);
% Add Image object to report (or chapter, section, etc)
add(rpt, img);
end
  댓글 수: 2
Anas El Fathi
Anas El Fathi 2020년 9월 16일
편집: Anas El Fathi 2020년 9월 16일
Hello Mary,
I am facing a similar problem to Roberto.
I can see that figure is not supported for Web apps (here). However, why calling figure with the visible flag set to off is not permitted?
I managed to get around this problem by writing a script that generate the reports, compile the script as a standalone application, then excute the script as a standalone app from within the web App! So technically, it is possible to generate a report in invisible figure from a Matlab web app.
Are there any plans of supporting this directly inside Web apps, instead of me doing the workaround?
PS: This works perfectly for normal Matlab Apps, my question is only about web apps.
figure('Visible', 'off')
Markus
Markus 2020년 11월 27일
편집: Markus 2020년 11월 27일
If you are using MATLAB 2020a and newer take a look to MATLAB "exportgraphics" and "exportapp" function. I have the same problem in my WebApp server. It is a workaround, not a perfect solution because it's a bit slow.
Solution:
1. Plot your graph into a ax=uiaxes, directly in the WebApp server
2. Use the function exportgraphics(ax,myPlot.jpg) to store the plot on disk
3. Use img=mlreportgen.dom.image(myPlot.jpg)
4. Add the Image to your Report with add(rpt, img);
Note:
The Report Generator works only if you have use the function „makeDOMCompilable() before your import statements.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Develop uifigure-Based Apps에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by