none
Change wpf scatter series chart plot marker style RRS feed

  • Question

  •  i have created the scattered series chart and want to change the marker style as circle or some other shapes and by default it is represented as rectangle.can any one tell me how to change the plot marker.

    thanks in advance.


    Sudhesh. G <br/> <a href="http://gurucoders.blogspot.com" target="_blank">http://gurucoders.blogspot.com</a><br/>

    Thursday, October 24, 2013 5:17 PM

Answers

  • Hi,

    As far as I know, it is difficult to use WPF to create a scatter series chart directly. We should use WPF Toolkit or other 3<sup>rd</sup> part toolkit to achieve this function. If you use WPF Toolkit, I am afraid that we cannot change scatter plot shapes. Here is a basic sample about how to create scatter series chart using WPF Toolkit.

    XAML Code:

    <Window x:Class="WpfScatterSeriesChart.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:DV="clr-namespace:System.Windows.Controls.DataVisualization;assembly=System.Windows.Controls.DataVisualization.Toolkit"
            xmlns:DVC="clr-namespace:System.Windows.Controls.DataVisualization.Charting;assembly=System.Windows.Controls.DataVisualization.Toolkit"
            Title="ChartTypeScatter" Height="350" Width="525">
        <Grid>
            <!-- Scatter Chart -->
            <DVC:Chart Name="mcChart"
               Background="LightSteelBlue" Margin="10">
                <DVC:Chart.Series>
                    <DVC:ScatterSeries Title="Dots" IndependentValueBinding="{Binding Path=Key}"
        		        DependentValueBinding="{Binding Path=Value}">
                    </DVC:ScatterSeries>
                </DVC:Chart.Series>
            </DVC:Chart>
        </Grid>
    </Window>
    


    C# Code:

    public partial class MainWindow : Window
    {
    	public MainWindow()
    	{
    		InitializeComponent();
    		LoadScatterChartData();
    	}
    
    	private void LoadScatterChartData()
    	{
    		((ScatterSeries)mcChart.Series[0]).ItemsSource =
    			new KeyValuePair<DateTime, int>[]{
    			new KeyValuePair<DateTime, int>(DateTime.Now, 100),
    			new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(1), 130),
    			new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(2), 150),
    			new KeyValuePair<DateTime, int>(DateTime.Now.AddMonths(3), 125)
    		};
    	}
    }

    The result is shown in the following figure,

    BTW, I suggested you to post a new thread on WPF Toolkit Discussion. Maybe you can get a better response there.

    Have a nice time!

    Regards,


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    • Marked as answer by Yang,Chenfei Friday, November 1, 2013 2:51 AM
    Friday, October 25, 2013 11:40 AM