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

Is it possible to have more than one pointmark shape within a series?

5 Answers 80 Views
Chart
This is a migrated thread and some comments may be shown as answers.
Scott
Top achievements
Rank 1
Scott asked on 24 Jun 2010, 09:57 PM
Hello,

I need to be able to place different custom pointmarks on the datapoints within the same series. Essentially I am required to mark an "out of limit" datapoint with a different custom pointmark than the other "within limit" datapoints.

Is this possible?

I have created custom pointmarks like this in the XAML:

                                                <Style x:Name="PointStyleLTASS" TargetType="chart:PointMark"
                                                    <Setter Property="Size" Value="8" /> 
                                                    <Setter Property="Template"
                                                        <Setter.Value> 
                                                            <ControlTemplate TargetType="chart:PointMark"
                                                                <Canvas> 
                                                                    <Path x:Name="PART_PointMarkPath" 
                                                          Style="{TemplateBinding ShapeStyle}"  
                                                          Width="{TemplateBinding Size}"  
                                                          Height="{TemplateBinding Size}" 
                                                          Stretch="Fill" 
                                                          Data="F1 M 10,0 L 0,0 0,5 10,5 10,10 0,10"
                                                                    </Path> 
                                                                </Canvas> 
                                                            </ControlTemplate> 
                                                        </Setter.Value> 
                                                    </Setter> 
                                                </Style> 
 


And attached them like this in code behind:

series.Definition.PointMarkItemStyle = this.PointStyleLTASS;

This of course adds them as my default for all of the datapoints in the series collection. Is it possible to set the pointmark definition on an individual basis, preferably programmatically?

Thanks in advance for your help!

5 Answers, 1 is accepted

Sort by
0
Giuseppe
Telerik team
answered on 30 Jun 2010, 12:07 PM
Hello Scott,

You can use the MVVM approach demonstrated here in order to achieve the desired effect. We have attached a sample application to get you started as well.

Hope this helps.


Kind regards,
Freddie
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
sachin
Top achievements
Rank 1
answered on 23 Nov 2010, 02:25 PM
Hi Freddie,

Apart from this MVVM approach is there some other way with which I can customize the data point at the time of loading. The issue is the customization scenario depends on some other data which is obtained dynamically.

Thanks,
Sachin
0
Giuseppe
Telerik team
answered on 25 Nov 2010, 06:16 PM
Hi sachin,

The chart control does not expose specialized API for this functionality but you can use the MVVM approach even if you need to update the pointmarks dynamically -- see the attached modified sample application to get you started.

Hope this helps.


Kind regards,
Freddie
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
0
sachin
Top achievements
Rank 1
answered on 26 Nov 2010, 10:20 AM
Hi Freddie,

Thanks for providing your inputs and direction. I am trying to evaluate the solution provided by you to see if it fits in my scenario. Also I am trying to achieve this in another way by using "Converter" in the 'PointMarkItemStyle' property. The converter code and the required XAML is given below. I am not sure how this can be done in a syntatically correct way. This code is given me a runtime error of 'AG_E_PARSER_BAD_PROPERTY_VALUE' which suggests some bad XAML syntax. Can you please look at this and provide your inputs or the correct way to do this.

public class DataPointStyleConverter : IValueConverter
    {
 
        private static Style DefaultDataPointStyle = XamlReader.Load(@"
                                            <Style TargetType=""chart:PointMark""
                                            xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                                            xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
                                            xmlns:chart=""clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting""
                                            >
                                            <Setter Property=""Size"" Value=""10"" />
                                            <Setter Property=""Template"">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType=""chart:PointMark"">
                                                        <Canvas>
                                                            <TextBlock ></TextBlock>
                                                        </Canvas>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                            </Setter>
                                        </Style>") as Style;
 
        private static Style SignalDataPointStyle = XamlReader.Load(@"<Style TargetType=""chart:PointMark""
                                                xmlns=""http://schemas.microsoft.com/winfx/2006/xaml/presentation""
                                                xmlns:x=""http://schemas.microsoft.com/winfx/2006/xaml""
                                                xmlns:chart=""clr-namespace:Telerik.Windows.Controls.Charting;assembly=Telerik.Windows.Controls.Charting"">
                                                <Setter Property=""Size"" Value=""20"" />
                                                <Setter Property=""Template"">
                                                <Setter.Value>
                                                    <ControlTemplate TargetType=""chart:PointMark"">
                                                        <Canvas>
                                                            <Path x:Name=""PART_PointMarkPath""
                                                                  Canvas.Left=""{TemplateBinding PointMarkCanvasLeft}""
                                                                  Canvas.Top=""{TemplateBinding PointMarkCanvasTop}""
                                                                  Style=""{TemplateBinding ShapeStyle}""
                                                                  Width=""{TemplateBinding Size}""
                                                                  Height=""{TemplateBinding Size}""
                                                                  Fill=""{}""
                                                                  Stretch=""Fill"">
                                                                <Path.Data>
                                                                    <PathGeometry x:Name=""PART_PointMarkPathGeometry"" />
                                                                </Path.Data>
                                                            </Path>
                                                        </Canvas>
                                                    </ControlTemplate>
                                                </Setter.Value>
                                                </Setter>
                                            </Style>") as Style;
 
 
        #region IValueConverter Members
 
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            bool IsSignal = (bool)value;
            Style Pointstyle = IsSignal ? SignalDataPointStyle : DefaultDataPointStyle;           
            return Pointstyle;
 
        }
 
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            Style pointStyle = (Style)value;
            if (pointStyle.Equals(DefaultDataPointStyle))
                return false;
            else if (pointStyle.Equals(SignalDataPointStyle))
                return true;
            else
                return false;
        }
 
        #endregion
    }
}


My datapoints are binded to an object which have a bool property IsSignal. The 'AG_E_PARSER_BAD_PROPERTY_VALUE'
error is coming just after I specify 'PointMarkItemStyle'property. The XAML code which is giving error is given below:

<control:RadChart.SeriesMappings>
                <chart:SeriesMapping CollectionIndex="0">
                    <chart:SeriesMapping.SeriesDefinition>
                        <chart:LineSeriesDefinition PointMarkItemStyle="{Binding IsSignal,Converter={StaticResource PointStyleConverter}}"  ShowItemLabels="False" ></chart:LineSeriesDefinition>
                    </chart:SeriesMapping.SeriesDefinition>
                    <chart:SeriesMapping.ItemMappings>
                        <chart:ItemMapping FieldName="value" DataPointMember="YValue"></chart:ItemMapping>
                        <chart:ItemMapping FieldName="key" DataPointMember="XValue"></chart:ItemMapping>
                    </chart:SeriesMapping.ItemMappings>
                </chart:SeriesMapping>
</control:RadChart.SeriesMappings>

Thanks,
Sachin
0
Giuseppe
Telerik team
answered on 01 Dec 2010, 04:58 PM
Hi sachin,

You should modify the Fill setter in the SignalDataPointStyle like this Fill=""{x:Null}"".

Hope this helps.


Regards,
Freddie
the Telerik team
Browse the videos here>> to help you get started with RadControls for Silverlight
Tags
Chart
Asked by
Scott
Top achievements
Rank 1
Answers by
Giuseppe
Telerik team
sachin
Top achievements
Rank 1
Share this question
or