add method

Chart add()

Add chart to the chart collection.

Workbook workbook = Workbook();
Worksheet sheet = workbook.worksheets[0];
ChartCollection chart = ChartCollection(sheet);
chart.add();
sheet.charts = chart;
List<int> bytes = workbook.saveAsStream();
File('EmptyChart.xlsx').writeAsBytes(bytes);
workbook.dispose();

Implementation

Chart add() {
  final Chart chart = Chart(_worksheet);
  chart.series = ChartSeriesCollection(_worksheet, chart);
  chart.primaryCategoryAxis = ChartCategoryAxis(_worksheet, chart);
  chart.primaryValueAxis = ChartValueAxis(_worksheet, chart);
  chart.primaryValueAxis.hasMajorGridLines = true;
  chart.plotArea = ChartPlotArea(_worksheet, chart);
  innerList.add(chart);
  chart.name = 'Chart${innerList.length}';
  chart.index = innerList.length;
  chart.topRow = 0;
  chart.bottomRow = 19;
  chart.leftColumn = 0;
  chart.rightColumn = 9;
  chart.primaryCategoryAxis.numberFormat = 'General';
  chart.primaryValueAxis.numberFormat = 'General';
  _worksheet.chartCount++;
  return chart;
}