MCPcopy
hub / github.com/automeris-io/WebPlotDigitizer / _deserializeVersion4

Method _deserializeVersion4

app/javascript/core/plotData.js:315–539  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

313 }
314
315 _deserializeVersion4(data) {
316 // collect page data if it exists
317 let documentMetadata = {};
318
319 const collectMetadata = (group, type, key, object) => {
320 if (!documentMetadata[group])
321 documentMetadata[group] = {};
322 if (!documentMetadata[group][type])
323 documentMetadata[group][type] = {};
324 if (!documentMetadata[group][type][key])
325 documentMetadata[group][type][key] = [];
326 documentMetadata[group][type][key].push(object);
327 };
328
329 // axes data
330 if (data.axesColl != null) {
331 for (let axIdx = 0; axIdx < data.axesColl.length; axIdx++) {
332 const axData = data.axesColl[axIdx];
333
334 // get calibration
335 let calibration = null;
336 if (axData.type !== "ImageAxes") {
337 if (axData.type === "TernaryAxes") {
338 calibration = new wpd.Calibration(3);
339 } else {
340 calibration = new wpd.Calibration(2);
341 }
342 for (let calIdx = 0; calIdx < axData.calibrationPoints.length; calIdx++) {
343 calibration.addPoint(axData.calibrationPoints[calIdx].px,
344 axData.calibrationPoints[calIdx].py,
345 axData.calibrationPoints[calIdx].dx,
346 axData.calibrationPoints[calIdx].dy,
347 axData.calibrationPoints[calIdx].dz);
348 }
349 }
350
351 // create axes
352 let axes = null;
353 if (axData.type === "XYAxes") {
354 axes = new wpd.XYAxes();
355 calibration.labels = ['X1', 'X2', 'Y1', 'Y2'];
356 calibration.labelPositions = ['N', 'N', 'E', 'E'];
357 calibration.maxPointCount = 4;
358 axes.calibrate(calibration, axData.isLogX, axData.isLogY, axData.noRotation);
359 } else if (axData.type === "BarAxes") {
360 axes = new wpd.BarAxes();
361 calibration.labels = ['P1', 'P2'];
362 calibration.labelPositions = ['S', 'S'];
363 calibration.maxPointCount = 2;
364 axes.calibrate(calibration, axData.isLog,
365 axData.isRotated == null ? false : axData.isRotated);
366 } else if (axData.type === "PolarAxes") {
367 axes = new wpd.PolarAxes();
368 calibration.labels = ['Origin', 'P1', 'P2'];
369 calibration.labelPositions = ['E', 'S', 'S'];
370 calibration.maxPointCount = 3;
371 axes.calibrate(calibration, axData.isDegrees, axData.isClockwise, axData.isLog);
372 } else if (axData.type === "TernaryAxes") {

Callers 1

deserializeMethod · 0.80

Calls 15

addPointMethod · 0.80
calibrateMethod · 0.80
setPointGroupsMethod · 0.80
setMetadataKeysMethod · 0.80
hasPointGroupsMethod · 0.80
addEmptyTupleAtMethod · 0.80
addToTupleAtMethod · 0.80
addPixelMethod · 0.80
getAxesNamesMethod · 0.80
setAxesForDatasetMethod · 0.80
setAxesForMeasurementMethod · 0.80

Tested by

no test coverage detected