Esempio n. 1
0
            /// <summary>
            /// Generates the data to use in the plot line
            /// </summary>
            /// <param name="source"></param>
            public void Generate(DataChart <T> source)
            {
                this.Data = new DataTable();
                Data.Columns.Add(source.XAxis, source.getExpressionType(source.XAxis, source.XAxisGetValue));
                Data.Columns.Add(Expression, source.getExpressionType(Expression, GetValue));

                List <string> symbols = source.GetSymbolList(Symbol);

                foreach (var s in symbols)
                {
                    List <StockDataSet <T> > sources;
                    if (!source.DataSets.TryGetValue(s, out sources))
                    {
                        return;
                    }

                    // Create a table of each data point in the specified range
                    for (int i = 0; i < sources.Count; i++)
                    {
                        if (sources[i].Start >= source.Start)
                        {
                            sources[i].Load(source.Session);
                            for (int j = 0; j < sources[i].Count; j++)
                            {
                                if (sources[i].Time(j) <= source.End)
                                {
                                    // Add the point to the table
                                    Data.Rows.Add(source.XAxisGetValue(sources[i], j), GetValue(sources[i], j));
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                // Update the line plot data
                if (Plot != null)
                {
                    Plot.SetData(Data);
                }
            }
Esempio n. 2
0
            /// <summary>
            /// Generates the data to use in the plot line
            /// </summary>
            /// <param name="source"></param>
            public void Generate(DataChart source)
            {
                DataMutex.WaitOne();
                List <string> symbols = source.GetSymbolList(Symbol);

                this.Data = new DataTable();

                foreach (var s in symbols)
                {
                    List <StockDataInterface> sources;
                    if (!source.getDataList(s, out sources) || (GetValue == null))
                    {
                        break;
                    }

                    // Load the sources first (need to load to the end before accessing the data since loading later sources could backfill data) */
                    for (int i = 0; i < sources.Count; i++)
                    {
                        sources[i].Load(source.Session);
                    }

                    // Ensure columns are added for the data types
                    if (Data.Columns.Count < 2)
                    {
                        Data.Columns.Add(source.XAxis, source.XAxisGetValue(sources[0], 0).GetType());
                        Data.Columns.Add(Expression, GetValue(sources[0], 0).GetType());
                    }

                    // Create a table of each data point in the specified range
                    for (int i = 0; i < sources.Count; i++)
                    {
                        string   symbol;
                        DateTime start;
                        TimeSpan interval;
                        sources[i].GetInfo(out symbol, out start, out interval);
                        if (start >= source.Start)
                        {
                            // Add the data set to the table
                            for (int j = 0; j < sources[i].GetCount(); j++)
                            {
                                if (start.AddSeconds(interval.TotalSeconds * j) <= source.End)
                                {
                                    // Add the point to the table
                                    Data.Rows.Add(source.XAxisGetValue(sources[i], j), GetValue(sources[i], j));
                                }
                                else
                                {
                                    break;
                                }
                            }
                        }
                    }
                }

                // Update the line plot data
                CreatePlotLine(source);
                if (Plot != null)
                {
                    Plot.SetData(Data);
                }
                DataMutex.ReleaseMutex();
            }