Web Components Axis Options
In all Ignite UI for Web Components charts, the axes provide properties for visual configurations such as titles, labels, and ranges. These features are demonstrated in the examples provided below.
Axis Titles Example
The axis titles feature of the Web Components charts, allows you to add contextual information to the your chart. You can customize the look and feel of the axis titles in many different ways such as applying different font styles, colors, margins, and alignments.
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 { IgcLegendModule, IgcCategoryChartModule } from 'igniteui-webcomponents-charts';
import { IgcLegendComponent, IgcCategoryChartComponent } from 'igniteui-webcomponents-charts';
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity';
import { ModuleManager } from 'igniteui-webcomponents-core';
import "./index.css";
ModuleManager.register(
IgcLegendModule,
IgcCategoryChartModule
);
export class Sample {
private legend: IgcLegendComponent
private chart: IgcCategoryChartComponent
private _bind: () => void;
constructor() {
var legend = this.legend = document.getElementById('legend') as IgcLegendComponent;
var chart = this.chart = document.getElementById('chart') as IgcCategoryChartComponent;
this._bind = () => {
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;
}
}
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="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, europe, china, america"
chart-type="Line"
is-horizontal-zoom-enabled="false"
is-vertical-zoom-enabled="false"
computed-plot-area-margin-mode="Series"
x-axis-title="Year"
x-axis-title-text-color="gray"
x-axis-title-text-style="10pt 'Titillium Web'"
x-axis-title-angle="0"
y-axis-title="Trillions of Watt-hours (Twh)"
y-axis-title-text-color="gray"
y-axis-title-text-style="10pt 'Titillium Web'"
y-axis-title-angle="90"
y-axis-title-left-margin="5">
</igc-category-chart>
</div>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
html/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
Like this sample? Get access to our complete Ignite UI for Web Components toolkit and start building your own apps in minutes. Download it for free.
Axis Labels Example
The Web Components Charts allows you full control over configuring, formatting, and styling the font of the labels displayed on an axis in your chart. You can change the rotation angle, margin, horizontal and vertical alignment, color, padding, and visibility of axis labels. The following example shows how to use these features of axes.
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 { 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 '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 propertyEditorPanel1: IgcPropertyEditorPanelComponent
private xAxisLabelAngleEditor: IgcPropertyEditorPropertyDescriptionComponent
private yAxisLabelAngleEditor: IgcPropertyEditorPropertyDescriptionComponent
private xAxisLabelTextColorEditor: IgcPropertyEditorPropertyDescriptionComponent
private chart: IgcCategoryChartComponent
private _bind: () => void;
constructor() {
var legend = this.legend = document.getElementById('legend') as IgcLegendComponent;
var propertyEditorPanel1 = this.propertyEditorPanel1 = document.getElementById('propertyEditorPanel1') as IgcPropertyEditorPanelComponent;
var xAxisLabelAngleEditor = this.xAxisLabelAngleEditor = document.getElementById('XAxisLabelAngleEditor') as IgcPropertyEditorPropertyDescriptionComponent;
var yAxisLabelAngleEditor = this.yAxisLabelAngleEditor = document.getElementById('YAxisLabelAngleEditor') as IgcPropertyEditorPropertyDescriptionComponent;
var xAxisLabelTextColorEditor = this.xAxisLabelTextColorEditor = document.getElementById('XAxisLabelTextColorEditor') as IgcPropertyEditorPropertyDescriptionComponent;
var chart = this.chart = document.getElementById('chart') as IgcCategoryChartComponent;
this._bind = () => {
propertyEditorPanel1.componentRenderer = this.renderer;
propertyEditorPanel1.target = this.chart;
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;
}
}
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
description-type="CategoryChart"
is-horizontal="true"
is-wrapping-enabled="true"
name="propertyEditorPanel1"
id="propertyEditorPanel1">
<igc-property-editor-property-description
property-path="XAxisLabelAngle"
name="XAxisLabelAngleEditor"
id="XAxisLabelAngleEditor"
label="X Axis Label Angle"
should-override-default-editor="true"
value-type="EnumValue"
drop-down-names="0, 45, 90, 135, 180, 225, 270"
drop-down-values="0, 45, 90, 135, 180, 225, 270"
primitive-value="0">
</igc-property-editor-property-description>
<igc-property-editor-property-description
property-path="YAxisLabelAngle"
name="YAxisLabelAngleEditor"
id="YAxisLabelAngleEditor"
label="Y Axis Label Angle"
should-override-default-editor="true"
value-type="EnumValue"
drop-down-names="-90, -45, 0, 45, 90"
drop-down-values="-90, -45, 0, 45, 90"
primitive-value="0">
</igc-property-editor-property-description>
<igc-property-editor-property-description
property-path="XAxisLabelTextColor"
name="XAxisLabelTextColorEditor"
id="XAxisLabelTextColorEditor"
label="Y Axis Label Color"
value-type="EnumValue"
should-override-default-editor="true"
drop-down-names="red, green"
drop-down-values="red, green"
primitive-value="red">
</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, europe, china, america"
chart-type="Line"
computed-plot-area-margin-mode="Series"
is-horizontal-zoom-enabled="false"
is-vertical-zoom-enabled="false"
top-margin="20"
x-axis-label-angle="0"
x-axis-label-text-color="gray"
x-axis-label-text-style="10pt 'Titillium Web'"
x-axis-label-top-margin="5"
y-axis-label-angle="0"
y-axis-label-text-color="gray"
y-axis-label-text-style="10pt 'Titillium Web'"
y-axis-label-right-margin="5"
y-axis-label-location="OutsideRight"
title-top-margin="10">
</igc-category-chart>
</div>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
html/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
Axis Labels Management & Formatting
The axes of the chart have the ability to perform an enhanced calculation regarding the amount of space available to the labels of the owning axis. This enhanced calculation allows the axis to optimize the amount of space given to it in order to display more labels for the given axis.
This enhanced calculation is something that you need to opt-in to, which you can do by setting the useEnhancedIntervalManagement
property to true. Then, if you prefer to display as many labels as can fit in the dimensions of the axis without manually setting the interval
property of the axis, you can set the enhancedIntervalPreferMoreCategoryLabels
property on the axis to true.
The chart also has the ability to consider auto-rotation of the labels if they will not fit in the allotted space as well as the ability to apply an automatic margin to the plot area to ensure the labels can fit. This is something that can be opted into initially by first setting the autoMarginAndAngleUpdateMode
property on the chart to either SizeChanging
or SizeChangingAndZoom
. This will tell the chart when to re-evaluate the auto margin and angle applied to the labels, if desired.
After setting the autoMarginAndAngleUpdateMode
, you can set the shouldAutoExpandMarginForInitialLabels
property to true to opt into the automatic margin or set the shouldConsiderAutoRotationForInitialLabels
property to true for the auto-rotation. You can also further customize the automatic margin that is applied by setting the autoExpandMarginExtraPadding
and autoExpandMarginMaximumValue
to provide extra space or a maximum possible margin, respectively.
Custom label formats such as IgcNumberFormatSpecifier
and IgcDateTimeFormatSpecifier
can be added to each axis via the XAxisLabelFormatSpecifier
and YAxisLabelFormatSpecifier
collections. Commonly used for applying Intl.NumberFormat and Intl.DateTimeFormat language sensitive number, date and time formatting. In order for a custom format to be applied to the labels, the yAxisLabelFormat
or xAxisLabelFormat
need to be set to data item's property name on the IgcCategoryChartComponent
, eg. {Date}
. For the IgcFinancialChartComponent
the number is the context because it uses a numeric axis, therefore this needs to be set to {0}
.
The following example formats the yAxis with a IgcNumberFormatSpecifier
to reprerent $USD prices for top box office movies in the United States.
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 { IgcPropertyEditorPanelModule } from 'igniteui-webcomponents-layouts';
import { IgcDataLegendModule, IgcCategoryChartModule } from 'igniteui-webcomponents-charts';
import { IgcNumberFormatSpecifierModule } from 'igniteui-webcomponents-core';
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, DataLegendDescriptionModule, CategoryChartDescriptionModule, NumberFormatSpecifierDescriptionModule } from 'igniteui-webcomponents-core';
import { IgcDataLegendComponent, IgcCategoryChartComponent } from 'igniteui-webcomponents-charts';
import { IgcNumberFormatSpecifier } from 'igniteui-webcomponents-core';
import { HighestGrossingMoviesItem, HighestGrossingMovies } from './HighestGrossingMovies';
import { ModuleManager } from 'igniteui-webcomponents-core';
import "./index.css";
ModuleManager.register(
IgcPropertyEditorPanelModule,
IgcDataLegendModule,
IgcCategoryChartModule,
IgcNumberFormatSpecifierModule
);
export class Sample {
private legend: IgcDataLegendComponent
private _numberFormatSpecifier1: IgcNumberFormatSpecifier[] | null = null;
public get numberFormatSpecifier1(): IgcNumberFormatSpecifier[] {
if (this._numberFormatSpecifier1 == null)
{
let numberFormatSpecifier1: IgcNumberFormatSpecifier[] = [];
var numberFormatSpecifier2 = new IgcNumberFormatSpecifier();
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: IgcCategoryChartComponent
private _numberFormatSpecifier3: IgcNumberFormatSpecifier[] | null = null;
public get numberFormatSpecifier3(): IgcNumberFormatSpecifier[] {
if (this._numberFormatSpecifier3 == null)
{
let numberFormatSpecifier3: IgcNumberFormatSpecifier[] = [];
var numberFormatSpecifier4 = new IgcNumberFormatSpecifier();
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: IgcNumberFormatSpecifier[] | null = null;
public get numberFormatSpecifier5(): IgcNumberFormatSpecifier[] {
if (this._numberFormatSpecifier5 == null)
{
let numberFormatSpecifier5: IgcNumberFormatSpecifier[] = [];
var numberFormatSpecifier6 = new IgcNumberFormatSpecifier();
numberFormatSpecifier6.style = "currency";
numberFormatSpecifier6.currency = "USD";
numberFormatSpecifier6.currencyDisplay = "symbol";
numberFormatSpecifier6.minimumFractionDigits = 0;
numberFormatSpecifier5.push(numberFormatSpecifier6)
this._numberFormatSpecifier5 = numberFormatSpecifier5;
}
return this._numberFormatSpecifier5;
}
private _bind: () => void;
constructor() {
var legend = this.legend = document.getElementById('legend') as IgcDataLegendComponent;
var chart = this.chart = document.getElementById('chart') as IgcCategoryChartComponent;
this._bind = () => {
legend.target = this.chart;
legend.valueFormatSpecifiers = this.numberFormatSpecifier1;
chart.dataSource = this.highestGrossingMovies;
chart.dataToolTipValueFormatSpecifiers = this.numberFormatSpecifier3;
chart.yAxisLabelFormatSpecifiers = this.numberFormatSpecifier5;
}
this._bind();
}
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;
}
}
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="legend-title">
Highest Grossing Movie Franchises
</div>
<div class="legend">
<igc-data-legend
name="legend"
id="legend"
value-format-string="{0} Billion">
</igc-data-legend>
</div>
<div class="container fill">
<igc-category-chart
name="chart"
id="chart"
chart-type="Column"
is-horizontal-zoom-enabled="false"
is-vertical-zoom-enabled="false"
final-value-annotations-precision="2"
data-tool-tip-value-format-string="{0} Billion"
y-axis-label-format="{0}B">
</igc-category-chart>
</div>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
html/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
Axis Range Example
In the Web Components charts, you can define a range minimum and range maximum value of a numeric or time axis. The range minimum is the lowest value of the axis and the range maximum is the highest value of the axis. These are set by setting the yAxisMinimumValue
and yAxisMaximumValue
options.
By default, charts will calculate the minimum and maximum values for the numeric and time axis range based on the lowest and highest corresponding value points in your data, but this automatic calculation may not be appropriate for your set of data points in all cases. For example, if your data has a minimum value of 850, you may want to set the yAxisMinimumValue
to 800 so that there will be a space value of 50 between the axis minimum and the lowest value of data points. The same idea can be applied to the axis minimum value and the highest value of data points using the yAxisMaximumValue
property.
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 { 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 propertyEditorPanel1: IgcPropertyEditorPanelComponent
private yAxisMinimumValue: IgcPropertyEditorPropertyDescriptionComponent
private yAxisMaximumValue: IgcPropertyEditorPropertyDescriptionComponent
private chart: IgcCategoryChartComponent
private _bind: () => void;
constructor() {
var legend = this.legend = document.getElementById('legend') as IgcLegendComponent;
var propertyEditorPanel1 = this.propertyEditorPanel1 = document.getElementById('propertyEditorPanel1') as IgcPropertyEditorPanelComponent;
var yAxisMinimumValue = this.yAxisMinimumValue = document.getElementById('YAxisMinimumValue') as IgcPropertyEditorPropertyDescriptionComponent;
this.editorChangeUpdateYAxisMinimumValue = this.editorChangeUpdateYAxisMinimumValue.bind(this);
var yAxisMaximumValue = this.yAxisMaximumValue = document.getElementById('YAxisMaximumValue') as IgcPropertyEditorPropertyDescriptionComponent;
this.editorChangeUpdateYAxisMaximumValue = this.editorChangeUpdateYAxisMaximumValue.bind(this);
var chart = this.chart = document.getElementById('chart') as IgcCategoryChartComponent;
this._bind = () => {
propertyEditorPanel1.componentRenderer = this.renderer;
propertyEditorPanel1.target = this.chart;
yAxisMinimumValue.changed = this.editorChangeUpdateYAxisMinimumValue;
yAxisMaximumValue.changed = this.editorChangeUpdateYAxisMaximumValue;
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 editorChangeUpdateYAxisMinimumValue(sender: any, args: IgcPropertyEditorPropertyDescriptionChangedEventArgs): void {
var yAxisMinimumVal = args.newValue;
this.chart.yAxisMinimumValue = parseInt(yAxisMinimumVal);
}
public editorChangeUpdateYAxisMaximumValue(sender: any, args: IgcPropertyEditorPropertyDescriptionChangedEventArgs): void {
var yAxisMaximumVal = args.newValue;
this.chart.yAxisMaximumValue = parseInt(yAxisMaximumVal);
}
}
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
description-type="CategoryChart"
is-horizontal="true"
is-wrapping-enabled="true"
name="propertyEditorPanel1"
id="propertyEditorPanel1">
<igc-property-editor-property-description
property-path="YAxisMinimumValueHandler"
name="YAxisMinimumValue"
id="YAxisMinimumValue"
label="Y Axis Minimum Value"
should-override-default-editor="true"
value-type="EnumValue"
drop-down-names="0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100"
drop-down-values="0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100"
primitive-value="0">
</igc-property-editor-property-description>
<igc-property-editor-property-description
property-path="YAxisMaximumValueHandler"
name="YAxisMaximumValue"
id="YAxisMaximumValue"
label="Y Axis Maximum Value"
should-override-default-editor="true"
value-type="EnumValue"
drop-down-names="100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200"
drop-down-values="100, 110, 120, 130, 140, 150, 160, 170, 180, 190, 200"
primitive-value="150">
</igc-property-editor-property-description>
</igc-property-editor-panel>
</div>
<div class="legend-title">
Highest Grossing Movie Franchises
</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, europe, china, america"
chart-type="Line"
computed-plot-area-margin-mode="Series"
is-horizontal-zoom-enabled="false"
is-vertical-zoom-enabled="false"
y-axis-minimum-value="0"
y-axis-maximum-value="150">
</igc-category-chart>
</div>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
html/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
Axis Modes & Scale
In the IgcFinancialChartComponent
and IgcCategoryChartComponent
controls, you can choose if your data is plotted on logarithmic scale along the y-axis when the yAxisIsLogarithmic
property is set to true or on linear scale when this property is set to false (default value). With the yAxisLogarithmBase
property, you can change base of logarithmic scale from default value of 10 to other integer value.
The IgcFinancialChartComponent
and control allows you to choose how your data is represented along the y-axis using yAxisMode
property that provides Numeric
and PercentChange
modes. The Numeric
mode will plot data with the exact values while the PercentChange
mode will display the data as percentage change relative to the first data point provided. The default value is Numeric
mode.
In addition to yAxisMode
property, the IgcFinancialChartComponent
control has xAxisMode
property that provides Time
and Ordinal
modes for the x-axis. The Time
mode will render space along the x-axis for gaps in data (e.g. no stock trading on weekends or holidays). The Ordinal
mode will collapse date areas where data does not exist. The default value is Ordinal
mode.
export class StocksUtility {
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: Date = this.addYears(dateEnd, -years);
return this.getStocksBetween(dateStart, dateEnd, true);
}
public static getStocksItems(points: number, intervalMinutes?: number): any {
if (intervalMinutes === undefined || intervalMinutes <= 0) {
intervalMinutes = 60;
}
const today: Date = new Date();
const year: number = today.getFullYear();
const dateEnd: Date = new Date(year, 11, 1);
const dateStart: Date = this.addHours(dateEnd, -points);
return this.getStocksBetween(dateStart, dateEnd, false, intervalMinutes);
}
// generates stocks data for specified number of months, with each item separated by specified interval in minutes
public static getStocksForMonths(rangeInMonths?: number, intervalMinutes?: number, stockName?: string): any {
if (rangeInMonths === undefined) {
rangeInMonths = 6;
}
const dateEnd: Date = new Date();
const dateStart: Date = this.addMonths(dateEnd, -rangeInMonths);
return this.getStocksBetween(dateStart, dateEnd, true, intervalMinutes, stockName);
}
public static getStocksBetween(dateStart: Date, dateEnd: Date, useRounding?:
boolean, intervalMinutes?: number, stockName?: string): any {
if (intervalMinutes === undefined || intervalMinutes <= 0) {
intervalMinutes = 60;
}
let time: Date = this.addDays(dateStart, 0);
let v: number = this.volumeStart;
let o: number = this.priceStart;
let h: number = o + (Math.random() * this.priceRange);
let l: number = o - (Math.random() * this.priceRange);
let c: number = l + (Math.random() * (h - l));
const stock: any[] = [];
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) + 10;
}
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;
}
if (useRounding === undefined || useRounding) {
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, intervalMinutes);
}
if (stockName === undefined) {
stockName = "Stock Prices";
}
// setting data intent for Series Title
(stock as any).__dataIntents = {
close: ["SeriesTitle/" + stockName]
};
// console.log("start " + this.ToString(dateStart));
// console.log("end " + this.ToString(dateEnd));
console.log("stocks " + stock.length);
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 this.addMinutes(date, hours * 60);
}
public static addDays(date: Date, days: number): Date {
return this.addHours(date, days * 24);
}
public static addMonths(date: Date, months: number): Date {
return this.addDays(date, 31 * months);
}
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 {
return Math.round((date.getMonth() + 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: any = this.getLastItem(array);
if (interval === undefined || interval <= 0) {
interval = 60;
}
const time: Date = this.addMinutes(lastItem.date, interval);
let v: number = lastItem.volume;
let o: number = lastItem.open;
let h: number = lastItem.high;
let l: number = lastItem.low;
let c: number = 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;
}
return { date: time, open: o, high: h, low: l, close: c, volume: v };
}
public static toString(date: Date): string {
const months: string[] = [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
];
const index: number = date.getMonth();
return months[index] + " " + date.getDay() + " " + date.getFullYear();
}
}
tsimport { IgcFinancialChartModule } from 'igniteui-webcomponents-charts';
import { IgcFinancialChartComponent } from 'igniteui-webcomponents-charts';
import { FinancialChartXAxisMode } from 'igniteui-webcomponents-charts';
import { FinancialChartYAxisMode } from 'igniteui-webcomponents-charts';
import { ModuleManager } from 'igniteui-webcomponents-core';
import { StocksUtility } from './StocksUtility';
ModuleManager.register(IgcFinancialChartModule);
export class FinancialChartAxisTypes {
private chart: IgcFinancialChartComponent;
private xAxisMode = FinancialChartXAxisMode.Ordinal;
private yAxisMode = FinancialChartYAxisMode.Numeric;
private yAxisIsLogarithmic = false;
constructor() {
this.chart = document.getElementById('chart') as IgcFinancialChartComponent;
this.chart.dataSource = this.initData();
this.chart.xAxisMode = this.xAxisMode;
this.chart.yAxisMode = this.yAxisMode;
this.chart.yAxisIsLogarithmic = this.yAxisIsLogarithmic;
let xAxisSelect = <HTMLSelectElement>document.getElementById('xAxisSelect');
xAxisSelect!.addEventListener('change', this.onXAxisModeChanged);
xAxisSelect!.value = "Ordinal";
let yAxisSelect = <HTMLSelectElement>document.getElementById('yAxisSelect');
yAxisSelect!.addEventListener('change', this.onYAxisModeChanged);
yAxisSelect!.value = "Numeric";
let yAxisIsLogarithmicSelect = document.getElementById('yAxisIsLogarithmicSelect');
yAxisIsLogarithmicSelect!.addEventListener('change', this.onYAxisIsLogarithmicChanged);
}
public onXAxisModeChanged = (e: any) => {
const mode: string = e.target.value;
if (mode === 'Time') {
this.xAxisMode = FinancialChartXAxisMode.Time;
} else if (mode === 'Ordinal') {
this.xAxisMode = FinancialChartXAxisMode.Ordinal;
}
this.chart.xAxisMode = this.xAxisMode;
}
public onYAxisModeChanged = (e: any) => {
const mode: string = e.target.value;
if (mode === 'PercentChange') {
this.yAxisMode = FinancialChartYAxisMode.PercentChange;
} else if (mode === 'Numeric') {
this.yAxisMode = FinancialChartYAxisMode.Numeric;
}
this.chart.yAxisMode = this.yAxisMode;
}
public onYAxisIsLogarithmicChanged = (e: any) => {
this.yAxisIsLogarithmic = e.target.checked;
this.chart.yAxisIsLogarithmic = this.yAxisIsLogarithmic;
}
initData(): any[] {
return StocksUtility.getStocksForMonths(12);
}
}
new FinancialChartAxisTypes();
ts<!DOCTYPE html>
<html>
<head>
<title>FinancialChartAxisTypes</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="options horizontal">
<label class="options-label">X-Axis Mode:</label>
<select id="xAxisSelect">
<option>Time</option>
<option>Ordinal</option>
</select>
<label class="options-label">Y-Axis Mode:</label>
<select id="yAxisSelect">
<option>PercentChange</option>
<option>Numeric</option>
</select>
<label class="options-label">
<input id="yAxisIsLogarithmicSelect" type="checkbox"></input> Y-Axis-IsLogarithmic
</label>
</div>
<div class="container" style="height: calc(100% - 3rem)">
<igc-financial-chart id="chart" width="100%" height="100%"
chart-type="Line"
thickness="2">
</igc-financial-chart>
</div>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
html/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
Axis Gap Example
The xAxisGap
property of the Web Components charts, determines the amount of space between columns or bars of plotted series. This property accepts a numeric value between 0.0 and 1.0. The value represents a relative width of the gap out of the available number of pixels between the series. Setting this property to 0 would mean there is no gap rendered between the series, and setting it 1 would render the maximum available gap.
The xAxisMaximumGap
property of the Web Components charts, determines the maximum gap value to allow. This default is set to 1.0 but can be changed depending on what you set xAxisGap
to.
The xAxisMinimumGapSize
property of the Web Components charts, determines the minimum amount of pixels to use for the gap between the categories, if possible.
The following example shows the average maximum temperature in Celsius in New York City's Central Park represented by a Column Chart with an xAxisGap
initially set to 1, and so there will be a full category's width between the columns. There is a slider that allows you to configure the gap in this example so that you can see what the different values do.
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 { IgcPropertyEditorPanelModule } from 'igniteui-webcomponents-layouts';
import { IgcLegendModule, IgcCategoryChartModule } from 'igniteui-webcomponents-charts';
import { ComponentRenderer, PropertyEditorPanelDescriptionModule, LegendDescriptionModule, CategoryChartDescriptionModule } from 'igniteui-webcomponents-core';
import { IgcPropertyEditorPanelComponent, IgcPropertyEditorPropertyDescriptionComponent } from 'igniteui-webcomponents-layouts';
import { IgcCategoryChartComponent } from 'igniteui-webcomponents-charts';
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from './CountryRenewableElectricity';
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 propertyEditorPanel1: IgcPropertyEditorPanelComponent
private xAxisGap: IgcPropertyEditorPropertyDescriptionComponent
private xAxisMaximumGap: IgcPropertyEditorPropertyDescriptionComponent
private chart: IgcCategoryChartComponent
private _bind: () => void;
constructor() {
var propertyEditorPanel1 = this.propertyEditorPanel1 = document.getElementById('propertyEditorPanel1') as IgcPropertyEditorPanelComponent;
var xAxisGap = this.xAxisGap = document.getElementById('XAxisGap') as IgcPropertyEditorPropertyDescriptionComponent;
var xAxisMaximumGap = this.xAxisMaximumGap = document.getElementById('XAxisMaximumGap') as IgcPropertyEditorPropertyDescriptionComponent;
var chart = this.chart = document.getElementById('chart') as IgcCategoryChartComponent;
this._bind = () => {
propertyEditorPanel1.componentRenderer = this.renderer;
propertyEditorPanel1.target = this.chart;
chart.dataSource = this.countryRenewableElectricity;
}
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;
}
}
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
description-type="CategoryChart"
is-horizontal="true"
is-wrapping-enabled="true"
name="propertyEditorPanel1"
id="propertyEditorPanel1">
<igc-property-editor-property-description
property-path="XAxisGap"
name="XAxisGap"
id="XAxisGap"
label="X Axis - Gap"
should-override-default-editor="true"
value-type="Slider"
primitive-value="0.5"
min="0"
max="1.5"
step="0.1">
</igc-property-editor-property-description>
<igc-property-editor-property-description
property-path="XAxisMaximumGap"
name="XAxisMaximumGap"
id="XAxisMaximumGap"
label="Maximum Gap"
should-override-default-editor="true"
value-type="EnumValue"
drop-down-names="1.5, 1.3, 1.0, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0"
drop-down-values="1.5, 1.3, 1.0, 0.6, 0.5, 0.4, 0.3, 0.2, 0.1, 0"
primitive-value="0.5">
</igc-property-editor-property-description>
</igc-property-editor-panel>
</div>
<div class="legend-title">
Renewable Electricity Generated
</div>
<div class="container fill">
<igc-category-chart
name="chart"
id="chart"
included-properties="year, europe, china, america"
chart-type="Column"
crosshairs-snap-to-data="true"
y-axis-title="TWh"
is-horizontal-zoom-enabled="false"
is-vertical-zoom-enabled="false"
x-axis-interval="1"
x-axis-gap="0.5"
x-axis-maximum-gap="1.5">
</igc-category-chart>
</div>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
html/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
Axis Overlap Example
The xAxisOverlap
property of the Web Components charts, allows setting the overlap of the rendered columns or bars of plotted series. This property accepts a numeric value between -1.0 and 1.0. The value represents a relative overlap out of the available number of pixels dedicated to each series. Setting this property to a negative value (down to -1.0) results in the categories being pushed away from each other, producing a gap between themselves. Conversely, setting this property to a positive value (up to 1.0) results in the categories overlapping each other. A value of 1 directs the chart to render the categories on top of each other.
The following example shows a comparison of the highest grossing worldwide film franchises compared by the total world box office revenue of the franchise and the highest grossing movie in the series, represented by a Column Chart with an xAxisOverlap
initially set to 1, and so the columns will completely overlap each other. There is a slider that allows you to configure the overlap in this example so that you can see what the different values do.
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 { 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 { HighestGrossingMoviesItem, HighestGrossingMovies } from './HighestGrossingMovies';
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 propertyEditorPanel1: IgcPropertyEditorPanelComponent
private xAxisOverlap: IgcPropertyEditorPropertyDescriptionComponent
private chart: IgcCategoryChartComponent
private _bind: () => void;
constructor() {
var legend = this.legend = document.getElementById('legend') as IgcLegendComponent;
var propertyEditorPanel1 = this.propertyEditorPanel1 = document.getElementById('propertyEditorPanel1') as IgcPropertyEditorPanelComponent;
var xAxisOverlap = this.xAxisOverlap = document.getElementById('XAxisOverlap') as IgcPropertyEditorPropertyDescriptionComponent;
var chart = this.chart = document.getElementById('chart') as IgcCategoryChartComponent;
this._bind = () => {
propertyEditorPanel1.componentRenderer = this.renderer;
propertyEditorPanel1.target = this.chart;
chart.dataSource = this.highestGrossingMovies;
}
this._bind();
}
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;
}
}
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
description-type="CategoryChart"
is-horizontal="true"
is-wrapping-enabled="true"
name="propertyEditorPanel1"
id="propertyEditorPanel1">
<igc-property-editor-property-description
property-path="XAxisOverlap"
name="XAxisOverlap"
id="XAxisOverlap"
label="X Axis - Overlap"
should-override-default-editor="true"
value-type="Slider"
min="0"
max="1"
step="0.1"
primitive-value="0">
</igc-property-editor-property-description>
</igc-property-editor-panel>
</div>
<div class="legend-title">
Highest Grossing Movie Franchises
</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"
chart-type="Column"
crosshairs-snap-to-data="true"
is-horizontal-zoom-enabled="false"
is-vertical-zoom-enabled="false"
x-axis-interval="1"
x-axis-overlap="1">
</igc-category-chart>
</div>
</div>
</div>
<!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><script src="src/index.ts"></script><% } %>
</body>
</html>
html/* shared styles are loaded from: */
/* https://static.infragistics.com/xplatform/css/samples */
css
Additional Resources
You can find more information about related chart features in these topics:
API References
The following is a list of API members mentioned in the above sections: