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

ChartView custom item in a ListView

3 Answers 70 Views
ListView
This is a migrated thread and some comments may be shown as answers.
Justin
Top achievements
Rank 1
Justin asked on 06 Mar 2014, 10:58 PM
Hello,

I am trying to create a ListView that contains a custom visual item containing multiple ChartViews.   What I am trying to achieve is a list, with some text for each item on the left and multiple pie charts horizontally across the item.  I have looked at the documentation for creating custom items in a ListView and taken basically the same approach.  I create a StackLayoutPanel in CreateChildItems in my SimpleListViewVisualItem derived class.  I add a LightVisualElement to the layout which will contain some text.  Then I try to add RadChartElements to the stack.  The problem is I cannot figure out the correct way to create the RadChartElement for this scenario.   I have tried many variations, but none seem to work. 

 I have tried to declare RadChartView's as members in the VisualItem class, create them in them in CreateChildItems and add them with a call like layout.Children.Add(myChartView.ChartElement).   Then in SynchronizeProperties, I go ahead and blow away the series for the chart and recreate it with the correct data for the item.  This almost works, except that only the first item in my list will ever display correctly. 

I have tried to declare RadChartElement's as members of the VisualItem class, but then I cannot figure out how to set the series for the chart in SynchronizeProperties

I have even tried creating the RadChartView in CreateChildItems, then in SynchronizeProperties, I just recreate the RadChartView and point the children of the layout to the newly created chart.ChartElement.

I have tried just recreating the entire layout in SynchronizeProperties.

...and many more combinations.

The best I could do with any of my attempts did correctly display the *first item*, with text on the left and four pie charts with correct data to the right, but *only the first item*.  In all the other items, the chart elements appear blank.

Is this impossible in the current version of the controls for Winforms, or am I missing something?

Best regards,
Justin

3 Answers, 1 is accepted

Sort by
0
George
Telerik team
answered on 11 Mar 2014, 03:33 PM
Hello Justin,

Thank you for contacting us.

It is possible to integrate RadChartView into RadListViewItems. I have created a small sample where this is achieved. Basically you need to get the Series from the data item, clone them (due to the virtualization of the visual items) and add them to the chart element.

Below you can find a sample project with these features implemented, feel free to implement any further changes.

Do not hesitate to write back, should you have further questions.

Regards,
George
Telerik

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

0
Justin
Top achievements
Rank 1
answered on 11 Mar 2014, 08:00 PM
Hello and thank you very much for your reply.  I have since discovered an error in my code that caused the unwanted behavior.  I have, however, noticed some somewhat odd behavior with the formatting of labels and colors during my attempts to get this working that I still don't fully understand.  Thank you for posting the example program.  I will take a look to see if I am using the best approach.  I'm sure others who would like to have ChartViews in their ListView will also find it helpful.

Thanks again,
Justin
0
George
Telerik team
answered on 14 Mar 2014, 05:11 PM
Hi Justin,

I am glad that this solution has worked well for your case.

Let us know if you have any other questions in future.

Regards,
George
Telerik
 

DevCraft Q1'14 is here! Watch the online conference to see how this release solves your top-5 .NET challenges. Watch on demand now.

 
Tags
ListView
Asked by
Justin
Top achievements
Rank 1
Answers by
George
Telerik team
Justin
Top achievements
Rank 1
Share this question
or