hasLegend property

bool get hasLegend

Gets the boolean value to display the chart legend, True by default.

Implementation

bool get hasLegend {
  return _bHasLegend;
}
set hasLegend (bool value)

sets the boolean value to display the chart legend, True by default.

Workbook workbook = new 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 = ChartCollection(sheet);
Chart chart = charts.add();
chart.chartType = ExcelChartType.bar;
chart.dataRange = sheet.getRangeByName('A1:B4');
chart.hasLegend = false;
sheet.charts = charts;
List<int> bytes = workbook.saveAsStream();
File('ChartHasLegend.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

set hasLegend(bool value) {
  if (_bHasLegend != value) {
    _bHasLegend = value;
    _legend = value ? ChartLegend(_worksheet, this) : null;
  }
}