Close
Angular React Web Components Blazor
Premium

Angular Toolbar Overview

The Angular 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 DataChart or CategoryChart components. You’ll be able to create custom tools for your project allowing end users to provide changes, offering an endless amount of customization.

Angular Toolbar Example

Dependencies

Install the Ignite UI for Angular layouts, inputs, charts and core packages:

npm install igniteui-angular-layouts
npm install igniteui-angular-inputs
npm install igniteui-angular-charts
npm install igniteui-angular-core

The following modules are required when using the Toolbar with the DataChart component and it’s features.

import { IgxToolbarModule } from 'igniteui-angular-layouts';
import { IgxDataChartToolbarModule, IgxDataChartCoreModule, IgxDataChartCategoryModule, IgxDataChartAnnotationModule, IgxDataChartInteractivityModule, IgxDataChartCategoryTrendLineModule  } from 'igniteui-angular-charts';

@NgModule({
    imports: [
        // ...
        IgxToolbarModule,
        IgxDataChartToolbarModule,
        IgxDataChartCoreModule,
        IgxDataChartCategoryModule,
        IgxDataChartAnnotationModule,
        IgxDataChartInteractivityModule,
        IgxDataChartCategoryTrendLineModule
        // ...
    ]
})
export class AppModule {}

Usage

Tool Actions

The following is a list of the different ToolAction items that you can add to the Toolbar.

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

New and existing tools can be repositioned and marked hidden using the OverlayId, BeforeId and AfterId properties on the ToolAction object. ToolActions also expose a Visibility property.

The following example demonstrates a couple of features. First you can group tools together in the ToolActionSubPanel 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 within the ZoomMenu by using the the AfterId property and assigning that to ZoomOut to be precise with it’s placement. It is also highlighted via the IsHighlighted property on the tool.

Angular Data Chart Integration

The Angular Toolbar contains a Target property. This is used to link a component, such as the DataChart as shown in the code below:

  <div class="legend">
    <igx-toolbar
      name="toolbar"
      [target]="chart"
      #toolbar>
    </igx-toolbar>
  </div>
  <div class="container fill">
    <igx-data-chart
    name="chart"
    #chart>
  </igx-data-chart>

Several pre-existing ToolAction items and menus become available when the DataChart is linked with the Toolbar. Here is a list of the built-in Angular DataChart Tool Actions and their associated OverlayId:

Zooming Actions

Trend Actions

  • AnalyzeMenu: A ToolActionIconMenu that contains several options for configuring different options of the chart.
  • AnalyzeHeader: A sub section header.
    • LinesMenu: A sub menu containing various tools for showing different dashed horizontal lines on the chart.
    • LinesHeader: A sub menu section header for the following three tools:
      • MaxValue: A ToolActionCheckbox that displays a dashed horizontal line along the yAxis at the maximum value of the series.
      • MinValue: A ToolActionCheckbox that displays a dashed horizontal line along the yAxis at the minimum value of the series.
      • Average: A ToolActionCheckbox that displays a dashed horizontal line along the yAxis at the average value of the series.
    • TrendsMenu: A sub menu containing tools for applying various trendlines to the DataChart plot area.
    • TrendsHeader: A sub menu section header for the following three tools:
  • HelpersHeader: A sub section header.
  • ShowCrosshairs: A ToolActionCheckbox that toggles mouse-over crosshair annotations via the chart’s CrosshairsDisplayMode property.
  • ShowGridlines: A ToolActionCheckbox that toggles extra gridlines by applying a MajorStroke to the X-Axis.

Save to Image Action

  • CopyAsImage: A ToolActionLabel that exposes an option to copy the chart to the clipboard.
  • CopyHeader: A sub section header.

SVG Icons

When adding tools manually, icons can be assigned using the RenderIconFromText method. There are three parameters 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.

<igx-tool-action-label
    title="Custom Icon"
    iconName="CustomIcon"
    iconCollectionName="CustomCollection">
</igx-tool-action-label>
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);
}
public toolbarCustomIconOnViewInit(): void {

  toolbar.registerIconFromDataURL("CustomCollection", "CustomIcon", "https://www.svgrepo.com/show/678/calculator.svg");

}
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);

}
public toolbarCustomIconOnViewInit(): void {

  toolbar.registerIconFromDataURL("CustomCollection", "CustomIcon", "https://www.svgrepo.com/show/678/calculator.svg");

}

Vertical Orientation

By default the Angular Toolbar is shown horizontally, but it also has the ability to shown vertically by setting the Orientation property.

<igx-toolbar orientation="Vertical" />

The following example demonstrates the vertical orientation of the Angular Toolbar.

Color Editor

You can add a custom color editor tool to the the Angular Toolbar, which will also work with the Command event to perform custom styling to your application.

<igx-toolbar
  name="toolbar"
  #toolbar>
      <igx-tool-action-color-editor
      title="Series Brush"
      name="colorEditorTool"
      #colorEditorTool>
      </igx-tool-action-color-editor>
</igx-toolbar>

The following example demonstrates styling the Angular Data Chart series brush with the Color Editor tool.

API References

Additional Resources