Web Components チャートのオーバーレイ
Web Components IgcDataChartComponent
を使用すると、IgcValueOverlayComponent
を使用して定義した単一の数値で水平線または垂直線を配置できます。特定のシリーズの平均値や中央値などのデータを視覚化するのに役立ちます。
Web Components 値オーバーレイの例
次の例は、いくつかの水平値オーバーレイがプロットされた縦棒チャート を示しています。
import { IgcDataChartCoreModule } from 'igniteui-webcomponents-charts' ;
import { IgcDataChartCategoryCoreModule } from 'igniteui-webcomponents-charts' ;
import { IgcDataChartCategoryModule } from 'igniteui-webcomponents-charts' ;
import { IgcDataChartInteractivityModule } from 'igniteui-webcomponents-charts' ;
import { IgcColumnSeriesModule } from 'igniteui-webcomponents-charts' ;
import { IgcValueOverlayModule } from 'igniteui-webcomponents-charts' ;
import { IgcDataChartComponent } from 'igniteui-webcomponents-charts' ;
import { ModuleManager } from 'igniteui-webcomponents-core' ;
ModuleManager.register(
IgcDataChartCoreModule,
IgcDataChartCategoryCoreModule,
IgcDataChartCategoryModule,
IgcDataChartInteractivityModule,
IgcColumnSeriesModule,
IgcValueOverlayModule
);
export class DataChartSeriesValueOverlay {
private chart: IgcDataChartComponent;
constructor ( ) {
this .chart = document .getElementById('chart' ) as IgcDataChartComponent;
this .chart.dataSource = this .getData();
}
getData(): any [] {
const data = [
{ 'Label' : 1 , 'Value' : 1.0 },
{ 'Label' : 2 , 'Value' : 2.0 },
{ 'Label' : 3 , 'Value' : 6.0 },
{ 'Label' : 4 , 'Value' : 8.0 },
{ 'Label' : 5 , 'Value' : 2.0 },
{ 'Label' : 6 , 'Value' : 6.0 },
{ 'Label' : 7 , 'Value' : 4.0 },
{ 'Label' : 8 , 'Value' : 2.0 },
{ 'Label' : 9 , 'Value' : 1.0 },
];
return data;
}
}
new DataChartSeriesValueOverlay();
ts コピー <!DOCTYPE html >
<html >
<head >
<title > DataChartSeriesValueOverlay</title >
<meta charset ="UTF-8" />
<link rel ="shortcut icon" href ="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel ="stylesheet" href ="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel ="stylesheet" href ="https://fonts.googleapis.com/css?family=Kanit&display=swap" />
<link rel ="stylesheet" href ="https://fonts.googleapis.com/css?family=Titillium Web" />
<link rel ="stylesheet" href ="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" type ="text/css" />
</head >
<body >
<div id ="root" >
<div class ="container sample" >
<div class ="container" style ="height: 100%" >
<igc-data-chart id ="chart" width ="100%" height ="100%"
is-horizontal-zoom-enabled ="true"
is-vertical-zoom-enabled ="true" >
<igc-category-x-axis name ="xAxis" label ="Label" >
</igc-category-x-axis >
<igc-numeric-y-axis name ="yAxis" minimum-value ="0" maximum-value ="10" >
</igc-numeric-y-axis >
<igc-column-series name ="series1" x-axis-name ="xAxis" y-axis-name ="yAxis" value-member-path ="Value" >
</igc-column-series >
<igc-value-overlay name ="overlay1" axis-name ="yAxis" value ="2.0" thickness ="5" >
</igc-value-overlay >
<igc-value-overlay name ="overlay2" axis-name ="yAxis" value ="3.6" thickness ="5" >
</igc-value-overlay >
<igc-value-overlay name ="overlay3" axis-name ="yAxis" value ="5.8" thickness ="5" >
</igc-value-overlay >
<igc-value-overlay name ="overlay4" axis-name ="yAxis" value ="1.0" thickness ="5" >
</igc-value-overlay >
<igc-value-overlay name ="overlay5" axis-name ="yAxis" value ="8.0" thickness ="5" >
</igc-value-overlay >
<igc-value-overlay name ="overlay6" axis-name ="yAxis" value ="7.0" thickness ="5" >
</igc-value-overlay >
<igc-value-overlay name ="overlay7" axis-name ="yAxis" value ="5.0" thickness ="5" >
</igc-value-overlay >
</igc-data-chart >
</div >
</div >
</div >
<% if (false) { %><script src ="src/index.ts" > </script > <% } %>
</body >
</html >
html コピー
このサンプルが気に入りましたか? 完全な Ignite UI for Web Componentsツールキットにアクセスして、すばやく独自のアプリの作成を開始します。無料でダウンロードできます。
Web Components 値オーバーレイのプロパティ
データバインディングに DataSource
を使用する他のシリーズ タイプとは異なり、値オーバーレイは ValueMemberPath
プロパティを使用して単一の数値をバインドします。さらに、値オーバーレイでは、使用する単一の axis
を定義する必要があります。X 軸を使用する場合、値のオーバーレイは垂直線になり、Y 軸を使用する場合は、水平線になります。
数値の X 軸または Y 軸を使用する場合、ValueMemberPath
プロパティは、値のオーバーレイを描画する軸上の実際の数値を反映する必要があります。カテゴリ X または Y 軸を使用する場合、ValueMemberPath
は、値オーバーレイを表示するカテゴリのインデックスを反映する必要があります。
数値オーバーレイを角度角軸で使用すると、チャートの中心からの線として表示され、半径半径軸を使用すると、円として表示されます。
IgcValueOverlayComponent
外観プロパティは、IgcSeriesComponent
から継承されているため、例えば brush
と thickness
を使用でき、他のタイプのシリーズと同じように機能します。
IgcValueOverlayComponent
に軸注釈を表示して、所有する軸にオーバーレイの値を表示することもできます。これを示すために、isAxisAnnotationEnabled
プロパティを true に設定できます。
Web Components 値レイヤー
Web Components チャート コンポーネントは、値の線を使用して、最小値、最大値、平均値などのデータのさまざまな焦点を示す機能も公開します。
IgcCategoryChartComponent
および IgcFinancialChartComponent
コンポーネントに IgcValueLayerComponent
を適用するには、チャート上で valueLines
プロパティを設定します。このプロパティは、ValueLayerValueMode
列挙体のコレクションを受け取ります。複数の ValueLayerValueMode
列挙をチャートの valueLines
コレクションに追加することで、同じチャート内で複数の値レイヤーを組み合わせたりできます。
IgcDataChartComponent
では、これは、チャートの IgcSeriesComponent
コレクションに IgcValueLayerComponent
を追加し、次に valueMode
プロパティを ValueLayerValueMode
列挙の 1 つに設定することによって行われます。これらの各列挙とその意味を以下に示します。
IgcValueLayerComponent
要素を使用するときに特定のシリーズが考慮されないようにする場合は、レイヤーに targetSeries
プロパティを設定できます。これにより、レイヤーは定義したシリーズを強制的にターゲットにするようになります。単一の IgcDataChartComponent
内に必要な数の IgcValueLayerComponent
要素を含めることができます。
次のサンプルは、IgcCategoryChartComponent
内のさまざまな valueLines
の使用法を示しています。
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 { IgcPropertyEditorPanelModule } from 'igniteui-webcomponents-layouts' ;
import { IgcLegendModule, IgcCategoryChartModule } from 'igniteui-webcomponents-charts' ;
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, LegendDescriptionModule, CategoryChartDescriptionModule } from 'igniteui-webcomponents-core' ;
import { IgcLegendComponent, IgcCategoryChartComponent } from 'igniteui-webcomponents-charts' ;
import { IgcPropertyEditorPanelComponent, IgcPropertyEditorPropertyDescriptionComponent } from 'igniteui-webcomponents-layouts' ;
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity' ;
import { IgcPropertyEditorPropertyDescriptionChangedEventArgs } from 'igniteui-webcomponents-layouts' ;
import { MarkerType, MarkerType_$type } from 'igniteui-webcomponents-charts' ;
import { EnumUtil } from 'igniteui-webcomponents-core' ;
import 'igniteui-webcomponents/themes/light/bootstrap.css' ;
import { defineAllComponents } from 'igniteui-webcomponents' ;
import { ModuleManager } from 'igniteui-webcomponents-core' ;
defineAllComponents();
import "./index.css" ;
ModuleManager.register(
IgcPropertyEditorPanelModule,
IgcLegendModule,
IgcCategoryChartModule
);
export class Sample {
private legend: IgcLegendComponent
private propertyEditor: IgcPropertyEditorPanelComponent
private valueListEditor: IgcPropertyEditorPropertyDescriptionComponent
private chart: IgcCategoryChartComponent
private _bind: () => void ;
constructor ( ) {
var legend = this .legend = document .getElementById('legend' ) as IgcLegendComponent;
var propertyEditor = this .propertyEditor = document .getElementById('PropertyEditor' ) as IgcPropertyEditorPanelComponent;
var valueListEditor = this .valueListEditor = document .getElementById('ValueListEditor' ) as IgcPropertyEditorPropertyDescriptionComponent;
this .editorChangeUpdateValueLines = this .editorChangeUpdateValueLines.bind(this );
var chart = this .chart = document .getElementById('chart' ) as IgcCategoryChartComponent;
this ._bind = () => {
propertyEditor.componentRenderer = this .renderer;
propertyEditor.target = this .chart;
valueListEditor.changed = this .editorChangeUpdateValueLines;
chart.dataSource = this .countryRenewableElectricity;
chart.legend = this .legend;
}
this ._bind();
}
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 editorChangeUpdateValueLines(sender: any , args : IgcPropertyEditorPropertyDescriptionChangedEventArgs): void {
var item = sender as IgcPropertyEditorPropertyDescriptionComponent;
var chart = this .chart;
var valueLineType = item.primitiveValue;
chart.valueLines = valueLineType;
}
}
new Sample();
ts コピー <!DOCTYPE html >
<html >
<head >
<title > Sample | Ignite UI | Web Components | infragistics</title >
<meta charset ="UTF-8" />
<link rel ="shortcut icon" href ="https://static.infragistics.com/xplatform/images/browsers/wc.png" >
<link rel ="stylesheet" href ="https://fonts.googleapis.com/icon?family=Material+Icons" />
<link rel ="stylesheet" href ="https://fonts.googleapis.com/css?family=Kanit&display=swap" />
<link rel ="stylesheet" href ="https://fonts.googleapis.com/css?family=Titillium Web" />
<link rel ="stylesheet" href ="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" />
<link rel ="stylesheet" href ="/src/index.css" type ="text/css" />
</head >
<body >
<div id ="root" >
<div class ="container sample" >
<div class ="options vertical" >
<igc-property-editor-panel
name ="PropertyEditor"
id ="PropertyEditor"
description-type ="CategoryChart"
is-horizontal ="true"
is-wrapping-enabled ="true" >
<igc-property-editor-property-description
property-path ="ValueListHandler"
name ="ValueListEditor"
id ="ValueListEditor"
label ="Value List"
should-override-default-editor ="true"
value-type ="EnumValue"
drop-down-values ="Auto, Average, GlobalAverage, GlobalMaximum, GlobalMinimum, Maximum, Minimum"
drop-down-names ="Auto, Average, GlobalAverage, GlobalMaximum, GlobalMinimum, Maximum, Minimum"
primitive-value ="Auto" >
</igc-property-editor-property-description >
</igc-property-editor-panel >
</div >
<div class ="legend-title" >
Renewable Electricity Generated
</div >
<div class ="legend" >
<igc-legend
name ="legend"
id ="legend"
orientation ="Horizontal" >
</igc-legend >
</div >
<div class ="container fill" >
<igc-category-chart
name ="chart"
id ="chart"
included-properties ="year, america, europe"
chart-type ="Column"
is-horizontal-zoom-enabled ="false"
is-vertical-zoom-enabled ="false"
crosshairs-display-mode ="None"
is-transition-in-enabled ="false"
y-axis-minimum-value ="0"
y-axis-maximum-value ="100" >
</igc-category-chart >
</div >
</div >
</div >
<% if (false) { %><script src ="src/index.ts" > </script > <% } %>
</body >
</html >
html コピー
Web Components ファイナンシャル オーバーレイ
Web Components 株価チャート に組み込みのファイナンシャル オーバーレイとインジケーターをプロットすることもできます。
その他のリソース
関連するチャート タイプの詳細については、以下のトピックを参照してください。
API リファレンス
以下は、上記のセクションで説明した API メンバーのリストです。