Close
Angular React Web Components Blazor Blazor
Premium

Blazor Toolbar (ツールバー) の概要

Blazor ツールバー コンポーネントは、主にチャート コンポーネントで使用される UI 操作のコンパニオン コンテナーです。ツールバーは、IgbDataChart または IgbCategoryChart コンポーネントにリンクされると、プロパティとツール項目のプリセットで動的に更新されます。プロジェクト用のカスタム ツールを作成して、エンド ユーザーが変更を提供できるようになり、無限のカスタマイズが可能になります。

Blazor ツールバーの例

依存関係

IgniteUI.Blazor.Controls 名前空間を _Imports.razor ファイルに追加します。

import { IgxToolbarModule } from 'igniteui-angular-layouts';
import { IgxDataChartToolbarModule, IgxDataChartCoreModule, IgxDataChartCategoryModule, IgxDataChartAnnotationModule, IgxDataChartInteractivityModule, IgxDataChartCategoryTrendLineModule  } from 'igniteui-angular-charts';

@NgModule({
    imports: [
        // ...
        IgxToolbarModule,
        IgxDataChartToolbarModule,
        IgxDataChartCoreModule,
        IgxDataChartCategoryModule,
        IgxDataChartAnnotationModule,
        IgxDataChartInteractivityModule,
        IgxDataChartCategoryTrendLineModule
        // ...
    ]
})
export class AppModule {}

IgbDataChart コンポーネントとその機能とともに IgbToolbar を使用する場合、次のモジュールが必要です。

import { IgxToolbarModule } from 'igniteui-react-layouts';
import { IgrDataChartToolbarModule, IgrDataChartCoreModule, IgrDataChartCategoryModule, IgrDataChartAnnotationModule, IgrDataChartInteractivityModule, IgrDataChartCategoryTrendLineModule  } from 'igniteui-react-charts';

IgxToolbarModule.register();
IgrDataChartToolbarModule.register();
IgrDataChartCoreModule.register();
IgrDataChartCategoryModule.register();
IgrDataChartAnnotationModule.register();
IgrDataChartInteractivityModule.register();
IgrDataChartCategoryTrendLineModule.register();

スタイルを IgbToolbar コンポーネントに適用するには、追加の CSS ファイルをリンクする必要もあります。以下は、Blazor Web Assembly プロジェクトの wwwroot/index.html ファイルまたは Blazor Server プロジェクトの Pages/_Host.cshtml ファイルに配置する必要があります。

import { ModuleManager } from 'igniteui-webcomponents-core';
import { IgcToolbarModule } from 'igniteui-webcomponents-layouts';
import { IgcDataChartToolbarModule, IgcDataChartCoreModule, IgcDataChartCategoryModule, IgcDataChartAnnotationModule, IgcDataChartInteractivityModule, IgcDataChartCategoryTrendLineModule } from 'igniteui-webcomponents-charts';

ModuleManager.register(
    IgcToolbarModule,
    IgcToolActionLabelModule,
    IgcDataChartToolbarModule,
    IgcDataChartCategoryModule,
    IgcDataChartCoreModule,
    IgcDataChartInteractivityModule,
    IgcDataChartAnnotationModule,
    IgcDataChartCategoryTrendLineModule
);

使用方法

ツール操作

以下は、ツールバーに追加できるさまざまな IgbToolAction 項目のリストです。

これらのツールはそれぞれ、マウスのクリックによってトリガーされる OnCommand イベントを公開します。注: IgbToolActionIconMenu は、IgbToolActionIconMenu 内にラップすることもできる他のツールのラッパーです。

IgbToolAction オブジェクトの OverlayIdBeforeId、および AfterId プロパティを使用して、新規および既存のツールの位置を変更したり、非表示にマークしたりすることができます。ToolActions は Visibility プロパティも公開します。

次の例は、いくつかの機能を示しています。まず、ZoomResetAnalyzeMenu メニュー ツール操作などの組み込みツールを非表示にするなど、IgbToolActionSubPanel でツールをグループ化できます。この例では、AfterId プロパティを使用して ZoomMenu 内に ZoomReset ツール操作の新しいインスタンスを作成し、それを ZoomOut に割り当てて配置を正確にします。また、ツールの IsHighlighted プロパティによってもハイライト表示されます。

Blazor データ チャートの統合

Blazor ツールバーには、Target プロパティが含まれています。これは、以下のコードに示すように、IgbDataChart などのコンポーネントをリンクするために使用されます。

  <IgbToolbar
    Name="Toolbar"
    @ref="toolbar"
    Target="@chart">
  <IgbToolbar>

  <IgbDataChart
    Name="chart"
    @ref="chart">
  </IgbDataChart>

IgbDataChart が Toolbar にリンクされると、いくつかの既存の IgbToolAction 項目とメニューが使用可能になります。以下は、組み込みの Blazor IgbDataChart ツール操作とそれに関連付けられた OverlayId のリストです。

ズーム操作

  • ZoomMenu: チャートのズーム レベルを増減するための ZoomIn および ZoomOut メソッドを呼び出す 3 つの IgbToolActionLabel 項目を公開する IgbToolActionIconMenu には、チャートの ResetZoom メソッドを呼び出してズーム レベルをデフォルトの位置にリセットする ZoomReset が含まれます。

トレンド操作

  • AnalyzeMenu: チャートのさまざまなオプションを構成するためのいくつかのオプションを含む IgbToolActionIconMenu
  • AnalyzeHeader: サブ セクションのヘッダー。
    • LinesMenu: チャート上で水平破線を表示するためのさまざまなツールが含まれるサブ メニュー。
    • LinesHeader: 次の 3 つのツールのサブメニュー セクション ヘッダー:
    • MaxValue: シリーズの最大値で yAxis に沿って水平破線を表示する IgbToolActionCheckbox
    • MinValue: シリーズの最小値で yAxis に沿って水平破線を表示する IgbToolActionCheckbox
    • Average: シリーズの平均値で yAxis に沿って水平破線を表示する IgbToolActionCheckbox
    • TrendsMenu: さまざまな近似曲線を IgbDataChart プロット領域に適用するためのツールを含むサブ メニュー。
    • TrendsHeader: 次の 3 つのツールのサブメニュー セクション ヘッダー:
    • Exponential: チャート内の各シリーズの TrendLineTypeExponentialFit に設定する IgbToolActionRadio
    • Linear: チャート内の各シリーズの TrendLineTypeLinearFit に設定する IgbToolActionRadio
    • Logarithmic: チャート内の各シリーズの TrendLineTypeLogarithmicFit に設定する IgbToolActionRadio
  • HelpersHeader: サブ セクションのヘッダー。
  • ShowCrosshairs: チャートの CrosshairsDisplayMode プロパティを介してマウスオーバー十字線の注釈を切り替える IgbToolActionCheckbox
  • ShowGridlines: X-Axis に MajorStroke を適用することで追加のグリッド線を切り替える IgbToolActionCheckbox

画像に保存アクション

  • CopyAsImage: チャートをクリップボードにコピーするオプションを公開する IgbToolActionLabel
  • CopyHeader: サブ セクションのヘッダー。

SVG アイコン

ツールを手動で追加する場合、RenderIconFromText メソッドを使用してアイコンを割り当てることができます。このメソッドには 3 つのパラメーターを渡す必要があります。1 つ目は、ツールで定義されたアイコン コレクション名です (例: IconCollectionName)。2 つ目は、ツールで定義されたアイコンの名前 (例: IconName) で、その後に SVG 文字列を追加します。

データ URL アイコン

svg を追加するのと同様に、RegisterIconFromDataURL を介して URL からアイコン画像を追加することもできます。メソッドの 3 番目のパラメーターは、文字列 URL を入力するために使用されます。

次のスニペットは、アイコンを追加する両方の方法を示しています。

public toolbarCustomIconOnViewInit(): void {

  const icon = '<svg width="28px" height="28px" stroke="none" viewBox="0 0 3.5 3.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M0.436 0.178a0.073 0.073 0 0 0 -0.062 0.036L0.01 0.846a0.073 0.073 0 0 0 0.063 0.109h0.729a0.073 0.073 0 0 0 0.063 -0.109L0.501 0.214a0.073 0.073 0 0 0 -0.064 -0.036zm0.001 0.219 0.238 0.413H0.199zM1.4 0.507v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245zM0.073 1.388A0.073 0.073 0 0 0 0 1.461v0.583a0.073 0.073 0 0 0 0.073 0.073h0.729A0.073 0.073 0 0 0 0.875 2.045V1.461a0.073 0.073 0 0 0 -0.073 -0.073zm0.073 0.146h0.583v0.438H0.146zM1.4 1.674v0.245h0.945v-0.245zm1.19 0v0.245h0.91v-0.245zM0.438 2.447c-0.241 0 -0.438 0.197 -0.438 0.438 0 0.241 0.197 0.438 0.438 0.438s0.438 -0.197 0.438 -0.438c0 -0.241 -0.197 -0.438 -0.438 -0.438zm0 0.146a0.291 0.291 0 0 1 0.292 0.292 0.291 0.291 0 0 1 -0.292 0.292 0.291 0.291 0 0 1 -0.292 -0.292A0.291 0.291 0 0 1 0.438 2.593zM1.4 2.842v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245z" fill="#000000" fill-rule="evenodd"/></svg>';

  this.toolbar.registerIconFromText("CustomCollection", "CustomIcon", icon);
}
public toolbarCustomIconOnViewInit(): void {

  toolbar.registerIconFromDataURL("CustomCollection", "CustomIcon", "https://www.svgrepo.com/show/678/calculator.svg");

}
public toolbarCustomIconOnViewInit(): void {

  const icon = '<svg width="28px" height="28px" stroke="none" viewBox="0 0 3.5 3.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M0.436 0.178a0.073 0.073 0 0 0 -0.062 0.036L0.01 0.846a0.073 0.073 0 0 0 0.063 0.109h0.729a0.073 0.073 0 0 0 0.063 -0.109L0.501 0.214a0.073 0.073 0 0 0 -0.064 -0.036zm0.001 0.219 0.238 0.413H0.199zM1.4 0.507v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245zM0.073 1.388A0.073 0.073 0 0 0 0 1.461v0.583a0.073 0.073 0 0 0 0.073 0.073h0.729A0.073 0.073 0 0 0 0.875 2.045V1.461a0.073 0.073 0 0 0 -0.073 -0.073zm0.073 0.146h0.583v0.438H0.146zM1.4 1.674v0.245h0.945v-0.245zm1.19 0v0.245h0.91v-0.245zM0.438 2.447c-0.241 0 -0.438 0.197 -0.438 0.438 0 0.241 0.197 0.438 0.438 0.438s0.438 -0.197 0.438 -0.438c0 -0.241 -0.197 -0.438 -0.438 -0.438zm0 0.146a0.291 0.291 0 0 1 0.292 0.292 0.291 0.291 0 0 1 -0.292 0.292 0.291 0.291 0 0 1 -0.292 -0.292A0.291 0.291 0 0 1 0.438 2.593zM1.4 2.842v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245z" fill="#000000" fill-rule="evenodd"/></svg>';

  this.toolbar.registerIconFromText("CustomCollection", "CustomIcon", icon);

}
public toolbarCustomIconOnViewInit(): void {

  toolbar.registerIconFromDataURL("CustomCollection", "CustomIcon", "https://www.svgrepo.com/show/678/calculator.svg");

}
<IgbToolActionLabel
    Title="Custom Icon"
    IconName="CustomIcon"
    IconCollectionName="CustomCollection">
</IgbToolActionLabel>

@code {

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        var toolbar = this.toolbar;

        if (firstRender) {
            this.ToolbarCustomIconOnViewInit();
        }
    }

    private IgbToolbar toolbar;

    public void ToolbarCustomIconOnViewInit()
    {
        this.toolbar.EnsureReady().ContinueWith(new Action<Task>((e) =>
        {
            string icon =
            @"
                <svg width=""28px"" height=""28px"" stroke=""none"" viewBox=""0 0 3.5 3.5"" xmlns=""http://www.w3.org/2000/svg"" xmlns:xlink=""http://www.w3.org/1999/xlink"" aria-hidden=""true"" role=""img"" class=""iconify iconify--gis"" preserveAspectRatio=""xMidYMid meet""><path d=""M0.436 0.178a0.073 0.073 0 0 0 -0.062 0.036L0.01 0.846a0.073 0.073 0 0 0 0.063 0.109h0.729a0.073 0.073 0 0 0 0.063 -0.109L0.501 0.214a0.073 0.073 0 0 0 -0.064 -0.036zm0.001 0.219 0.238 0.413H0.199zM1.4 0.507v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245zM0.073 1.388A0.073 0.073 0 0 0 0 1.461v0.583a0.073 0.073 0 0 0 0.073 0.073h0.729A0.073 0.073 0 0 0 0.875 2.045V1.461a0.073 0.073 0 0 0 -0.073 -0.073zm0.073 0.146h0.583v0.438H0.146zM1.4 1.674v0.245h0.945v-0.245zm1.19 0v0.245h0.91v-0.245zM0.438 2.447c-0.241 0 -0.438 0.197 -0.438 0.438 0 0.241 0.197 0.438 0.438 0.438s0.438 -0.197 0.438 -0.438c0 -0.241 -0.197 -0.438 -0.438 -0.438zm0 0.146a0.291 0.291 0 0 1 0.292 0.292 0.291 0.291 0 0 1 -0.292 0.292 0.291 0.291 0 0 1 -0.292 -0.292A0.291 0.291 0 0 1 0.438 2.593zM1.4 2.842v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245z"" fill=""#000000"" fill-rule=""evenodd""/></svg>
            ";
            this.toolbar.RegisterIconFromTextAsync("CustomCollection", "CustomIcon", icon);
        }));
    }

}

Vertical Orientation

By default the Blazor Toolbar is shown horizontally, but it also has the ability to shown vertically by setting the Orientation property.

<IgbToolbar Orientation="ToolbarOrientation.Vertical" />

The following example demonstrates the vertical orientation of the Blazor Toolbar.

Color Editor

You can add a custom color editor tool to the the Blazor Toolbar, which will also work with the Command event to perform custom styling to your application.

<IgbToolbar
Name="toolbar"
@ref="toolbar">
    <IgbToolActionColorEditor
    Title="Series Brush">
    </IgbToolActionColorEditor>
</IgbToolbar>

The following example demonstrates styling the Blazor Data Chart series brush with the Color Editor tool.

API References

Additional Resources