ark::plotting::DataSeriesStore

Defined in header “ark/plotting/data_series_store.hh”.


Stores and computes data for a single variable’s series (ie, a 1D value stored against some other value). For example, you might have ‘CPU usage’ which is emitted at some dynamic frequency. This class could store it, recording each sample with its time, and applying limits and computing minimums/maximums.

Methods

  • DataSeriesStore()
    Initialize the data series with a default configuration.

  • DataSeriesStore(DataSeriesStoreConfig config)
    Initialize the data series with the given configuration.

  • void add_sample(double key, double value)
    Adds a new sample to the data series.

  • void set_filter(DataSeriesFilter filter)
    Updates the filter to the new filter. It may be applied immediately, dropping data when this is set.

  • void sort()
    Sorts all of the samples, ascending, based on key. Many operations, such as search operations, assume a sorted set of keys.

  • void reset()
    Removes every sample in this data series store. All existing filters are left intact.

  • const std::vector< DataSeriesSample > & samples()
    Returns all of the samples stored in memory, as-is (may not be sorted).

  • std::optional< double > sample_value_from_greatest_key()
    Returns the value of the sample with the greatest key (for example, if key is time, this would be the most recently seen sample).Returns an empty optional if there are no samples.

  • std::optional< double > sample_value_from_key(double key)
    Returns the value of the sample that most closely matches the given key. Essentially, this is the value of the sample of the key that comes right before the first key that is greater than the supplied key.

  • std::span< const DataSeriesSample > span_from_greatest_key(double offset)
    Returns a span starting from the “greatest key minus the offset” to the “greatest key”.

  • std::span< const DataSeriesSample > span_from_key_range(double minimum_key, double maximum_key)
    Returns a span starting from the minimum key to the maximum key (inclusive). Assumes data is sorted.

  • double min_key()
    Returns the minimum key seen.

  • double max_key()
    Returns the maximum key seen.

  • double min_value()
    Returns the minimum value seen.

  • double max_value()
    Returns the maximum value seen.

  • std::vector< AggregatedDataSeriesSamples > aggregate_samples(double bin_size)
    Aggregates all of the samples into the given bin size. Can be used to help reduce the number of points being returned.

    You must call sort() before invoking this API, or you may not get back the most optimal bins.