React 축 옵션
모든 Ignite UI for 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 { IgrLegendModule, IgrCategoryChartModule } from "@infragistics/igniteui-react-charts";
import { IgrLegend, IgrCategoryChart } from "@infragistics/igniteui-react-charts";
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity';
const mods: any[] = [
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 chart: IgrCategoryChart
private chartRef(r: IgrCategoryChart) {
this.chart = r;
this.setState({});
}
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">
<IgrCategoryChart
ref={this.chartRef}
dataSource={this.countryRenewableElectricity}
includedProperties={["year", "europe", "china", "america"]}
chartType="Line"
legend={this.legend}
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
computedPlotAreaMarginMode="Series"
xAxisTitle="Year"
xAxisTitleTextColor="gray"
xAxisTitleTextStyle="10pt 'Titillium Web'"
xAxisTitleAngle="0"
yAxisTitle="Trillions of Watt-hours (Twh)"
yAxisTitleTextColor="gray"
yAxisTitleTextStyle="10pt 'Titillium Web'"
yAxisTitleAngle="90"
yAxisTitleLeftMargin="5">
</IgrCategoryChart>
</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
이 샘플이 마음에 드시나요? Ignite UI for React 전체에 액세스하고 몇 분 만에 나만의 앱을 빌드하기 시작하세요. 무료로 다운로드하세요.
축 레이블 예
React Charts를 사용하면 차트의 축에 표시된 레이블의 글꼴을 구성, 서식 지정 및 스타일링하는 데 대한 완전한 제어가 가능합니다. 축 레이블의 회전 각도, 여백, 수평 및 수직 정렬, 색상, 패딩 및 가시성을 변경할 수 있습니다. 다음 예는 축의 이러한 기능을 사용하는 방법을 보여줍니다.
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 xAxisLabelAngleEditor: IgrPropertyEditorPropertyDescription
private yAxisLabelAngleEditor: IgrPropertyEditorPropertyDescription
private xAxisLabelTextColorEditor: 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="XAxisLabelAngle"
name="XAxisLabelAngleEditor"
label="X Axis Label Angle"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["0", "45", "90", "135", "180", "225", "270"]}
dropDownValues={["0", "45", "90", "135", "180", "225", "270"]}
primitiveValue="0">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="YAxisLabelAngle"
name="YAxisLabelAngleEditor"
label="Y Axis Label Angle"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["-90", "-45", "0", "45", "90"]}
dropDownValues={["-90", "-45", "0", "45", "90"]}
primitiveValue="0">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="XAxisLabelTextColor"
name="XAxisLabelTextColorEditor"
label="Y Axis Label Color"
valueType="EnumValue"
shouldOverrideDefaultEditor="true"
dropDownNames={["red", "green"]}
dropDownValues={["red", "green"]}
primitiveValue="red">
</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"]}
chartType="Line"
computedPlotAreaMarginMode="Series"
legend={this.legend}
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
topMargin="20"
xAxisLabelAngle="0"
xAxisLabelTextColor="gray"
xAxisLabelTextStyle="10pt 'Titillium Web'"
xAxisLabelTopMargin="5"
yAxisLabelAngle="0"
yAxisLabelTextColor="gray"
yAxisLabelTextStyle="10pt 'Titillium Web'"
yAxisLabelRightMargin="5"
yAxisLabelLocation="OutsideRight"
titleTopMargin="10">
</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
Axis 라벨 관리 & 포맷
차트의 축에는 소유 축의 레이블에 사용할 수 있는 공간의 양에 관해 향상된 계산을 수행하는 기능이 있습니다. 이 향상된 계산을 통해 축은 주어진 축에 대해 더 많은 레이블을 표시하기 위해 주어진 공간의 양을 최적화할 수 있습니다.
이 향상된 계산은 사용자가 선택해야 하는 작업으로, useEnhancedIntervalManagement
속성을 true로 설정하여 수행할 수 있습니다. 그런 다음 축의 interval
속성을 수동으로 설정하지 않고 축의 크기에 맞출 수 있는 만큼 많은 레이블을 표시하려는 경우 축의 enhancedIntervalPreferMoreCategoryLabels
속성을 true로 설정할 수 있습니다.
또한 차트에는 할당된 공간에 맞지 않는 경우 레이블의 자동 회전을 고려하는 기능과 레이블이 들어갈 수 있도록 플롯 영역에 자동 여백을 적용하는 기능도 있습니다. 이는 먼저 차트의 autoMarginAndAngleUpdateMode
속성을 SizeChanging
또는 SizeChangingAndZoom
으로 설정하여 처음에 선택할 수 있는 것입니다. 원하는 경우 레이블에 적용된 자동 여백과 각도를 언제 재평가할지 차트에 알려줍니다.
autoMarginAndAngleUpdateMode
설정한 후 shouldAutoExpandMarginForInitialLabels
속성을 true로 설정하여 자동 여백을 선택하거나 자동 회전을 위해 shouldConsiderAutoRotationForInitialLabels
속성을 true로 설정할 수 있습니다. autoExpandMarginExtraPadding
및 autoExpandMarginMaximumValue
를 설정하여 각각 추가 공간 또는 가능한 최대 여백을 제공함으로써 적용되는 자동 여백을 추가로 사용자 정의할 수도 있습니다.
다음과 같은 사용자 지정 레이블 형식 IgrNumberFormatSpecifier
그리고 IgrDateTimeFormatSpecifier
를 통해 각 축에 추가할 수 있습니다. XAxisLabelFormatSpecifier
그리고 YAxisLabelFormatSpecifier
컬렉션. 일반적으로 Intl.NumberFormat 및 Intl.DateTimeFormat 언어에 민감한 숫자, 날짜 및 시간 형식을 적용하는 데 사용됩니다. 사용자 지정 형식을 레이블에 적용하려면 yAxisLabelFormat
또는 xAxisLabelFormat
에서 데이터 항목의 속성 이름으로 설정해야 합니다. IgrCategoryChart
예. {Date}
. 에 대한 IgrFinancialChart
숫자는 숫자 축을 사용하기 때문에 컨텍스트이므로 다음과 같이 설정해야 합니다. {0}
.
다음 예에서는 미국 최고의 박스오피스 영화에 대한 $USD 가격을 나타내기 위해 IgrNumberFormatSpecifier
를 사용하여 yAxis의 형식을 지정합니다.
export class HighestGrossingMoviesItem {
public constructor(init: Partial<HighestGrossingMoviesItem>) {
Object.assign(this, init);
}
public franchise: string;
public totalRevenue: number;
public highestGrossing: number;
}
export class HighestGrossingMovies extends Array<HighestGrossingMoviesItem> {
public constructor(items: Array<HighestGrossingMoviesItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new HighestGrossingMoviesItem(
{
franchise: `Marvel Universe`,
totalRevenue: 22.55,
highestGrossing: 2.8
}),
new HighestGrossingMoviesItem(
{
franchise: `Star Wars`,
totalRevenue: 10.32,
highestGrossing: 2.07
}),
new HighestGrossingMoviesItem(
{
franchise: `Harry Potter`,
totalRevenue: 9.19,
highestGrossing: 1.34
}),
new HighestGrossingMoviesItem(
{
franchise: `Avengers`,
totalRevenue: 7.76,
highestGrossing: 2.8
}),
new HighestGrossingMoviesItem(
{
franchise: `Spider Man`,
totalRevenue: 7.22,
highestGrossing: 1.28
}),
new HighestGrossingMoviesItem(
{
franchise: `James Bond`,
totalRevenue: 7.12,
highestGrossing: 1.11
}),
];
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 { IgrDataLegendModule, IgrCategoryChartModule } from "@infragistics/igniteui-react-charts";
import { IgrNumberFormatSpecifierModule } from "@infragistics/igniteui-react-core";
import { IgrDataLegend, IgrCategoryChart } from "@infragistics/igniteui-react-charts";
import { IgrNumberFormatSpecifier } from "@infragistics/igniteui-react-core";
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, DataLegendDescriptionModule, CategoryChartDescriptionModule, NumberFormatSpecifierDescriptionModule } from "@infragistics/igniteui-react-core";
import { HighestGrossingMoviesItem, HighestGrossingMovies } from './HighestGrossingMovies';
const mods: any[] = [
IgrPropertyEditorPanelModule,
IgrDataLegendModule,
IgrCategoryChartModule,
IgrNumberFormatSpecifierModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component<any, any> {
private legend: IgrDataLegend
private legendRef(r: IgrDataLegend) {
this.legend = r;
this.setState({});
}
private _numberFormatSpecifier1: IgrNumberFormatSpecifier[] | null = null;
public get numberFormatSpecifier1(): IgrNumberFormatSpecifier[] {
if (this._numberFormatSpecifier1 == null)
{
let numberFormatSpecifier1: IgrNumberFormatSpecifier[] = [];
var numberFormatSpecifier2 = new IgrNumberFormatSpecifier();
numberFormatSpecifier2.style = "currency";
numberFormatSpecifier2.currency = "USD";
numberFormatSpecifier2.currencyDisplay = "symbol";
numberFormatSpecifier2.maximumFractionDigits = 2;
numberFormatSpecifier2.minimumFractionDigits = 2;
numberFormatSpecifier1.push(numberFormatSpecifier2)
this._numberFormatSpecifier1 = numberFormatSpecifier1;
}
return this._numberFormatSpecifier1;
}
private chart: IgrCategoryChart
private chartRef(r: IgrCategoryChart) {
this.chart = r;
this.setState({});
}
private _numberFormatSpecifier3: IgrNumberFormatSpecifier[] | null = null;
public get numberFormatSpecifier3(): IgrNumberFormatSpecifier[] {
if (this._numberFormatSpecifier3 == null)
{
let numberFormatSpecifier3: IgrNumberFormatSpecifier[] = [];
var numberFormatSpecifier4 = new IgrNumberFormatSpecifier();
numberFormatSpecifier4.style = "currency";
numberFormatSpecifier4.currency = "USD";
numberFormatSpecifier4.currencyDisplay = "symbol";
numberFormatSpecifier4.maximumFractionDigits = 2;
numberFormatSpecifier4.minimumFractionDigits = 2;
numberFormatSpecifier3.push(numberFormatSpecifier4)
this._numberFormatSpecifier3 = numberFormatSpecifier3;
}
return this._numberFormatSpecifier3;
}
private _numberFormatSpecifier5: IgrNumberFormatSpecifier[] | null = null;
public get numberFormatSpecifier5(): IgrNumberFormatSpecifier[] {
if (this._numberFormatSpecifier5 == null)
{
let numberFormatSpecifier5: IgrNumberFormatSpecifier[] = [];
var numberFormatSpecifier6 = new IgrNumberFormatSpecifier();
numberFormatSpecifier6.style = "currency";
numberFormatSpecifier6.currency = "USD";
numberFormatSpecifier6.currencyDisplay = "symbol";
numberFormatSpecifier6.minimumFractionDigits = 0;
numberFormatSpecifier5.push(numberFormatSpecifier6)
this._numberFormatSpecifier5 = numberFormatSpecifier5;
}
return this._numberFormatSpecifier5;
}
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">
Highest Grossing Movie Franchises
</div>
<div className="legend">
<IgrDataLegend
ref={this.legendRef}
target={this.chart}
valueFormatString="{0} Billion"
valueFormatSpecifiers={this.numberFormatSpecifier1}>
</IgrDataLegend>
</div>
<div className="container fill">
<IgrCategoryChart
ref={this.chartRef}
dataSource={this.highestGrossingMovies}
chartType="Column"
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
finalValueAnnotationsPrecision="2"
dataToolTipValueFormatString="{0} Billion"
dataToolTipValueFormatSpecifiers={this.numberFormatSpecifier3}
yAxisLabelFormat="{0}B"
yAxisLabelFormatSpecifiers={this.numberFormatSpecifier5}>
</IgrCategoryChart>
</div>
</div>
);
}
private _highestGrossingMovies: HighestGrossingMovies = null;
public get highestGrossingMovies(): HighestGrossingMovies {
if (this._highestGrossingMovies == null)
{
this._highestGrossingMovies = new HighestGrossingMovies();
}
return this._highestGrossingMovies;
}
private _componentRenderer: ComponentRenderer = null;
public get renderer(): ComponentRenderer {
if (this._componentRenderer == null) {
this._componentRenderer = new ComponentRenderer();
var context = this._componentRenderer.context;
PropertyEditorPanelDescriptionModule.register(context);
DataLegendDescriptionModule.register(context);
CategoryChartDescriptionModule.register(context);
NumberFormatSpecifierDescriptionModule.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 차트에서 숫자 또는 시간 축의 범위 최소값과 범위 최대값을 정의할 수 있습니다. 범위 최소값은 축의 가장 낮은 값이고 범위 최대값은 축의 가장 높은 값입니다. 이는 yAxisMinimumValue
및 yAxisMaximumValue
옵션을 설정하여 설정합니다.
기본적으로 차트는 데이터의 해당 최저 및 최고 값 포인트를 기반으로 숫자 및 시간 축 범위의 최소값과 최대값을 계산하지만 이 자동 계산은 모든 경우에 데이터 포인트 세트에 적합하지 않을 수 있습니다. 예를 들어, 데이터의 최소값이 850인 경우 yAxisMinimumValue
를 800으로 설정하여 축 최소값과 데이터 포인트의 최저값 사이에 공백 값 50이 있도록 할 수 있습니다. yAxisMaximumValue
속성을 사용하여 데이터 포인트의 축 최소값과 최대값에 동일한 아이디어를 적용할 수 있습니다.
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 { IgrPropertyEditorPropertyDescriptionChangedEventArgs } from "@infragistics/igniteui-react-layouts";
import { MarkerType, MarkerType_$type } from "@infragistics/igniteui-react-charts";
import { EnumUtil } from "@infragistics/igniteui-react-core";
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 yAxisMinimumValue: IgrPropertyEditorPropertyDescription
private yAxisMaximumValue: 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.editorChangeUpdateYAxisMinimumValue = this.editorChangeUpdateYAxisMinimumValue.bind(this);
this.editorChangeUpdateYAxisMaximumValue = this.editorChangeUpdateYAxisMaximumValue.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="YAxisMinimumValueHandler"
name="YAxisMinimumValue"
label="Y Axis Minimum Value"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"]}
dropDownValues={["0", "10", "20", "30", "40", "50", "60", "70", "80", "90", "100"]}
primitiveValue="0"
changed={this.editorChangeUpdateYAxisMinimumValue}>
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="YAxisMaximumValueHandler"
name="YAxisMaximumValue"
label="Y Axis Maximum Value"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["100", "110", "120", "130", "140", "150", "160", "170", "180", "190", "200"]}
dropDownValues={["100", "110", "120", "130", "140", "150", "160", "170", "180", "190", "200"]}
primitiveValue="150"
changed={this.editorChangeUpdateYAxisMaximumValue}>
</IgrPropertyEditorPropertyDescription>
</IgrPropertyEditorPanel>
</div>
<div className="legend-title">
Highest Grossing Movie Franchises
</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"
yAxisMinimumValue="0"
yAxisMaximumValue="150">
</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;
}
public editorChangeUpdateYAxisMinimumValue(sender: any, args: IgrPropertyEditorPropertyDescriptionChangedEventArgs): void {
var yAxisMinimumVal = args.newValue;
this.chart.yAxisMinimumValue = parseInt(yAxisMinimumVal);
}
public editorChangeUpdateYAxisMaximumValue(sender: any, args: IgrPropertyEditorPropertyDescriptionChangedEventArgs): void {
var yAxisMaximumVal = args.newValue;
this.chart.yAxisMaximumValue = parseInt(yAxisMaximumVal);
}
}
// 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
축 모드 및 배율
IgrFinancialChart
및 IgrCategoryChart
컨트롤에서는 yAxisIsLogarithmic
속성이 true로 설정된 경우 데이터가 y축을 따라 로그 눈금으로 표시되는지, 이 속성이 false(기본값)로 설정된 경우 선형 눈금으로 표시되는지 선택할 수 있습니다. yAxisLogarithmBase
속성을 사용하면 로그 스케일의 기준을 기본값 10에서 다른 정수 값으로 변경할 수 있습니다.
IgrFinancialChart
및 컨트롤을 사용하면 Numeric
및 PercentChange
모드를 제공하는 yAxisMode
속성을 사용하여 y축을 따라 데이터가 표시되는 방식을 선택할 수 있습니다. Numeric
모드는 정확한 값으로 데이터를 표시하는 반면 PercentChange
모드는 제공된 첫 번째 데이터 포인트에 대한 백분율 변화로 데이터를 표시합니다. 기본값은 Numeric
모드입니다.
yAxisMode
속성 외에도 IgrFinancialChart
컨트롤에는 x축에 대한 Time
및 Ordinal
모드를 제공하는 xAxisMode
속성이 있습니다. Time
모드는 데이터의 공백을 위해 x축을 따라 공간을 렌더링합니다(예: 주말이나 공휴일에는 주식 거래가 없음). Ordinal
모드는 데이터가 존재하지 않는 날짜 영역을 축소합니다. 기본값은 Ordinal
모드입니다.
export class StocksUtility {
public static intervalDays: number = 1;
public static intervalHours: number = 0;
public static intervalMinutes: number = 0;
public static priceStart: number = 200;
public static priceRange: number = 1;
public static volumeRange: number = 1000;
public static volumeStart: number = 20000000;
public static GetStocksFrom(dateEnd: Date, years: number): any {
const dateStart = this.AddYears(dateEnd, -years);
return this.GetStocksBetween(dateStart, dateEnd);
}
public static GetStocksItems(points: number): any {
this.intervalDays = 0;
this.intervalHours = 1;
this.intervalMinutes = 0;
const today = new Date();
const year = today.getFullYear();
const dateEnd = new Date(year, 11, 1);
const dateStart = this.AddHours(dateEnd, -points);
return this.GetStocksBetween(dateStart, dateEnd);
}
public static GetStocksBetween(dateStart: Date, dateEnd: Date): any {
let interval = this.intervalDays * 24 * 60;
interval += this.intervalHours * 60;
interval += this.intervalMinutes;
let time = this.AddDays(dateStart, 0);
let v = this.volumeStart;
let o = this.priceStart;
let h = o + (Math.random() * this.priceRange);
let l = o - (Math.random() * this.priceRange);
let c = l + (Math.random() * (h - l));
const stock = [];
while (time.getTime() < dateEnd.getTime()) {
stock.push({ date: time, open: o, high: h, low: l, close: c, volume: v });
o = c + ((Math.random() - 0.5) * this.priceRange);
if (o < 0) {
o = Math.abs(o) + 2;
}
h = o + (Math.random() * this.priceRange);
l = o - (Math.random() * this.priceRange);
c = l + (Math.random() * (h - l));
v = v + ((Math.random() - 0.5) * this.volumeRange);
if (v < 0) {
v = Math.abs(v) + 10000;
}
o = Math.round(o * 100) / 100;
h = Math.round(h * 100) / 100;
l = Math.round(l * 100) / 100;
c = Math.round(c * 100) / 100;
v = Math.round(v * 100) / 100;
time = this.AddMinutes(time, interval);
}
// setting data intent for Series Title
(stock as any).__dataIntents = {
close: ["SeriesTitle/Stock Prices"]
};
return stock;
}
public static AddMinutes(date: Date, minutes: number): Date {
return new Date(date.getTime() + minutes * 60 * 1000);
}
public static AddHours(date: Date, hours: number): Date {
return new Date(date.getTime() + hours * 60 * 60 * 1000);
}
public static AddDays(date: Date, days: number): Date {
return new Date(date.getTime() + days * 24 * 60 * 60 * 1000);
}
public static AddYears(date: Date, years: number): Date {
return new Date(date.getFullYear() + years, date.getMonth(), date.getDate());
}
public static toShortString(largeValue: number): string {
let roundValue: number;
if (largeValue >= 1000000) {
roundValue = Math.round(largeValue / 100000) / 10;
return roundValue + "M";
}
if (largeValue >= 1000) {
roundValue = Math.round(largeValue / 100) / 10;
return roundValue + "K";
}
roundValue = Math.round(largeValue);
return roundValue + "";
}
public static GetYear(date: Date): number {
return date.getFullYear();
}
public static GetQuarter(date: Date): number {
const month = date.getMonth();
return Math.round((month + 2) / 3);
}
public static GetLastItem(array: any[]): any {
if (array.length === 0) {
return null;
}
return array[array.length - 1];
}
public static GetNewItem(array: any[], interval?: number): any {
const lastItem = this.GetLastItem(array);
if (interval === undefined) {
interval = this.intervalDays * 24 * 60;
interval += this.intervalHours * 60;
interval += this.intervalMinutes;
}
const time = this.AddMinutes(lastItem.date, interval);
let v = lastItem.volume;
let o = lastItem.open;
let h = lastItem.high;
let l = lastItem.low;
let c = lastItem.close;
o = c + ((Math.random() - 0.5) * this.priceRange);
if (o < 0) {
o = Math.abs(o) + 2;
}
h = o + (Math.random() * this.priceRange);
l = o - (Math.random() * this.priceRange);
c = l + (Math.random() * (h - l));
v = v + ((Math.random() - 0.5) * this.volumeRange);
if (v < 0) {
v = Math.abs(v) + 10000;
}
const newValue = { date: time, open: o, high: h, low: l, close: c, volume: v };
return newValue;
}
}
tsimport React from 'react';
import ReactDOM from 'react-dom/client';
import './index.css';
import { IgrFinancialChart } from "@infragistics/igniteui-react-charts";
import { IgrFinancialChartModule } from "@infragistics/igniteui-react-charts";
import { StocksUtility } from './StocksUtility';
IgrFinancialChartModule.register();
export default class FinancialChartAxisTypes extends React.Component<any, any> {
public data: any[];
constructor(props: any) {
super(props);
this.state = { xAxisMode: "Ordinal", yAxisMode: "Numeric", yAxisIsLogarithmic: false }
this.initData();
}
public render(): JSX.Element {
return (
<div className="container sample" >
<div className="options horizontal">
<label className="options-label">X-Axis Mode:</label>
<select value={this.state.xAxisMode}
onChange={this.onXAxisModeChanged}>
<option>Ordinal</option>
<option>Time</option>
</select>
<label className="options-label">Y-Axis Mode:</label>
<select value={this.state.yAxisMode}
onChange={this.onYAxisModeChanged}>
<option>PercentChange</option>
<option>Numeric</option>
</select>
<label className="options-item">
<input type="checkbox"
checked={this.state.yAxisIsLogarithmic}
onChange={this.onYAxisIsLogarithmicChanged}/> Y-Axis IsLogarithmic
</label>
</div>
<div className="container" style={{height: "calc(100% - 65px)"}}>
<IgrFinancialChart
width="100%"
height="100%"
xAxisMode={this.state.xAxisMode}
yAxisMode={this.state.yAxisMode}
yAxisIsLogarithmic={this.state.yAxisIsLogarithmic}
chartType="Candle"
dataSource={this.data}/>
</div>
</div>
);
}
public onXAxisModeChanged = (e: any) =>{
const mode = e.target.value;
this.setState({xAxisMode: mode});
}
public onYAxisModeChanged = (e: any) =>{
const mode = e.target.value;
this.setState({yAxisMode: mode});
}
public onYAxisIsLogarithmicChanged = (e: any) => {
const setValue = e.target.checked;
this.setState({yAxisIsLogarithmic: setValue});
}
public initData() {
const today = new Date();
const year = today.getFullYear();
const month = today.getMonth();
const dateEnd = new Date(year, month, 1);
const dateStart = new Date(year - 1, month, 1);
this.data = StocksUtility.GetStocksBetween(dateStart, dateEnd);
}
}
// rendering above class to the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<FinancialChartAxisTypes/>);
tsx
축 간격 예
React 차트의 xAxisGap
속성은 플롯된 시리즈의 열 또는 막대 사이의 공간 양을 결정합니다. 이 속성은 0.0과 1.0 사이의 숫자 값을 허용합니다. 값은 시리즈 사이의 사용 가능한 픽셀 수에서 갭의 상대적 너비를 나타냅니다. 이 속성을 0으로 설정하면 시리즈 사이에 갭이 렌더링되지 않고, 1로 설정하면 사용 가능한 최대 갭이 렌더링됩니다.
React 차트의 xAxisMaximumGap
속성은 허용할 최대 갭 값을 결정합니다. 이 기본값은 1.0으로 설정되지만 xAxisGap
무엇으로 설정하느냐에 따라 변경될 수 있습니다.
React 차트의 xAxisMinimumGapSize
속성은 가능한 경우 카테고리 간 간격에 사용할 최소 픽셀 양을 결정합니다.
다음 예는 뉴욕시 센트럴 파크의 평균 최대 온도(섭씨)를 보여줍니다. 기둥 차트와 xAxisGap
처음에는 1로 설정되므로 열 사이에 전체 범주의 너비가 있게 됩니다. 이 예에는 간격을 구성할 수 있는 슬라이더가 있어 다양한 값의 역할을 확인할 수 있습니다.
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 { IgrPropertyEditorPanel, IgrPropertyEditorPropertyDescription } from "@infragistics/igniteui-react-layouts";
import { IgrCategoryChart } from "@infragistics/igniteui-react-charts";
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 propertyEditorPanel1: IgrPropertyEditorPanel
private propertyEditorPanel1Ref(r: IgrPropertyEditorPanel) {
this.propertyEditorPanel1 = r;
this.setState({});
}
private xAxisGap: IgrPropertyEditorPropertyDescription
private xAxisMaximumGap: IgrPropertyEditorPropertyDescription
private chart: IgrCategoryChart
private chartRef(r: IgrCategoryChart) {
this.chart = r;
this.setState({});
}
constructor(props: any) {
super(props);
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="XAxisGap"
name="XAxisGap"
label="X Axis - Gap"
shouldOverrideDefaultEditor="true"
valueType="Slider"
primitiveValue="0.5"
min="0"
max="1.5"
step="0.1">
</IgrPropertyEditorPropertyDescription>
<IgrPropertyEditorPropertyDescription
propertyPath="XAxisMaximumGap"
name="XAxisMaximumGap"
label="Maximum Gap"
shouldOverrideDefaultEditor="true"
valueType="EnumValue"
dropDownNames={["1.5", "1.3", "1.0", "0.6", "0.5", "0.4", "0.3", "0.2", "0.1", "0"]}
dropDownValues={["1.5", "1.3", "1.0", "0.6", "0.5", "0.4", "0.3", "0.2", "0.1", "0"]}
primitiveValue="0.5">
</IgrPropertyEditorPropertyDescription>
</IgrPropertyEditorPanel>
</div>
<div className="legend-title">
Renewable Electricity Generated
</div>
<div className="container fill">
<IgrCategoryChart
ref={this.chartRef}
dataSource={this.countryRenewableElectricity}
includedProperties={["year", "europe", "china", "america"]}
chartType="Column"
crosshairsSnapToData="true"
yAxisTitle="TWh"
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
xAxisInterval="1"
xAxisGap="0.5"
xAxisMaximumGap="1.5">
</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 차트의 xAxisOverlap
속성을 사용하면 플롯된 시리즈의 렌더링된 열 또는 막대의 겹침을 설정할 수 있습니다. 이 속성은 -1.0과 1.0 사이의 숫자 값을 허용합니다. 값은 각 시리즈에 할당된 사용 가능한 픽셀 수에서 상대적인 겹침을 나타냅니다. 이 속성을 음수 값(-1.0까지)으로 설정하면 범주가 서로 밀려나서 서로 사이에 간격이 생깁니다. 반대로 이 속성을 양수 값(1.0까지)으로 설정하면 범주가 서로 겹칩니다. 값 1은 차트가 범주를 서로 위에 렌더링하도록 지시합니다.
다음 예에서는 프랜차이즈의 총 세계 박스오피스 수익과 시리즈에서 가장 높은 수익을 올린 영화를 비교하여 전 세계에서 가장 높은 수익을 올린 영화 프랜차이즈를 비교합니다. 기둥 차트와 xAxisOverlap
처음에는 1로 설정되므로 열이 서로 완전히 겹칩니다. 이 예에는 서로 다른 값의 역할을 확인할 수 있도록 겹침을 구성할 수 있는 슬라이더가 있습니다.
export class HighestGrossingMoviesItem {
public constructor(init: Partial<HighestGrossingMoviesItem>) {
Object.assign(this, init);
}
public franchise: string;
public totalRevenue: number;
public highestGrossing: number;
}
export class HighestGrossingMovies extends Array<HighestGrossingMoviesItem> {
public constructor(items: Array<HighestGrossingMoviesItem> | number = -1) {
if (Array.isArray(items)) {
super(...items);
} else {
const newItems = [
new HighestGrossingMoviesItem(
{
franchise: `Marvel Universe`,
totalRevenue: 22.55,
highestGrossing: 2.8
}),
new HighestGrossingMoviesItem(
{
franchise: `Star Wars`,
totalRevenue: 10.32,
highestGrossing: 2.07
}),
new HighestGrossingMoviesItem(
{
franchise: `Harry Potter`,
totalRevenue: 9.19,
highestGrossing: 1.34
}),
new HighestGrossingMoviesItem(
{
franchise: `Avengers`,
totalRevenue: 7.76,
highestGrossing: 2.8
}),
new HighestGrossingMoviesItem(
{
franchise: `Spider Man`,
totalRevenue: 7.22,
highestGrossing: 1.28
}),
new HighestGrossingMoviesItem(
{
franchise: `James Bond`,
totalRevenue: 7.12,
highestGrossing: 1.11
}),
];
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 { HighestGrossingMoviesItem, HighestGrossingMovies } from './HighestGrossingMovies';
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 xAxisOverlap: 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="XAxisOverlap"
name="XAxisOverlap"
label="X Axis - Overlap"
shouldOverrideDefaultEditor="true"
valueType="Slider"
min="0"
max="1"
step="0.1"
primitiveValue="0">
</IgrPropertyEditorPropertyDescription>
</IgrPropertyEditorPanel>
</div>
<div className="legend-title">
Highest Grossing Movie Franchises
</div>
<div className="legend">
<IgrLegend
ref={this.legendRef}
orientation="Horizontal">
</IgrLegend>
</div>
<div className="container fill">
<IgrCategoryChart
ref={this.chartRef}
dataSource={this.highestGrossingMovies}
chartType="Column"
crosshairsSnapToData="true"
isHorizontalZoomEnabled="false"
isVerticalZoomEnabled="false"
xAxisInterval="1"
xAxisOverlap="1">
</IgrCategoryChart>
</div>
</div>
);
}
private _highestGrossingMovies: HighestGrossingMovies = null;
public get highestGrossingMovies(): HighestGrossingMovies {
if (this._highestGrossingMovies == null)
{
this._highestGrossingMovies = new HighestGrossingMovies();
}
return this._highestGrossingMovies;
}
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
추가 리소스
다음 항목에서 관련 차트 기능에 대한 자세한 내용을 확인할 수 있습니다.
API 참조
다음은 위 섹션에서 언급된 API 멤버 목록입니다.