This is a migrated thread and some comments may be shown as answers.

Binding SeriesDefinition properties. RadChart is not updated

6 Answers 203 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Peter
Top achievements
Rank 1
Peter asked on 01 Apr 2011, 04:31 PM
Hi,

I am trying to implement a binding for some properties of SeriesDefinition for RadChart in XAML. Here is a part of my XAML:

<telerik:RadChart.SeriesMappings>
    <telerik:SeriesMapping LegendLabel="Rates" CollectionIndex="1">
        <telerik:SeriesMapping.SeriesDefinition>
            <telerik:LineSeriesDefinition AxisName="Rate" ItemLabelFormat="0.00 \%">
                <telerik:LineSeriesDefinition.Visibility>
                    <Binding Path="ChartRateSeriesVisible" Source="{StaticResource ViewModel}" Converter="{StaticResource BooleanToSeriesVisibilityConverter}" />
                </telerik:LineSeriesDefinition.Visibility>
            </telerik:LineSeriesDefinition>
        </telerik:SeriesMapping.SeriesDefinition>
    </telerik:SeriesMapping>
</telerik:RadChart.SeriesMappings>

This binding works fine, it gets the value from my ViewModel, so series are either visible on invisible.

The issue is the following:
I have a CheckBox on my View (UserControl defined in XAML) which is also binded to the same property of ViewModel (ChartRateSeriesVisible  property). And I want to control the visibility of a series by clicking on the checkbox. CheckBox's binding is defined property. I can see in the trace that checking/unchecking the checkbox updates the value of ChartRateSeriesVisible property.

But chart is not updated automatically. Only then I reload the chart completely (by updating its ItemsSource for instance), my LineSeries is hidden or visible depending on the value of ChartRateSeriesVisible.

What am I doing wrong or what am I missing?
In the telerik's sample application 'Simple Filtering' almost the same approach is used! Series Visiblity property is also binded to the ViewModel's property, etc.

I am using WPF 3.5 and the version of telerik assemblies is 2010.2.924.35.

Thanks in advance.

6 Answers, 1 is accepted

Sort by
0
Peter
Top achievements
Rank 1
answered on 01 Apr 2011, 04:50 PM
One more thing. If I write the following event handler for checkbox in code-behind, my chart is updated right away.
But I am trying to archive this 'filter' of series in XAML and ViewModel.

(this.outputChart.DefaultView.ChartArea.DataSeries[1].Definition as LineSeriesDefinition).Visibility = checkBox.IsChecked.Value ? SeriesVisibility.Visible : SeriesVisibility.Collapsed;
0
Accepted
Giuseppe
Telerik team
answered on 06 Apr 2011, 01:44 PM
Hello Peter,

Indeed it seems there was a problem in this scenario with the version of RadChart you are using. Our developers have already addressed the issue and the use case works as expected in our local tests with the latest version of the control (see the attached sample application).

Note that the DataContext is properly propagated to the SeriesDefinition now, so you do not need to explicitly set the binding source any more.

Hope this helps.


Regards,
Giuseppe
the Telerik team
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
0
Nidhi
Top achievements
Rank 1
answered on 07 Jul 2011, 11:06 AM
Hi Team,

I have usercontrol contains chart. Iam using MVVM. I have binded Series Definition property of chart with ViewModel property.
I added this control to Listbox items collection and its working first time. But second time, Chart is showing "No Series Defined". But view model property has value.

The step iam taking to add usercontrol in List collection is..

----- Working First Time----Series Definition bind-- and showing chart
UserControl_View cntrl=new UserControl_View();
cntrl.DataContext=ViewModel(sigleton);
List.items.Add(cntrl)

Second time-- I remove from listbox items collection and add cntrl  again--but Series Definition is not binded
UserControl_View cntrl=new UserControl_View();
cntrl.DataContext=ViewModel(sigleton);
List.items.Add(cntrl)

If I create a another instance opf viewmodel , then its showing chart...
UserControl_View cntrl=new UserControl_View();
ViewModel viewmodel=new ViewModel();
cntrl.DataContext=viewmodel
List.items.Add(cntrl)

But In don't want to create viewmodel instance every time.

WE are loading single or multiple control in a listbox .

Please see this issue...

Thanks,
Nidhi
0
Giuseppe
Telerik team
answered on 12 Jul 2011, 05:19 PM
Hi Nidhi,

Find attached a sample application that demonstrates how you can achieve the desired effect.

Hope this helps.


All the best,
Giuseppe
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

0
Gregory
Top achievements
Rank 1
answered on 16 Jul 2011, 01:37 AM
I am using version 2011.1.315.40 of the Chart controls and am  having a similar issue where, if I change any of the properties of the SeriesDefinition on a SeriesMapping instance, the change is applied to the chart the first time, but not on subsequent changes. I have tried a couple of workarounds, including calling the Rebind() method on the Chart as well as trying to upgrade to newer versions of the controls. I cannot use the newer versions because they don't seem to be backwards compatible with the 2011.1.315.40 release (for example, using the CollectionIndex with a SeriesMapping doesn't seem to work for me in the April release, and the Telerik.Windows.Themes.Office_Black.dll is no longer available in the July release; the Docking styles seem to have changed as well).

Is there a workaround that I can apply on the 2011.1.315.40 release that will allow me to update the chart appearance any time that the SeriesDefinition properties are changed?
0
Giuseppe
Telerik team
answered on 21 Jul 2011, 08:43 AM
Hello Gregory,

Find attached a sample application that demonstrates how you can change appearance settings through bindings with version 2011.1.315.40.

As for the CollectionIndex issue -- we have addressed the following issue in the July release: SeriesMapping.ItemsSource not respected when SeriesMapping.CollectionIndex is set. Also, generally the Office_Black theme is the default theme for all WPF controls and it is embedded in the control assembly.

About the docking styles -- could you elaborate a bit on the problems you are experiencing so we can advise you properly how to proceed.


Greetings,
Giuseppe
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
Chart
Asked by
Peter
Top achievements
Rank 1
Answers by
Peter
Top achievements
Rank 1
Giuseppe
Telerik team
Nidhi
Top achievements
Rank 1
Gregory
Top achievements
Rank 1
Share this question
or