Sparkline requires explicit width?

3 posts, 0 answers
  1. Katherine
    Katherine avatar
    5 posts
    Member since:
    Aug 2012

    Posted 29 Apr 2011 Link to this post

    Hello,

    It seems that all the RadSparkline variants require an explicit width and height to render. Is this true? I'm trying to get a sparkline to stretch to the width of its container, and it just doesn't seem to work.

    I've been more or less spamming HorizontalAlignment="Stretch" attributes in an attempt to get this to work, and have ended up with:

    <StackPanel Grid.Row="3" Grid.Column="1" Orientation="Vertical" HorizontalAlignment="Stretch">
        <ListBox ItemsSource="{Binding BinarySeries}" ItemContainerStyle="{StaticResource ListBoxItemStyle2}" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch">
            <ListBox.ItemTemplate>
                <DataTemplate>
                    <telerik:RadColumnSparkline AutoRange="True" Height="40" HorizontalAlignment="Stretch" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Values}" XValuePath="Timestamp" YValuePath="Value"  />
                </DataTemplate>
            </ListBox.ItemTemplate>
        </ListBox>                                    
    </StackPanel>

    Simply adding Width="xxx" to the RadColumnSparkline instantly causes it to render, but causes major issues on the UI side.

    Is there any way around this?

    Thanks for your time,
    Loren Van Spronsen
  2. Vladimir Milev
    Admin
    Vladimir Milev avatar
    1061 posts

    Posted 02 May 2011 Link to this post

    Hi Loren,

    The RadSparkline controls do not require you to set Height/Width explicitly per se, but they do require specific dimensions to be set from their parent controls. For example if you place a sparkline in a grid panel it will stretch the sparkline and will display it correctly because the grid panel measures its children with real height/width. If you place a sparkline in a panel which measures it with Infinity (such as canvas, stack panel, scroll viewer, etc.) it will not render. This is the organic behavior for shapes (like rectangle, circle) and the rad sparkline. Any sparkline will behave just like a native silverlight rectangle shape when placed in such a panel.

    Greetings,
    Vladimir Milev
    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
  3. DevCraft banner
  4. Katherine
    Katherine avatar
    5 posts
    Member since:
    Aug 2012

    Posted 04 May 2011 Link to this post

    Thanks for that! I should be able to get everything on that side working properly now
Back to Top