Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
25
How to change the style of marker?
posted

I have a custom style for Marker in a scatterline chart.

How can i change the marker styles based on conditons in the c# file?

  • 1134
    posted

    Hi shrutipatra,

    You can change the marker style of your ScatterLine chart in C# by setting the MarkerType on your series to Custom, and then setting the Marker.Style property to the custom style you created.  Here's an example of what I did:

    Here's my custom Marker in my UserControl resources:

    <Style TargetType="igChart:MarkerPointTemplate" x:Name="MarkerStyle">

           <Setter Property="Template">

             <Setter.Value>

                 <ControlTemplate TargetType="igChart:MarkerPointTemplate">

                       <Path Fill="Green" Stretch="Fill" Stroke="Magenta" Data="M157,234 L172.5,190.5 182.5,232.5 147.5,207.5 193.5,205.5 z"/>

         </ControlTemplate>

          </Setter.Value>

       </Setter>

    </Style>     

    Here is the code I perform on a button click to set my ScatterLine series marker to my custom marker:

     private void btnSetMarkerStyle_Click(object sender, RoutedEventArgs e)
            {
                Marker m = new Marker();
                m.Type = MarkerType.Custom;
                this.Chart1.Series[0].Marker = m;
                this.Chart1.Series[0].Marker.Style = this.Resources["MarkerStyle"] as Style;
            }
    
    
    Hope this helps!
    -Marisa