hasTitle property

bool hasTitle

Gets indicates whether to display chart title or not.

Implementation

bool get hasTitle {
  bool result = false;
  if (_textArea != null) {
    if (_textArea!.text != null) {
      result = true;
    }
  }
  return result;
}
void hasTitle=(bool value)

Sets indicates whether to display chart title or not.

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.bar;
chart.dataRange = sheet.getRangeByName('A1:B4');
chart.hasTitle = true;
sheet.charts = charts;
List<int> bytes = workbook.saveAsStream();
File('ChartHasTitle.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

set hasTitle(bool value) {
  if (_textArea != null) {
    if (value && _textArea!.text == null) {
      _textArea!.text = _defaultChartTitle;
    } else if (!value) {
      _textArea!.text = null;
    }
  }
}