React 棒チャート
Ignite UI for React 棒チャートはカテゴリ チャートのグループに属し、チャートの左から右にデータ ポイントの値に向かって伸びる長方形のコレクションを使用して描画されます。IgrBarSeries
は、IgrColumnSeries
と同じデータ プロットの概念を使用していますが、データ ポイントは、水平 (x 軸) でなく垂直軸 (y 軸) に沿って拡大します。つまり、棒チャートは縦棒チャートのように描画されますが、時計回りに 90 度回転します。
React 棒チャートの例
軸の要件
React データ チャート コンポーネントはさまざまなタイプの軸を提供しますが、IgrBarSeries
で使用できるのは以下のタイプの軸のみです。
データの要件
IgrBarSeries
には以下のデータ要件があります。
- データソースはデータ項目の配列またはリストである必要があります。
- データソースにはデータ項目を少なくとも 1 つ含む必要があり、含まれない場合はチャートで
IgrBarSeries
がレンダリングされません。 - すべてのデータ項目には、財務軸 (
IgrCategoryYAxis
など) のIgrLabel
プロパティにマッピングする必要があるデータ列 (文字列または日時)を少なくとも 1 列含める必要があります - すべてのデータ項目には、
IgrBarSeries
のValueMemberPath
プロパティにマッピングする必要がある数値データ列を少なくとも 1 列含める必要があります。
上記データ要件を満たすデータソースとして SampleCategoryData を使用できます。
public dataSource: any[] = SampleCategoryData.create();
モジュールの要件
IgrBarSeries
を作成するには、以下のモジュールが必要です。
// axis' modules:
import { IgrNumericXAxis } from 'igniteui-react-charts';
import { IgrCategoryYAxis } from 'igniteui-react-charts';
// series' modules:
import { IgrBarSeries } from 'igniteui-react-charts';
// data chart's modules:
import { IgrDataChart } from 'igniteui-react-charts';
import { IgrDataChartCoreModule } from 'igniteui-react-charts';
import { IgrDataChartCategoryModule } from 'igniteui-react-charts';
// registering data chart's modules:
IgrDataChartCoreModule.register();
IgrDataChartCategoryModule.register();
コード例
このコードは、IgrBarSeries
を使用して Ignite UI for React データ チャートのインスタンスを作成し、それをデータソースにバインドする方法を示します。
<IgrDataChart
dataSource={this.state.dataSource}
width="700px"
height="500px">
{/* axes */}
<IgrNumericXAxis name="xAxis" />
<IgrCategoryYAxis name="yAxis" label="Year" />
{/* series */}
<IgrBarSeries
name="series1"
xAxisName="xAxis"
yAxisName="yAxis"
valueMemberPath="USA" />
</IgrDataChart>
const series1 = new IgrBarSeries({ name: "series1" });
series1.valueMemberPath = "USA";
series1.xAxisName = "xAxis";
series1.yAxisName = "yAxis";
const xAxis = new IgrNumericXAxis({ name: "xAxis" });
const yAxis = new IgrCategoryYAxis({ name: "yAxis" });
yAxis.label = "Year";
this.chart = new IgrDataChart({ name: "chart" });
this.chart.dataSource = SampleCategoryData.create();
this.chart.axes.add(yAxis);
this.chart.axes.add(xAxis);
this.chart.series.add(series1);