diff --git a/js/mx.js b/js/mx.js index 04ad5f4..32e2254 100644 --- a/js/mx.js +++ b/js/mx.js @@ -5352,6 +5352,32 @@ mx.update_image_row = function(Mx, buf, data, row, zmin, zmax, xcompression) { var imgd = new Uint32Array(buf, row * buf.width * 4, buf.width); + // special case xcompression type 6 should run outside of for loop + if (data && xcompression === 6) { + + let formattedData = []; + let simplifiedData = []; + let reformattedData = []; + + // format data with x and y properties + for (var index = 0; index < data.length; index++) { + value = data[index]; + formattedData.push({ ['x']: index, ['y']: value }); + } + + // run formatted data through simplify js + simplifiedData = simplify(formattedData, 1, false); + + // reformat array back to original + reformattedData = simplifiedData.map((item) => { + return item.y + }); + + // set data equal to reformatted, simplified data + data = reformattedData; + } + + Mx.pixel.setRange(zmin, zmax); var xc = Math.max(1, data.length / buf.width); @@ -5379,6 +5405,7 @@ value = Math.max(Math.abs(value), Math.abs(data[didx + j])); } } + } var colorIdx = Mx.pixel.getColorIndex(value); imgd[i] = colorIdx; diff --git a/js/sigplot.js b/js/sigplot.js index 06ec5b0..cc59bba 100644 --- a/js/sigplot.js +++ b/js/sigplot.js @@ -5001,7 +5001,6 @@ text: "XLABel...", handler: function() { var validator = function(value) { - console.log("The value is " + value); var isValid = mx.intValidator(value); return isValid; }; diff --git a/package.json b/package.json index c0a7c86..7f5f8f7 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ }, "dependencies": { "loglevel": "^1.4.1", + "simplify-js": "^1.2.3", "spin": "0.0.1", "tinycolor2": "^1.4.1", "travis": "^0.1.1" diff --git a/test/test.html b/test/test.html index c994db6..ffc4b8f 100644 --- a/test/test.html +++ b/test/test.html @@ -4,7 +4,7 @@ WebSigPlot Unit Test - +