I have a RadChart (2011.2.920.1040) that is filled in code behind using WCF results. The user is allowed to pick the data they want to chart. This works the first time but if they make a second choice, the legend is empty.
Before I cleared the dataseries, the chart and legend kept the old data along with the new. Now that I have cleared the dataseries, if the user makes a second selection, the legend is empty.
I manually added a legend item to the ChartLegend and the associated legend but the legend is still empty.
// Global Variables
// Clear the previously plotted data if this is not the first time through
chartName.DefaultView.ChartArea.Legend.Items.Clear();
chartName.DefaultView.ChartArea.DataSeries.Clear();
where p.SensorName == sensorItem
select p).ToList();
Before I cleared the dataseries, the chart and legend kept the old data along with the new. Now that I have cleared the dataseries, if the user makes a second selection, the legend is empty.
I manually added a legend item to the ChartLegend and the associated legend but the legend is still empty.
// Global Variables
RadChart chartName =
new RadChart();
ChartLegend chartLegend =
new ChartLegend();
// SET LEGEND TO CHARTAREA
chartName.DefaultView.ChartArea.LegendName =
"chartLegend";
// Clear the previously plotted data if this is not the first time through
chartName.DefaultView.ChartArea.Legend.Items.Clear();
chartName.DefaultView.ChartArea.DataSeries.Clear();
// CREATE A SERIES FOR EACH SENSOR RETURNED.
foreach (var sensorItem in sensorReturned)
{
DataSeries lineSeries = new DataSeries();
lineSeries.LegendLabel = sensorItem.ToString();
lineSeries.Definition =
new LineSeriesDefinition();
var sensorPlotItems = (from p in e.Result
where p.SensorName == sensorItem
select p).ToList();
foreach (var item in sensorPlotItems)
{
lineSeries.Add(
new DataPoint() { XCategory = item.TimeStamp.ToString(), YValue = item.SelectedFieldValue, LegendLabel = sensorItem.ToString() });
}
chartName.DefaultView.ChartArea.DataSeries.Add(lineSeries);
ChartLegendItem legendItem = new ChartLegendItem();
legendItem.Label = sensorItem.ToString();
chartLegend.Items.Add(legendItem);
chartName.DefaultView.ChartLegend.Items.Add(legendItem);
// TEST TO SEE IF THE NEWLY ADDED LEGEND ITEM IS INSIDE THE LEGEND
bool associatedLegendFilled = chartLegend.HasItems; // true but nothing shows
bool filled = chartName.DefaultView.ChartLegend.HasItems; // false
}
Any ideas?