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

TemplateSelector refresh when object changes?

1 Answer 134 Views
ChartView
This is a migrated thread and some comments may be shown as answers.
Louis
Top achievements
Rank 1
Louis asked on 01 Aug 2014, 09:13 PM
In my app, I have 4 data templates that represent the state of points on the chart. This all works fine when first drawn, and my TemplateSelector assigns the proper template to the point based on the state of the underlying object.

My problem is that when the underlying object changes, I need it to trigger a refresh of that point, to get the chart to re-evaluate the TemplateSelector to apply the correct DataTemplate to reflect the new state. Is there any way to set up a binding, or absent that a way to poke it from the code-behind in a way that's not terribly horrible and get it to re-plot a single point? The only way I've found is to re-plot the whole series, which is a big performance issue with large datasets (10-50k items).

Thanks,
Louis

1 Answer, 1 is accepted

Sort by
0
Petar Marchev
Telerik team
answered on 04 Aug 2014, 10:26 AM
Hi Louis,

Unfortunately the templŠ°te selector functionality of the series works series-wise and not point-wise and it is not possible to reevaluate the template of a single point. If this performance hit is very large, perhaps you can implement your own data-template-selector logic by using only the PointTemplate property of the series. In the template you can define your own visual that chooses its template based on the data-point (data-item) at hand. In that visual you can also implement logic that observes if the template should be changed.

Note that the approach described above may not be a very good idea if you have zooming on. This is because the chart has a virtualization mechanism where the content presenters are reused. This may result in you custom visuals changing their templates way too often, thus resulting in a more prominent performance loss.

Another option is for you to use different series for the different templates. You mention having 4 templates. Perhaps you can use 4 different series and when the template of the point needs to be changed, simply move the item in the desired collection.

Regards,
Petar Marchev
Telerik
 
Check out Telerik Analytics, the service which allows developers to discover app usage patterns, analyze user data, log exceptions, solve problems and profile application performance at run time. Watch the videos and start improving your app based on facts, not hunches.
 
Tags
ChartView
Asked by
Louis
Top achievements
Rank 1
Answers by
Petar Marchev
Telerik team
Share this question
or