Class DataGrouping

  • All Implemented Interfaces:
    Serializable

    public class DataGrouping
    extends AbstractConfigurationObject

    Data grouping is the concept of sampling the data values into larger blocks in order to ease readability and increase performance of the JavaScript charts. Highstock by default applies data grouping when the points become closer than a certain pixel value, determined by the groupPixelWidth option.

    If data grouping is applied, the grouping information of grouped points can be read from the Point.dataGroup.

    See Also:
    Serialized Form
    • Constructor Detail

      • DataGrouping

        public DataGrouping()
      • DataGrouping

        public DataGrouping​(Boolean enabled)
    • Method Detail

      • setDateTimeLabelFormats

        public void setDateTimeLabelFormats​(DateTimeLabelFormats dateTimeLabelFormats)

        Datetime formats for the header of the tooltip in a stock chart. The format can vary within a chart depending on the currently selected time range and the current data grouping.

        The default formats are:

         {
                   millisecond: ['%A, %b %e, %H:%M:%S.%L', '%A, %b %e, %H:%M:%S.%L', '-%H:%M:%S.%L'],
                   second: ['%A, %b %e, %H:%M:%S', '%A, %b %e, %H:%M:%S', '-%H:%M:%S'],
                   minute: ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
                   hour: ['%A, %b %e, %H:%M', '%A, %b %e, %H:%M', '-%H:%M'],
                   day: ['%A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
                   week: ['Week from %A, %b %e, %Y', '%A, %b %e', '-%A, %b %e, %Y'],
                   month: ['%B %Y', '%B', '-%B %Y'],
                   year: ['%Y', '%Y', '-%Y']
                }
         

        For each of these array definitions, the first item is the format used when the active time span is one unit. For instance, if the current data applies to one week, the first item of the week array is used. The second and third items are used when the active time span is more than two units. For instance, if the current data applies to two weeks, the second and third item of the week array are used, and applied to the start and end date of the time span.

      • setEnabled

        public void setEnabled​(Boolean enabled)
        Enable or disable data grouping.

        Defaults to: true

      • setForced

        public void setForced​(Boolean forced)
        When data grouping is forced, it runs no matter how small the intervals are. This can be handy for example when the sum should be calculated for values appearing at random times within each hour.

        Defaults to: false

      • setGroupPixelWidth

        public void setGroupPixelWidth​(Number groupPixelWidth)
        The approximate pixel width of each group. If for example a series with 30 points is displayed over a 600 pixel wide plot area, no grouping is performed. If however the series contains so many points that the spacing is less than the groupPixelWidth, Highcharts will try to group it into appropriate groups so that each is more or less two pixels wide. If multiple series with different group pixel widths are drawn on the same x axis, all series will take the greatest width. For example, line series have 2px default group width, while column series have 10px. If combined, both the line and the column will have 10px by default.

        Defaults to: 2

      • setSmoothed

        public void setSmoothed​(Boolean smoothed)
        Normally, a group is indexed by the start of that group, so for example when 30 daily values are grouped into one month, that month's x value will be the 1st of the month. This apparently shifts the data to the left. When the smoothed option is true, this is compensated for. The data is shifted to the middle of the group, and min and max values are preserved. Internally, this is used in the Navigator series.

        Defaults to: false

      • setUnits

        public void setUnits​(TimeUnitMultiples... units)
        An array determining what time intervals the data is allowed to be grouped to. Each array item is an array where the first value is the time unit and the second value another array of allowed multiples. Defaults to:
         units: [[
                        'millisecond', // unit name
                        [1, 2, 5, 10, 20, 25, 50, 100, 200, 500] // allowed multiples
                ], [
                        'second',
                        [1, 2, 5, 10, 15, 30]
                ], [
                        'minute',
                        [1, 2, 5, 10, 15, 30]
                ], [
                        'hour',
                        [1, 2, 3, 4, 6, 8, 12]
                ], [
                        'day',
                        [1]
                ], [
                        'week',
                        [1]
                ], [
                        'month',
                        [1, 3, 6]
                ], [
                        'year',
                        null
                ]]