ChartSheet.Chart Property
Provides access to the chart on the current chart sheet.
Namespace: DevExpress.Spreadsheet
Assembly: DevExpress.Spreadsheet.v18.2.Core.dll
Declaration
Property Value
Type | Description |
---|---|
ChartObject | A ChartObject object specifying a chart on the chart sheet. |
Remarks
Use the Chart property to get access to the chart located on the current chart sheet and specify its settings: select chart data (ChartObject.SelectData, ChartObject.Series), change the chart type (ChartObject.ChangeType), modify the chart layout (ChartObject.PlotArea, ChartObject.PrimaryAxes, ChartObject.SecondaryAxes, ChartObject.Legend, ChartObject.Title) and adjust the chart appearance (ChartObject.Style, ChartObject.Views, ChartObject.View3D).
Example
Note
A complete sample project is available at https://github.com/DevExpress-Examples/winforms-spreadsheet-chart-api-e5222
Dim worksheet As Worksheet = workbook.Worksheets("chartTask2")
' Create an empty chart sheet of the specified type.
Dim chartSheet As ChartSheet = workbook.ChartSheets.Add(ChartType.BarFullStacked)
' Access a chart on the chart sheet.
Dim chart As ChartObject = chartSheet.Chart
' Select chart data.
chart.SelectData(worksheet("B3:C8"), ChartDataDirection.Row)
' Display the chart title.
chart.Title.Visible = True
chart.Title.SetReference(worksheet("B1"))
' Change the legend position.
chart.Legend.Position = LegendPosition.Bottom
' Hide the category axis.
chart.PrimaryAxes(0).Visible = False
' Set the value axis' major unit.
chart.PrimaryAxes(1).MajorUnit = 0.2
workbook.ChartSheets.ActiveChartSheet = chartSheet