Example: setSourceData method

This example creates a chart for range(A2:F8) first, then changes the source range of the chart to (C2:D5).

  Range range = sheet.range("A1:F8");
  chartObject = sheet.getChartObjects().add("TotalReport",6000,8000,8000,6000);
  chartObject.getChart().chartWizard(range,Constant.SYMPHONY_CHART_PIEDIAGRAM,Constant.SYMPHONY_CHART_PLOTBY_COLUMNS,"total",false);
  range = sheet.range("C2:D5");
  chartObject.getChart().setSourceData(range);

Related information

setSourceData method