MCPcopy Index your code
hub / github.com/apache/echarts / dataToLayout

Method dataToLayout

src/coord/matrix/Matrix.ts:181–231  ·  view source on GitHub ↗

* @implement * - The input is allowed to be `[NaN/null/undefined, xxx]`/`[xxx, NaN/null/undefined]`; * the return is `{x: NaN, width: NaN, y: xxxresulty, height: xxxresulth}`/ * `{y: NaN, height: NaN, x: xxxresultx, width: xxxresultw}` or clamped boundary value * if `clamp` pa

(
        data: MatrixCoordRangeOption[],
        opt?: {
            // No clamp by default, considering the possibility of supporting dataZoom (overflow/scroll).
            clamp?: MatrixClampOption | NullUndefined;
            // Expand if cell merging is encountered.
            //  - `false`: If intersecting with a rect of merged cells, expand the result to cover it.
            //      This is the default option, becuase `series.data` do not support the format
            //      `MatrixCoordRangeOption` (e.g., `[[3,5], [5,8]]`), thus merged cells can only
            //      be located by single cell locators (e.g., `[3, 5]`).
            //  - `true`: regardless of cell merging, even if the resulting rect spans accorss the merged cells.
            ignoreMergeCells?: boolean;
        },
        out?: CoordinateSystemDataLayout
    )

Source from the content-addressed store, hash-verified

179 * avoid covering cell borders, if necessary.
180 */
181 dataToLayout(
182 data: MatrixCoordRangeOption[],
183 opt?: {
184 // No clamp by default, considering the possibility of supporting dataZoom (overflow/scroll).
185 clamp?: MatrixClampOption | NullUndefined;
186 // Expand if cell merging is encountered.
187 // - `false`: If intersecting with a rect of merged cells, expand the result to cover it.
188 // This is the default option, becuase `series.data` do not support the format
189 // `MatrixCoordRangeOption` (e.g., `[[3,5], [5,8]]`), thus merged cells can only
190 // be located by single cell locators (e.g., `[3, 5]`).
191 // - `true`: regardless of cell merging, even if the resulting rect spans accorss the merged cells.
192 ignoreMergeCells?: boolean;
193 },
194 out?: CoordinateSystemDataLayout
195 ): CoordinateSystemDataLayout {
196 const dims = this._dims;
197
198 out = out || {} as CoordinateSystemDataLayout;
199 const outRect = out.rect = out.rect || {} as RectLike;
200 outRect.x = outRect.y = outRect.width = outRect.height = NaN;
201 const outLocRange = out.matrixXYLocatorRange = resetXYLocatorRange(out.matrixXYLocatorRange);
202
203 if (!isArray(data)) {
204 if (__DEV__) {
205 error('Input data must be an array in `convertToLayout`, `convertToPixel`');
206 }
207 return out;
208 }
209
210 parseCoordRangeOption(
211 outLocRange,
212 null,
213 data,
214 dims,
215 retrieve2(opt && opt.clamp, MatrixClampOption.none)
216 );
217
218 if (!opt || !opt.ignoreMergeCells) {
219 if (!opt || opt.clamp !== MatrixClampOption.corner) {
220 this._model.getBody().expandRangeByCellMerge(outLocRange);
221 }
222 if (!opt || opt.clamp !== MatrixClampOption.body) {
223 this._model.getCorner().expandRangeByCellMerge(outLocRange);
224 }
225 }
226
227 xyLocatorRangeToRectOneDim(outRect, outLocRange, dims, 0);
228 xyLocatorRangeToRectOneDim(outRect, outLocRange, dims, 1);
229
230 return out;
231 }
232
233 /**
234 * The returned locator pair can be the input of `dataToPoint` or `dataToLayout`.

Callers 1

dataToPointMethod · 0.95

Calls 8

resetXYLocatorRangeFunction · 0.90
errorFunction · 0.90
parseCoordRangeOptionFunction · 0.90
isArrayFunction · 0.85
getBodyMethod · 0.80
getCornerMethod · 0.80

Tested by

no test coverage detected