function prepare_average_data(data){

    // empty current lists
    line_data_x.length = 0
    line_data_y.length = 0
    var line_data = []


    // determine the data for the line
    data.forEach(function(d){
        line_data.push({"x": d[currentvariable_scatter_x], "y":d[currentvariable_scatter_y]})
    })

    // sort data for the line
    line_data.sort(function(a, b) {
        return parseFloat(a.x) - parseFloat(b.x);
    });

    // add data of line to separate lists
    line_data.forEach(function(d){
        line_data_x.push(d.x)
        line_data_y.push(d.y)
    })

    // use moving average function
    var average_data = moving_average(line_data_y, 3)
    return average_data
}
// prepare data to be converted to moving average line
prepare data to be converted to moving average line
prepare data to be converted to moving average line
function prepare_average_data(data){
    line_data_x.length = 0
    line_data_y.length = 0
    var line_data = []
    data.forEach(function(d){
        line_data.push({"x": d[currentvariable_scatter_x], "y":d[currentvariable_scatter_y]})
    })
    line_data.sort(function(a, b) {
        return parseFloat(a.x) - parseFloat(b.x);
    });
    line_data.forEach(function(d){
        line_data_x.push(d.x)
        line_data_y.push(d.y)
    })
    var average_data = moving_average(line_data_y, 3)
    return average_data
}
function prepare_average_data ( data ) { line_data_x . length = 0 line_data_y . length = 0 var line_data = [ ] data . forEach ( function ( d ) { line_data . push ( { "x" : d [ currentvariable_scatter_x ] , "y" : d [ currentvariable_scatter_y ] } ) } ) line_data . sort ( function ( a , b ) { return parseFloat ( a . x ) - parseFloat ( b . x ) ; } ) ; line_data . forEach ( function ( d ) { line_data_x . push ( d . x ) line_data_y . push ( d . y ) } ) var average_data = moving_average ( line_data_y , 3 ) return average_data }
prepare data to be converted to moving average line
prepare data to be converted to moving average line
// empty current lists // determine the data for the line // sort data for the line // add data of line to separate lists // use moving average function