Back to Devexpress

Series.ChangeType(ChartType) Method

officefileapi-devexpress-dot-spreadsheet-dot-charts-dot-series-dot-changetype-x28-devexpress-dot-spreadsheet-dot-charts-dot-charttype-x29.md

latest6.3 KB
Original Source

Series.ChangeType(ChartType) Method

Changes the chart type used to plot the series.

Namespace : DevExpress.Spreadsheet.Charts

Assembly : DevExpress.Spreadsheet.v25.2.Core.dll

NuGet Package : DevExpress.Spreadsheet.Core

Declaration

csharp
void ChangeType(
    ChartType chartType
)
vb
Sub ChangeType(
    chartType As ChartType
)

Parameters

NameTypeDescription
chartTypeChartType

A ChartType enumeration specifying the chart type used to plot the series.

|

Remarks

The chart type used to plot the series (Series.SeriesType) is the same as the ChartView.ViewType of the Series.View to which a series belongs. When the ChangeType changes the series type, it also creates a new ChartView if the view of the specified type does not exist, or moves the series to an existing view of the same type.

Note

The series with the changed chart type has display priority over other series. If the modified series cannot be displayed in the combination chart with other series, the chart displays a view containing this series only.

View Example

csharp
Worksheet worksheet = workbook.Worksheets["chartTask5"];
workbook.Worksheets.ActiveWorksheet = worksheet;

// Create a chart and specify its location.
Chart chart = worksheet.Charts.Add(ChartType.LineMarker, worksheet["B2:D8"]);
chart.TopLeftCell = worksheet.Cells["F2"];
chart.BottomRightCell = worksheet.Cells["L15"];

// Change the type of the second series.
chart.Series[1].ChangeType(ChartType.ColumnClustered);

// Use the secondary axis.
chart.Series[1].AxisGroup = AxisGroup.Secondary;

// Specify the position of the legend.
chart.Legend.Position = LegendPosition.Top;
vb
Dim worksheet As Worksheet = workbook.Worksheets("chartTask5")
workbook.Worksheets.ActiveWorksheet = worksheet

' Create a chart and specify its location.
Dim chart As Chart = worksheet.Charts.Add(ChartType.LineMarker, worksheet("B2:D8"))
chart.TopLeftCell = worksheet.Cells("F2")
chart.BottomRightCell = worksheet.Cells("L15")

' Change the type of the second series.
chart.Series(1).ChangeType(ChartType.ColumnClustered)

' Use the secondary axis.
chart.Series(1).AxisGroup = AxisGroup.Secondary

' Specify the position of the legend.
chart.Legend.Position = LegendPosition.Top

The following code snippets (auto-collected from DevExpress Examples) contain references to the ChangeType(ChartType) method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

wpf-spreadsheet-chart-api/CS/SpreadsheetWPFChartAPISamples/CodeExamples/SeriesActions.cs#L73

csharp
// Change the type of the second series.
chart.Series[1].ChangeType(ChartType.ColumnClustered);

winforms-spreadsheet-chart-api/CS/SpreadsheetChartAPISamples/CodeExamples/SeriesActions.cs#L73

csharp
// Change the type of the second series.
chart.Series[1].ChangeType(ChartType.ColumnClustered);

spreadsheet-document-api-chart-examples/CS/SpreadsheetDocServerChartAPISamples/CodeExamples/SeriesActions.cs#L80

csharp
// Change the type of the second series.
chart.Series[1].ChangeType(ChartType.ColumnClustered);

wpf-spreadsheet-chart-api/VB/SpreadsheetWPFChartAPISamples/CodeExamples/SeriesActions.vb#L77

vb
' Change the type of the second series.
chart.Series(1).ChangeType(ChartType.ColumnClustered)

winforms-spreadsheet-chart-api/VB/SpreadsheetChartAPISamples/CodeExamples/SeriesActions.vb#L76

vb
' Change the type of the second series.
chart.Series(1).ChangeType(ChartType.ColumnClustered)

spreadsheet-document-api-chart-examples/VB/SpreadsheetDocServerChartAPISamples/CodeExamples/SeriesActions.vb#L76

vb
' Change the type of the second series.
chart.Series(1).ChangeType(ChartType.ColumnClustered)

See Also

Series Interface

Series Members

DevExpress.Spreadsheet.Charts Namespace