public SCChart AddLegend(string name, LegendOptions options = null) { if (string.IsNullOrWhiteSpace(name)) { throw new Exception("Legend name cannot be empty."); } options ??= new LegendOptions(); var legend = new Legend(name); Chart.Legends.Add(legend); options.SetupXtraChartLegend(this, legend); return(this); }
public SCChart SetLegend(string name = null, LegendOptions options = null) { options ??= new LegendOptions(); if (!string.IsNullOrWhiteSpace(name)) { var legend = Chart.Legends[name]; if (legend == null) { throw new Exception($"Cannot find legend '{name}'."); } options.SetupXtraChartLegend(this, legend); } else { options.SetupXtraChartLegend(this, Chart.Legend); } return(this); }