| 82 | * If typed array used, chunk size must be fixed. |
| 83 | */ |
| 84 | export class DefaultDataProvider implements DataProvider { |
| 85 | |
| 86 | private _source: Source; |
| 87 | |
| 88 | private _data: OptionSourceData; |
| 89 | |
| 90 | private _offset: number; |
| 91 | |
| 92 | private _dimSize: number; |
| 93 | |
| 94 | pure: boolean; |
| 95 | |
| 96 | persistent: boolean; |
| 97 | |
| 98 | static protoInitialize = (function () { |
| 99 | // PENDING: To avoid potential incompat (e.g., prototype |
| 100 | // is visited somewhere), still init them on prototype. |
| 101 | const proto = DefaultDataProvider.prototype; |
| 102 | proto.pure = false; |
| 103 | proto.persistent = true; |
| 104 | })(); |
| 105 | |
| 106 | |
| 107 | constructor(sourceParam: Source | OptionSourceData, dimSize?: number) { |
| 108 | // let source: Source; |
| 109 | const source: Source = !isSourceInstance(sourceParam) |
| 110 | ? createSourceFromSeriesDataOption(sourceParam as OptionSourceData) |
| 111 | : sourceParam as Source; |
| 112 | |
| 113 | // declare source is Source; |
| 114 | this._source = source; |
| 115 | const data = this._data = source.data; |
| 116 | const sourceFormat = source.sourceFormat; |
| 117 | const seriesLayoutBy = source.seriesLayoutBy; |
| 118 | |
| 119 | // Typed array. TODO IE10+? |
| 120 | if (sourceFormat === SOURCE_FORMAT_TYPED_ARRAY) { |
| 121 | if (__DEV__) { |
| 122 | if (dimSize == null) { |
| 123 | throw new Error('Typed array data must specify dimension size'); |
| 124 | } |
| 125 | } |
| 126 | this._offset = 0; |
| 127 | this._dimSize = dimSize; |
| 128 | this._data = data; |
| 129 | } |
| 130 | |
| 131 | if (__DEV__) { |
| 132 | const validator = rawSourceDataValidatorMap[getMethodMapKey(sourceFormat, seriesLayoutBy)]; |
| 133 | validator && validator(data, source.dimensionsDefine); |
| 134 | } |
| 135 | |
| 136 | mountMethods(this, data, source); |
| 137 | } |
| 138 | |
| 139 | getSource(): Source { |
| 140 | return this._source; |
| 141 | } |
nothing calls this directly
no test coverage detected
searching dependent graphs…