Source/NFX.WinForms/Controls/ChartKit/Temporal/Series.cs
/// <summary>
/// Adds sample to the series at the appropriate position.
/// This method respects MaxSamples and first deletes older samples making room for new additions
/// </summary>
Adds sample to the series at the appropriate position.
This method respects MaxSamples and first deletes older samples making room for new additions
Adds sample to the series at the appropriate position . This method respects MaxSamples and first deletes older samples making room for new additions
protected void Add(ITimeSeriesSample sample)
    {
      if (sample==null) throw new WFormsException(StringConsts.ARGUMENT_ERROR+"TimeSeries.Add(sample==null)");
      while(m_Data.Count >= m_MaxSamples)
        m_Data.RemoveFirst();
      var dt = sample.TimeStamp;
      var head = m_Data.First;
      if (head==null || head.Value.TimeStamp >= dt)
      {
          m_Data.AddFirst(sample);
          return;
      }
      var last = m_Data.Last;
      if (last.Value.TimeStamp <= dt)
      {
        m_Data.AddLast(sample);
        return;
      }
      var d1 = dt - head.Value.TimeStamp;
      var d2 = last.Value.TimeStamp - dt;
      if (d1<d2)
      {
          var node = head;
          while(node!=null)
          {
            if (node.Value.TimeStamp>=dt)
            {
              m_Data.AddBefore(node, sample);
              return;
            }
            node = node.Next;
          }
          m_Data.AddLast(sample);
      }
      else
      {
          var node = last;
          while(node!=null)
          {
            if (node.Value.TimeStamp<=dt)
            {
              m_Data.AddAfter(node, sample);
              return;
            }
            node = node.Previous;
          }
          m_Data.AddFirst(sample);
      }
    }
protected void Add ( ITimeSeriesSample sample ) { if ( sample == null ) throw new WFormsException ( StringConsts . ARGUMENT_ERROR + " " ) ; while ( m_Data . Count >= m_MaxSamples ) m_Data . RemoveFirst ( ) ; var dt = sample . TimeStamp ; var head = m_Data . First ; if ( head == null || head . Value . TimeStamp >= dt ) { m_Data . AddFirst ( sample ) ; return ; } var last = m_Data . Last ; if ( last . Value . TimeStamp <= dt ) { m_Data . AddLast ( sample ) ; return ; } var d1 = dt - head . Value . TimeStamp ; var d2 = last . Value . TimeStamp - dt ; if ( d1 < d2 ) { var node = head ; while ( node != null ) { if ( node . Value . TimeStamp >= dt ) { m_Data . AddBefore ( node , sample ) ; return ; } node = node . Next ; } m_Data . AddLast ( sample ) ; } else { var node = last ; while ( node != null ) { if ( node . Value . TimeStamp <= dt ) { m_Data . AddAfter ( node , sample ) ; return ; } node = node . Previous ; } m_Data . AddFirst ( sample ) ; } }
Adds sample to the series at the appropriate position.
Adds sample to the series at the appropriate position .
//remove data over max samples
sample
ITimeSeriesSample