メインコンテンツ

イメージ マップの作成

HTML レポートや PDF レポートでは、イメージの領域をリンクとして指定できます。HTML ブラウザーのイメージ内でリンク領域をクリックすると、ターゲットが開きます。イメージ内のさまざまな領域をさまざまなリンク ターゲットにマッピングできます。

  1. リンクとして機能するそれぞれのイメージ領域に対して mlreportgen.dom.ImageArea オブジェクトを作成します。イメージが表示されない場合に表示するテキストを指定できます。

    イメージ領域には、以下のいずれかの形状を指定できます。

    • 四角形

    • 多角形

    詳細については、mlreportgen.dom.ImageArea を参照してください。

  2. リンク領域をイメージに関連付けるには、mlreportgen.dom.ImageMap オブジェクトを作成します。ImageArea オブジェクトを ImageMap オブジェクトに追加します。

たとえば、プロット イメージからプロットに関するドキュメンテーションへのリンクを作成できます。

import mlreportgen.dom.*
d = Document("imageArea","pdf");
open(d);

% Set page size to A4
pageSize = d.CurrentPageLayout.PageSize;
pageSize.Height = "297mm";
pageSize.Width = "230mm";

% Set margins to 0
pageMargins = d.CurrentPageLayout.PageMargins;
pageMargins.Top = "0mm";
pageMargins.Bottom = "0mm";
pageMargins.Left = "0mm";
pageMargins.Right = "0mm";

% Create a plot and save it as an image file
x = 0:pi/100:2*pi;
y = sin(x);
plot(x,y);
annotation("textbox", [0.2,0.4,0.1,0.1],...
           "string", "Help on plot function");
saveas(gcf,"plot_img.png");

% Create the DOM image object and append it to your document
plot1 = Image("plot_img.png");
append(d,plot1);

% Define the area and link target using ImageArea
target = ["https://www.mathworks.com/help/matlab/ref/" ...
"plot.html?searchHighlight=plot"];
area1 = ImageArea( target, ...
"plot function help",160,340,383,392);

% Create the image map object and append the area to it
map = ImageMap();
append(map,area1);
plot1.Map = map;

close(d);
rptview(d.OutputPath);

参考

クラス

関数

トピック