The Web Components Toolbar component is a companion container for UI operations to be used primarily with our charting components. The toolbar will dynamically update with a preset of properties and tool items when linked to our IgcDataChartComponent or IgcCategoryChartComponent components. You'll be able to create custom tools for your project allowing end users to provide changes, offering an endless amount of customization.
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample"><divclass="legend-title">
Renewable Electricity Generated
</div><divclass="aboveContentSplit"><divclass="aboveContentLeftContainer"><igc-toolbarname="toolbar"id="toolbar"orientation="Horizontal"></igc-toolbar></div><divclass="aboveContentRightContainer"><igc-legendname="legend"id="legend"orientation="Horizontal"></igc-legend></div></div><divclass="container fill"><igc-category-chartname="chart"id="chart"chart-type="Line"is-horizontal-zoom-enabled="true"is-vertical-zoom-enabled="true"included-properties="year, europe, china, america"y-axis-title="TWh"y-axis-title-left-margin="10"y-axis-title-right-margin="5"y-axis-label-left-margin="0"y-axis-label-location="OutsideRight"is-transition-in-enabled="true"></igc-category-chart></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
The following example demonstrates a couple of features. First you can group tools together in the IgcToolActionSubPanelComponent including hiding built in tools such as the ZoomReset and AnalyzeMenu menu tool actions. In this example a new instance of the ZoomReset tool action is added and placed within the ZoomMenu by using the the afterId property and assigning that to ZoomOut. It is also highlighted via the isHighlighted property on the tool. This will ensure the new Reset tool is promptly displayed at the bottom of the ZoomMenu.
import { IgcToolbarModule } from'igniteui-webcomponents-layouts';
import { IgcDataChartToolbarModule, IgcDataChartCoreModule, IgcDataChartCategoryModule, IgcDataChartAnnotationModule, IgcDataChartInteractivityModule, IgcDataChartCategoryTrendLineModule } from'igniteui-webcomponents-charts';
import { IgcToolbarComponent, IgcToolActionIconMenuComponent, IgcToolActionGroupHeaderComponent, IgcToolActionSubPanelComponent, IgcToolActionCheckboxComponent, IgcToolActionLabelComponent } from'igniteui-webcomponents-layouts';
import { IgcDataChartComponent, IgcCategoryXAxisComponent, IgcNumericYAxisComponent, IgcLineSeriesComponent } from'igniteui-webcomponents-charts';
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from'./CountryRenewableElectricity';
import { IgcToolCommandEventArgs } from'igniteui-webcomponents-layouts';
import { IgcSeriesComponent, IgcDataToolTipLayerComponent, IgcCrosshairLayerComponent, IgcFinalValueLayerComponent } from'igniteui-webcomponents-charts';
import { ModuleManager } from'igniteui-webcomponents-core';
import"./index.css";
ModuleManager.register(
IgcToolbarModule,
IgcDataChartToolbarModule,
IgcDataChartCoreModule,
IgcDataChartCategoryModule,
IgcDataChartAnnotationModule,
IgcDataChartInteractivityModule,
IgcDataChartCategoryTrendLineModule
);
exportclassSample{
private toolbar: IgcToolbarComponent
private menuForSubPanelTool: IgcToolActionIconMenuComponent
private subPanelGroup: IgcToolActionGroupHeaderComponent
private customSubPanelTools: IgcToolActionSubPanelComponent
private enableTooltipsLabel: IgcToolActionCheckboxComponent
private enableCrosshairsLabel: IgcToolActionCheckboxComponent
private enableFinalValuesLabel: IgcToolActionCheckboxComponent
private zoomResetLabel: IgcToolActionLabelComponent
private zoomResetHidden: IgcToolActionLabelComponent
private analyzeMenu: IgcToolActionIconMenuComponent
private copyMenu: IgcToolActionLabelComponent
private chart: IgcDataChartComponent
private xAxis: IgcCategoryXAxisComponent
private yAxis: IgcNumericYAxisComponent
private lineSeries1: IgcLineSeriesComponent
private lineSeries2: IgcLineSeriesComponent
private lineSeries3: IgcLineSeriesComponent
private _bind: () =>void;
constructor() {
var toolbar = this.toolbar = document.getElementById('toolbar') as IgcToolbarComponent;
this.toolbarToggleAnnotations = this.toolbarToggleAnnotations.bind(this);
var menuForSubPanelTool = this.menuForSubPanelTool = document.getElementById('MenuForSubPanelTool') as IgcToolActionIconMenuComponent;
var subPanelGroup = this.subPanelGroup = document.getElementById('SubPanelGroup') as IgcToolActionGroupHeaderComponent;
var customSubPanelTools = this.customSubPanelTools = document.getElementById('CustomSubPanelTools') as IgcToolActionSubPanelComponent;
var enableTooltipsLabel = this.enableTooltipsLabel = document.getElementById('EnableTooltipsLabel') as IgcToolActionCheckboxComponent;
var enableCrosshairsLabel = this.enableCrosshairsLabel = document.getElementById('EnableCrosshairsLabel') as IgcToolActionCheckboxComponent;
var enableFinalValuesLabel = this.enableFinalValuesLabel = document.getElementById('EnableFinalValuesLabel') as IgcToolActionCheckboxComponent;
var zoomResetLabel = this.zoomResetLabel = document.getElementById('zoomResetLabel') as IgcToolActionLabelComponent;
var zoomResetHidden = this.zoomResetHidden = document.getElementById('zoomResetHidden') as IgcToolActionLabelComponent;
var analyzeMenu = this.analyzeMenu = document.getElementById('AnalyzeMenu') as IgcToolActionIconMenuComponent;
var copyMenu = this.copyMenu = document.getElementById('CopyMenu') as IgcToolActionLabelComponent;
var chart = this.chart = document.getElementById('chart') as IgcDataChartComponent;
var xAxis = this.xAxis = document.getElementById('xAxis') as IgcCategoryXAxisComponent;
var yAxis = this.yAxis = document.getElementById('yAxis') as IgcNumericYAxisComponent;
var lineSeries1 = this.lineSeries1 = document.getElementById('lineSeries1') as IgcLineSeriesComponent;
var lineSeries2 = this.lineSeries2 = document.getElementById('LineSeries2') as IgcLineSeriesComponent;
var lineSeries3 = this.lineSeries3 = document.getElementById('LineSeries3') as IgcLineSeriesComponent;
this._bind = () => {
toolbar.target = this.chart;
toolbar.onCommand = this.toolbarToggleAnnotations;
xAxis.dataSource = this.countryRenewableElectricity;
lineSeries1.xAxis = this.xAxis;
lineSeries1.yAxis = this.yAxis;
lineSeries1.dataSource = this.countryRenewableElectricity;
lineSeries2.xAxis = this.xAxis;
lineSeries2.yAxis = this.yAxis;
lineSeries2.dataSource = this.countryRenewableElectricity;
lineSeries3.xAxis = this.xAxis;
lineSeries3.yAxis = this.yAxis;
lineSeries3.dataSource = this.countryRenewableElectricity;
}
this._bind();
}
private _countryRenewableElectricity: CountryRenewableElectricity = null;
publicgetcountryRenewableElectricity(): CountryRenewableElectricity {
if (this._countryRenewableElectricity == null)
{
this._countryRenewableElectricity = new CountryRenewableElectricity();
}
returnthis._countryRenewableElectricity;
}
public toolbarToggleAnnotations(sender: any, args: IgcToolCommandEventArgs): void {
var target = this.chart;
switch (args.command.commandId)
{
case"EnableTooltips":
var enable = args.command.argumentsList[0].value asboolean;
if (enable)
{
target.series.add(new IgcDataToolTipLayerComponent());
}
else
{
var toRemove = null;
for (var i = 0; i < target.actualSeries.length; i++) {
let s = target.actualSeries[i] as IgcSeriesComponent;
if (s instanceof IgcDataToolTipLayerComponent)
{
toRemove = s;
}
}
if (toRemove != null)
{
target.series.remove(toRemove);
}
}
break;
case"EnableCrosshairs":
var enable = args.command.argumentsList[0].value asboolean;
if (enable)
{
target.series.add(new IgcCrosshairLayerComponent());
}
else
{
var toRemove = null;
for (var i = 0; i < target.actualSeries.length; i++) {
let s = target.actualSeries[i] as IgcSeriesComponent;
if (s instanceof IgcCrosshairLayerComponent)
{
toRemove = s;
}
}
if (toRemove != null)
{
target.series.remove(toRemove);
}
}
break;
case"EnableFinalValues":
var enable = args.command.argumentsList[0].value asboolean;
if (enable)
{
target.series.add(new IgcFinalValueLayerComponent());
}
else
{
var toRemove = null;
for (var i = 0; i < target.actualSeries.length; i++) {
let s = target.actualSeries[i] as IgcSeriesComponent;
if (s instanceof IgcFinalValueLayerComponent)
{
toRemove = s;
}
}
if (toRemove != null)
{
target.series.remove(toRemove);
}
}
break;
}
}
}
new Sample();
ts
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample"><divclass="aboveContentSplit"><divclass="aboveContentLeftContainer"><igc-toolbarname="toolbar"id="toolbar"orientation="Horizontal"><igc-tool-action-icon-menuname="MenuForSubPanelTool"id="MenuForSubPanelTool"icon-collection-name="ChartToolbarIcons"icon-name="analyze"><igc-tool-action-group-headername="SubPanelGroup"id="SubPanelGroup"close-on-execute="true"title="Visualizations"subtitle="Layers"></igc-tool-action-group-header><igc-tool-action-sub-panelname="CustomSubPanelTools"id="CustomSubPanelTools"><igc-tool-action-checkboxname="EnableTooltipsLabel"id="EnableTooltipsLabel"title="Enable Tooltips"command-id="EnableTooltips"></igc-tool-action-checkbox><igc-tool-action-checkboxname="EnableCrosshairsLabel"id="EnableCrosshairsLabel"title="Enable Crosshairs"command-id="EnableCrosshairs"></igc-tool-action-checkbox><igc-tool-action-checkboxname="EnableFinalValuesLabel"id="EnableFinalValuesLabel"title="Enable Final Values"command-id="EnableFinalValues"></igc-tool-action-checkbox></igc-tool-action-sub-panel></igc-tool-action-icon-menu><igc-tool-action-labelname="zoomResetLabel"id="zoomResetLabel"title="Reset"after-id="ZoomOut"icon-name="reset"icon-collection-name="ChartToolbarIcons"command-id="ZoomReset"is-highlighted="true"></igc-tool-action-label><igc-tool-action-labelname="zoomResetHidden"id="zoomResetHidden"overlay-id="ZoomReset"visibility="Collapsed"></igc-tool-action-label><igc-tool-action-icon-menuname="AnalyzeMenu"id="AnalyzeMenu"overlay-id="AnalyzeMenu"visibility="Collapsed"></igc-tool-action-icon-menu><igc-tool-action-labelname="CopyMenu"id="CopyMenu"overlay-id="CopyMenu"visibility="Collapsed"></igc-tool-action-label></igc-toolbar></div><divclass="aboveContentRightContainer"><!-- insert aboveContentRight --><!-- end aboveContentRight --></div></div><divclass="container fill"><igc-data-chartcomputed-plot-area-margin-mode="Series"is-horizontal-zoom-enabled="true"is-vertical-zoom-enabled="true"name="chart"id="chart"><igc-category-x-axisname="xAxis"id="xAxis"label="year"></igc-category-x-axis><igc-numeric-y-axisname="yAxis"id="yAxis"title="TWh"label-location="OutsideRight"></igc-numeric-y-axis><igc-line-seriesname="lineSeries1"id="lineSeries1"title="Electricity"value-member-path="america"></igc-line-series><igc-line-seriesname="LineSeries2"id="LineSeries2"title="Electricity"value-member-path="europe"></igc-line-series><igc-line-seriesname="LineSeries3"id="LineSeries3"title="Electricity"value-member-path="china"></igc-line-series></igc-data-chart></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
When adding tools manually, icons can be assigned using the RenderIconFromText method. There are three paramters to pass in this method. The first is the icon collection name defined on the tool eg. iconCollectionName. The second is the name of the icon defined on the tool eg. iconName, followed by adding the SVG string.
Data URL Icons
Similarly to adding svg, you can also add an Icon image from a URL via the RegisterIconFromDataURL. The method's third parameter would be used to enter a string URL.
The following snippet shows both methods of adding an Icon.
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample"><divclass="aboveContent"><igc-toolbarname="toolbar"id="toolbar"orientation="Vertical"></igc-toolbar></div><divclass="container fill"><igc-data-chartis-horizontal-zoom-enabled="true"name="chart"id="chart"><igc-category-x-axisname="xAxis"id="xAxis"label="year"></igc-category-x-axis><igc-numeric-y-axisname="yAxis"id="yAxis"title="TWh"label-location="OutsideRight"></igc-numeric-y-axis><igc-line-seriesname="lineSeries1"id="lineSeries1"title="Electricity"value-member-path="america"></igc-line-series></igc-data-chart></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html
/* shared styles are loaded from: *//* https://static.infragistics.com/xplatform/css/samples */css
Color Editor
You can add a custom color editor tool to the the Web Components Toolbar, which will also work with the Command event to perform custom styling to your application.
import { IgcToolbarModule, IgcToolActionComboModule, IgcToolActionColorEditorModule } from'igniteui-webcomponents-layouts';
import { IgcDataChartToolbarModule, IgcDataLegendModule, IgcNumberAbbreviatorModule, IgcDataChartCategoryModule, IgcDataChartCoreModule, IgcDataChartAnnotationModule, IgcDataChartInteractivityModule } from'igniteui-webcomponents-charts';
import { IgcToolbarComponent, IgcToolActionColorEditorComponent } from'igniteui-webcomponents-layouts';
import { IgcDataChartComponent, IgcCategoryXAxisComponent, IgcNumericYAxisComponent, IgcLineSeriesComponent } from'igniteui-webcomponents-charts';
import { CountryRenewableElectricityItem, CountryRenewableElectricity } from'./CountryRenewableElectricity';
import { IgcToolCommandEventArgs } from'igniteui-webcomponents-layouts';
import { IgcSeriesComponent } from'igniteui-webcomponents-charts';
import { ModuleManager } from'igniteui-webcomponents-core';
import"./index.css";
ModuleManager.register(
IgcToolbarModule,
IgcToolActionComboModule,
IgcToolActionColorEditorModule,
IgcDataChartToolbarModule,
IgcDataLegendModule,
IgcNumberAbbreviatorModule,
IgcDataChartCategoryModule,
IgcDataChartCoreModule,
IgcDataChartCategoryModule,
IgcDataChartAnnotationModule,
IgcDataChartInteractivityModule,
IgcDataChartAnnotationModule
);
exportclassSample{
private toolbar: IgcToolbarComponent
private colorEditorTool: IgcToolActionColorEditorComponent
private chart: IgcDataChartComponent
private xAxis: IgcCategoryXAxisComponent
private yAxis: IgcNumericYAxisComponent
private lineSeries1: IgcLineSeriesComponent
private _bind: () =>void;
constructor() {
var toolbar = this.toolbar = document.getElementById('toolbar') as IgcToolbarComponent;
this.colorEditorToggleSeriesBrush = this.colorEditorToggleSeriesBrush.bind(this);
var colorEditorTool = this.colorEditorTool = document.getElementById('colorEditorTool') as IgcToolActionColorEditorComponent;
var chart = this.chart = document.getElementById('chart') as IgcDataChartComponent;
var xAxis = this.xAxis = document.getElementById('xAxis') as IgcCategoryXAxisComponent;
var yAxis = this.yAxis = document.getElementById('yAxis') as IgcNumericYAxisComponent;
var lineSeries1 = this.lineSeries1 = document.getElementById('lineSeries1') as IgcLineSeriesComponent;
this._bind = () => {
toolbar.target = this.chart;
toolbar.onCommand = this.colorEditorToggleSeriesBrush;
xAxis.dataSource = this.countryRenewableElectricity;
lineSeries1.xAxis = this.xAxis;
lineSeries1.yAxis = this.yAxis;
lineSeries1.dataSource = this.countryRenewableElectricity;
}
this._bind();
}
private _countryRenewableElectricity: CountryRenewableElectricity = null;
publicgetcountryRenewableElectricity(): CountryRenewableElectricity {
if (this._countryRenewableElectricity == null)
{
this._countryRenewableElectricity = new CountryRenewableElectricity();
}
returnthis._countryRenewableElectricity;
}
public colorEditorToggleSeriesBrush(sender: any, args: IgcToolCommandEventArgs): void {
var target = this.chart;
var color = args.command.argumentsList[0].value;
switch (args.command.commandId)
{
case"ToggleSeriesBrush":
let series = target.contentSeries[0] as IgcSeriesComponent;
series.brush = color asany;
break;
}
}
}
new Sample();
ts
<!DOCTYPE html><html><head><title>Sample | Ignite UI | Web Components | infragistics</title><metacharset="UTF-8" /><linkrel="shortcut icon"href="https://static.infragistics.com/xplatform/images/browsers/wc.png" ><linkrel="stylesheet"href="https://fonts.googleapis.com/icon?family=Material+Icons" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Kanit&display=swap" /><linkrel="stylesheet"href="https://fonts.googleapis.com/css?family=Titillium Web" /><linkrel="stylesheet"href="https://static.infragistics.com/xplatform/css/samples/shared.v8.css" /><linkrel="stylesheet"href="/src/index.css"type="text/css" /></head><body><divid="root"><divclass="container sample"><divclass="aboveContentSplit"><divclass="aboveContentLeftContainer"><igc-toolbarname="toolbar"id="toolbar"><igc-tool-action-color-editortitle="Series Brush"name="colorEditorTool"id="colorEditorTool"command-id="ToggleSeriesBrush"></igc-tool-action-color-editor></igc-toolbar></div><divclass="aboveContentRightContainer"><!-- insert aboveContentRight --><!-- end aboveContentRight --></div></div><divclass="container fill"><igc-data-chartis-horizontal-zoom-enabled="true"name="chart"id="chart"><igc-category-x-axisname="xAxis"id="xAxis"label="year"></igc-category-x-axis><igc-numeric-y-axisname="yAxis"id="yAxis"title="TWh"label-location="OutsideRight"></igc-numeric-y-axis><igc-line-seriesname="lineSeries1"id="lineSeries1"title="Electricity"value-member-path="america"marker-type="None"></igc-line-series></igc-data-chart></div></div></div><!-- This script is needed only for parcel and it will be excluded for webpack -->
<% if (false) { %><scriptsrc="src/index.ts"></script><% } %>
</body></html>html