IDalton Posted April 9, 2007 Report Share Posted April 9, 2007 I am trying to refresh the grid and legend. When I try to refresh the grid it clears fine and the new data shows up but the legend keeps on adding more series and not matter what I do I can't seem to stop it adding more series instead of just showing one which is what I want. I'm using chart1.Data.Clear() to clear the grid and legend,but the legend is not getting cleared. what syntax do I need to get this to work? Thanks Ian Link to comment Share on other sites More sharing options...
Frank Posted April 9, 2007 Report Share Posted April 9, 2007 You need to add: chart.Series.Clear() Also, if your legend box is displaying axis sections, conditional attributes or custom gridlines you need to clear those too. Data.Clear only clears the values. Link to comment Share on other sites More sharing options...
IDalton Posted April 10, 2007 Author Report Share Posted April 10, 2007 I added that line of code and it didn't help my issue. Everytime I rerun the process to load the chart it just adds another series. Here is my code please let me know what I am missing (for some reason everytime I paste my code it duplicates!) chartWARF.Data.Clear() chartWARF.Series.Clear() chartWARF.Gallery = ChartFX.WinForms.Gallery.Lines chartWARF.DataSourceSettings.Fields.Add(New FieldMap("StartDate", FieldUsage.XValue)) chartWARF.DataSourceSettings.Fields.Add(New FieldMap("Result", FieldUsage.Value)) chartWARF.AxisY.Step = 50 chartWARF.AxisY.Min = Min - 100 chartWARF.AxisY.Max = Max + 100 chartWARF.DataSource = dsChartWARF.Tables("Data") chartWARF.AxisY.Step = 50 chartWARF.AxisY.Min = Min - 100 chartWARF.AxisY.Max = Max + 100 chartWARF.DataSource = dsChartWARF.Tables("Data") chartWARF.DataSourceSettings.Fields.Add(New FieldMap("Result", FieldUsage.Value)) chartWARF.AxisY.Step = 50 chartWARF.AxisY.Min = Min - 100 chartWARF.AxisY.Max = Max + 100 chartWARF.DataSource = dsChartWARF.Tables("Data") chartWARF.AxisY.Step = 50 chartWARF.AxisY.Min = Min - 100 chartWARF.AxisY.Max = Max + 100 chartWARF.DataSource = dsChartWARF.Tables("Data") Link to comment Share on other sites More sharing options...
Frank Posted April 11, 2007 Report Share Posted April 11, 2007 Here is the problem: chartWARF.DataSourceSettings.Fields.Add(New FieldMap("StartDate", FieldUsage.XValue)) chartWARF.DataSourceSettings.Fields.Add(New FieldMap("Result", FieldUsage.Value)) You are adding these every time. You need to clear the Fields Collection. chartWARF.DataSourceSettings.Fields.Clear(); If you want to start over. Link to comment Share on other sites More sharing options...
IDalton Posted April 12, 2007 Author Report Share Posted April 12, 2007 Thank you that worked. Link to comment Share on other sites More sharing options...
Frank Posted April 12, 2007 Report Share Posted April 12, 2007 Excellent! Link to comment Share on other sites More sharing options...
cpelow Posted September 12, 2007 Report Share Posted September 12, 2007 How about for a statistics legend because I can clear everything but the legend? I end up with two legends on my postback: my code: ControlChart.DataSourceSettings.Fields.Clear() ControlChart.Series.Clear() Dim statisticsControl As Statistics = New Statistical.Statistics statisticsControl.Studies.Clear() statisticsControl.Chart = ControlChart statisticsControl.Chart.Data.Clear() statisticsControl.LegendBox.Visible = True ControlChart.Data.Clear() ControlChart.Titles.Clear() ControlChart.LegendBox.Visible = False Please help? Link to comment Share on other sites More sharing options...
Frank Posted September 13, 2007 Report Share Posted September 13, 2007 Either do this if !IsPostBack or do: chart.Extensions.Clear(); Link to comment Share on other sites More sharing options...
cpelow Posted September 13, 2007 Report Share Posted September 13, 2007 Perfect. Thank you! Link to comment Share on other sites More sharing options...
kort Posted September 18, 2007 Report Share Posted September 18, 2007 Hi all, I Have some pb with Legend when I change my binding object I'm doing like that : chart1.Reset(); chart1.Data.Clear();chart1.Series.Clear(); chart1.AxesX.Clear(); chart1.AxesY.Clear(); chart1.DataSourceSettings.Fields.Clear(); chart1.Extensions.Clear();ChartFX.WinForms.DataProviders.ListProvider l = new ListProvider(list); CrosstabDataProvider cfxCT = new CrosstabDataProvider();cfxCT.DataSource = l; chart1.DataSourceSettings.Fields.Add(new FieldMap("name", FieldUsage.ColumnHeading)); chart1.DataSourceSettings.Fields.Add(new FieldMap("date", FieldUsage.RowHeading)); chart1.DataSourceSettings.Fields.Add(new FieldMap("Last", FieldUsage.Value)); chart1.DataSourceSettings.DataSource = cfxCT; but I have always the same Legend Thank you for any help Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.