Descripción general de la barra de herramientas de Web Components
El componente Web Components barra de herramientas es un contenedor complementario para las operaciones de la interfaz de usuario que se usará principalmente con nuestros componentes de gráficos. La barra de herramientas se actualizará dinámicamente con un ajuste preestablecido de propiedades y elementos de herramienta cuando se vincule a nuestros IgcDataChartComponent componentes o IgcCategoryChartComponent. Podrá crear herramientas personalizadas para su proyecto, lo que permitirá a los usuarios finales proporcionar cambios, ofreciendo una cantidad infinita de personalización.
<!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
¿Te gusta esta muestra? Obtenga acceso a nuestro kit de herramientas de Ignite UI for Web Components completo y comience a crear sus propias aplicaciones en minutos. Descárgalo gratis.
dependencias
Instale los Ignite UI for Web Components diseños, entradas, gráficos y paquetes principales:
Las herramientas nuevas y existentes se pueden reposicionar y marcar como ocultas usando las propiedades overlayId, beforeId y afterId en el objeto IgcToolActionComponent. ToolActions también expone una propiedad visibility.
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
La barra de herramientas Web Components contiene una Target propiedad. Esto se utiliza para vincular un componente, como se IgcDataChartComponent muestra en el código a continuación:
private _bind: () =>void;
constructor() {
var toolbar = this.toolbar = document.getElementById('Toolbar') as IgcToolbarComponent;
var chart = this.chart = document.getElementById('chart') as IgcDataChartComponent;
this._bind = () => {
toolbar.target = this.chart;
}
this._bind();
}
ts
Varios elementos y menús preexistentes IgcToolActionComponent están disponibles cuando se IgcDataChartComponent vincula con la barra de herramientas. A continuación, se muestra una lista de las acciones de herramienta Web Components IgcDataChartComponent integradas y sus asociadas overlayId:
Acciones de zoom
ZoomReset: un IgcToolActionLabelComponent que invoca el método resetZoom en el gráfico para restablecer el nivel de zoom a su posición predeterminada.
Al agregar herramientas manualmente, los iconos se pueden asignar mediante el RenderIconFromText método. Hay tres parámetros que se deben pasar en este método. El primero es el nombre de la colección de iconos definido en la herramienta, por ejemplo. iconCollectionName El segundo es el nombre del icono definido en la herramienta, por ejemplo iconName, seguido de la adición de la cadena SVG.
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.
De forma predeterminada, la barra de herramientas Web Components se muestra horizontalmente, pero también tiene la capacidad de mostrarse verticalmente estableciendo la orientation propiedad.
<igc-toolbarorientation="Vertical" />html
En el ejemplo siguiente se muestra la orientación vertical de la barra de herramientas Web Components.
<!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
Puede agregar una herramienta de editor de color personalizada a la barra de herramientas Web Components, que también funcionará con el evento Command para realizar un estilo personalizado en la aplicación.
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