SciChart® the market leader in Fast WPF Charts, WPF 3D Charts, and iOS Chart & 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!

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.

0
0

I have DataTable with ~100,000 records. Table have 2 columns “Val” (double) and “Date” (DateTime). Every 250 ms new record adding to table.
Is it possible bind this table to SciChart (XAxis – “Date”, YAxis – “Val”) with realtime updating chart while data adding? Zoom and scrolling must be available too.

  • You must to post comments
0
0

Hi there,

Unfortunately, you can’t bind to DataTable directly, we require that data is loaded into a proprietary DataSeries. You may however create and fill DataSeries in a ViewModel and bind a chart to this is several ways, which are demonstrated throughout our examples. You can use these techniques to achieve decoupled, testable viewmodels.

Also, we provide a number of ways to fill data-series with data (via MVVM) and update it when required, and there are several real-time examples where you can see this in action, such as Real time ticking stock chart and Realtime Fifo chart, which demonstrates usage of FIFO(circular) buffer.

The reason for our API is because allowing users to data-bind to any data model can be extremely slow. By requiring users to store points in an optimized, proprietary buffer we are able to achieve a host of optimizations to achieve high performance charting of tens of millions of data-points.

Zooming and scrolling are separated from data(it can be used independently), we provide nice and extensible API for interaction via ChartModifiers, please, take a look at Interacting with a chart via modifiers tutorial(a bit out of date, we are going to update it ASAP) and ChartModifier overview from documentation for more info.

Please, feel free to ask if you have any questions!

Best regards,
Yuriy

  • You must to post comments
0
0

Great thanks, Yuriy

My code perhaps in the future will be useful to someone realties

   public MainWindow()
    {
        InitializeComponent();

        var dataset = new DataSeriesSet<DateTime, double>();
        var series = dataset.AddSeries();
        scichart.DataSet = dataset;

        Random rand = new Random(DateTime.Now.Millisecond);
        DataTable dataTable = new DataTable();
        dataTable.Columns.Add("Val", typeof(double));
        dataTable.Columns.Add("Date", typeof(DateTime));
        dataTable.RowChanged += (s1, e1) =>
            {
                if (e1.Action == DataRowAction.Add)
                    series.Append((DateTime)e1.Row["Date"], (double)e1.Row["Val"]);
            };

        //--- generate first 100 000 pints
        DateTime baseDT = DateTime.Now;
        int index;
        for (index = 0; index < 100000; index++)
        {
            DataRow dataRow = dataTable.NewRow();
            dataRow["Val"] = rand.Next(1000);
            dataRow["Date"] = new DateTime(baseDT.AddMilliseconds(index*250).Ticks);
            dataTable.Rows.Add(dataRow);
        }

        //start data adding process
        BackgroundWorker mainThread = new BackgroundWorker();
        mainThread.WorkerReportsProgress = true;
        mainThread.WorkerSupportsCancellation = false;
        mainThread.DoWork += (sender1, e) =>
        {
            while (true)
            {
                DataRow dataRow = dataTable.NewRow();
                dataRow["Val"] = rand.Next(1000);
                dataRow["Date"] = new DateTime(baseDT.AddMilliseconds(index * 250).Ticks);
                dataTable.Rows.Add(dataRow);
                index++;
                Thread.Sleep(250);
            }
        };
         mainThread.RunWorkerAsync();


    }

ChartModifiers very easy to implement zooming and scrolling. 🙂

  • Yuriy
    Hi there, Thank you for posting the code :) I'm sure it will be useful for other users! One remark regarding implementation: in SciChart 2.0v DataSet is no longer in usage, so in 2.0 you should create DataSeries and map them to RenderableSeries directly, or use SeriesSource instead (both approaches are demonstrated in our example suite). Thanks, Yuriy
  • You must to post comments
Showing 2 results
Your Answer

Please first to submit.