js/main.js
// Like sample plot, but accepts timing information.
Like sample plot, but accepts timing information.
Like sample plot but accepts timing information .
function samplen() {
        var dataSeries = [],
            chart = terminal.getChart(),
            argsLen = args.length;
        if (argsLen === 0) {
          return preerr + 'The samplen chart needs to know what data to plot.  Please see <em>help samplen</em> for more information.' + sufans;
        } else {
          try {
            for (var i = 0; i < argsLen; i++) {
              try {
                args[i] = parser.eval(args[i]);
              } catch (error) {
              }
              if (math.typeof(args[i]) === 'Matrix') {
                try {
                  args[i] = JSON.parse(args[i]);
                } catch (error) {
                }
              }
            }
            if (!args.every(elem => Array.isArray(elem))) {
              throw new Error('The samplen chart only accepts arrays (ie, [1,2,3,4]) as arguments. Please see <em>help samplen</em> for more information.');
            }
            if (args.some(elem => math.typeof(elem[0]) === "Complex")) {
              throw new Error('If working with complex values, make sure to select either the real or imaginary component of your data using re() or im() prior to plotting.  Please see <em>help conv</em> for an example.');
            }
            dataSeries = parseDataSamplen.apply(null, args);
          } catch(error) {
            if (error.name.toString() == "TypeError") {
              return preerr + error.name + ': The samplen chart requires data to be submitted as [x1] [y1] [x2] [y2] etc.  Please see <em>help samplen</em> for more information.' + sufans;
            }
            return preerr + 'The samplen chart requires data to be submitted as [x1] [y1] [x2] [y2] etc.  Please see <em>help samplen</em> for more information. ' + error + sufans; 
          }
        }
        if (chart) {
          chart.destroy();
          terminal.setChart(chart);
        }
        chart = createSampleChart(chartDiv, dataSeries);
        terminal.setChart(chart);
        return '';
      }
function samplen ( ) { var dataSeries = [ ] , chart = terminal . getChart ( ) , argsLen = args . length ; if ( argsLen === 0 ) { return preerr + 'The samplen chart needs to know what data to plot.  Please see <em>help samplen</em> for more information.' + sufans ; } else { try { for ( var i = 0 ; i < argsLen ; i ++ ) { try { args [ i ] = parser . eval ( args [ i ] ) ; } catch ( error ) { } if ( math . typeof ( args [ i ] ) === 'Matrix' ) { try { args [ i ] = JSON . parse ( args [ i ] ) ; } catch ( error ) { } } } if ( ! args . every ( elem => Array . isArray ( elem ) ) ) { throw new Error ( 'The samplen chart only accepts arrays (ie, [1,2,3,4]) as arguments. Please see <em>help samplen</em> for more information.' ) ; } if ( args . some ( elem => math . typeof ( elem [ 0 ] ) === "Complex" ) ) { throw new Error ( 'If working with complex values, make sure to select either the real or imaginary component of your data using re() or im() prior to plotting.  Please see <em>help conv</em> for an example.' ) ; } dataSeries = parseDataSamplen . apply ( null , args ) ; } catch ( error ) { if ( error . name . toString ( ) == "TypeError" ) { return preerr + error . name + ': The samplen chart requires data to be submitted as [x1] [y1] [x2] [y2] etc.  Please see <em>help samplen</em> for more information.' + sufans ; } return preerr + 'The samplen chart requires data to be submitted as [x1] [y1] [x2] [y2] etc.  Please see <em>help samplen</em> for more information. ' + error + sufans ; } } if ( chart ) { chart . destroy ( ) ; terminal . setChart ( chart ) ; } chart = createSampleChart ( chartDiv , dataSeries ) ; terminal . setChart ( chart ) ; return '' ; }
Like sample plot, but accepts timing information.
Like sample plot but accepts timing information .
// Try to parse the data and format it for plotting. // Check if argument is a terminal variable by trying to retrieve the value. // Not a variable in the console. // No need to catch this, just proceed. // Need to decide if error should be thrown. // Check if all the arguments are arrays.  If not throw an error. // Check for presence of any complex numbers. // Format the data for plotting. // Catch any errors. // This usually means the data was passed without using pairs of arrays for x and y values. // Some other kind of error has occurred. // Recommended by Highcharts for memory management. // Chart the data in the correct div. // If all went well, just return an empty string to the terminal.