Search code examples
chartswpftoolkitsilverlight-toolkittoolkit

How do I style Silverlight chart marker?


I am using the Silverlight 4 Toolkit chart control (and also the WPF chart control).

My goal is to have a marker that is an arbitrary symbol - for example I need a marker style that is an X.

It can be an image, or a char, I don't mind.

Any idea how to achieve this? Thanks all.


Solution

  • I found the answer.

    Here is the style for an arbitrary squiggle.

    (DVC is my xmlns for the Datavisualistion Charting toolkit).

    In my Grid.Resources:

    <Style x:Key="Squiggle" TargetType="DVC:ScatterDataPoint">
                <Setter Property="Width" Value="18" />
                <Setter Property="Height" Value="18" />
                <Setter Property="Template">
                    <Setter.Value>
                        <ControlTemplate  TargetType="DVC:ScatterDataPoint">
                            <Canvas>
                                <Path Stroke="Black" StrokeThickness="1"
                                    Data="M 1,20 C 10,30 40,30 40,20 H 30" />
                            </Canvas>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
    

    The squiggle marker is just an example. You can draw any shape you like: Shapes and drawing

    Then in the Chart.Series:

    <DVC:ScatterSeries Title="Squiggles" DataPointStyle="{StaticResource Squiggle}"
            IndependentValueBinding="{Binding Path=Key}"
            DependentValueBinding="{Binding Path=Value}">
                </DVC:ScatterSeries>