SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and now iOS Charting & Android Chart Components

Welcome to the SciChart Community Forums!

Please use the forums below to ask questions about SciChart. Take a moment to read our Question asking guidelines on how to ask a good question and our support policy. We also have a tag=SciChart on where you can earn rep for your questions!

Please note: SciChart team will only answer questions from customers with active support subscriptions. Expired support questions will be ignored. If your support status shows incorrectly, contact us and we will be glad to help.


Hi guys,

I have a big problem that It may be small for you đŸ™‚

I have a chart with multiple series. the number of series is not fix. sometimes the chart can have 3 series but sometimes it can have 20 series. Anyway…. so can you give me an idea or perhaps a test application where I can set the properties for each serie, especially the color of each serie which will be different(random).

I did the following for another chart where the series number was defined, but remember that now I have to create this another chart where the series number is not defined.

In the .XAML:

<sciChart:FastLineRenderableSeries SeriesColor="{Binding SeriesColor1}" StrokeThickness="1" YAxisId="Right1"/>
<sciChart:FastLineRenderableSeries SeriesColor="{Binding SeriesColor2}" StrokeThickness="1" YAxisId="Left1"/>
<sciChart:FastLineRenderableSeries SeriesColor="{Binding SeriesColor3}" StrokeThickness="1" YAxisId="Left1"/>
<sciChart:FastLineRenderableSeries SeriesColor="{Binding SeriesColor4}" StrokeThickness="1" YAxisId="Left1"/>
<sciChart:FastLineRenderableSeries SeriesColor="{Binding SeriesColor5}" StrokeThickness="1" YAxisId="Left1"/>
<sciChart:FastLineRenderableSeries SeriesColor="{Binding SeriesColor6}" StrokeThickness="1" YAxisId="Left1"/>

And in the ViewModel:

private static readonly PropertyChangedEventArgs SeriesColor1ChangeArgs = ObservableHelper.CreateArgs<AnalysisVelocityChartViewModel>(x => x.SeriesColor1);
private string _seriesColor1;
public string SeriesColor1
get { return _seriesColor1; }
_seriesColor1 = value;

    private static readonly PropertyChangedEventArgs SeriesColor2ChangeArgs = ObservableHelper.CreateArgs&lt;AnalysisVelocityChartViewModel&gt;(x =&gt; x.SeriesColor2);
    private string _seriesColor2;
    public string SeriesColor2
        get { return _seriesColor2; }
            _seriesColor2 = value;

    private static readonly PropertyChangedEventArgs SeriesColor3ChangeArgs = ObservableHelper.CreateArgs&lt;AnalysisVelocityChartViewModel&gt;(x =&gt; x.SeriesColor3);
    private string _seriesColor3;
    public string SeriesColor3
        get { return _seriesColor3; }
            _seriesColor3 = value;

    private static readonly PropertyChangedEventArgs SeriesColor4ChangeArgs = ObservableHelper.CreateArgs&lt;AnalysisVelocityChartViewModel&gt;(x =&gt; x.SeriesColor4);
    private string _seriesColor4;
    public string SeriesColor4
        get { return _seriesColor4; }
            _seriesColor4 = value;

    private static readonly PropertyChangedEventArgs SeriesColor5ChangeArgs = ObservableHelper.CreateArgs&lt;AnalysisVelocityChartViewModel&gt;(x =&gt; x.SeriesColor5);
    private string _seriesColor5;
    public string SeriesColor5
        get { return _seriesColor5; }
            _seriesColor5 = value;

    private static readonly PropertyChangedEventArgs SeriesColor6ChangeArgs = ObservableHelper.CreateArgs&lt;AnalysisVelocityChartViewModel&gt;(x =&gt; x.SeriesColor6);
    private string _seriesColor6;
    public string SeriesColor6
        get { return _seriesColor6; }
            _seriesColor6 = value;

        SeriesColor1 = &quot;Brown&quot;;
        SeriesColor2 = &quot;Blue&quot;;
        SeriesColor3 = &quot;Red&quot;;
        SeriesColor4 = &quot;Yellow&quot;;
        SeriesColor5 = &quot;Green&quot;;
        SeriesColor6 = &quot;Black&quot;;

Thanks so much Guys,


  • You must to post comments

Hi there,

You could consider using of SciChartSurface.SeriesSource instead. It allows you to bind to an ObservableCollection which marries one DataSeries with one RenderableSeries, and in this case the DataSet creation is implicit (done internally by SciChart). Please, take a look at Databinding annotations with MVVM tutorial for an example of series creation via SeriesSource.

Also there is the tutorial How to add/remove series dynamically, which shows how to achieve this using the DataSet/RenderableSeries, and you can find corresponding example in our example suite Add/remove data series.

Hope this helps, please, feel free to ask if you have more questions!

Best regards,

  • vaquita50
    Hi Yuriy.I tried to implement it using the examples on the links that you provided. But I am getting the following error ("The calling thread must be STA, because many UI components require this." and I cannot understand because I am doing exactly the same thing as in the examples..XAML
    <sciChart:SciChartSurface x:Name="SciChartSurface" Padding="0 0 0 30" Margin="0"
                                          VerticalAlignment="Stretch" HorizontalAlignment="Stretch"
                                          SeriesSource="{Binding SeriesSource}"
                    <!--  Declare Axes  -->
                        <sciChart:DateTimeAxis x:Name="XAxisData" AxisTitle="{x:Static prop:Resources.time}" VerticalAlignment="Top"
                                               Margin="0" Padding="0" FontSize="10" TitleFontSize="10"
                                               VisibleRange="{Binding SharedXVisibleRange, Mode=TwoWay}"  
                                               TextFormatting="HH:mm MMM dd" 
                                               SubDayTextFormatting="HH:mm:ss MMM dd">
                                <sciChart:DoubleRange Min="0.1" Max="0.1"/>
                        <sciChart:NumericAxis Name="YAxisData" Id="Left1" Margin="0" Padding="0" AxisAlignment="Left"  FontSize="10" TitleFontSize="10"
                                              Width="50" AxisTitle="{Binding ChartModel.YaxisName}" MinorDelta="0" AutoRange="True">
                                <sciChart:DoubleRange Min="0.1" Max="0.1"/>
                        <sciChart:NumericAxis Id="Right1" Margin="0" Padding="0" AxisAlignment="Right"  FontSize="10" TitleFontSize="10"
                                              AxisTitle="{Binding RightYaxisName}" MinorDelta="0" AutoRange="True">
                                <sciChart:DoubleRange Min="0.1" Max="0.1"/>
                    <!--  Declare ChartModifiers  -->
                        <sciChart:ModifierGroup Margin="0" Padding="0" FontSize="8" sciChart:MouseManager.MouseEventGroup="myCustomGroup">
                            <sciChart:LegendModifier x:Name="LegendModifier" GetLegendDataFor="AllSeries"/>
                            <sciChart:RubberBandXyZoomModifier IsEnabled="True" IsXAxisOnly="True"  ReceiveHandledEvents="True" />
                            <sciChart:ZoomPanModifier IsEnabled="False"/>
                            <sciChart:MouseWheelZoomModifier IsEnabled="False"/>
                            <sciChart:RolloverModifier IsEnabled="True" ReceiveHandledEvents="True"/>
                            <sciChart:CursorModifier ReceiveHandledEvents="True" ShowTooltip="False" ShowAxisLabels="True"/>
                            <sciChart:YAxisDragModifier YAxisId="Right1"/>
                            <sciChart:YAxisDragModifier YAxisId="Left1"/>
                            <sciChart:ZoomExtentsModifier ExecuteOn="MouseRightButton"/>
                        <sciChart:VerticalLineAnnotation YAxisId="Left1" X1="{Binding ScanRange.StartScan.Date, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Stretch" Stroke="DimGray" StrokeThickness="2" />
                        <sciChart:VerticalLineAnnotation YAxisId="Left1" X1="{Binding ScanRange.EndScan.Date, UpdateSourceTrigger=PropertyChanged}" VerticalAlignment="Stretch" Stroke="Blue" StrokeThickness="2" />
    private static readonly PropertyChangedEventArgs SeriesSourceChangeArgs = ObservableHelper.CreateArgs<AnalysisVelocityChartViewModel>(x => x.SeriesSource);
            private ObservableCollection<IChartSeriesViewModel> _seriesSource;
            public ObservableCollection<IChartSeriesViewModel> SeriesSource
                get { return _seriesSource; }
                    _seriesSource = value;
    private void LoadVelocityChartViewModel()
                // Create a dataset on the ChartViewModel
                ChartData = new DataSeriesSet<DateTime, double>();
               var renderableSeries = new FastLineRenderableSeries();
                foreach (var chartDataModel in _chartModel.ChartDataModels)
                    var dataSeries = ChartData.AddSeries();
                    dataSeries.SeriesName = chartDataModel.SeriesName;
                    dataSeries.Append(chartDataModel.ChartData.Keys, chartDataModel.ChartData.Values);
                    renderableSeries.SeriesColor = GetRandomColor();
                    var vm = new ChartSeriesViewModel(dataSeries, renderableSeries);
                RightYaxisName = ChartSeriesName.VelocityDeformation;
    Thanks so much, I will really appreciate your help.Sandra
  • Yuriy
    Hi Sandra,Sorry, cannot tell you how to fix it without looking in the code. Generally, you need to check if all your methods can be called in the UI thread. Consider using BackgroundWorker and Dispatcher.Invoke() for those calls which can't be called.Best regards, Yuriy
  • You must to post comments
Showing 1 result
Your Answer

Please first to submit.