SamplesGenerator
Description
Initializes the samples generator with the data factory function used to retrieve cell values during sampling.
Members
allowDuplicates
samplesGenerator.allowDuplicates : boolean
true if duplicate samples collection should be allowed, false otherwise.
Default: {false}
customSampleCount
samplesGenerator.customSampleCount : number
Custom number of samples to take of each value length.
Default: {null}
dataFactory
samplesGenerator.dataFactory : function
Function which give the data to collect samples.
includeHidden
samplesGenerator.includeHidden : boolean
true if hidden samples should be included, false otherwise.
Default: {false}
SAMPLE_COUNT
SamplesGenerator.SAMPLE_COUNT : number
Number of samples to take of each value length.
samples
samplesGenerator.samples : Map
Samples prepared for calculations.
Default: {null}
Methods
applySamplingOptions
samplesGenerator.applySamplingOptions(options) ⇒ boolean
Applies both sampling options at once and reports whether either of them changed.
Callers use the return value to decide whether the sizes they measured earlier are still
usable. Both options change which cells end up in a sample, so a size measured under the
previous options cannot be trusted once they change - the auto-size plugins answer a true
here by re-measuring.
The raw samplingRatio is resolved here rather than by each caller, so that every plugin
reading the option agrees on what it means. See resolveSampleCount.
| Param | Type | Description |
|---|---|---|
| options | object | The sampling options to apply. |
| options.samplingRatio | * | The raw samplingRatio option value. |
| options.allowDuplicates | boolean | true to allow duplicate values. |
Returns: boolean - true when at least one option changed its value.
generateColumnSamples
samplesGenerator.generateColumnSamples(colRange, rowRange) ⇒ object
Generate samples for column. You can control which area should be sampled by passing colRange object and rowRange object.
| Param | Type | Description |
|---|---|---|
| colRange | object number | The columns range to generate the samples. |
| rowRange | object Array<number> | The row range (or an explicit list of row indexes) to generate the samples. |
generateRowSamples
samplesGenerator.generateRowSamples(rowRange, colRange) ⇒ object
Generate samples for row. You can control which area should be sampled by passing rowRange object and colRange object.
| Param | Type | Description |
|---|---|---|
| rowRange | object number | The rows range to generate the samples. |
| colRange | object Array<number> | The column range (or an explicit list of column indexes) to generate the samples. |
generateSample
samplesGenerator.generateSample(type, range, specifierValue, [existingSamples]) ⇒ Map
Generate sample for specified type (row or col).
When existingSamples is provided, the new samples are accumulated into it instead of a fresh
map. This lets callers sweep a large range in slices (e.g. one slice per animation frame)
while keeping the per-bucket sample limits and the duplicate detection working across slices.
| Param | Type | Description |
|---|---|---|
| type | string | Samples type row or col. |
| range | object Array<number> | The range (or an explicit list of indexes) to generate the samples. |
| specifierValue | number | The row (for row type) or column (for col type) index to sample. |
| [existingSamples] | Map | optional A samples map from a previous call to accumulate into. |
generateSampleFromValues
samplesGenerator.generateSampleFromValues(type, entries) ⇒ Map
Generates one samples map from already-known values, bypassing the data factory. Used to bucket-and-cap values that can no longer be read from the data source (e.g. the previous cell values carried by a change batch).
| Param | Type | Description |
|---|---|---|
| type | string | Samples type row or col. |
| entries | Array | An array of { index, value } objects, where index is the opposite-axis index the value belongs to (a row index for col type samples). |
generateSamples
samplesGenerator.generateSamples(type, range, specifierRange) ⇒ Map
Generate collection of samples.
| Param | Type | Description |
|---|---|---|
| type | string | Type to generate. Can be col or row. |
| range | object Array<number> | The range (or an explicit list of indexes) to generate the samples. |
| specifierRange | object number | The range to generate the samples. |
getSampleCount
samplesGenerator.getSampleCount() ⇒ number
Get the sample count for this instance.
resolveSampleCount
SamplesGenerator.resolveSampleCount(samplingRatio) ⇒ number | null
Resolves a samplingRatio option into a usable sample count.
Anything that is not a whole number above zero resolves to null, meaning the default
SAMPLE_COUNT. That covers the option being absent, but also the values
that used to be stored raw and then quietly broke the sampler: true and [] became NaN,
which made every later comparison report a change because NaN !== NaN; a negative number
became a needed count that collected no samples at all; and the string '6' compared as
different from the number 6.
| Param | Type | Description |
|---|---|---|
| samplingRatio | * | The raw option value. |
Returns: number | null - The sample count to use, or null for the default.
setIncludeHidden
samplesGenerator.setIncludeHidden(includeHidden)
Sets the sampler to the mode where it will generate samples for hidden indexes.
| Param | Type | Description |
|---|---|---|
| includeHidden | boolean | true to include hidden indexes, false otherwise. |
Description
Initializes the samples generator with the data factory function used to retrieve cell values during sampling.
Members
allowDuplicates
samplesGenerator.allowDuplicates : boolean
true if duplicate samples collection should be allowed, false otherwise.
Default: {false}
customSampleCount
samplesGenerator.customSampleCount : number
Custom number of samples to take of each value length.
Default: {null}
dataFactory
samplesGenerator.dataFactory : function
Function which give the data to collect samples.
includeHidden
samplesGenerator.includeHidden : boolean
true if hidden samples should be included, false otherwise.
Default: {false}
SAMPLE_COUNT
SamplesGenerator.SAMPLE_COUNT : number
Number of samples to take of each value length.
samples
samplesGenerator.samples : Map
Samples prepared for calculations.
Default: {null}
Methods
applySamplingOptions
samplesGenerator.applySamplingOptions(options) ⇒ boolean
Applies both sampling options at once and reports whether either of them changed.
Callers use the return value to decide whether the sizes they measured earlier are still
usable. Both options change which cells end up in a sample, so a size measured under the
previous options cannot be trusted once they change - the auto-size plugins answer a true
here by re-measuring.
The raw samplingRatio is resolved here rather than by each caller, so that every plugin
reading the option agrees on what it means. See resolveSampleCount.
| Param | Type | Description |
|---|---|---|
| options | object | The sampling options to apply. |
| options.samplingRatio | * | The raw samplingRatio option value. |
| options.allowDuplicates | boolean | true to allow duplicate values. |
Returns: boolean - true when at least one option changed its value.
generateColumnSamples
samplesGenerator.generateColumnSamples(colRange, rowRange) ⇒ object
Generate samples for column. You can control which area should be sampled by passing colRange object and rowRange object.
| Param | Type | Description |
|---|---|---|
| colRange | object number | The columns range to generate the samples. |
| rowRange | object Array<number> | The row range (or an explicit list of row indexes) to generate the samples. |
generateRowSamples
samplesGenerator.generateRowSamples(rowRange, colRange) ⇒ object
Generate samples for row. You can control which area should be sampled by passing rowRange object and colRange object.
| Param | Type | Description |
|---|---|---|
| rowRange | object number | The rows range to generate the samples. |
| colRange | object Array<number> | The column range (or an explicit list of column indexes) to generate the samples. |
generateSample
samplesGenerator.generateSample(type, range, specifierValue, [existingSamples]) ⇒ Map
Generate sample for specified type (row or col).
When existingSamples is provided, the new samples are accumulated into it instead of a fresh
map. This lets callers sweep a large range in slices (e.g. one slice per animation frame)
while keeping the per-bucket sample limits and the duplicate detection working across slices.
| Param | Type | Description |
|---|---|---|
| type | string | Samples type row or col. |
| range | object Array<number> | The range (or an explicit list of indexes) to generate the samples. |
| specifierValue | number | The row (for row type) or column (for col type) index to sample. |
| [existingSamples] | Map | optional A samples map from a previous call to accumulate into. |
generateSampleFromValues
samplesGenerator.generateSampleFromValues(type, entries) ⇒ Map
Generates one samples map from already-known values, bypassing the data factory. Used to bucket-and-cap values that can no longer be read from the data source (e.g. the previous cell values carried by a change batch).
| Param | Type | Description |
|---|---|---|
| type | string | Samples type row or col. |
| entries | Array | An array of { index, value } objects, where index is the opposite-axis index the value belongs to (a row index for col type samples). |
generateSamples
samplesGenerator.generateSamples(type, range, specifierRange) ⇒ Map
Generate collection of samples.
| Param | Type | Description |
|---|---|---|
| type | string | Type to generate. Can be col or row. |
| range | object Array<number> | The range (or an explicit list of indexes) to generate the samples. |
| specifierRange | object number | The range to generate the samples. |
getSampleCount
samplesGenerator.getSampleCount() ⇒ number
Get the sample count for this instance.
resolveSampleCount
SamplesGenerator.resolveSampleCount(samplingRatio) ⇒ number | null
Resolves a samplingRatio option into a usable sample count.
Anything that is not a whole number above zero resolves to null, meaning the default
SAMPLE_COUNT. That covers the option being absent, but also the values
that used to be stored raw and then quietly broke the sampler: true and [] became NaN,
which made every later comparison report a change because NaN !== NaN; a negative number
became a needed count that collected no samples at all; and the string '6' compared as
different from the number 6.
| Param | Type | Description |
|---|---|---|
| samplingRatio | * | The raw option value. |
Returns: number | null - The sample count to use, or null for the default.
setIncludeHidden
samplesGenerator.setIncludeHidden(includeHidden)
Sets the sampler to the mode where it will generate samples for hidden indexes.
| Param | Type | Description |
|---|---|---|
| includeHidden | boolean | true to include hidden indexes, false otherwise. |