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

Dynamic series and axis

4 Answers 248 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Klemens
Top achievements
Rank 1
Klemens asked on 18 Apr 2014, 11:01 AM
Hi,
in my application I'm recording values at run-time. So I add series dynamic to my chartview. Next step would be to add vertical axis dynamically to my chartview.
So I added a collection where I can add the axis at run-time. Then when I want to change from one axis to another i got a InvalidOperationException: Specified element is already the logical child of another element. Disconnect it first.

Here is my SeriesProvider:
<telerik:RadCartesianChart.SeriesProvider>
    <telerik:ChartSeriesProvider Source="{Binding RecItemCollection}">
        <telerik:ChartSeriesProvider.SeriesDescriptors>
            <telerik:CategoricalSeriesDescriptor ItemsSourcePath="DataItems" ValuePath="ItemValue" CategoryPath="Time">
                <telerik:CategoricalSeriesDescriptor.Style>
                    <Style TargetType="telerik:LineSeries">
                        <Setter Property="RenderMode" Value="Full"/>
                        <Setter Property="StrokeThickness" Value="2"/>
                        <Setter Property="Stroke" Value="{Binding Stroke}"/>
                        <Setter Property="Visibility" Value="{Binding Visibility}"/>
                        <Setter Property="VerticalAxis" Value="{Binding VerticalAxis}"/>                                   
                    </Style>
                </telerik:CategoricalSeriesDescriptor.Style>
            </telerik:CategoricalSeriesDescriptor>
        </telerik:ChartSeriesProvider.SeriesDescriptors>
    </telerik:ChartSeriesProvider>
</telerik:RadCartesianChart.SeriesProvider>

Is there another way to do this?

Reagards Markus

4 Answers, 1 is accepted

Sort by
0
Klemens
Top achievements
Rank 1
answered on 22 Apr 2014, 06:25 AM
Primary I want to realize a dynamic switching between the vertical axis and also add vertical axis dynamically.

Regards Markus
0
Martin Ivanov
Telerik team
answered on 22 Apr 2014, 08:49 AM
Hi Markus,

I wasn't able to reproduce the reported exception. However, I prepared a sample project which demonstrates dynamic change of vertical axis. Please give it a try and let me if I am missing something. If this doesn't help can you send me a runnable project that isolates the issue. This will allow me to test it locally and investigate further this behavior. 

Thank you in advance for your cooperation.

Regards,
Martin
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Klemens
Top achievements
Rank 1
answered on 22 Apr 2014, 12:20 PM
Hi,
thank you for your help. I have build my own sample and here all works like it should. Only on the original project i got this error.
Very frustrating.

Regards Markus
0
Klemens
Top achievements
Rank 1
answered on 24 Apr 2014, 11:52 AM
Well to solve this:

I had a Gridview with a GridViewComboBoxColumn in this I am setting the ItemsSource  to be the collection of vertical axes. Well, the axis in ChartView is a visual element. When you click on the combo box, some elements are created (like RadToggleButton). Then the toggle button claims that its the axis' Parent (axis.Parent == toggleButton). And when the chart tries to attach the axis to the visual tree, an exception is thrown because the axis is already in the visual tree.

One way to resolve this is to wrap the actual axis visuals in custom classes so that the actual visual is never placed in the visual tree due to the combo box.

Regards Markus
Tags
ChartView
Asked by
Klemens
Top achievements
Rank 1
Answers by
Klemens
Top achievements
Rank 1
Martin Ivanov
Telerik team
Share this question
or