chartType property

ExcelChartType get chartType

Excel chart type

Workbook workbook = Workbook();
Worksheet sheet = workbook.worksheets[0];
sheet.getRangeByName('A1').text = 'Items';
sheet.getRangeByName('B1').text = 'Count';
sheet.getRangeByName('A2').text = 'Beverages';
sheet.getRangeByName('A3').text = 'Condiments';
sheet.getRangeByName('A4').text = 'Confections';
sheet.getRangeByName('B2').number = 2776;
sheet.getRangeByName('B3').number = 1077;
sheet.getRangeByName('B4').number = 2287;
ChartCollection charts = new ChartCollection(sheet);
Chart chart = charts.add();
chart.chartType = ExcelChartType.pie;
chart.dataRange = sheet.getRangeByName('A1:B4');
chart.isSeriesInRows = false;
sheet.charts = charts;
List<int> bytes = workbook.saveAsStream();
File('ChartType.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

ExcelChartType get chartType {
  return _chartType;
}
set chartType (ExcelChartType value)

Implementation

set chartType(ExcelChartType value) {
  _chartType = value;
  if (!_chartType.toString().contains('area')) {
    _primaryCategoryAxis.isBetween = true;
  }
  if (value.toString().endsWith('3D')) {
    _is3DChart = true;
  }
  if (value.toString().contains('column') ||
      value.toString().contains('bar')) {
    _isColumnOrBar = true;
  }
}