I have an ChartDashboardItem with CheckedLegend.When I Maximize the ChartDashboardItem,the state of Checked Legend is not working.Please check attached screencast and advise how to do that…
Dashboard - CheckedLegend State not working in Maximize Mode.
Answers approved by DevExpress Support
Hi Junaid,
To display an item in maximized mode, we create a new instance of this item. Then, we apply the state of the initial item (a master filter, drill down, etc.) to the maximized item and display the maximized item over the dashboard. Although the DashboardItemControlCreated / DashboardItemControlUpdated events are raised for the maximized item, we cannot apply custom states (like unchecked series in the legend) to it automatically. You would need to apply this custom state manually.
For instance, you can store unchecked series names in a separate storage:
C#List<string> uncheckedSeries = new List<string>();
private void ChartControl_LegendItemChecked(object sender, DevExpress.XtraCharts.LegendItemCheckedEventArgs e)
{
ChartControl chart = (ChartControl)sender;
if (e.CheckedElement is Series)
{
var series = (Series)e.CheckedElement;
chart.Series[series.LegendTextPattern].Visible = e.NewCheckState;
//save unchecked series and remove checked ones
if (!e.NewCheckState)
uncheckedSeries.Add(series.LegendTextPattern);
else if (uncheckedSeries.Contains(series.LegendTextPattern))
uncheckedSeries.Remove(series.LegendTextPattern);
}
}
And modify series according to series names stored in this storage in the DashboardItemControlUpdated event handler:
C#private void DashboardDesigner1_DashboardItemControlUpdated(object sender, DevExpress.DashboardWin.DashboardItemControlEventArgs e)
{
if (e.ChartControl!= null)
{
foreach(Series series in e.ChartControl.Series)
{
series.Visible = !uncheckedSeries.Contains(series.Name);
series.CheckedInLegend = !uncheckedSeries.Contains(series.LegendTextPattern);
}
}
}
private void dashboardDesigner1_DashboardItemControlCreated(object sender, DevExpress.DashboardWin.DashboardItemControlEventArgs e)
{
if (e.ChartControl != null)
{
e.ChartControl.Legend.MarkerMode = DevExpress.XtraCharts.LegendMarkerMode.CheckBoxAndMarker;
e.ChartControl.LegendItemChecked += ChartControl_LegendItemChecked;
}
}
Sorry for late reply…
I have again an issue in Checked Legend When I Maximize.
Pls check and help…
Hi Junaid,
We published the How to Apply the ChartControl CheckedLegend State to the Maximized ChartDashboardItem example demonstrating how to show checkboxes in chart items' legend and synchronize the checked state between maximized and minimized items. Try this approach in your application and let me know whether it operates correctly.