Hi,
I've implemented the logic as the telerik sample http://demos.telerik.com/silverlight/#Chart/SimpleFiltering
Everything are working fine - I've implemented the same Setter template for the checkbox (e.g in this sample "PART_MainContainer")
Problem
-At the moment my charts display 5 legends with check box on each of the legend and each of the legend check box corresponded to the hiding/showing corresponded series line
-By default all those 5 series line are showed and the 5 checkboxes on every legend are checked
-Initially I want to display only just 2 legends and 2 corresponded series line
-At the moment I know how to hide the corresponded series line that I want to hide but I have an issue where i can hide the series line but I can't uncheck the check box beside the legend (I can't get/Don't know how to get the Check Box object from the LegendItem object) (e.g because initially 2 series lines are loaded but 5 check boxes in the legend are checked)
These are my codes
XAML
These are the code behind that hiding the lines
I've implemented the logic as the telerik sample http://demos.telerik.com/silverlight/#Chart/SimpleFiltering
Everything are working fine - I've implemented the same Setter template for the checkbox (e.g in this sample "PART_MainContainer")
Problem
-At the moment my charts display 5 legends with check box on each of the legend and each of the legend check box corresponded to the hiding/showing corresponded series line
-By default all those 5 series line are showed and the 5 checkboxes on every legend are checked
-Initially I want to display only just 2 legends and 2 corresponded series line
-At the moment I know how to hide the corresponded series line that I want to hide but I have an issue where i can hide the series line but I can't uncheck the check box beside the legend (I can't get/Don't know how to get the Check Box object from the LegendItem object) (e.g because initially 2 series lines are loaded but 5 check boxes in the legend are checked)
These are my codes
XAML
<
Style
x:Key
=
"CustomLegendItemStyle"
TargetType
=
"telerik:ChartLegendItem"
>
<
Setter
Property
=
"Template"
>
<
Setter.Value
>
<
ControlTemplate
TargetType
=
"telerik:ChartLegendItem"
>
<
Grid
x:Name
=
"PART_MainContainer"
HorizontalAlignment
=
"Stretch"
VerticalAlignment
=
"Top"
Margin
=
"0,0,5,0"
>
<
Path
x:Name
=
"PART_LegendItemMarker"
Height
=
"25"
Width
=
"220"
Style
=
"{TemplateBinding ItemStyle}"
Stretch
=
"Fill"
>
<
Path.Data
>
<
PathGeometry
x:Name
=
"PART_ItemMarkerGeometry"
/>
</
Path.Data
>
</
Path
>
<
CheckBox
IsChecked
=
"True"
VerticalAlignment
=
"Center"
Margin
=
"2,0"
Content
=
"{TemplateBinding Label}"
Foreground
=
"{TemplateBinding Foreground}"
Checked
=
"CheckBox_Checked"
Unchecked
=
"CheckBox_Checked"
/>
</
Grid
>
</
ControlTemplate
>
</
Setter.Value
>
</
Setter
>
</
Style
>
These are the code behind that hiding the lines
radChartReport.Loaded += (o, b) =>
{
var dataSeries = radChartReport.DefaultView.ChartArea.DataSeries.FirstOrDefault();
if
(dataSeries !=
null
)
{
foreach
(var point
in
dataSeries.ToList())
{
for
(
int
i=0;i<point.DataSeries.Count;i++)
{
ChartLegendItem legendItem = (radChartReport.DefaultView.ChartLegend
as
Telerik.Windows.Controls.ItemsControl).Items[i]
as
ChartLegendItem;
if
(legendItem.Label.ToLower().Contains(
"importance by affiliation"
) || legendItem.Label.ToLower().Contains(
"performance by staff"
)
|| legendItem.Label.ToLower().Contains(
"importance by manager"
))
{
//legendItem.Label = "test";
var a = legendItem.Template;
radChartReport.DefaultView.ChartArea.DataSeries[i].Definition.Visibility = SeriesVisibility.Hidden;
}
}
}
}
};