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

How to change the chart item ControlTemplate?

3 Answers 105 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Mathias Parge
Top achievements
Rank 1
Mathias Parge asked on 25 Apr 2010, 06:52 PM

Hello,

in the ChartControl-Help I found this hint to increase charting performace:

Simplify the chart item ControlTemplate - e.g. the Line item template contains by default an item label and a point mark visual. The point mark visual can be removed (as they are relatively insignificant when rendering thousands of records). With lots of points the sheer number of UI elements simply bogs the system down as discussed above). So if you cannot reduce the data points, you will need to simplify the chart item ControlTemplate.

Can anybody give me an example how to do this?

3 Answers, 1 is accepted

Sort by
0
Velin
Telerik team
answered on 28 Apr 2010, 12:46 PM
Hello Mathias Parge,

Here is how you can apply a new Line template that does not contain point marks:
xmlns:telerikCharting="clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"
  
<Style x:Key="LineStyle" TargetType="telerikCharting:Line">
                <Setter Property="Template" >
                    <Setter.Value>
                        <ControlTemplate TargetType="telerikCharting:Line">
                            <Canvas>
                                <Line x:Name="PART_LineGeometry"
                              Fill="Transparent"
                              Stroke="Transparent"
                              X1="0"
                              Y1="{TemplateBinding StartPointY}"
                              X2="{TemplateBinding EndPointX}"
                              Y2="{TemplateBinding EndPointY}"
                              Style="{TemplateBinding ItemStyle}" />
                            </Canvas>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
  
ISeriesDefinition def = new LineSeriesDefinition() { ItemStyle = this.LayoutRoot.Resources["LineStyle"] as Style };


Hope this will help.

Greetings,
Velin
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
Earnest
Top achievements
Rank 1
answered on 23 Jul 2010, 04:06 PM
I'm using this method, seems to work but I have the following results where it appears the "EndPointX" value seems to be calculated incorrectly when plotting. I would expect that EndPointX would be the same value as StartPointX for the next segment. I have attached an image of the results I am seeing and the style below, I modified it to show a red stroke so I could visualize the style. Notice the red lines do not overlay the drawn waveform. Interestingly, at some zoom and scroll settings they do align. Is there a way to fix this?

<Style
            x:Key="LineStyle"
            TargetType="telerik:Line">
            <Setter
                Property="Template">
                <Setter.Value>
                    <ControlTemplate
                        TargetType="telerik:Line">
                        <Canvas>
                            <Line
                                x:Name="PART_LineGeometry"
                                Fill="Transparent"
                                Stroke="Red"
                                StrokeThickness="3"
                                X1="0"
                                Y1="{TemplateBinding StartPointY}"
                                X2="{TemplateBinding EndPointX}"
                                Y2="{TemplateBinding EndPointY}"
                                Style="{TemplateBinding ItemStyle}" />
                        </Canvas>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
0
Lauren
Top achievements
Rank 1
answered on 26 Jul 2010, 04:18 PM
Earnest, Thanks for the link.

I created the LineStyle in my App.xaml.
WITHOUT applying it to any chart, i get the following exception "Unable to cast object of type 'System.Windows.Style' to type 'System.Collections.Generic.IList`1[System.Windows.Style]'." when doing chart.Rebind().

I then removed all the chart.Rebind(), and applied the style to one of my chart. When zooming on that chart, i get the same exception.

Any idea about what's happening ?

Thanks for your help.
Tags
Chart
Asked by
Mathias Parge
Top achievements
Rank 1
Answers by
Velin
Telerik team
Earnest
Top achievements
Rank 1
Lauren
Top achievements
Rank 1
Share this question
or