React Toolbar 구성 요소는 주로 차트 구성 요소와 함께 사용되는 UI 작업을 위한 동반 컨테이너입니다. 툴바는 IgrDataChart
또는 IgrCategoryChart
구성 요소에 연결될 때 속성 및 도구 항목의 사전 설정으로 동적으로 업데이트됩니다. 프로젝트에 대한 사용자 정의 도구를 만들어 최종 사용자가 변경 사항을 제공할 수 있으므로 무한한 양의 사용자 정의가 가능합니다.
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 ));
}
}
}
ts コピー import React from 'react' ;
import ReactDOM from 'react-dom/client' ;
import './index.css' ;
import { IgrLegendModule, IgrCategoryChartModule, IgrCategoryChartToolbarModule } from "@infragistics/igniteui-react-charts" ;
import { IgrToolbarModule } from "@infragistics/igniteui-react-layouts" ;
import { IgrCheckboxListModule } from "@infragistics/igniteui-react-data-grids" ;
import { IgrLegend, IgrCategoryChart } from "@infragistics/igniteui-react-charts" ;
import { IgrToolbar } from "@infragistics/igniteui-react-layouts" ;
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity' ;
const mods : any [] = [
IgrLegendModule,
IgrToolbarModule,
IgrCategoryChartModule,
IgrCategoryChartToolbarModule,
IgrCheckboxListModule
];
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 toolbar: IgrToolbar
private toolbarRef(r: IgrToolbar) {
this .toolbar = 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 .toolbarRef = this .toolbarRef.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 ="aboveContentSplit" >
<div className ="aboveContentLeftContainer" >
<div >
<IgrToolbar
ref ={this.toolbarRef}
target ={this.chart}
orientation ="Horizontal" >
</IgrToolbar >
</div >
</div >
<div className ="aboveContentRightContainer" >
<div >
<IgrLegend
ref ={this.legendRef}
orientation ="Horizontal" >
</IgrLegend >
</div >
</div >
</div >
<div className ="container fill" >
<IgrCategoryChart
ref ={this.chartRef}
chartType ="Line"
isHorizontalZoomEnabled ="true"
isVerticalZoomEnabled ="true"
dataSource ={this.countryRenewableElectricity}
includedProperties ={[ "year ", "europe ", "china ", "america "]}
legend ={this.legend}
yAxisTitle ="TWh"
yAxisTitleLeftMargin ="10"
yAxisTitleRightMargin ="5"
yAxisLabelLeftMargin ="0"
yAxisLabelLocation ="OutsideRight"
isTransitionInEnabled ="true" >
</IgrCategoryChart >
</div >
</div >
);
}
private _countryRenewableElectricity: CountryRenewableElectricity = null ;
public get countryRenewableElectricity(): CountryRenewableElectricity {
if (this ._countryRenewableElectricity == null )
{
this ._countryRenewableElectricity = new CountryRenewableElectricity();
}
return this ._countryRenewableElectricity;
}
}
const root = ReactDOM.createRoot (document.getElementById('root' ));
root.render (<Sample /> );
tsx コピー
.aboveContentSplit {
display : flex;
flex-direction : row;
}
.aboveContentLeftContainer {
margin-left : 1.25rem ;
display : flex;
flex-grow : 1 ;
justify-content : flex-start;
align-items : flex-end;
}
.aboveContentRightContainer {
margin-right : 1.25rem ;
display : flex;
flex-grow : 1 ;
justify-content : flex-end;
align-items : flex-end;
}
css コピー
이 샘플이 마음에 드시나요? Ignite UI for React 전체에 액세스하고 몇 분 만에 나만의 앱을 빌드하기 시작하세요. 무료로 다운로드하세요.
종속성
Ignite UI for React 설치:
npm install igniteui-react-layouts
npm install igniteui-react-inputs
npm install igniteui-react-charts
npm install igniteui-react-core
cmd
다음 모듈은 구성 요소 및 해당 기능과 함께 IgrDataChart
사용할 IgrToolbar
때 필요합니다.
import { IgxToolbarModule } from 'igniteui-react-layouts' ;
import { IgrDataChartToolbarModule, IgrDataChartCoreModule, IgrDataChartCategoryModule, IgrDataChartAnnotationModule, IgrDataChartInteractivityModule, IgrDataChartCategoryTrendLineModule } from 'igniteui-react-charts' ;
IgxToolbarModule.register();
IgrDataChartToolbarModule.register();
IgrDataChartCoreModule.register();
IgrDataChartCategoryModule.register();
IgrDataChartAnnotationModule.register();
IgrDataChartInteractivityModule.register();
IgrDataChartCategoryTrendLineModule.register();
ts
용법
다음은 도구 모음에 추가할 수 있는 다양한 IgrToolAction
항목 목록입니다.
이러한 각 도구는 마우스 클릭에 의해 트리거되는 이벤트를 노출합니다 OnCommand
. 참고로, the IgrToolActionIconMenu
는 내부에 래핑할 수 있는 다른 도구에 대한 래퍼입니다 IgrToolActionIconMenu
.
새 도구와 기존 도구는 개체의 및 beforeId
afterId
속성을 사용하여 overlayId
위치를 변경하고 숨김으로 IgrToolAction
표시할 수 있습니다. ToolActions는 속성도 노출합니다 visibility
.
다음 예제에서는 몇 가지 기능을 보여 줍니다. 먼저 도구를 그룹화할 수 있습니다. IgrToolActionSubPanel
다음과 같은 내장 도구 숨기기를 포함합니다. 줌리셋 그리고 분석메뉴 메뉴 도구 작업. 이 예에서는 의 새 인스턴스가 있습니다. 줌리셋 tool action 내의 줌메뉴 를 사용하여 afterId
속성을 할당하고 축소 정확하게 말하면 배치입니다. 또한 를 통해 강조 표시됩니다. isHighlighted
속성을 사용합니다.
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 ));
}
}
}
ts コピー import React from 'react' ;
import ReactDOM from 'react-dom/client' ;
import './index.css' ;
import { IgrToolbarModule } from "@infragistics/igniteui-react-layouts" ;
import { IgrDataChartToolbarModule, IgrDataChartCoreModule, IgrDataChartCategoryModule, IgrDataChartAnnotationModule, IgrDataChartInteractivityModule, IgrDataChartCategoryTrendLineModule } from "@infragistics/igniteui-react-charts" ;
import { IgrToolbar, IgrToolActionIconMenu, IgrToolActionGroupHeader, IgrToolActionSubPanel, IgrToolActionCheckbox, IgrToolActionLabel } from "@infragistics/igniteui-react-layouts" ;
import { IgrDataChart, IgrCategoryXAxis, IgrNumericYAxis, IgrLineSeries } from "@infragistics/igniteui-react-charts" ;
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity' ;
import { IgrToolCommandEventArgs } from "@infragistics/igniteui-react-layouts" ;
import { IgrSeries, IgrDataToolTipLayer, IgrCrosshairLayer, IgrFinalValueLayer } from "@infragistics/igniteui-react-charts" ;
const mods : any [] = [
IgrToolbarModule,
IgrDataChartToolbarModule,
IgrDataChartCoreModule,
IgrDataChartCategoryModule,
IgrDataChartAnnotationModule,
IgrDataChartInteractivityModule,
IgrDataChartCategoryTrendLineModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component <any, any> {
private toolbar: IgrToolbar
private toolbarRef(r: IgrToolbar) {
this .toolbar = r;
this .setState({});
}
private menuForSubPanelTool: IgrToolActionIconMenu
private subPanelGroup: IgrToolActionGroupHeader
private customSubPanelTools: IgrToolActionSubPanel
private enableTooltipsLabel: IgrToolActionCheckbox
private enableCrosshairsLabel: IgrToolActionCheckbox
private enableFinalValuesLabel: IgrToolActionCheckbox
private zoomResetLabel: IgrToolActionLabel
private zoomResetHidden: IgrToolActionLabel
private analyzeMenu: IgrToolActionIconMenu
private copyMenu: IgrToolActionLabel
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 .toolbarRef = this .toolbarRef.bind(this );
this .toolbarToggleAnnotations = this .toolbarToggleAnnotations.bind(this );
this .chartRef = this .chartRef.bind(this );
}
public render (): JSX .Element {
return (
<div className ="container sample" >
<div className ="aboveContentSplit" >
<div className ="aboveContentLeftContainer" >
<div >
<IgrToolbar
ref ={this.toolbarRef}
target ={this.chart}
orientation ="Horizontal"
onCommand ={this.toolbarToggleAnnotations} >
<IgrToolActionIconMenu
name ="MenuForSubPanelTool"
iconCollectionName ="ChartToolbarIcons"
iconName ="analyze" >
<IgrToolActionGroupHeader
name ="SubPanelGroup"
closeOnExecute ="true"
title ="Visualizations"
subtitle ="Layers" >
</IgrToolActionGroupHeader >
<IgrToolActionSubPanel
name ="CustomSubPanelTools" >
<IgrToolActionCheckbox
name ="EnableTooltipsLabel"
title ="Enable Tooltips"
commandId ="EnableTooltips" >
</IgrToolActionCheckbox >
<IgrToolActionCheckbox
name ="EnableCrosshairsLabel"
title ="Enable Crosshairs"
commandId ="EnableCrosshairs" >
</IgrToolActionCheckbox >
<IgrToolActionCheckbox
name ="EnableFinalValuesLabel"
title ="Enable Final Values"
commandId ="EnableFinalValues" >
</IgrToolActionCheckbox >
</IgrToolActionSubPanel >
</IgrToolActionIconMenu >
<IgrToolActionLabel
name ="zoomResetLabel"
title ="Reset"
afterId ="ZoomOut"
iconName ="reset"
iconCollectionName ="ChartToolbarIcons"
commandId ="ZoomReset"
isHighlighted ="true" >
</IgrToolActionLabel >
<IgrToolActionLabel
name ="zoomResetHidden"
overlayId ="ZoomReset"
visibility ="Collapsed" >
</IgrToolActionLabel >
<IgrToolActionIconMenu
name ="AnalyzeMenu"
overlayId ="AnalyzeMenu"
visibility ="Collapsed" >
</IgrToolActionIconMenu >
<IgrToolActionLabel
name ="CopyMenu"
overlayId ="CopyMenu"
visibility ="Collapsed" >
</IgrToolActionLabel >
</IgrToolbar >
</div >
</div >
</div >
<div className ="container fill" >
<IgrDataChart
computedPlotAreaMarginMode ="Series"
isHorizontalZoomEnabled ="true"
isVerticalZoomEnabled ="true"
ref ={this.chartRef} >
<IgrCategoryXAxis
name ="xAxis"
dataSource ={this.countryRenewableElectricity}
label ="year" >
</IgrCategoryXAxis >
<IgrNumericYAxis
name ="yAxis"
title ="TWh"
labelLocation ="OutsideRight" >
</IgrNumericYAxis >
<IgrLineSeries
name ="lineSeries1"
title ="Electricity"
xAxisName ="xAxis"
yAxisName ="yAxis"
dataSource ={this.countryRenewableElectricity}
valueMemberPath ="america" >
</IgrLineSeries >
<IgrLineSeries
name ="LineSeries2"
title ="Electricity"
xAxisName ="xAxis"
yAxisName ="yAxis"
dataSource ={this.countryRenewableElectricity}
valueMemberPath ="europe" >
</IgrLineSeries >
<IgrLineSeries
name ="LineSeries3"
title ="Electricity"
xAxisName ="xAxis"
yAxisName ="yAxis"
dataSource ={this.countryRenewableElectricity}
valueMemberPath ="china" >
</IgrLineSeries >
</IgrDataChart >
</div >
</div >
);
}
private _countryRenewableElectricity: CountryRenewableElectricity = null ;
public get countryRenewableElectricity(): CountryRenewableElectricity {
if (this ._countryRenewableElectricity == null )
{
this ._countryRenewableElectricity = new CountryRenewableElectricity();
}
return this ._countryRenewableElectricity;
}
public toolbarToggleAnnotations(sender: any , args: IgrToolCommandEventArgs): void {
var target = this .chart;
switch (args.command.commandId)
{
case "EnableTooltips" :
var enable = args.command.argumentsList[0 ].value as boolean ;
if (enable)
{
target.series.add(new IgrDataToolTipLayer({ name: "tooltipLayer" }));
}
else
{
var toRemove = null ;
for (var i = 0 ; i < target.actualSeries.length; i++) {
let s = target.actualSeries[i] as IgrSeries;
if (s instanceof IgrDataToolTipLayer)
{
toRemove = s;
}
}
if (toRemove != null)
{
target.series.remove(toRemove);
}
}
break;
case "EnableCrosshairs":
var enable = args.command.argumentsList[0].value as boolean;
if (enable)
{
target.series.add(new IgrCrosshairLayer({ name: "crosshairLayer" }));
}
else
{
var toRemove = null;
for (var i = 0; i < target.actualSeries.length; i++) {
let s = target.actualSeries[i] as IgrSeries;
if (s instanceof IgrCrosshairLayer)
{
toRemove = s;
}
}
if (toRemove != null)
{
target.series.remove(toRemove);
}
}
break;
case "EnableFinalValues":
var enable = args.command.argumentsList[0].value as boolean;
if (enable)
{
target.series.add(new IgrFinalValueLayer({ name: "finalValueLayer" }));
}
else
{
var toRemove = null;
for (var i = 0; i < target.actualSeries.length; i++) {
let s = target.actualSeries[i] as IgrSeries;
if (s instanceof IgrFinalValueLayer)
{
toRemove = s;
}
}
if (toRemove != null)
{
target.series.remove(toRemove);
}
}
break;
}
}
}
// rendering above component in the React DOM
const root = ReactDOM.createRoot(document.getElementById('root'));
root.render(<Sample /> );
tsx コピー
.aboveContentSplit {
display : flex;
flex-direction : row;
}
.aboveContentLeftContainer {
margin-left : 1.25rem ;
display : flex;
flex-grow : 1 ;
justify-content : flex-start;
align-items : flex-end;
}
.aboveContentRightContainer {
margin-right : 1.25rem ;
display : flex;
flex-grow : 1 ;
justify-content : flex-end;
align-items : flex-end;
}
css コピー
React 데이터 차트 통합
React Toolbar에는 Target
속성이 들어 있습니다. 이는 아래 코드에 표시된 IgrDataChart
와 같은 구성 요소를 연결하는 데 사용됩니다.
private toolbar: IgrToolbar
private toolbarRef(r: IgrToolbar) {
this .toolbar = r;
this .setState({});
}
private chart: IgrDataChart
private chartRef(r: IgrDataChart) {
this .chart = r;
this .toolbar.target = this .chart;
this .setState({});
}
public render (): JSX .Element {
return (
<div >
<IgrToolbar
ref ={this.toolbarRef} >
</IgrToolbar >
</div >
<div >
<IgrDataChart
ref ={this.chartRef} >
</IgrDataChart >
</div >
);
}
tsx
IgrDataChart
툴바와 연결되면 기존 IgrToolAction
항목과 메뉴가 여러 개 사용 가능해집니다. 내장된 React IgrDataChart
도구 작업과 관련 overlayId
목록은 다음과 같습니다.
확대/축소 작업
추세 조치
이미지에 저장 작업
SVG 아이콘
도구를 수동으로 추가할 때 이 RenderIconFromText
방법을 사용하여 아이콘을 할당할 수 있습니다. 이 메서드에는 세 가지 매개 변수가 있습니다. 첫 번째는 도구에 정의된 아이콘 컬렉션 이름입니다. iconCollectionName
두 번째는 도구에 정의된 아이콘의 이름(예: iconName
SVG 문자열 추가)입니다.
데이터 URL 아이콘
svg를 추가하는 것과 마찬가지로 URL RegisterIconFromDataURL
에서 아이콘 이미지를 추가할 수도 있습니다. 메서드의 세 번째 매개 변수는 문자열 URL을 입력하는 데 사용됩니다.
다음 코드 조각은 아이콘을 추가하는 두 가지 방법을 모두 보여 줍니다.
public toolbarCustomIconOnViewInit(): void {
const icon = '<svg width="28px" height="28px" stroke="none" viewBox="0 0 3.5 3.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M0.436 0.178a0.073 0.073 0 0 0 -0.062 0.036L0.01 0.846a0.073 0.073 0 0 0 0.063 0.109h0.729a0.073 0.073 0 0 0 0.063 -0.109L0.501 0.214a0.073 0.073 0 0 0 -0.064 -0.036zm0.001 0.219 0.238 0.413H0.199zM1.4 0.507v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245zM0.073 1.388A0.073 0.073 0 0 0 0 1.461v0.583a0.073 0.073 0 0 0 0.073 0.073h0.729A0.073 0.073 0 0 0 0.875 2.045V1.461a0.073 0.073 0 0 0 -0.073 -0.073zm0.073 0.146h0.583v0.438H0.146zM1.4 1.674v0.245h0.945v-0.245zm1.19 0v0.245h0.91v-0.245zM0.438 2.447c-0.241 0 -0.438 0.197 -0.438 0.438 0 0.241 0.197 0.438 0.438 0.438s0.438 -0.197 0.438 -0.438c0 -0.241 -0.197 -0.438 -0.438 -0.438zm0 0.146a0.291 0.291 0 0 1 0.292 0.292 0.291 0.291 0 0 1 -0.292 0.292 0.291 0.291 0 0 1 -0.292 -0.292A0.291 0.291 0 0 1 0.438 2.593zM1.4 2.842v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245z" fill="#000000" fill-rule="evenodd"/></svg>' ;
this .toolbar.registerIconFromText("CustomCollection" , "CustomIcon" , icon);
}
ts
public toolbarCustomIconOnViewInit(): void {
toolbar.registerIconFromDataURL("CustomCollection" , "CustomIcon" , "https://www.svgrepo.com/show/678/calculator.svg" );
}
ts
public toolbarCustomIconOnViewInit(): void {
const icon = '<svg width="28px" height="28px" stroke="none" viewBox="0 0 3.5 3.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M0.436 0.178a0.073 0.073 0 0 0 -0.062 0.036L0.01 0.846a0.073 0.073 0 0 0 0.063 0.109h0.729a0.073 0.073 0 0 0 0.063 -0.109L0.501 0.214a0.073 0.073 0 0 0 -0.064 -0.036zm0.001 0.219 0.238 0.413H0.199zM1.4 0.507v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245zM0.073 1.388A0.073 0.073 0 0 0 0 1.461v0.583a0.073 0.073 0 0 0 0.073 0.073h0.729A0.073 0.073 0 0 0 0.875 2.045V1.461a0.073 0.073 0 0 0 -0.073 -0.073zm0.073 0.146h0.583v0.438H0.146zM1.4 1.674v0.245h0.945v-0.245zm1.19 0v0.245h0.91v-0.245zM0.438 2.447c-0.241 0 -0.438 0.197 -0.438 0.438 0 0.241 0.197 0.438 0.438 0.438s0.438 -0.197 0.438 -0.438c0 -0.241 -0.197 -0.438 -0.438 -0.438zm0 0.146a0.291 0.291 0 0 1 0.292 0.292 0.291 0.291 0 0 1 -0.292 0.292 0.291 0.291 0 0 1 -0.292 -0.292A0.291 0.291 0 0 1 0.438 2.593zM1.4 2.842v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245z" fill="#000000" fill-rule="evenodd"/></svg>' ;
this .toolbar.registerIconFromText("CustomCollection" , "CustomIcon" , icon);
}
ts
public toolbarCustomIconOnViewInit(): void {
toolbar.registerIconFromDataURL("CustomCollection" , "CustomIcon" , "https://www.svgrepo.com/show/678/calculator.svg" );
}
ts
@code {
protected override async Task OnAfterRenderAsync (bool firstRender )
{
var toolbar = this .toolbar;
if (firstRender) {
this .ToolbarCustomIconOnViewInit();
}
}
private IgbToolbar toolbar;
public void ToolbarCustomIconOnViewInit ( )
{
this .toolbar.EnsureReady().ContinueWith(new Action<Task>((e ) =>
{
this .toolbar.RegisterIconFromDataURLAsync("CustomCollection" , "CustomIcon" , "https://www.svgrepo.com/show/678/calculator.svg" );
}));
}
typescript
}
```tsx
<IgrToolbar orientation="Vertical" />
autohotkey
수직 방향
기본적으로 React 툴바는 가로로 표시되지만, orientation
속성을 설정하여 세로로 표시할 수도 있습니다.
<IgrToolbar orientation ="Vertical" />
tsx
다음 예제는 React Toolbar의 수직 방향을 보여줍니다.
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 ));
}
}
}
ts コピー import React from 'react' ;
import ReactDOM from 'react-dom/client' ;
import './index.css' ;
import { IgrToolbarModule } from "@infragistics/igniteui-react-layouts" ;
import { IgrDataChartToolbarModule, IgrDataChartCoreModule, IgrDataChartCategoryModule, IgrDataChartAnnotationModule, IgrDataChartInteractivityModule, IgrAnnotationLayerProxyModule, IgrDataChartCategoryTrendLineModule } from "@infragistics/igniteui-react-charts" ;
import { IgrToolbar } from "@infragistics/igniteui-react-layouts" ;
import { IgrDataChart, IgrCategoryXAxis, IgrNumericYAxis, IgrLineSeries } from "@infragistics/igniteui-react-charts" ;
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity' ;
const mods : any [] = [
IgrToolbarModule,
IgrDataChartToolbarModule,
IgrDataChartCoreModule,
IgrDataChartCategoryModule,
IgrDataChartAnnotationModule,
IgrDataChartInteractivityModule,
IgrAnnotationLayerProxyModule,
IgrDataChartCategoryTrendLineModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component <any, any> {
private toolbar: IgrToolbar
private toolbarRef(r: IgrToolbar) {
this .toolbar = r;
this .setState({});
}
private chart: IgrDataChart
private chartRef(r: IgrDataChart) {
this .chart = r;
this .setState({});
}
private xAxis: IgrCategoryXAxis
private yAxis: IgrNumericYAxis
private lineSeries1: IgrLineSeries
constructor (props: any ) {
super (props);
this .toolbarRef = this .toolbarRef.bind(this );
this .chartRef = this .chartRef.bind(this );
}
public render (): JSX .Element {
return (
<div className ="container sample" >
<div className ="aboveContent" >
<IgrToolbar
ref ={this.toolbarRef}
target ={this.chart}
orientation ="Vertical" >
</IgrToolbar >
</div >
<div className ="container fill" >
<IgrDataChart
isHorizontalZoomEnabled ="true"
ref ={this.chartRef} >
<IgrCategoryXAxis
name ="xAxis"
dataSource ={this.countryRenewableElectricity}
label ="year" >
</IgrCategoryXAxis >
<IgrNumericYAxis
name ="yAxis"
title ="TWh"
labelLocation ="OutsideRight" >
</IgrNumericYAxis >
<IgrLineSeries
name ="lineSeries1"
title ="Electricity"
xAxisName ="xAxis"
yAxisName ="yAxis"
dataSource ={this.countryRenewableElectricity}
valueMemberPath ="america" >
</IgrLineSeries >
</IgrDataChart >
</div >
</div >
);
}
private _countryRenewableElectricity: CountryRenewableElectricity = null ;
public get countryRenewableElectricity(): CountryRenewableElectricity {
if (this ._countryRenewableElectricity == null )
{
this ._countryRenewableElectricity = new CountryRenewableElectricity();
}
return this ._countryRenewableElectricity;
}
}
const root = ReactDOM.createRoot (document.getElementById('root' ));
root.render (<Sample /> );
tsx コピー
색상 편집기
React 툴바에 사용자 정의 색상 편집기 도구를 추가할 수 있으며, 이 도구는 Command 이벤트와 함께 작동하여 응용 프로그램에 사용자 정의 스타일을 수행합니다.
<igc-toolbar
name="toolbar"
id="toolbar" >
<igc-tool-action-color-editor
title ="Series Brush Color"
name ="colorEditorTool"
id ="colorEditorTool" >
</igc-tool-action-color-editor >
</igc-toolbar>
ts
<IgrToolbar
ref ={this.toolbarRef}
target ={this.chart} >
<IgrToolActionColorEditor
title ="Series Brush Color"
name ="colorEditorTool" >
</IgrToolActionColorEditor >
</IgrToolbar >
tsx
다음 예제에서는 색 편집기 도구를 사용하여 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 ));
}
}
}
ts コピー import React from 'react' ;
import ReactDOM from 'react-dom/client' ;
import './index.css' ;
import { IgrToolbarModule, IgrToolActionComboModule, IgrToolActionColorEditorModule } from "@infragistics/igniteui-react-layouts" ;
import { IgrDataChartToolbarModule, IgrDataLegendModule, IgrNumberAbbreviatorModule, IgrDataChartCategoryModule, IgrDataChartCoreModule, IgrDataChartAnnotationModule, IgrDataChartInteractivityModule } from "@infragistics/igniteui-react-charts" ;
import { IgrToolbar, IgrToolActionColorEditor } from "@infragistics/igniteui-react-layouts" ;
import { IgrDataChart, IgrCategoryXAxis, IgrNumericYAxis, IgrLineSeries } from "@infragistics/igniteui-react-charts" ;
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity' ;
import { IgrToolCommandEventArgs } from "@infragistics/igniteui-react-layouts" ;
import { IgrSeries } from "@infragistics/igniteui-react-charts" ;
const mods : any [] = [
IgrToolbarModule,
IgrToolActionComboModule,
IgrToolActionColorEditorModule,
IgrDataChartToolbarModule,
IgrDataLegendModule,
IgrNumberAbbreviatorModule,
IgrDataChartCategoryModule,
IgrDataChartCoreModule,
IgrDataChartCategoryModule,
IgrDataChartAnnotationModule,
IgrDataChartInteractivityModule,
IgrDataChartAnnotationModule
];
mods.forEach((m) => m.register());
export default class Sample extends React.Component <any, any> {
private toolbar: IgrToolbar
private toolbarRef(r: IgrToolbar) {
this .toolbar = r;
this .setState({});
}
private colorEditorTool: IgrToolActionColorEditor
private chart: IgrDataChart
private chartRef(r: IgrDataChart) {
this .chart = r;
this .setState({});
}
private xAxis: IgrCategoryXAxis
private yAxis: IgrNumericYAxis
private lineSeries1: IgrLineSeries
constructor (props: any ) {
super (props);
this .toolbarRef = this .toolbarRef.bind(this );
this .colorEditorToggleSeriesBrush = this .colorEditorToggleSeriesBrush.bind(this );
this .chartRef = this .chartRef.bind(this );
}
public render (): JSX .Element {
return (
<div className ="container sample" >
<div className ="aboveContentSplit" >
<div className ="aboveContentLeftContainer" >
<div >
<IgrToolbar
ref ={this.toolbarRef}
target ={this.chart}
onCommand ={this.colorEditorToggleSeriesBrush} >
<IgrToolActionColorEditor
title ="Series Brush"
name ="colorEditorTool"
commandId ="ToggleSeriesBrush" >
</IgrToolActionColorEditor >
</IgrToolbar >
</div >
</div >
</div >
<div className ="container fill" >
<IgrDataChart
isHorizontalZoomEnabled ="true"
ref ={this.chartRef} >
<IgrCategoryXAxis
name ="xAxis"
dataSource ={this.countryRenewableElectricity}
label ="year" >
</IgrCategoryXAxis >
<IgrNumericYAxis
name ="yAxis"
title ="TWh"
labelLocation ="OutsideRight" >
</IgrNumericYAxis >
<IgrLineSeries
name ="lineSeries1"
title ="Electricity"
xAxisName ="xAxis"
yAxisName ="yAxis"
dataSource ={this.countryRenewableElectricity}
valueMemberPath ="america"
markerType ="None" >
</IgrLineSeries >
</IgrDataChart >
</div >
</div >
);
}
private _countryRenewableElectricity: CountryRenewableElectricity = null ;
public get countryRenewableElectricity(): CountryRenewableElectricity {
if (this ._countryRenewableElectricity == null )
{
this ._countryRenewableElectricity = new CountryRenewableElectricity();
}
return this ._countryRenewableElectricity;
}
public colorEditorToggleSeriesBrush(sender: any , args: IgrToolCommandEventArgs): void {
var target = this .chart;
switch (args.command.commandId)
{
case "ToggleSeriesBrush" :
var color = args.command.argumentsList[0 ].value
var series = target.contentSeries[0 ] as IgrSeries;
series.brush = color as any ;
break ;
}
}
}
const root = ReactDOM.createRoot (document.getElementById('root' ));
root.render (<Sample /> );
tsx コピー
.aboveContentSplit {
display : flex;
flex-direction : row;
}
.aboveContentLeftContainer {
margin-left : 1.25rem ;
display : flex;
flex-grow : 1 ;
justify-content : flex-start;
align-items : flex-end;
}
.aboveContentRightContainer {
margin-right : 1.25rem ;
display : flex;
flex-grow : 1 ;
justify-content : flex-end;
align-items : flex-end;
}
css コピー
API 참조
추가 리소스