LGSInnovations / sigplot

SigPlot provides fast interactive web-plotting for software defined radio.
https://sigplot.lgsinnovations.com
Apache License 2.0
36 stars 26 forks source link

m.initialize has a bug setting the subsize if the array input is array of data views #82

Open desean1625 opened 4 years ago

desean1625 commented 4 years ago

Describe the bug m.initialize has a bug setting the subsize if the array input is array of data views

To Reproduce

data = [new DataView(new ArrayBuffer(10))];
plot.overlay_array(data);//throw "subsize must be provided with type 2000 files";

Expected behavior The code allows arrays of Dataviews to be set and attempts to get the length for the subsize using data[0].length. However, dataviews it should be data[0].byteLength

Additional context Fix should be

else if (Array.isArray(data) && (Array.isArray(data[0]) || ArrayBuffer.isView(data[0]))) {
            //If this is a 2-D array automatically set subsize
            hcb.type = 2000;
            hcb.subsize = ArrayBuffer.isView(data[0]) ? data[0].byteLength: data[0].length;
            hcb.size = data.length;
        }
desean1625 commented 4 years ago

Also this needs to be corrected in bluefile.js when it flattens the 2d array https://github.com/LGSInnovations/sigplot/blob/39e66f415a018563dcd0cf778df50253c3817be7/js/bluefile.js#L577

mrecachinas commented 4 years ago

@desean1625 can you go ahead and submit a PR with these fixes?