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.

    Ejemplo de barra de herramientas Web Components

    EXAMPLE
    DATA
    TS
    HTML
    CSS

    ¿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:

    npm install igniteui-webcomponents-layouts
    npm install igniteui-webcomponents-inputs
    npm install igniteui-webcomponents-charts
    npm install igniteui-webcomponents-core
    cmd

    Los siguientes módulos son necesarios cuando se utiliza IgcToolbarComponent con el componente IgcDataChartComponent y sus características.

    import { ModuleManager } from 'igniteui-webcomponents-core';
    import { IgcToolbarModule } from 'igniteui-webcomponents-layouts';
    import { IgcDataChartToolbarModule, IgcDataChartCoreModule, IgcDataChartCategoryModule, IgcDataChartAnnotationModule, IgcDataChartInteractivityModule, IgcDataChartCategoryTrendLineModule } from 'igniteui-webcomponents-charts';
    
    ModuleManager.register(
        IgcToolbarModule,
        IgcToolActionLabelModule,
        IgcDataChartToolbarModule,
        IgcDataChartCategoryModule,
        IgcDataChartCoreModule,
        IgcDataChartInteractivityModule,
        IgcDataChartAnnotationModule,
        IgcDataChartCategoryTrendLineModule
    );
    ts
    Ignite UI for Web Components | CTA Banner

    Uso

    Acciones de herramienta

    La siguiente es una lista de los diferentes elementos IgcToolActionComponent que puede agregar a la barra de herramientas.

    Each of these tools exposes an OnCommand event that is triggered by mouse click. Note, the IgcToolActionIconMenuComponent is a wrapper for other tools that can also be wrapped inside a IgcToolActionIconMenuComponent.

    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.

    EXAMPLE
    DATA
    TS
    HTML
    CSS

    Integración Web Components Gráfico de datos

    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:

      <div>
          <igc-toolbar
          name="Toolbar"
          id="Toolbar">
          </igc-toolbar>
      </div>
    
      <div class="container fill">
          <igc-data-chart
          is-horizontal-zoom-enabled="true"
          name="chart"
          id="chart">
          </igc-data-chart>
      </div>
    html
      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

    Acciones de tendencia

    Acción Guardar en imagen

    • CopyAsImage: A IgcToolActionLabelComponent que expone una opción para copiar el gráfico en el portapapeles.
    • CopyHeader: Un encabezado de subsección.

    Iconos SVG

    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.

    public toolbarCustomIconOnViewInit(): void {
    
      const icon = '<svg width="28px" height="28px" stroke="none" viewBox="0 0 3.5 3.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M0.436 0.178a0.073 0.073 0 0 0 -0.062 0.036L0.01 0.846a0.073 0.073 0 0 0 0.063 0.109h0.729a0.073 0.073 0 0 0 0.063 -0.109L0.501 0.214a0.073 0.073 0 0 0 -0.064 -0.036zm0.001 0.219 0.238 0.413H0.199zM1.4 0.507v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245zM0.073 1.388A0.073 0.073 0 0 0 0 1.461v0.583a0.073 0.073 0 0 0 0.073 0.073h0.729A0.073 0.073 0 0 0 0.875 2.045V1.461a0.073 0.073 0 0 0 -0.073 -0.073zm0.073 0.146h0.583v0.438H0.146zM1.4 1.674v0.245h0.945v-0.245zm1.19 0v0.245h0.91v-0.245zM0.438 2.447c-0.241 0 -0.438 0.197 -0.438 0.438 0 0.241 0.197 0.438 0.438 0.438s0.438 -0.197 0.438 -0.438c0 -0.241 -0.197 -0.438 -0.438 -0.438zm0 0.146a0.291 0.291 0 0 1 0.292 0.292 0.291 0.291 0 0 1 -0.292 0.292 0.291 0.291 0 0 1 -0.292 -0.292A0.291 0.291 0 0 1 0.438 2.593zM1.4 2.842v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245z" fill="#000000" fill-rule="evenodd"/></svg>';
      
      this.toolbar.registerIconFromText("CustomCollection", "CustomIcon", icon);
    }
    ts
    public toolbarCustomIconOnViewInit(): void {
    
      toolbar.registerIconFromDataURL("CustomCollection", "CustomIcon", "https://www.svgrepo.com/show/678/calculator.svg");
    
    }
    ts
    <igc-tool-action-label
        title="Custom Icon"
        icon-name="CustomIcon"
        icon-collection-name="CustomCollection">
    </igc-tool-action-label>
    html
    public toolbarCustomIconOnViewInit(): void {
    
      const icon = '<svg width="28px" height="28px" stroke="none" viewBox="0 0 3.5 3.5" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" aria-hidden="true" role="img" class="iconify iconify--gis" preserveAspectRatio="xMidYMid meet"><path d="M0.436 0.178a0.073 0.073 0 0 0 -0.062 0.036L0.01 0.846a0.073 0.073 0 0 0 0.063 0.109h0.729a0.073 0.073 0 0 0 0.063 -0.109L0.501 0.214a0.073 0.073 0 0 0 -0.064 -0.036zm0.001 0.219 0.238 0.413H0.199zM1.4 0.507v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245zM0.073 1.388A0.073 0.073 0 0 0 0 1.461v0.583a0.073 0.073 0 0 0 0.073 0.073h0.729A0.073 0.073 0 0 0 0.875 2.045V1.461a0.073 0.073 0 0 0 -0.073 -0.073zm0.073 0.146h0.583v0.438H0.146zM1.4 1.674v0.245h0.945v-0.245zm1.19 0v0.245h0.91v-0.245zM0.438 2.447c-0.241 0 -0.438 0.197 -0.438 0.438 0 0.241 0.197 0.438 0.438 0.438s0.438 -0.197 0.438 -0.438c0 -0.241 -0.197 -0.438 -0.438 -0.438zm0 0.146a0.291 0.291 0 0 1 0.292 0.292 0.291 0.291 0 0 1 -0.292 0.292 0.291 0.291 0 0 1 -0.292 -0.292A0.291 0.291 0 0 1 0.438 2.593zM1.4 2.842v0.245h0.525v-0.245zm0.77 0v0.245h1.33v-0.245z" fill="#000000" fill-rule="evenodd"/></svg>';
    
      this.toolbar.registerIconFromText("CustomCollection", "CustomIcon", icon);
    
    }
    ts
    public toolbarCustomIconOnViewInit(): void {
    
      toolbar.registerIconFromDataURL("CustomCollection", "CustomIcon", "https://www.svgrepo.com/show/678/calculator.svg");
      
    }
    ts

    @code {

    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        var toolbar = this.toolbar;
    
        if (firstRender) {
            this.ToolbarCustomIconOnViewInit();
        }
    }
    
    private IgbToolbar toolbar;
    
    public void ToolbarCustomIconOnViewInit()
    {
    	this.toolbar.EnsureReady().ContinueWith(new Action<Task>((e) =>
    	{
            this.toolbar.RegisterIconFromDataURLAsync("CustomCollection", "CustomIcon", "https://www.svgrepo.com/show/678/calculator.svg");
    	}));
    }
    typescript

    }

    
    ```tsx
    <IgrToolbar orientation="Vertical" />
    autohotkey

    Orientación vertical

    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-toolbar orientation="Vertical" />
    html

    En el ejemplo siguiente se muestra la orientación vertical de la barra de herramientas Web Components.

    EXAMPLE
    DATA
    TS
    HTML
    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.

    <igc-toolbar
      name="toolbar"
      id="toolbar">
          <igc-tool-action-color-editor
          title="Series Brush Color"
          name="colorEditorTool"
          id="colorEditorTool">
          </igc-tool-action-color-editor>
    </igc-toolbar>
    ts

    En el ejemplo siguiente se muestra el estilo del pincel de la serie Web Components Gráfico de datos con la herramienta Editor de color.

    EXAMPLE
    DATA
    TS
    HTML
    CSS

    Referencias de API

    Recursos adicionales