Blazor Working with Charts
The Infragistics Blazor Excel Engine's WorksheetChart functionality allows you to add visual charting representations of data trends across regions of cells in a worksheet. For example, if you want to see your Excel data in a region of cells visualized as a column, line, or over 70 other chart types, this feature can help you to achieve that.
Blazor Working with Charts Example
[!Note] The XLSX format is required. Other formats are not supported at this time.
Usage
Para adicionar um gráfico a uma planilha, você deve usar oAddChart método da coleção de formas da planilha. Nesse método, você pode especificar o tipo de gráfico que deseja usar, a célula superior esquerda, a célula inferior direita e as porcentagens dessas células que deseja que o gráfico ocupe.
The AddChart method returns the worksheet chart element to be added to the worksheet. Once you have this, you can use the SetSourceData method on the chart to set a cell address of the region of worksheet cells that you wish to use as a data source, as well as whether or not you want to switch the mapping of columns and rows to the X and Y axis.
Existem mais de 70 tipos de gráficos suportados, incluindoLine,Area,IgbColumn, ePie.
O código a seguir demonstra como usar o recurso de gráficos do Excel. O snippet abaixo adicionará um gráfico de colunas entre a primeira célula e a 13ª célula na primeira linha da planilha. Os dados de origem são então definidos para os dados na região de A2:M6, alternando o mapeamento de colunas e linhas para os eixos X e Y do gráfico de colunas:
var chart = sheet.Shapes.AddChart(Documents.Excel.Charts.ChartType.ColumnClustered,
sheet.Rows[0].Cells[0], new Core.Point(0, 0),
sheet.Rows[0].Cells[props.Length - 1], new Core.Point(100, 100));
chart.SetSourceData("A2:M6", true);
API References
AddChartAreaIgbColumnLinePieWorksheetChart