OrganizationChartは、階層的な組織データを表す視覚化コンポーネントです。
import OrganizationChart from 'primevue/organizationchart';
OrganizationChartは、valueとしてTreeNodeインスタンスのコレクションを必要とします。
アルゼンチン | |||||||||||||||||||||||||||||||||||||||
|
|
<OrganizationChart :value="data">
<template #default="slotProps">
<span>{{ slotProps.node.label }}</span>
</template>
</OrganizationChart>
OrganizationChartNodeのtypeプロパティは、ノードにテンプレートをマッピングするために使用されます。未定義の場合は、デフォルトテンプレートが使用されます。
<OrganizationChart :value="data" collapsible>
<template #country="slotProps">
<div class="flex flex-col items-center">
<img :alt="slotProps.node.label" src="https://primefaces.org/cdn/primevue/images/flag/flag_placeholder.png" :class="`w-2rem flag flag-${slotProps.node.data}`" />
<div class="mt-4 font-medium text-lg">{{ slotProps.node.label }}</div>
</div>
</template>
<template #default="slotProps">
<span>{{slotProps.node.data.label}}</span>
</template>
</OrganizationChart>
選択は、selectionModeを「single」または「multiple」に設定し、v-modelディレクティブでselectionKeysを指定することで有効になります。特定のノードの選択は、ノードインスタンスのselectableがfalseの場合、無効にすることができます。
<OrganizationChart v-model:selectionKeys="selection" :value="data" collapsible selectionMode="multiple">
<template #person="slotProps">
<div class="flex flex-col">
<div class="flex flex-col items-center">
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-4 w-12 h-12" />
<span class="font-bold mb-2">{{ slotProps.node.data.name }}</span>
<span>{{ slotProps.node.data.title }}</span>
</div>
</div>
</template>
<template #default="slotProps">
<span>{{ slotProps.node.label }}</span>
</template>
</OrganizationChart>
特定のノードのスタイル設定は、TreeNodeのstyleClassとstyleオプションで構成されます。
<OrganizationChart :value="data" collapsible>
<template #person="slotProps">
<div class="flex flex-col">
<div class="flex flex-col items-center">
<img :alt="slotProps.node.data.name" :src="slotProps.node.data.image" class="mb-4 w-12 h-12" />
<span class="font-bold mb-2">{{ slotProps.node.data.name }}</span>
<span>{{ slotProps.node.data.title }}</span>
</div>
</div>
</template>
<template #default="slotProps">
<span>{{ slotProps.node.label }}</span>
</template>
</OrganizationChart>
このコンポーネントは現在、テーブルベースの実装を使用しており、高度なスクリーンリーダーサポートを提供していません。今後のバージョンでは、ariaロールと属性をツリーウィジェットに合わせたネストされたリスト実装に置き換え、高度なリーダーサポートを提供する予定です。
キー | 機能 |
---|---|
tab | チャート内のフォーカス可能な要素間を移動します。 |
enter | ノードの展開状態を切り替えます。 |
space | ノードの展開状態を切り替えます。 |