Angular 積層型縦棒チャート
Ignite UI for Angular 積層型縦棒チャートはカテゴリ チャートのグループに属し、互いの上に積み上げられた長方形のコレクション (IgxStackedFragmentSeriesComponent
) を使用して描画されます。コレクションのそれぞれの積層フラグメントは各積層の視覚的な要素を表します。各積層は正の値と負の値の両方を含みます。正の値はいずれも y 軸の正の側にグループ化され、負の値は y 軸の負の側にグループ化されます。IgxStackedColumnSeriesComponent
は IgxStackedBarSeriesComponent
と同じデータプロットの概念を使用しますが、データポイントは水平線 (x 軸) ではなく垂直線 (y 軸) に沿って積み重ねられます。つまり、積層型縦棒チャートは積層棒チャートのように描画されますが、反時計回りに 90 度回転します。
サンプル
IgxStackedColumnSeriesComponent
には、IgxStackedFragmentSeriesComponent
要素を配置できる独自の IgxSeriesComponent
コレクションがあります。これらのフラグメントは、チャートの実際のレンダリングを構成するものであり、ValueMemberPath
を受け取る要素です。
軸の要件
Angular データ チャート コンポーネントはさまざまなタイプの軸を提供しますが、IgxStackedColumnSeriesComponent
で使用できるのは以下のタイプの軸のみです。
IgxCategoryXAxisComponent
IgxOrdinalTimeXAxisComponent
IgxTimeXAxisComponent
IgxNumericYAxisComponent
データの要件
IgxStackedColumnSeriesComponent
には以下のデータ要件があります。
- データソースはデータ項目の配列またはリストである必要があります。
- データソースにはデータ項目を少なくとも 1 つ含む必要があり、含まれない場合はチャートで
IgxStackedColumnSeriesComponent
がレンダリングされません。 - すべてのデータ項目には、財務軸 (
IgxCategoryXAxisComponent
など) のIgxLabelComponent
プロパティにマッピングする必要があるデータ列 (文字列または日時)を少なくとも 1 列含める必要があります - すべてのデータ項目には、
IgxStackedColumnSeriesComponent
のIgxSeriesComponent
コレクションに追加するIgxStackedFragmentSeriesComponent
のvalueMemberPath
プロパティを使用してマップする必要がある少なくとも 1 つの数値データ列が含まれている必要があります。
モジュールの要件
IgxStackedColumnSeriesComponent
を作成するには、以下のモジュールが必要です。 モジュールはアプリケーションのエントリ ポイントに登録する必要があります。
- DataChartCoreModule
- DataChartInteractivityModule
- DataChartCategoryModule
- DataChartStackedModule,
- StackedFragmentSeriesModule,
// axis' modules:
import { IgxCategoryXAxis } from 'igniteui-angular-charts';
import { IgxNumericYAxis } from 'igniteui-angular-charts';
// series' modules:
import { IgxStackedColumnSeries } from 'igniteui-angular-charts';
// data chart's modules:
import { IgxDataChartCoreModule } from 'igniteui-angular-charts';
import { IgxDataChartCategoryModule } from 'igniteui-angular-charts';
import { IgxDataChartStackedModule } from 'igniteui-angular-charts';
@NgModule({
imports: [
// ...
IgxDataChartCoreModule,
IgxDataChartCategoryModule,
IgxDataChartStackedModule
// ...
]
})
コード例
このコードは、IgxStackedColumnSeriesComponent
を使用して Ignite UI for Angular データ チャートのインスタンスを作成し、それをデータソースにバインドする方法を示します。
<igx-data-chart #chart height="100%" width="100%" [dataSource]="data">
<igx-category-x-axis #xAxis label="Country"></igx-category-x-axis>
<igx-numeric-y-axis #yAxis></igx-numeric-y-axis>
<igx-stacked-column-series [xAxis]="xAxis" [yAxis]="yAxis">
<igx-stacked-fragment-series valueMemberPath="Coal"></igx-stacked-fragment-series>
<igx-stacked-fragment-series valueMemberPath="Hydro"></igx-stacked-fragment-series>
<igx-stacked-fragment-series valueMemberPath="Nuclear"></igx-stacked-fragment-series>
<igx-stacked-fragment-series valueMemberPath="Gas"></igx-stacked-fragment-series>
<igx-stacked-fragment-series valueMemberPath="Oil"></igx-stacked-fragment-series>
</igx-stacked-column-series>
</igx-data-chart>