El componente Blazor 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 IgbDataChart componentes o IgbCategoryChart. Podrá crear herramientas personalizadas para su proyecto, lo que permitirá a los usuarios finales proporcionar cambios, ofreciendo una cantidad infinita de personalización.
Blazor Toolbar Example
EXAMPLE
DATA
MODULES
RAZOR
CSS
using System;
using System.Collections.Generic;
publicclassCountryRenewableElectricityItem
{
publicstring Year { get; set; }
publicdouble Europe { get; set; }
publicdouble China { get; set; }
publicdouble America { get; set; }
}
publicclassCountryRenewableElectricity
: List<CountryRenewableElectricityItem>
{
publicCountryRenewableElectricity()
{
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2009",
Europe = 34,
China = 21,
America = 19
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2010",
Europe = 43,
China = 26,
America = 24
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2011",
Europe = 66,
China = 29,
America = 28
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2012",
Europe = 69,
China = 32,
America = 26
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2013",
Europe = 58,
China = 47,
America = 38
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2014",
Europe = 40,
China = 46,
America = 31
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2015",
Europe = 78,
China = 50,
America = 19
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2016",
Europe = 13,
China = 90,
America = 52
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2017",
Europe = 78,
China = 132,
America = 50
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2018",
Europe = 40,
China = 134,
America = 34
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2018",
Europe = 40,
China = 134,
America = 34
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2019",
Europe = 80,
China = 96,
America = 38
});
}
}cs
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modulesnamespaceInfragistics.Samples
{
publicclassProgram
{
publicstaticasync Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbLegendModule),
typeof(IgbToolbarModule),
typeof(IgbCategoryChartModule),
typeof(IgbCategoryChartToolbarModule),
typeof(IgbCheckboxListModule)
);
await builder.Build().RunAsync();
}
}
}cs
También deberá vincular un archivo CSS adicional para aplicar el estilo al IgbToolbar componente. Lo siguiente debe colocarse en el archivo wwwroot/index.html de un proyecto de Blazor Web Assembly o en el archivo Pages/_Host.cshtml de un proyecto de Blazor Server:
Cada una de estas herramientas expone un OnCommand evento que se desencadena al hacer clic del mouse. Tenga en cuenta que es IgbToolActionIconMenu un envoltorio para otras herramientas que también se pueden envolver dentro de un IgbToolActionIconMenu.
Las herramientas nuevas y existentes se pueden reposicionar y marcar como ocultas usando las propiedades OverlayId, BeforeId y AfterId en el objeto IgbToolAction. ToolActions también expone una propiedad Visibility.
En el ejemplo siguiente se muestran un par de características. En primer lugar, puede agrupar herramientas en las IgbToolActionSubPanel herramientas integradas de ocultación, incluidas las acciones de la herramienta de menú ZoomReset y AnalyzeMenu. En este ejemplo, se agrega una nueva instancia de la acción de la herramienta ZoomReset y se coloca dentro de ZoomMenu mediante la propiedad the AfterId y asignándola a ZoomOut. También se resalta a través de la IsHighlighted propiedad de la herramienta. Esto asegurará que la nueva herramienta de restablecimiento se muestre rápidamente en la parte inferior del ZoomMenu.
EXAMPLE
DATA
MODULES
RAZOR
CSS
using System;
using System.Collections.Generic;
publicclassCountryRenewableElectricityItem
{
publicstring Year { get; set; }
publicdouble Europe { get; set; }
publicdouble China { get; set; }
publicdouble America { get; set; }
}
publicclassCountryRenewableElectricity
: List<CountryRenewableElectricityItem>
{
publicCountryRenewableElectricity()
{
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2009",
Europe = 34,
China = 21,
America = 19
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2010",
Europe = 43,
China = 26,
America = 24
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2011",
Europe = 66,
China = 29,
America = 28
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2012",
Europe = 69,
China = 32,
America = 26
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2013",
Europe = 58,
China = 47,
America = 38
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2014",
Europe = 40,
China = 46,
America = 31
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2015",
Europe = 78,
China = 50,
America = 19
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2016",
Europe = 13,
China = 90,
America = 52
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2017",
Europe = 78,
China = 132,
America = 50
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2018",
Europe = 40,
China = 134,
America = 34
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2018",
Europe = 40,
China = 134,
America = 34
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2019",
Europe = 80,
China = 96,
America = 38
});
}
}cs
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modulesnamespaceInfragistics.Samples
{
publicclassProgram
{
publicstaticasync Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbToolbarModule),
typeof(IgbDataChartToolbarModule),
typeof(IgbDataChartCoreModule),
typeof(IgbDataChartCategoryModule),
typeof(IgbDataChartAnnotationModule),
typeof(IgbDataChartInteractivityModule),
typeof(IgbDataChartCategoryTrendLineModule)
);
await builder.Build().RunAsync();
}
}
}cs
@using IgniteUI.Blazor.Controls@using IgniteUI.Blazor.Controls@using System<style>/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/#aboveContentSplit {
display: flex;
flex-direction: row;
}
#aboveContentLeftContainer {
margin-left: 1.25rem;
display: flex;
flex-grow: 1;
justify-content: start;
align-items: end;
}
#aboveContentRightContainer {
margin-right: 1.25rem;
display: flex;
flex-grow: 1;
justify-content: end;
align-items: end;
}
</style><divclass="container vertical"><divid="aboveContentSplit"><divid="aboveContentLeftContainer"><IgbToolbarName="toolbar"
@ref="toolbar"Orientation="ToolbarOrientation.Horizontal"OnCommand="ToolbarToggleAnnotations"><IgbToolActionIconMenuName="MenuForSubPanelTool"
@ref="menuForSubPanelTool"IconCollectionName="ChartToolbarIcons"IconName="analyze"><IgbToolActionGroupHeaderName="SubPanelGroup"
@ref="subPanelGroup"CloseOnExecute="true"Title="Visualizations"Subtitle="Layers"></IgbToolActionGroupHeader><IgbToolActionSubPanelName="CustomSubPanelTools"
@ref="customSubPanelTools"><IgbToolActionCheckboxName="EnableTooltipsLabel"
@ref="enableTooltipsLabel"Title="Enable Tooltips"CommandId="EnableTooltips"></IgbToolActionCheckbox><IgbToolActionCheckboxName="EnableCrosshairsLabel"
@ref="enableCrosshairsLabel"Title="Enable Crosshairs"CommandId="EnableCrosshairs"></IgbToolActionCheckbox><IgbToolActionCheckboxName="EnableFinalValuesLabel"
@ref="enableFinalValuesLabel"Title="Enable Final Values"CommandId="EnableFinalValues"></IgbToolActionCheckbox></IgbToolActionSubPanel></IgbToolActionIconMenu><IgbToolActionLabelName="zoomResetLabel"
@ref="zoomResetLabel"Title="Reset"AfterId="ZoomOut"IconName="reset"IconCollectionName="ChartToolbarIcons"CommandId="ZoomReset"IsHighlighted="true"></IgbToolActionLabel><IgbToolActionLabelName="zoomResetHidden"
@ref="zoomResetHidden"OverlayId="ZoomReset"Visibility="Visibility.Collapsed"></IgbToolActionLabel><IgbToolActionIconMenuName="AnalyzeMenu"
@ref="analyzeMenu"OverlayId="AnalyzeMenu"Visibility="Visibility.Collapsed"></IgbToolActionIconMenu><IgbToolActionLabelName="CopyMenu"
@ref="copyMenu"OverlayId="CopyMenu"Visibility="Visibility.Collapsed"></IgbToolActionLabel></IgbToolbar></div><divid="aboveContentRightContainer"><!-- insert aboveContentRight --><!-- end aboveContentRight --></div></div><divclass="container vertical fill"><IgbDataChartComputedPlotAreaMarginMode="ComputedPlotAreaMarginMode.Series"IsHorizontalZoomEnabled="true"IsVerticalZoomEnabled="true"Name="chart"
@ref="chart"><IgbCategoryXAxisName="xAxis"
@ref="xAxis"DataSource="CountryRenewableElectricity"Label="Year"></IgbCategoryXAxis><IgbNumericYAxisName="yAxis"
@ref="yAxis"Title="TWh"LabelLocation="AxisLabelsLocation.OutsideRight"></IgbNumericYAxis><IgbLineSeriesName="lineSeries1"
@ref="lineSeries1"Title="Electricity"XAxisName="xAxis"YAxisName="yAxis"DataSource="CountryRenewableElectricity"ValueMemberPath="America"></IgbLineSeries><IgbLineSeriesName="LineSeries2"
@ref="lineSeries2"Title="Electricity"XAxisName="xAxis"YAxisName="yAxis"DataSource="CountryRenewableElectricity"ValueMemberPath="Europe"></IgbLineSeries><IgbLineSeriesName="LineSeries3"
@ref="lineSeries3"Title="Electricity"XAxisName="xAxis"YAxisName="yAxis"DataSource="CountryRenewableElectricity"ValueMemberPath="China"></IgbLineSeries></IgbDataChart></div></div>@code {private Action BindElements { get; set; }
protectedoverrideasync Task OnAfterRenderAsync(bool firstRender)
{
var toolbar = this.toolbar;
var menuForSubPanelTool = this.menuForSubPanelTool;
var subPanelGroup = this.subPanelGroup;
var customSubPanelTools = this.customSubPanelTools;
var enableTooltipsLabel = this.enableTooltipsLabel;
var enableCrosshairsLabel = this.enableCrosshairsLabel;
var enableFinalValuesLabel = this.enableFinalValuesLabel;
var zoomResetLabel = this.zoomResetLabel;
var zoomResetHidden = this.zoomResetHidden;
var analyzeMenu = this.analyzeMenu;
var copyMenu = this.copyMenu;
var chart = this.chart;
var xAxis = this.xAxis;
var yAxis = this.yAxis;
var lineSeries1 = this.lineSeries1;
var lineSeries2 = this.lineSeries2;
var lineSeries3 = this.lineSeries3;
this.BindElements = () => {
toolbar.Target = this.chart;
};
this.BindElements();
}
private IgbToolbar toolbar;
private IgbToolActionIconMenu menuForSubPanelTool;
private IgbToolActionGroupHeader subPanelGroup;
private IgbToolActionSubPanel customSubPanelTools;
private IgbToolActionCheckbox enableTooltipsLabel;
private IgbToolActionCheckbox enableCrosshairsLabel;
private IgbToolActionCheckbox enableFinalValuesLabel;
private IgbToolActionLabel zoomResetLabel;
private IgbToolActionLabel zoomResetHidden;
private IgbToolActionIconMenu analyzeMenu;
private IgbToolActionLabel copyMenu;
private IgbDataChart chart;
private IgbCategoryXAxis xAxis;
private IgbNumericYAxis yAxis;
private IgbLineSeries lineSeries1;
private IgbLineSeries lineSeries2;
private IgbLineSeries lineSeries3;
publicvoidToolbarToggleAnnotations(IgbToolCommandEventArgs args)
{
var target = this.chart;
switch (args.Command.CommandId)
{
case"EnableTooltips":
IgbSeries annotationSeries = null;
foreach (var s in target.Series)
{
if (s is IgbDataToolTipLayer)
{
annotationSeries = s;
}
}
if (annotationSeries == null) {
target.Series.Add(new IgbDataToolTipLayer());
} else {
target.Series.Remove(annotationSeries);
}
break;
case"EnableCrosshairs":
IgbSeries crosshairSeries = null;
foreach (var s in target.Series)
{
if (s is IgbCrosshairLayer)
{
crosshairSeries = s;
}
}
if (crosshairSeries == null)
{
target.Series.Add(new IgbCrosshairLayer());
}
else
{
target.Series.Remove(crosshairSeries);
}
break;
case"EnableFinalValues":
IgbSeries finalValuesSeries = null;
foreach (var s in target.Series)
{
if (s is IgbFinalValueLayer)
{
finalValuesSeries = s;
}
}
if (finalValuesSeries == null)
{
target.Series.Add(new IgbFinalValueLayer());
}
else
{
target.Series.Remove(finalValuesSeries);
}
break;
}
}
private CountryRenewableElectricity _countryRenewableElectricity = null;
public CountryRenewableElectricity CountryRenewableElectricity
{
get
{
if (_countryRenewableElectricity == null)
{
_countryRenewableElectricity = new CountryRenewableElectricity();
}
return _countryRenewableElectricity;
}
}
}razor
La barra de herramientas Blazor contiene una Target propiedad. Esto se utiliza para vincular un componente, como se IgbDataChart muestra en el código a continuación:
Varios elementos y menús IgbToolAction preexistentes se vuelven disponibles cuando IgbDataChart se vincula con la barra de herramientas. Aquí hay una lista de las acciones de herramientas IgbDataChart integradas Blazor y su OverlayId asociado:
Acciones de zoom
ZoomReset: un IgbToolActionLabel que invoca el método ResetZoom en el gráfico para restablecer el nivel de zoom a su posición predeterminada.
SeriesAvg: una IgbToolActionCheckbox que agrega o elimina un IgbValueLayer a la colección de series del gráfico usando ValueLayerValueMode de tipo Average.
ValueLabelsMenu: Un submenú que contiene varias herramientas para mostrar diferentes anotaciones en el IgbDataChart área de la trama.
ValueLabelsHeader: encabezado de sección del submenú para las siguientes herramientas:
ShowGridlines: una IgbToolActionCheckbox que alterna líneas de cuadrícula adicionales aplicando un MajorStroke al eje X.
Acción Guardar en imagen
CopyAsImage: A IgbToolActionLabel que expone una opción para copiar el gráfico en el portapapeles.
CopyHeader: Un encabezado de subsección.
SVG Icons
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
De manera similar a agregar svg, también puede agregar una imagen de icono desde una URL a través de la RegisterIconFromDataURL. El tercer parámetro del método se usaría para introducir una URL de cadena.
En el siguiente fragmento de código se muestran ambos métodos para agregar un icono.
De forma predeterminada, la barra de herramientas Blazor se muestra horizontalmente, pero también tiene la capacidad de mostrarse verticalmente estableciendo la Orientation propiedad.
El siguiente ejemplo demuestra la orientación vertical de la barra de herramientas Blazor.
EXAMPLE
DATA
MODULES
RAZOR
CSS
using System;
using System.Collections.Generic;
publicclassCountryRenewableElectricityItem
{
publicstring Year { get; set; }
publicdouble Europe { get; set; }
publicdouble China { get; set; }
publicdouble America { get; set; }
}
publicclassCountryRenewableElectricity
: List<CountryRenewableElectricityItem>
{
publicCountryRenewableElectricity()
{
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2009",
Europe = 34,
China = 21,
America = 19
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2010",
Europe = 43,
China = 26,
America = 24
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2011",
Europe = 66,
China = 29,
America = 28
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2012",
Europe = 69,
China = 32,
America = 26
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2013",
Europe = 58,
China = 47,
America = 38
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2014",
Europe = 40,
China = 46,
America = 31
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2015",
Europe = 78,
China = 50,
America = 19
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2016",
Europe = 13,
China = 90,
America = 52
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2017",
Europe = 78,
China = 132,
America = 50
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2018",
Europe = 40,
China = 134,
America = 34
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2018",
Europe = 40,
China = 134,
America = 34
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2019",
Europe = 80,
China = 96,
America = 38
});
}
}cs
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modulesnamespaceInfragistics.Samples
{
publicclassProgram
{
publicstaticasync Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbToolbarModule),
typeof(IgbDataChartToolbarModule),
typeof(IgbDataChartCoreModule),
typeof(IgbDataChartCategoryModule),
typeof(IgbDataChartAnnotationModule),
typeof(IgbDataChartInteractivityModule),
typeof(IgbAnnotationLayerProxyModule),
typeof(IgbDataChartCategoryTrendLineModule)
);
await builder.Build().RunAsync();
}
}
}cs
/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/css
Color Editor
Puede agregar una herramienta de editor de color personalizada a la barra de herramientas Blazor, que también funcionará con el evento Command para realizar un estilo personalizado en la aplicación.
En el ejemplo siguiente se muestra el estilo del pincel de la serie Blazor Gráfico de datos con la herramienta Editor de color.
EXAMPLE
DATA
MODULES
RAZOR
CSS
using System;
using System.Collections.Generic;
publicclassCountryRenewableElectricityItem
{
publicstring Year { get; set; }
publicdouble Europe { get; set; }
publicdouble China { get; set; }
publicdouble America { get; set; }
}
publicclassCountryRenewableElectricity
: List<CountryRenewableElectricityItem>
{
publicCountryRenewableElectricity()
{
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2009",
Europe = 34,
China = 21,
America = 19
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2010",
Europe = 43,
China = 26,
America = 24
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2011",
Europe = 66,
China = 29,
America = 28
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2012",
Europe = 69,
China = 32,
America = 26
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2013",
Europe = 58,
China = 47,
America = 38
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2014",
Europe = 40,
China = 46,
America = 31
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2015",
Europe = 78,
China = 50,
America = 19
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2016",
Europe = 13,
China = 90,
America = 52
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2017",
Europe = 78,
China = 132,
America = 50
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2018",
Europe = 40,
China = 134,
America = 34
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2018",
Europe = 40,
China = 134,
America = 34
});
this.Add(new CountryRenewableElectricityItem()
{
Year = @"2019",
Europe = 80,
China = 96,
America = 38
});
}
}cs
using System;
using System.Net.Http;
using System.Collections.Generic;
using System.Threading.Tasks;
using System.Text;
using Microsoft.AspNetCore.Components.WebAssembly.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using IgniteUI.Blazor.Controls; // for registering Ignite UI modulesnamespaceInfragistics.Samples
{
publicclassProgram
{
publicstaticasync Task Main(string[] args)
{
var builder = WebAssemblyHostBuilder.CreateDefault(args);
builder.RootComponents.Add<App>("app");
builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });
// registering Ignite UI modules
builder.Services.AddIgniteUIBlazor(
typeof(IgbToolbarModule),
typeof(IgbToolActionComboModule),
typeof(IgbToolActionColorEditorModule),
typeof(IgbDataChartToolbarModule),
typeof(IgbDataLegendModule),
typeof(IgbNumberAbbreviatorModule),
typeof(IgbDataChartCategoryModule),
typeof(IgbDataChartCoreModule),
typeof(IgbDataChartCategoryModule),
typeof(IgbDataChartAnnotationModule),
typeof(IgbDataChartInteractivityModule),
typeof(IgbDataChartAnnotationModule)
);
await builder.Build().RunAsync();
}
}
}cs
@using IgniteUI.Blazor.Controls@using IgniteUI.Blazor.Controls@using System<style>/*
CSS styles are loaded from the shared CSS file located at:
https://static.infragistics.com/xplatform/css/samples/
*/#aboveContentSplit {
display: flex;
flex-direction: row;
}
#aboveContentLeftContainer {
margin-left: 1.25rem;
display: flex;
flex-grow: 1;
justify-content: start;
align-items: end;
}
#aboveContentRightContainer {
margin-right: 1.25rem;
display: flex;
flex-grow: 1;
justify-content: end;
align-items: end;
}
</style><divclass="container vertical"><divid="aboveContentSplit"><divid="aboveContentLeftContainer"><IgbToolbarName="toolbar"
@ref="toolbar"OnCommand="ColorEditorToggleSeriesBrush"><IgbToolActionColorEditorTitle="Series Brush"Name="colorEditorTool"
@ref="colorEditorTool"CommandId="ToggleSeriesBrush"></IgbToolActionColorEditor></IgbToolbar></div><divid="aboveContentRightContainer"><!-- insert aboveContentRight --><!-- end aboveContentRight --></div></div><divclass="container vertical fill"><IgbDataChartIsHorizontalZoomEnabled="true"Name="chart"
@ref="chart"><IgbCategoryXAxisName="xAxis"
@ref="xAxis"DataSource="CountryRenewableElectricity"Label="Year"></IgbCategoryXAxis><IgbNumericYAxisName="yAxis"
@ref="yAxis"Title="TWh"LabelLocation="AxisLabelsLocation.OutsideRight"></IgbNumericYAxis><IgbLineSeriesName="lineSeries1"
@ref="lineSeries1"Title="Electricity"XAxisName="xAxis"YAxisName="yAxis"DataSource="CountryRenewableElectricity"ValueMemberPath="America"MarkerType="MarkerType.None"></IgbLineSeries></IgbDataChart></div></div>@code {private Action BindElements { get; set; }
protectedoverrideasync Task OnAfterRenderAsync(bool firstRender)
{
var toolbar = this.toolbar;
var colorEditorTool = this.colorEditorTool;
var chart = this.chart;
var xAxis = this.xAxis;
var yAxis = this.yAxis;
var lineSeries1 = this.lineSeries1;
this.BindElements = () => {
toolbar.Target = this.chart;
};
this.BindElements();
}
private IgbToolbar toolbar;
private IgbToolActionColorEditor colorEditorTool;
private IgbDataChart chart;
private IgbCategoryXAxis xAxis;
private IgbNumericYAxis yAxis;
private IgbLineSeries lineSeries1;
publicvoidColorEditorToggleSeriesBrush(IgbToolCommandEventArgs args)
{
var target = this.chart;
var color = args.Command.ArgumentsList[0].Value;
switch (args.Command.CommandId)
{
case"ToggleSeriesBrush":
IgbSeries series = target.ContentSeries[0];
series.Brush = color.ToString();
break;
}
}
private CountryRenewableElectricity _countryRenewableElectricity = null;
public CountryRenewableElectricity CountryRenewableElectricity
{
get
{
if (_countryRenewableElectricity == null)
{
_countryRenewableElectricity = new CountryRenewableElectricity();
}
return _countryRenewableElectricity;
}
}
}razor