React 軸グリッド線
すべての Ignite UI for React チャートには、軸線の外観、X 軸と Y 軸に描画される主/副グリッド線および目盛りの頻度を変更するための組み込み機能が含まれています。
次の例は、IgrCategoryChart および IgrFinancialChart コントロールに適用されます。
軸の主グリッド線は、軸ラベルの位置から水平 (Y 軸) または垂直 (X 軸) に伸びる長い線であり、チャートのプロット領域を介して描画されます。軸の副グリッド線は、軸の主グリッド線の間に描画される線です。
軸目盛りは、React チャートのすべての主線の位置で各ラベルのすべての水平軸および垂直軸に沿って表示されます。
React 軸グリッド線の例
この例は、指定した間隔で主グリッド線と副グリッド線を表示するために軸グリッド線を構成する方法を示しています。
export class CountryRenewableElectricityItem {
public constructor(init: Partial<CountryRenewableElectricityItem>) {
Object.assign(this, init);
}
public year: string;
public europe: number;
public china: number;
public america: number;
}
export class CountryRenewableElectricity extends Array<CountryRenewableElectricityItem> {
public constructor(items: Array<CountryRenewableElectricityItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new CountryRenewableElectricityItem(
{
year: `2009`,
europe: 34,
china: 21,
america: 19
}),
new CountryRenewableElectricityItem(
{
year: `2010`,
europe: 43,
china: 26,
america: 24
}),
new CountryRenewableElectricityItem(
{
year: `2011`,
europe: 66,
china: 29,
america: 28
}),
new CountryRenewableElectricityItem(
{
year: `2012`,
europe: 69,
china: 32,
america: 26
}),
new CountryRenewableElectricityItem(
{
year: `2013`,
europe: 58,
china: 47,
america: 38
}),
new CountryRenewableElectricityItem(
{
year: `2014`,
europe: 40,
china: 46,
america: 31
}),
new CountryRenewableElectricityItem(
{
year: `2015`,
europe: 78,
china: 50,
america: 19
}),
new CountryRenewableElectricityItem(
{
year: `2016`,
europe: 13,
china: 90,
america: 52
}),
new CountryRenewableElectricityItem(
{
year: `2017`,
europe: 78,
china: 132,
america: 50
}),
new CountryRenewableElectricityItem(
{
year: `2018`,
europe: 40,
china: 134,
america: 34
}),
new CountryRenewableElectricityItem(
{
year: `2018`,
europe: 40,
china: 134,
america: 34
}),
new CountryRenewableElectricityItem(
{
year: `2019`,
europe: 80,
china: 96,
america: 38
}),
];
super(...newItems.slice(0));
}
}
}
tsimport React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrPropertyEditorPanelModule } from "@infragistics/igniteui-react-layouts";
import { IgrLegendModule, IgrCategoryChartModule } from "@infragistics/igniteui-react-charts";
import { IgrLegend, IgrCategoryChart } from "@infragistics/igniteui-react-charts";
import { IgrPropertyEditorPanel, IgrPropertyEditorPropertyDescription } from "@infragistics/igniteui-react-layouts";
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, LegendDescriptionModule, CategoryChartDescriptionModule } from "@infragistics/igniteui-react-core";
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity';
import 'igniteui-webcomponents/themes/light/bootstrap.css';
const mods: any[] = [
IgrPropertyEditorPanelModule,
IgrLegendModule,
IgrCategoryChartModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private legend: IgrLegend
private legendRef(r: IgrLegend) {
this.legend = r;
this.setState({});
}
private propertyEditorPanel1: IgrPropertyEditorPanel
private propertyEditorPanel1Ref(r: IgrPropertyEditorPanel) {
this.propertyEditorPanel1 = r;
this.setState({});
}
private xAxisStroke: IgrPropertyEditorPropertyDescription
private xAxisMajorStroke: IgrPropertyEditorPropertyDescription
private yAxisStroke: IgrPropertyEditorPropertyDescription
private yAxisMajorStroke: IgrPropertyEditorPropertyDescription
private yAxisMinorStroke: IgrPropertyEditorPropertyDescription
private chart: IgrCategoryChart
private chartRef(r: IgrCategoryChart) {
this.chart = r;
this.setState({});
}
constructor(props: any) {
super(props);
this.legendRef = this.legendRef.bind(this);
this.propertyEditorPanel1Ref = this.propertyEditorPanel1Ref.bind(this);
this.chartRef = this.chartRef.bind(this);
}
public render(): JSX.Element {
return (
<div className="container sample">
<div className="options vertical">
<IgrPropertyEditorPanel
componentRenderer={this.renderer}
target={this.chart}
descriptionType="CategoryChart"
isHorizontal="true"
isWrappingEnabled="true"
ref={this.propertyEditorPanel1Ref}>
<IgrPropertyEditorPropertyDescription
propertyPath="XAxisStroke"
name="XAxisStroke"
label="X Axis Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="gray">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="XAxisMajorStroke"
name="XAxisMajorStroke"
label="X Axis Major Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="darkslategray">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="YAxisStroke"
name="YAxisStroke"
label="Y Axis Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="gray">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="YAxisMajorStroke"
name="YAxisMajorStroke"
label="Y Axis Major Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="darkslategray">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="YAxisMinorStroke"
name="YAxisMinorStroke"
label="Y Axis Minor Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="gray">
</IgrPropertyEditorPropertyDescription>
</IgrPropertyEditorPanel>
</div>
<div className="legend-title">
Renewable Electricity Generated
</div>
<div className="legend">
<IgrLegend
ref={this.legendRef}
orientation="Horizontal">
</IgrLegend>
</div>
<div className="container fill">
<IgrCategoryChart
ref={this.chartRef}
computedPlotAreaMarginMode="Series"
dataSource={this.countryRenewableElectricity}
includedProperties={["year", "europe", "china", "america"]}
chartType="Line"
legend={this.legend}
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
xAxisStroke="rgba(145, 145, 145, 1)"
xAxisStrokeThickness="2"
xAxisInterval="1"
xAxisMajorStroke="rgba(71, 71, 71, 1)"
xAxisMajorStrokeThickness="0.5"
yAxisStroke="gray"
yAxisStrokeThickness="2"
yAxisInterval="20"
yAxisMajorStroke="darkslategray"
yAxisMajorStrokeThickness="1"
yAxisMinorInterval="5"
yAxisMinorStroke="gray"
yAxisMinorStrokeThickness="0.5"
thickness="2">
</IgrCategoryChart>
</div>
</div>
);
}
private _countryRenewableElectricity: CountryRenewableElectricity = null;
public get countryRenewableElectricity(): CountryRenewableElectricity {
if (this._countryRenewableElectricity == null)
{
this._countryRenewableElectricity = new CountryRenewableElectricity();
}
return this._countryRenewableElectricity;
}
private _componentRenderer: ComponentRenderer = null;
public get renderer(): ComponentRenderer {
if (this._componentRenderer == null) {
this._componentRenderer = new ComponentRenderer();
var context = this._componentRenderer.context;
PropertyEditorPanelDescriptionModule.register(context);
LegendDescriptionModule.register(context);
CategoryChartDescriptionModule.register(context);
}
return this._componentRenderer;
}
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
このサンプルが気に入りましたか? 完全な Ignite UI for Reactツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
React 軸グリッド線のプロパティ
軸間隔プロパティを設定すると、主グリッド線と軸ラベルが軸に描画される頻度を指定します。同様に、軸副間隔のプロパティは副グリッド線が軸に描画される頻度を指定します。
副間隔に対応する副グリッド線を表示するには、軸に xAxisMinorStroke
と xAxisMinorStrokeThickness
プロパティを設定する必要があります。これは、副グリッド線にはデフォルトの色または太さがなく、最初に割り当てるまで表示されないためです。
以下のプロパティを設定して、React チャートでのグリッド線の表示をカスタマイズできます。
軸ビジュアル | タイプ | プロパティ名 | 説明 |
---|---|---|---|
主なストロークの色 | 文字列 | xAxisMajorStroke yAxisMajorStroke |
これらのプロパティは、軸の主グリッド線の色を設定します。 |
副ストロークの色 | 文字列 | xAxisMinorStroke yAxisMinorStroke |
これらのプロパティは、軸の副グリッド線の色を設定します。 |
主なストロークの太さ | 数 | xAxisMajorStrokeThickness yAxisMajorStrokeThickness |
これらのプロパティは、軸の主グリッド線の太さをピクセル単位で設定します。 |
副ストロークの太さ | 数 | xAxisMinorStrokeThickness yAxisMinorStrokeThickness |
これらのプロパティは、軸の副グリッド線の太さをピクセル単位で設定します。 |
主間隔 | 数 | xAxisInterval yAxisInterval |
これらのプロパティは、軸の主グリッド線とラベルの間隔を設定します。 |
副間隔 | 数 | xAxisMinorInterval yAxisMinorInterval |
これらのプロパティは、軸の副グリッド線の間隔を設定します (使用する場合)。 |
軸線のストローク色 | 文字列 | xAxisStroke yAxisStroke |
これらのプロパティは、軸線の色を設定します。 |
軸のストロークの太さ | 数 | xAxisStrokeThickness yAxisStrokeThickness |
これらのプロパティは、軸線のピクセル単位の太さを設定します。 |
上記のテーブルの主間隔と副間隔については、軸ラベルの主間隔も、この値によって設定され、間隔に関連付けられた軸のポイントにラベルが 1 つ表示されることに注意してください。副間隔グリッド線は常に主グリッド線の間に描画されるため、副間隔プロパティは常に主間隔プロパティの値よりもはるかに小さい値 (通常は 2〜5 倍小さい値) に設定する必要があります。
カテゴリ軸では、間隔は、最初の項目から最後のカテゴリ項目の範囲のインデックスとして表されます。通常、この値は、主間隔のカテゴリ項目の合計数の 10~20% に相当します。その結果、すべての軸ラベルは軸にフィットし、他の軸ラベルによって切り取られることはありません。副間隔の場合、主間隔プロパティの一部として表されます。通常、この値の範囲は 0.25~0.5 です。
数値軸では、間隔値は軸の最小値と最大値の間の double 値として表されます。数値軸はデフォルトで、軸の最小値および最大値から四捨五入されたバランスの良い数値に、自動的に計算されます。
日付/時刻軸では、この値は軸の最小値から最大値の範囲の時間間隔として表されます。
以下の例は、上記のプロパティを設定してグリッド線をカスタマイズする方法を示しています。
export class CountryRenewableElectricityItem {
public constructor(init: Partial<CountryRenewableElectricityItem>) {
Object.assign(this, init);
}
public year: string;
public europe: number;
public china: number;
public america: number;
}
export class CountryRenewableElectricity extends Array<CountryRenewableElectricityItem> {
public constructor(items: Array<CountryRenewableElectricityItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new CountryRenewableElectricityItem(
{
year: `2009`,
europe: 34,
china: 21,
america: 19
}),
new CountryRenewableElectricityItem(
{
year: `2010`,
europe: 43,
china: 26,
america: 24
}),
new CountryRenewableElectricityItem(
{
year: `2011`,
europe: 66,
china: 29,
america: 28
}),
new CountryRenewableElectricityItem(
{
year: `2012`,
europe: 69,
china: 32,
america: 26
}),
new CountryRenewableElectricityItem(
{
year: `2013`,
europe: 58,
china: 47,
america: 38
}),
new CountryRenewableElectricityItem(
{
year: `2014`,
europe: 40,
china: 46,
america: 31
}),
new CountryRenewableElectricityItem(
{
year: `2015`,
europe: 78,
china: 50,
america: 19
}),
new CountryRenewableElectricityItem(
{
year: `2016`,
europe: 13,
china: 90,
america: 52
}),
new CountryRenewableElectricityItem(
{
year: `2017`,
europe: 78,
china: 132,
america: 50
}),
new CountryRenewableElectricityItem(
{
year: `2018`,
europe: 40,
china: 134,
america: 34
}),
new CountryRenewableElectricityItem(
{
year: `2018`,
europe: 40,
china: 134,
america: 34
}),
new CountryRenewableElectricityItem(
{
year: `2019`,
europe: 80,
china: 96,
america: 38
}),
];
super(...newItems.slice(0));
}
}
}
tsimport React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrPropertyEditorPanelModule } from "@infragistics/igniteui-react-layouts";
import { IgrLegendModule, IgrCategoryChartModule } from "@infragistics/igniteui-react-charts";
import { IgrLegend, IgrCategoryChart } from "@infragistics/igniteui-react-charts";
import { IgrPropertyEditorPanel, IgrPropertyEditorPropertyDescription } from "@infragistics/igniteui-react-layouts";
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, LegendDescriptionModule, CategoryChartDescriptionModule } from "@infragistics/igniteui-react-core";
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity';
import 'igniteui-webcomponents/themes/light/bootstrap.css';
const mods: any[] = [
IgrPropertyEditorPanelModule,
IgrLegendModule,
IgrCategoryChartModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private legend: IgrLegend
private legendRef(r: IgrLegend) {
this.legend = r;
this.setState({});
}
private propertyEditorPanel1: IgrPropertyEditorPanel
private propertyEditorPanel1Ref(r: IgrPropertyEditorPanel) {
this.propertyEditorPanel1 = r;
this.setState({});
}
private xAxisStroke: IgrPropertyEditorPropertyDescription
private xAxisMajorStroke: IgrPropertyEditorPropertyDescription
private yAxisStroke: IgrPropertyEditorPropertyDescription
private yAxisMajorStroke: IgrPropertyEditorPropertyDescription
private yAxisMinorStroke: IgrPropertyEditorPropertyDescription
private chart: IgrCategoryChart
private chartRef(r: IgrCategoryChart) {
this.chart = r;
this.setState({});
}
constructor(props: any) {
super(props);
this.legendRef = this.legendRef.bind(this);
this.propertyEditorPanel1Ref = this.propertyEditorPanel1Ref.bind(this);
this.chartRef = this.chartRef.bind(this);
}
public render(): JSX.Element {
return (
<div className="container sample">
<div className="options vertical">
<IgrPropertyEditorPanel
componentRenderer={this.renderer}
target={this.chart}
descriptionType="CategoryChart"
isHorizontal="true"
isWrappingEnabled="true"
ref={this.propertyEditorPanel1Ref}>
<IgrPropertyEditorPropertyDescription
propertyPath="XAxisStroke"
name="XAxisStroke"
label="X Axis Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="gray">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="XAxisMajorStroke"
name="XAxisMajorStroke"
label="X Axis Major Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="darkslategray">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="YAxisStroke"
name="YAxisStroke"
label="Y Axis Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="gray">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="YAxisMajorStroke"
name="YAxisMajorStroke"
label="Y Axis Major Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="darkslategray">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="YAxisMinorStroke"
name="YAxisMinorStroke"
label="Y Axis Minor Stroke"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
dropDownValues={["gray", "darkslategray", "salmon", "cornflowerblue", "darkgreen"]}
primitiveValue="gray">
</IgrPropertyEditorPropertyDescription>
</IgrPropertyEditorPanel>
</div>
<div className="legend-title">
Renewable Electricity Generated
</div>
<div className="legend">
<IgrLegend
ref={this.legendRef}
orientation="Horizontal">
</IgrLegend>
</div>
<div className="container fill">
<IgrCategoryChart
ref={this.chartRef}
computedPlotAreaMarginMode="Series"
dataSource={this.countryRenewableElectricity}
includedProperties={["year", "europe", "china", "america"]}
chartType="Line"
legend={this.legend}
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
xAxisStroke="rgba(145, 145, 145, 1)"
xAxisStrokeThickness="2"
xAxisInterval="1"
xAxisMajorStroke="rgba(71, 71, 71, 1)"
xAxisMajorStrokeThickness="0.5"
yAxisStroke="gray"
yAxisStrokeThickness="2"
yAxisInterval="20"
yAxisMajorStroke="darkslategray"
yAxisMajorStrokeThickness="1"
yAxisMinorInterval="5"
yAxisMinorStroke="gray"
yAxisMinorStrokeThickness="0.5"
thickness="2">
</IgrCategoryChart>
</div>
</div>
);
}
private _countryRenewableElectricity: CountryRenewableElectricity = null;
public get countryRenewableElectricity(): CountryRenewableElectricity {
if (this._countryRenewableElectricity == null)
{
this._countryRenewableElectricity = new CountryRenewableElectricity();
}
return this._countryRenewableElectricity;
}
private _componentRenderer: ComponentRenderer = null;
public get renderer(): ComponentRenderer {
if (this._componentRenderer == null) {
this._componentRenderer = new ComponentRenderer();
var context = this._componentRenderer.context;
PropertyEditorPanelDescriptionModule.register(context);
LegendDescriptionModule.register(context);
CategoryChartDescriptionModule.register(context);
}
return this._componentRenderer;
}
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
IgrDataChart
の軸には、それぞれ majorStrokeDashArray
プロパティと minorStrokeDashArray
プロパティを利用して、主グリッド線と副グリッド線にダッシュ配列を配置する機能もあります。対応する軸の strokeDashArray
プロパティを設定することで、実際の軸線も破線にすることができます。これらのプロパティは、対応するグリッド線のダッシュの長さを記述する数値の配列を受け取ります。
次の例は、上記のダッシュ配列プロパティが設定された IgrDataChart
を示しています。
export class CountryRenewableElectricityItem {
public constructor(init: Partial<CountryRenewableElectricityItem>) {
Object.assign(this, init);
}
public year: string;
public europe: number;
public china: number;
public america: number;
}
export class CountryRenewableElectricity extends Array<CountryRenewableElectricityItem> {
public constructor(items: Array<CountryRenewableElectricityItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new CountryRenewableElectricityItem(
{
year: `2009`,
europe: 34,
china: 21,
america: 19
}),
new CountryRenewableElectricityItem(
{
year: `2010`,
europe: 43,
china: 26,
america: 24
}),
new CountryRenewableElectricityItem(
{
year: `2011`,
europe: 66,
china: 29,
america: 28
}),
new CountryRenewableElectricityItem(
{
year: `2012`,
europe: 69,
china: 32,
america: 26
}),
new CountryRenewableElectricityItem(
{
year: `2013`,
europe: 58,
china: 47,
america: 38
}),
new CountryRenewableElectricityItem(
{
year: `2014`,
europe: 40,
china: 46,
america: 31
}),
new CountryRenewableElectricityItem(
{
year: `2015`,
europe: 78,
china: 50,
america: 19
}),
new CountryRenewableElectricityItem(
{
year: `2016`,
europe: 13,
china: 90,
america: 52
}),
new CountryRenewableElectricityItem(
{
year: `2017`,
europe: 78,
china: 132,
america: 50
}),
new CountryRenewableElectricityItem(
{
year: `2018`,
europe: 40,
china: 134,
america: 34
}),
new CountryRenewableElectricityItem(
{
year: `2018`,
europe: 40,
china: 134,
america: 34
}),
new CountryRenewableElectricityItem(
{
year: `2019`,
europe: 80,
china: 96,
america: 38
}),
];
super(...(newItems.slice(0, items)));
}
}
}
tsimport React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrLegendModule, IgrDataChartCategoryModule, IgrDataChartInteractivityModule } from "@infragistics/igniteui-react-charts";
import { IgrLegend, IgrDataChart, IgrCategoryXAxis, IgrNumericYAxis, IgrLineSeries } from "@infragistics/igniteui-react-charts";
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity';
const mods: any[] = [
IgrLegendModule,
IgrDataChartCategoryModule,
IgrDataChartInteractivityModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private legend: IgrLegend
private legendRef(r: IgrLegend) {
this.legend = r;
this.setState({});
}
private chart: IgrDataChart
private chartRef(r: IgrDataChart) {
this.chart = r;
this.setState({});
}
private xAxis: IgrCategoryXAxis
private yAxis: IgrNumericYAxis
private lineSeries1: IgrLineSeries
private lineSeries2: IgrLineSeries
private lineSeries3: IgrLineSeries
constructor(props: any) {
super(props);
this.legendRef = this.legendRef.bind(this);
this.chartRef = this.chartRef.bind(this);
}
public render(): JSX.Element {
return (
<div className="container sample">
<div className="legend-title">
Renewable Electricity Generated
</div>
<div className="legend">
<IgrLegend
ref={this.legendRef}
orientation="Horizontal">
</IgrLegend>
</div>
<div className="container fill">
<IgrDataChart
ref={this.chartRef}
legend={this.legend}
computedPlotAreaMarginMode="Series">
<IgrCategoryXAxis
name="xAxis"
dataSource={this.countryRenewableElectricity}
label="year"
interval="1"
majorStroke="rgba(71, 71, 71, 1)"
majorStrokeThickness="0.5"
stroke="rgba(145, 145, 145, 1)"
strokeThickness="2"
strokeDashArray="5, 5"
majorStrokeDashArray="5, 5"
tickLength="0">
</IgrCategoryXAxis>
<IgrNumericYAxis
name="yAxis"
stroke="gray"
strokeThickness="2"
interval="20"
majorStroke="darkslategray"
majorStrokeThickness="1"
minorInterval="5"
minorStroke="gray"
minorStrokeThickness="0.5"
strokeDashArray="5, 5"
majorStrokeDashArray="5, 5"
minorStrokeDashArray="2.5, 2.5"
tickLength="0">
</IgrNumericYAxis>
<IgrLineSeries
name="LineSeries1"
title="Europe"
xAxisName="xAxis"
yAxisName="yAxis"
markerType="Circle"
dataSource={this.countryRenewableElectricity}
valueMemberPath="europe"
showDefaultTooltip="true">
</IgrLineSeries>
<IgrLineSeries
name="LineSeries2"
title="China"
xAxisName="xAxis"
yAxisName="yAxis"
markerType="Circle"
dataSource={this.countryRenewableElectricity}
valueMemberPath="china"
showDefaultTooltip="true">
</IgrLineSeries>
<IgrLineSeries
name="LineSeries3"
title="America"
xAxisName="xAxis"
yAxisName="yAxis"
markerType="Circle"
dataSource={this.countryRenewableElectricity}
valueMemberPath="america"
showDefaultTooltip="true">
</IgrLineSeries>
</IgrDataChart>
</div>
</div>
);
}
private _countryRenewableElectricity: CountryRenewableElectricity = null;
public get countryRenewableElectricity(): CountryRenewableElectricity {
if (this._countryRenewableElectricity == null)
{
this._countryRenewableElectricity = new CountryRenewableElectricity();
}
return this._countryRenewableElectricity;
}
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
React 軸目盛りの例
軸の目盛りは、xAxisTickLength
と yAxisTickLength
プロパティを 0 より大きい値に設定することで有効になります。これらのプロパティは、目盛りを形成する線セグメントの長さを指定します。
目盛りは常に軸線から伸び、ラベルの方向を指します。ラベルは、重ならないように目盛りの長さの値でオフセットされます。たとえば、yAxisTickLength
プロパティが 5 に設定されている場合、軸ラベルはその量だけ左にシフトされます。
以下の例は、上記のプロパティを設定して目盛りをカスタマイズする方法を示します。
export class CountryRenewableElectricityItem {
public constructor(init: Partial<CountryRenewableElectricityItem>) {
Object.assign(this, init);
}
public year: string;
public europe: number;
public china: number;
public america: number;
}
export class CountryRenewableElectricity extends Array<CountryRenewableElectricityItem> {
public constructor(items: Array<CountryRenewableElectricityItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new CountryRenewableElectricityItem(
{
year: `2009`,
europe: 34,
china: 21,
america: 19
}),
new CountryRenewableElectricityItem(
{
year: `2010`,
europe: 43,
china: 26,
america: 24
}),
new CountryRenewableElectricityItem(
{
year: `2011`,
europe: 66,
china: 29,
america: 28
}),
new CountryRenewableElectricityItem(
{
year: `2012`,
europe: 69,
china: 32,
america: 26
}),
new CountryRenewableElectricityItem(
{
year: `2013`,
europe: 58,
china: 47,
america: 38
}),
new CountryRenewableElectricityItem(
{
year: `2014`,
europe: 40,
china: 46,
america: 31
}),
new CountryRenewableElectricityItem(
{
year: `2015`,
europe: 78,
china: 50,
america: 19
}),
new CountryRenewableElectricityItem(
{
year: `2016`,
europe: 13,
china: 90,
america: 52
}),
new CountryRenewableElectricityItem(
{
year: `2017`,
europe: 78,
china: 132,
america: 50
}),
new CountryRenewableElectricityItem(
{
year: `2018`,
europe: 40,
china: 134,
america: 34
}),
new CountryRenewableElectricityItem(
{
year: `2018`,
europe: 40,
china: 134,
america: 34
}),
new CountryRenewableElectricityItem(
{
year: `2019`,
europe: 80,
china: 96,
america: 38
}),
];
super(...newItems.slice(0));
}
}
}
tsimport React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrPropertyEditorPanelModule } from "@infragistics/igniteui-react-layouts";
import { IgrLegendModule, IgrCategoryChartModule } from "@infragistics/igniteui-react-charts";
import { IgrLegend, IgrCategoryChart } from "@infragistics/igniteui-react-charts";
import { IgrPropertyEditorPanel, IgrPropertyEditorPropertyDescription } from "@infragistics/igniteui-react-layouts";
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, LegendDescriptionModule, CategoryChartDescriptionModule } from "@infragistics/igniteui-react-core";
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity';
import 'igniteui-webcomponents/themes/light/bootstrap.css';
const mods: any[] = [
IgrPropertyEditorPanelModule,
IgrLegendModule,
IgrCategoryChartModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private legend: IgrLegend
private legendRef(r: IgrLegend) {
this.legend = r;
this.setState({});
}
private propertyEditorPanel1: IgrPropertyEditorPanel
private propertyEditorPanel1Ref(r: IgrPropertyEditorPanel) {
this.propertyEditorPanel1 = r;
this.setState({});
}
private xAxisTickLength: IgrPropertyEditorPropertyDescription
private chart: IgrCategoryChart
private chartRef(r: IgrCategoryChart) {
this.chart = r;
this.setState({});
}
constructor(props: any) {
super(props);
this.legendRef = this.legendRef.bind(this);
this.propertyEditorPanel1Ref = this.propertyEditorPanel1Ref.bind(this);
this.chartRef = this.chartRef.bind(this);
}
public render(): JSX.Element {
return (
<div className="container sample">
<div className="options vertical">
<IgrPropertyEditorPanel
componentRenderer={this.renderer}
target={this.chart}
descriptionType="CategoryChart"
isHorizontal="true"
isWrappingEnabled="true"
ref={this.propertyEditorPanel1Ref}>
<IgrPropertyEditorPropertyDescription
propertyPath="XAxisTickLength"
name="XAxisTickLength"
label="X Axis Tick Length"
shouldOverrideDefaultEditor="true"
valueType="Slider"
min="0"
max="20"
primitiveValue="10">
</IgrPropertyEditorPropertyDescription>
</IgrPropertyEditorPanel>
</div>
<div className="legend-title">
Renewable Electricity Generated
</div>
<div className="legend">
<IgrLegend
ref={this.legendRef}
orientation="Horizontal">
</IgrLegend>
</div>
<div className="container fill">
<IgrCategoryChart
ref={this.chartRef}
dataSource={this.countryRenewableElectricity}
includedProperties={["year", "europe", "china", "america"]}
legend={this.legend}
chartType="Line"
computedPlotAreaMarginMode="Series"
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
xAxisTickLength="10"
xAxisTickStrokeThickness="1"
xAxisTickStroke="gray"
yAxisTickLength="0"
yAxisTickStrokeThickness="0"
yAxisTickStroke="rgba(0, 0, 0, 0)">
</IgrCategoryChart>
</div>
</div>
);
}
private _countryRenewableElectricity: CountryRenewableElectricity = null;
public get countryRenewableElectricity(): CountryRenewableElectricity {
if (this._countryRenewableElectricity == null)
{
this._countryRenewableElectricity = new CountryRenewableElectricity();
}
return this._countryRenewableElectricity;
}
private _componentRenderer: ComponentRenderer = null;
public get renderer(): ComponentRenderer {
if (this._componentRenderer == null) {
this._componentRenderer = new ComponentRenderer();
var context = this._componentRenderer.context;
PropertyEditorPanelDescriptionModule.register(context);
LegendDescriptionModule.register(context);
CategoryChartDescriptionModule.register(context);
}
return this._componentRenderer;
}
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample/>);
tsx/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
React 軸目盛りのプロパティ
以下のプロパティを設定して、React チャートで軸の目盛りの表示方法をカスタマイズできます。
軸ビジュアル | タイプ | プロパティ名 | 説明 |
---|---|---|---|
目盛りストロークの色 | 文字列 | xAxisTickStroke yAxisTickStroke |
これらのプロパティは、目盛りの色を設定します。 |
目盛りストロークの太さ | 数 | xAxisTickStrokeThickness yAxisTickStrokeThickness |
これらのプロパティは、軸の目盛りの太さを設定します。 |
目盛りストロークの長さ | 数 | xAxisTickLength yAxisTickLength |
これらのプロパティは、軸の目盛りの長さを設定します。 |
その他のリソース
関連するチャート機能の詳細については、以下のトピックを参照してください。
API リファレンス
以下は、上記のセクションで説明されている API メンバーのリストです。