We use cookies to give you the best experience on our website. If you continue to browse, then you agree to our privacy policy and cookie policy. Image for the cookie policy date
close icon

2 Questions Regarding LineChart

Hi There,

     I have successfully embedded a PieChart when I have 1 month's of data.  I am trying to use a LineChart when I have multiple months of data, and I am running into 2 small issues before I can call it done.

1) The sample shows a fixed fill brush value in the LabelTemplate for the DataTemplate.  Is it possible to actually bind whatever the series color is for the Ellipse??  I tried using the following w/o luck:

    <Ellipse Fill="{Binding Interior}" Height="26" Width="26" StrokeThickness="0"/>

2)  I can't figure out how to get the Legend properly bound to the data in the LineSeries().  I see the legend created and it has swatches of the series color, but what property needs to be bound for the Series Title that I want to appear in the Legend text?

Thanks in advance for any advice.


3 Replies

VK Vinoth Kumar J Syncfusion Team July 3, 2013 10:25 AM UTC

Hi Rob,

 

Thanks for contacting Syncfusion.

 

We have analyzed your query.

 

Query 1: Can I bind the Series Interior in LabelTemplate?

We have created a simple sample for binding the Series Interior in the Axis Labels. Please find the sample in the attachment

Query 2: What property of Series is used to bind the Legend Item Title?

The Label property of the Series is used to be as legend item title.

 

Code Snippet [XAML]:

<chart:LineSeries Label="Legend Title for Series" ItemsSource="{Binding Collection}" XBindingPath="X" YBindingPath="Y" Interior="Red"></chart:LineSeries>

 

Please let us know if you need further assistance. 

Thanks,

Vinoth Kumar J



LineSeriesSample_23a2a81e.zip


RS Rob Skoon July 8, 2013 11:46 PM UTC

This kind of works for what I am trying to do, but if I try to use an ItemTemplate for the legend, I still am unable to get the fill color or the label to bind.  What binding properties should be used?

After incorporating your changes, I am also now seeing a weird behavior in terms of the rendering (see attached screenshot).  On my layout I am switching from a PieChart -> LineChart.  If I refresh the data in the LineChart (Series.Clear() and regenerate / add the new series), it will then display properly.



Clipped_Chart_fdff969a.zip


VK Vinoth Kumar J Syncfusion Team July 10, 2013 11:40 AM UTC

Hi Rob,

 

Thanks for the update.

 

You can use any property of LegendItem to the Binding in the ItemTemplate for the ChartLegend. Mostly if you want to bind the series Interior, simply you could bind the Interior property as like in the below code snippet.

 

Code Snippet [XAML]:

 

<DataTemplate x:Key="lineChartLegendTemplate">

            <Grid>

    <Ellipse Fill="{Binding Interior}" Height="26" Width="26" StrokeThickness="0"/>

   <TextBlock HorizontalAlignment="Center" VerticalAlignment="Center"            Text="{Binding Label}"></TextBlock>

            </Grid>

</DataTemplate>

 

We have created a sample based on your requirement and the reported issue is not reproducing with this sample. Can you please check with the sample from the following location? If you still face the problem, please revert us by modifying the sample based on your application along with replication procedure. This would be helpful for us to serve you.

 

Please let us know if you have any queries.

 

Regards,

Vinoth Kumar J



LineSeriesSample_dbd6cfaa.zip

Loader.
Live Chat Icon For mobile
Up arrow icon