protected void Dispose(bool disposing) { if (!disposing) { return; } if (Chart == null) { return; } Legend.Dispose(); Legend = null; Chart.Dispose(); Chart = null; }
private void ApplyLegends(UI.DataVisualization.Charting.Chart chart) { foreach (var legendData in _legends) { var legend = new Legend(); try { legend.Name = legendData.Name ?? String.Empty; legend.Title = legendData.Title ?? String.Empty; } catch (Exception) { // see notes above legend.Dispose(); throw; } chart.Legends.Add(legend); } }