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
60
Multiple series lines via scatterSeries plot
posted

Hi,

I am using Infragisitcis XamDataChart 2016.1 for WPF. I am trying to create a scatter series plot with multiple lines and each lines having different styles. ie., the first series need to have a plain line, the second series need to have a dotted line and third being dashed and dotted line, etc.. currently I am only getting lines with different colors but i am unable to change the style of the lines. Could you please send me any sample code to get different line styles.

This is the sample code which gives just all as lines with different colors:

foreach (points in seriescollection)
{
     ScatterSeries series = new ScatterSeries();        
         series.Brush = colors[nextSeries];
         series.MarkerType = MarkerType.Pentagram;
         series.MarkerTemplate = CreateTemp(plotType, nextSeries, c.TestId.ToString(), c.RecordId.ToString(), c.Datacode, colors);
         series.ItemsSource = newdpc.Collection;
         series.XMemberPath = "ValueX";
         series.YMemberPath = "ValueY";
         series.XAxis = xmXAxis;
         series.YAxis = xmYAxisL;
     xamDataChart.Series.Add(series);
         nextSeries++;
}

private DataTemplate CreateTemp(PlotType plotType, int whichSeries, Brush[] colors, bool smallpts = false)
{
    DataTemplate returnValue = new DataTemplate();
    FrameworkElementFactory factory = null;

   switch (whichSeries)
    {
        case 0:
            {
                factory = new FrameworkElementFactory(typeof(Polygon));
                if (smallpts)
                {
                    factory.SetValue(Polygon.PointsProperty, new PointCollection() { new Point(2, 0), new Point(0.0978, 1.382), new Point(0.825, 3.618), new Point(3.175, 3.618), new Point(3.9022, 1.382) });
                }
                else
                {
                    factory.SetValue(Polygon.PointsProperty, new PointCollection() { new Point(4, 0), new Point(0.1956, 2.764), new Point(1.65, 7.236), new Point(6.35, 7.236), new Point(7.8044, 2.764) });
                }
                break;
            }
    }
    factory.SetValue(Polygon.StrokeProperty, colors[whichSeries]);
    factory.SetValue(Polygon.VisibilityProperty, Visibility.Visible);
    factory.SetValue(Polygon.HorizontalAlignmentProperty, HorizontalAlignment.Stretch);
    factory.SetValue(Polygon.VerticalAlignmentProperty, VerticalAlignment.Stretch);
    factory.SetValue(Polygon.StrokeThicknessProperty, 0.5);
    
    returnValue.VisualTree = factory;

   return returnValue;
}

Colors is just a array of different colors.

Thanks,

Boom

  • 29105
    Offline posted

    Hello and thank you for contacting Infragistics. Have you considered to use multiple LineSeries and use its Dash Array property to achieve the requirements?

    eg.

     <ig:XamDataChart x:Name="chart" Grid.Row="2" ComputedPlotAreaMarginMode="Series" ShouldAutoExpandMarginForInitialLabels="True" ShouldConsiderAutoRotationForInitialLabels="True" Margin="10">
                <ig:XamDataChart.Axes>
                    <ig:CategoryXAxis x:Name="xAxis" ItemsSource="{StaticResource data}" Label="{}{Country}"/>
                    <ig:NumericYAxis x:Name="yAxis"/>
                </ig:XamDataChart.Axes>
                <ig:XamDataChart.Series>
                    <ig:LineSeries ItemsSource="{StaticResource data}" DashArray="5"
                                   ValueMemberPath="Nuclear"
                                   XAxis="{Binding ElementName=xAxis}"
                                   YAxis="{Binding ElementName=yAxis}"/>
                    <ig:LineSeries ItemsSource="{StaticResource data}" DashArray="1"
                                   ValueMemberPath="Gas"
                                   XAxis="{Binding ElementName=xAxis}"
                                   YAxis="{Binding ElementName=yAxis}"/>
                    <ig:LineSeries ItemsSource="{StaticResource data}"
                                   ValueMemberPath="Oil"
                                   XAxis="{Binding ElementName=xAxis}"
                                   YAxis="{Binding ElementName=yAxis}"/>
                </ig:XamDataChart.Series>
            </ig:XamDataChart>