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

Method _deserializePreVersion4

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

Source from the content-addressed store, hash-verified

194 }
195
196 _deserializePreVersion4(data) {
197 // read axes info
198 if (data.axesType == null) {
199 return true;
200 }
201 if (data.axesType !== "ImageAxes" &&
202 (data.calibration == null || data.axesParameters == null)) {
203 return false;
204 }
205
206 // get calibration points
207 let calibration = null;
208 if (data.axesType !== "ImageAxes") {
209 if (data.axesType === "TernaryAxes") {
210 calibration = new wpd.Calibration(3);
211 } else {
212 calibration = new wpd.Calibration(2);
213 }
214 for (let calIdx = 0; calIdx < data.calibration.length; calIdx++) {
215 calibration.addPoint(data.calibration[calIdx].px, data.calibration[calIdx].py,
216 data.calibration[calIdx].dx, data.calibration[calIdx].dy,
217 data.calibration[calIdx].dz);
218 }
219 }
220
221 let axes = null;
222 if (data.axesType === "XYAxes") {
223 axes = new wpd.XYAxes();
224 calibration.labels = ['X1', 'X2', 'Y1', 'Y2'];
225 calibration.labelPositions = ['N', 'N', 'E', 'E'];
226 calibration.maxPointCount = 4;
227 axes.calibrate(calibration, data.axesParameters.isLogX, data.axesParameters.isLogY);
228 } else if (data.axesType === "BarAxes") {
229 axes = new wpd.BarAxes();
230 calibration.labels = ['P1', 'P2'];
231 calibration.labelPositions = ['S', 'S'];
232 calibration.maxPointCount = 2;
233 axes.calibrate(calibration, data.axesParameters.isLog);
234 } else if (data.axesType === "PolarAxes") {
235 axes = new wpd.PolarAxes();
236 calibration.labels = ['Origin', 'P1', 'P2'];
237 calibration.labelPositions = ['E', 'S', 'S'];
238 calibration.maxPointCount = 3;
239 axes.calibrate(calibration, data.axesParameters.isDegrees,
240 data.axesParameters.isClockwise);
241 } else if (data.axesType === "TernaryAxes") {
242 axes = new wpd.TernaryAxes();
243 calibration.labels = ['A', 'B', 'C'];
244 calibration.labelPositions = ['S', 'S', 'E'];
245 calibration.maxPointCount = 3;
246 axes.calibrate(calibration, data.axesParameters.isRange100,
247 data.axesParameters.isNormalOrientation);
248 } else if (data.axesType === "MapAxes") {
249 axes = new wpd.MapAxes();
250 calibration.labels = ['P1', 'P2'];
251 calibration.labelPositions = ['S', 'S'];
252 calibration.maxPointCount = 2;
253 axes.calibrate(calibration, data.axesParameters.scaleLength,

Callers 1

deserializeMethod · 0.80

Calls 9

addPointMethod · 0.80
calibrateMethod · 0.80
setMetadataKeysMethod · 0.80
addPixelMethod · 0.80
addDatasetMethod · 0.80
setAxesForDatasetMethod · 0.80
addConnectionMethod · 0.80
addMeasurementMethod · 0.80
setAxesForMeasurementMethod · 0.80

Tested by

no test coverage detected