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 añadir un cuadro a una hoja de trabajo, debes usar elAddChart método de la colección de formas de la hoja de trabajo. En este método, puedes especificar el tipo de carta que deseas usar, la celda superior izquierda, la celda inferior derecha y los porcentajes de esas celdas que deseas que ocupe la carta.

    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.

    Hay más de 70 tipos de gráficos soportados, incluyendoLine,Area,IgbColumn, yPie.

    El siguiente código demuestra cómo utilizar la función de gráficos de Excel. El siguiente fragmento agregará un gráfico de columnas entre la primera celda y la celda 13 en la primera fila de la hoja de trabajo. Luego, los datos de origen se configuran para los datos en la región de A2:M6, cambiando la asignación de columnas y filas para los ejes X e Y del gráfico de columnas:

    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

    • AddChart
    • Area
    • IgbColumn
    • Line
    • Pie
    • WorksheetChart