Dynamic series and axis

5 posts, 0 answers
  1. Markus
    Markus avatar
    42 posts
    Member since:
    Nov 2012

    Posted 18 Apr 2014 Link to this post

    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
  2. Markus
    Markus avatar
    42 posts
    Member since:
    Nov 2012

    Posted 22 Apr 2014 Link to this post

    Primary I want to realize a dynamic switching between the vertical axis and also add vertical axis dynamically.

    Regards Markus
  3. UI for WPF is Visual Studio 2017 Ready
  4. Martin
    Admin
    Martin avatar
    1101 posts

    Posted 22 Apr 2014 Link to this post

    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.

     
  5. Markus
    Markus avatar
    42 posts
    Member since:
    Nov 2012

    Posted 22 Apr 2014 Link to this post

    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
  6. Markus
    Markus avatar
    42 posts
    Member since:
    Nov 2012

    Posted 24 Apr 2014 Link to this post

    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
Back to Top
UI for WPF is Visual Studio 2017 Ready