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 Stackoverflow.com where you can earn rep for your questions!

0
0

I try to add data series and have them rendered on a chart surface. The surface and entire chart library is wrapped in an mvvm-based api. The sci chart control and wrapping library are rendered on a document panel. I add new data series via the viewmodel and here is where I have some unexpected behavior:

a) When being on a different document panel, meaning the chart control is NOT visible, and when I add a new data series via view model and then view the document panel that hosts the sci chart control, no chart series are rendered on the chart but I do see the correct legend data (such as chart series name, color, stroke thickness). Please see below screen shot “Capture1.jpg” .

b) When I make the sci chart control visible by viewing the document panel that hosts the sci chart control and then via a button and command add the very same data series via my chart control’s view model the charts are correctly rendered. Please see “Capture2.jpg”.

My question is why is that the case? I basically expose a method in my chart library view model that lets me add data and if I invoke that methods while being on a document panel that does not host the chart control the added data series is not rendered on the chart. But strangely the correct chart legend data are displayed and also the chart control itself is correctly rendered. No problems when the hosting document panel is active and the very same method is invoked.

Basically what I currently observe is that the data series are not rendered at all as long as the chart control is not “in view” or the hosting document panel is not selected. I am sure programmatically all references and bindings are correct.

I have spend many hours debugging this issue and do not seem to find an answer. Any pointers?

Thanks a lot,
Matt

Edit:

Here is how I bind the content control to the view model of my sci chart charting library (user control)

<ContentControl Grid.Row="1" Content="{Binding ChartControl, Mode=OneWay}" />

…and the view model is instantiated in the hosting view model constructor:

public MainWindowViewModel()
{
   ChartControl = new SciChartControlViewModel();

    ExitApplicationCommand = new RelayCommand(OnExitApplicationCommand);
    LoadDataSeriesFromFilesCommand = new RelayCommand(OnLoadDataSeriesFromFilesCommand);
    RefreshDataSeriesFromFilesCommand = new RelayCommand(OnRefreshDataSeriesFromFilesCommand);


    Test();

}

…Test() performs the following action:

private void Test()
{
    var quotes = new List<Quote>();
    List<DateTime> timeStamps = new List<DateTime>();
    List<double> values = new List<double>();
    List<SciChartAnnotation> annotations = new List<SciChartAnnotation>();
    Random rand = new Random((int)DateTime.Now.Ticks);
    DateTime currentDt = DateTime.Now;
    double currentValue = 0;

    for (int index = 0; index <= 50000; index++)
    {
        var randomValue = rand.NextDouble();
        currentDt = currentDt + TimeSpan.FromSeconds(randomValue);
        currentValue = currentValue + randomValue - 0.5;

        if (index % 1000 == 0)
        {
            var buySell = rand.NextDouble() > 0.5 ? SciChartAnnotationDirection.Buy : SciChartAnnotationDirection.Sell;
            annotations.Add(new SciChartAnnotation(buySell, currentDt, currentValue, "Index:" + index));
        }

        timeStamps.Add(currentDt);
        values.Add(currentValue);

        quotes.Add(new Quote(){DataProviderId = "Provider1", SymbolId = "Symbol1", QuoteType = QuoteType.BidAsk, CompressionType = TimeCompressionType.NoCompression, CompressionUnits = 0, TimeStamp = currentDt, Bid = currentValue, Ask= currentValue + 0.05, });

    }

    ChartControl.AddDataSet("Pane1", "0.00000", quotes, annotations);
    //ChartControl.AddDataSet("MattSeries", ChartType.Scatter, 1, "0.00000", timeStamps, values);

}

…it basically tries to render chart series and annotations.

Strangely, as mentioned before, the series legends render correctly and the annotations also all render correctly but the chart series do not! Could this be a bug?

Version
3.1.x and also trial 4.2.x
Attachments
  • You must to post comments
0
0

Hi Matt,

I am sorry to tell but we don’t support SciChart Version 3. Although your code works just fine in a newest 4.2.x version. So, please, try the newest 4.2 version for your purpose.

Best regards,
Markiyan
SciChart WPF Developer

  • You must to post comments
0
0

Hi,

I’m observing the same behaviour with the 4.2.5 version.

Like Matt did, I’m trying to add dynamically Series throught a button bound to a command in my ChartViewModel but the Series is never rendered or maybe it’s something related to the SeriesBinding or ToRenderableSeriesCollectionConverter classes.

The property SeriesCollection of my ChartViewModel is of type ObservableCollection, and I was expecting the view to be updated when the CollectionChanged is thrown but to make it works, I need to manually raise the PropertyChanged event for the SeriesCollection property.

Any idea what happens?

Thank you in advance,
Philippe

  • You must to post comments
0
0

Hi gentlemen,

This is not the behaviour we observe in our Manipulate Series MVVM example.

Here we bind a SciChartSurface to an ObservableCollection of IRenderableSeriesViewModel and we have buttons to add and remove series dynamically. This simply appends a series to the collection – which raises CollectionChanged – which updates the chart.

Can you have a look at this example on your local computers – what is different in this example vs. your own code which doesn’t work?

Best regards,
Andrew

  • You must to post comments
Showing 3 results
Your Answer

Please first to submit.