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

Sparkline requires explicit width?

2 Answers 69 Views
Sparkline
This is a migrated thread and some comments may be shown as answers.
Katherine
Top achievements
Rank 1
Katherine asked on 29 Apr 2011, 10:10 PM

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 Answers, 1 is accepted

Sort by
0
Vladimir Milev
Telerik team
answered on 02 May 2011, 11:42 AM
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
0
Katherine
Top achievements
Rank 1
answered on 04 May 2011, 11:54 AM
Thanks for that! I should be able to get everything on that side working properly now
Tags
Sparkline
Asked by
Katherine
Top achievements
Rank 1
Answers by
Vladimir Milev
Telerik team
Katherine
Top achievements
Rank 1
Share this question
or