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

6 posts, 0 answers
  1. Scott
    Scott avatar
    5 posts
    Member since:
    Jun 2006

    Posted 24 Jun 2010 Link to this post

    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!

  2. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 30 Jun 2010 Link to this post

    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
  3. DevCraft banner
  4. sachin
    sachin avatar
    11 posts
    Member since:
    Nov 2008

    Posted 23 Nov 2010 Link to this post

    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
  5. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 25 Nov 2010 Link to this post

    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
  6. sachin
    sachin avatar
    11 posts
    Member since:
    Nov 2008

    Posted 26 Nov 2010 Link to this post

    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
  7. Giuseppe
    Admin
    Giuseppe avatar
    2363 posts

    Posted 01 Dec 2010 Link to this post

    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
Back to Top
DevCraft banner