React 축 그리드라인
모든 Ignite UI for React 차트에는 X축과 Y축에 렌더링되는 축 선의 모양은 물론 주요/보조 격자선과 눈금 표시의 빈도를 수정하는 기본 기능이 포함되어 있습니다.
다음 예제는 IgrCategoryChart 및 IgrFinancialChart 컨트롤에 적용될 수 있습니다.
축 주요 눈금선은 축 레이블 위치에서 Y축을 따라 수평으로 또는 X축을 따라 수직으로 확장되는 긴 선이며 차트의 그림 영역을 통해 렌더링됩니다. 축 보조 격자선은 축 주요 격자선 사이에 렌더링되는 선입니다.
축 눈금 표시는 React 차트의 모든 주요 선 위치에 있는 각 레이블의 모든 수평 및 수직 축을 따라 표시됩니다.
React Axis Gridlines 예제
이 예에서는 지정된 간격으로 주요 격자선과 보조 격자선을 표시하도록 축 격자선을 구성하는 방법을 보여줍니다.
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 Axis Gridlines 속성
축 간격 속성을 설정하면 주요 눈금선과 축 레이블이 축에 렌더링되는 빈도를 지정합니다. 마찬가지로 축 보조 간격 속성은 축에서 보조 격자선이 렌더링되는 빈도를 지정합니다.
보조 간격에 해당하는 보조 격자선을 표시하려면 축에 xAxisMinorStroke
및 xAxisMinorStrokeThickness
속성을 설정해야 합니다. 보조 눈금선에는 기본 색상이나 두께가 없으며 먼저 지정하지 않으면 표시되지 않기 때문입니다.
다음 속성을 설정하여 React 차트에서 격자선이 표시되는 방식을 사용자 정의할 수 있습니다.
축 비주얼 | 유형 | 속성 이름 | 설명 |
---|---|---|---|
주요 획 색상 | 끈 | xAxisMajorStroke yAxisMajorStroke |
이러한 속성은 축 주요 눈금선의 색상을 설정합니다. |
보조 획 색상 | 끈 | xAxisMinorStroke yAxisMinorStroke |
이러한 속성은 축 보조 격자선의 색상을 설정합니다. |
주요 스트로크 두께 | 숫자 | xAxisMajorStrokeThickness yAxisMajorStrokeThickness |
이러한 속성은 축 주요 격자선의 두께를 픽셀 단위로 설정합니다. |
작은 스트로크 두께 | 숫자 | xAxisMinorStrokeThickness yAxisMinorStrokeThickness |
이러한 속성은 축 보조 격자선의 두께를 픽셀 단위로 설정합니다. |
주요 간격 | 숫자 | xAxisInterval yAxisInterval |
이러한 속성은 축 주요 눈금선과 레이블 사이의 간격을 설정합니다. |
마이너 간격 | 숫자 | xAxisMinorInterval yAxisMinorInterval |
이러한 속성은 사용되는 경우 축 보조 격자선 사이의 간격을 설정합니다. |
축 선 획 색상 | 끈 | xAxisStroke yAxisStroke |
이 속성은 축 선의 색상을 설정합니다. |
축 스트로크 두께 | 숫자 | xAxisStrokeThickness yAxisStrokeThickness |
이러한 속성은 축 선의 두께를 픽셀 단위로 설정합니다. |
위 표의 주요 및 보조 간격과 관련하여 축 레이블의 주요 간격도 이 값으로 설정되어 간격과 관련된 축의 지점에 하나의 레이블이 표시된다는 점에 유의하는 것이 중요합니다. 보조 간격 눈금선은 항상 주요 눈금선 사이에 렌더링되므로 보조 간격 속성은 항상 주요 간격 속성 값보다 훨씬 작은 값(보통 2-5배 작은 값)으로 설정되어야 합니다.
범주 축에서 간격은 첫 번째 항목과 마지막 범주 항목 사이의 인덱스로 표시됩니다. 일반적으로 이 값은 모든 축 레이블이 다른 축 레이블에 의해 잘리지 않도록 모든 축 레이블이 축에 맞도록 주요 간격에 대한 총 범주 항목 수의 10-20%와 같아야 합니다. 작은 간격의 경우 이는 주요 간격 속성의 일부로 표시됩니다. 이 값은 일반적으로 0.25에서 0.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 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 Axis Tickmarks 예제
축 눈금 표시는 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 멤버 목록입니다.