1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
/**
 * initialize likelihood of correlations plot
 */
function initialize_likelihood_of_correlations_plot() {
    add_heading(id_likelihood_of_correlation, get_language_label_by_id(language_id_likelihood_of_correlation_plot_heading));
    add_content_div(id_likelihood_of_correlation);



    /*let content_div = d3.select('#' + id_likelihood_of_correlation + id_content_ending);
    content_div.attr('id', 'div').style('overflow-x', 'auto');
    content_div.append('div').attr('id', id_likelihood_of_correlation + id_content_ending).style('width', '100%').style('height', '100%')
        .style('display', 'flex').style('flex-direction', 'row').style('flex-wrap', 'nowrap');
*/
}

function initialize_one_dimensional_plot() {

    let col_width = column_values_cleaned.length * (200 + 20);

    d3.select('#' + id_likelihood_of_correlation + id_content_ending).style('width', col_width + 'px');

    column_values_cleaned.forEach(function (col, index) {
        let col_div = d3.select('#' + id_likelihood_of_correlation + id_content_ending)
            .append('div')
            .attr('class', id_likelihood_of_correlation_divs_class)
            .attr('id', col[key_id] + id_likelihood_of_correlations_ending)
            .style('order', index)
            .on('click', function () {
                selectedIndex = column_values_filtered.map(col => col[key_id]).indexOf(col[key_id]);
                rotateCarousel(true);
            });

        let radar_chart_div = col_div.append('div')
            .attr('id', col[key_id] + id_likelihood_of_correlations_ending + id_likelihood_of_correlations_radar_plot_ending)
            .attr('class', id_radarChartDiv_class);

        append_radar_chart(radar_chart_div, col[key_data_type], col);


        col_div.append('div')
            .attr('class', id_class_heading).append('svg')//.attr('id', parent_div_id + id_heading_ending + id_svg_endging)
            .style('width', '100%')
            .style('height', '100%')
            .append('text')
            .text(col[key_header])
            .attr('font-size', '0.8em')
            .attr('text-anchor', 'middle')
            .attr('transform', 'translate(' + parseFloat(getComputedStyle(col_div.node()).width) / 2 + ',' + 33 / 2 + ')');
    });


}

function append_radar_chart(parent_div, dataType) {

    var margin = {top: 30, right: 30, bottom: 20, left: 30},
        width = parseFloat(getComputedStyle(parent_div.node()).width) - margin.left - margin.right,
        height = Math.min(width, parseFloat(getComputedStyle(parent_div.node()).height) - margin.top - margin.bottom - 20);


    let data = [[]];


    let color_data_type = color__numerical_data;

    if (dataType === id_data_type__numerical || dataType === id_data_type__date) {
        all_descriptive_statistic_measures_numerical.forEach(function (key_stat) {
            data[0].push({'axis': get_language_label_by_id(key_stat+radar_chart_stats_key_ending), value: 0});
        });

        if (dataType === id_data_type__date) {
            color_data_type = color__date_data;
        }
    } else {
        color_data_type = color__categorical_data;
        all_descriptive_statistic_measures_categorical.forEach(function (key_stat) {
            data[0].push({'axis': get_language_label_by_id(key_stat+radar_chart_stats_key_ending), value: 0});
        })
    }
    //////////////////////////////////////////////////////////////
    //////////////////// Draw the Chart //////////////////////////
    //////////////////////////////////////////////////////////////

    let color = d3version3.scale.ordinal()
        .range([color_data_type]);

    radarChartOptions = {
        w: width,
        h: height,
        margin: margin,
        maxValue: 1,
        levels: 3,
        roundStrokes: true,
        color: color
    };
    //Call function to draw the Radar chart
    RadarChart(parent_div.node(), data, radarChartOptions);

    parent_div.selectAll('.axisLabel').style('opacity', 0);
    parent_div.selectAll('.legend').style('fill', 'white');
    parent_div.selectAll('.gridCircle').style('fill', 'white').style('filter', '').style('opacity', 0.4);
    if (dataType === id_data_type__categorical) {
        // parent_div.selectAll('.legend').style('opacity', 0);
        // parent_div.selectAll('.axis').style('opacity', 0);


    }
}

function append_radar_chart_tooltip(parent_div, dataType, col, deviation) {

    var margin = {top: 30, right: 30, bottom: 30, left: 30},
        width = parseFloat(getComputedStyle(parent_div.node()).width) - margin.left - margin.right,
        height = Math.min(width, parseFloat(getComputedStyle(parent_div.node()).height) - margin.top - margin.bottom - 20);

    let data = [[]];

    let color_data_type = color__numerical_data;

    if (dataType === id_data_type__numerical || dataType === id_data_type__date) {
/*        all_descriptive_statistic_measures_numerical.forEach(function (key_stat) {
            data[0].push({'axis': get_language_label_by_id(key_stat+radar_chart_stats_key_ending), value: Math.abs(col.descriptive_statistics[key_stat] / 100)});
        });*/

        if (dataType === id_data_type__date) {
            color_data_type = color__date_data;
        }
    } else {
        color_data_type = color__categorical_data;
/*        all_descriptive_statistic_measures_categorical.forEach(function (key_stat) {
            data[0].push({'axis': get_language_label_by_id(key_stat+radar_chart_stats_key_ending), value: Math.abs(col.descriptive_statistics[key_stat] / 100)});
        })*/
    }

    let deviation_ending_ = "";
    if (deviation) {
        deviation_ending_ = deviation_ending;
    }
    all_descriptive_statistic_measures_all_dimensions.forEach(function (key_stat) {

        if (key_stat !== number_of_modes) {
            data[0].push({'axis': get_language_label_by_id(key_stat+radar_chart_stats_key_ending + deviation_ending_), value: Math.abs(col.descriptive_statistics[key_stat+deviation_ending_])});
        }
    });
    //////////////////////////////////////////////////////////////
    //////////////////// Draw the Chart //////////////////////////
    //////////////////////////////////////////////////////////////

    let color = d3version3.scale.ordinal()
        .range([color_data_type]);

    radarChartOptions = {
        w: width,
        h: height,
        margin: margin,
        maxValue: 1,
        levels: 3,
        roundStrokes: true,
        color: color
    };
    //Call function to draw the Radar chart
    RadarChart(parent_div.node(), data, radarChartOptions);

    parent_div.selectAll('.axisLabel').style('opacity', 0);
    parent_div.selectAll('.legend').style('fill', 'white');
    parent_div.selectAll('.gridCircle').style('fill', 'white').style('filter', '').style('opacity', 0.4);
}

let radarChartOptions = {};

function update_likelihood_of_correlations_plot() {


    let col_values_filtered = JSON.parse(JSON.stringify(column_values_filtered)).sort((a, b) => (a.descriptive_statistics[statistics_key_overall_deviation] < b.descriptive_statistics[statistics_key_overall_deviation]) ? 1 : -1);

    let myColor = d3.scaleLinear()
        .domain([0, col_values_filtered.length-1])
        .range([color_applied_filters, 'white']);

    col_values_filtered.forEach(function (col, index) {

        d3.select('#' + col[key_id] + id_likelihood_of_correlations_ending).style('order', index);

        let data = [[]];

        let data_type = id_data_type__numerical;
        let color_data_type = color__numerical_data;

        if (col[key_data_type] === id_data_type__numerical || col[key_data_type] === id_data_type__date) {
            all_descriptive_statistic_measures_numerical.forEach(function (key_stat) {
                data[0].push({
                    'axis': get_language_label_by_id(key_stat),
                    value: Math.abs(col.descriptive_statistics[key_stat + deviation_ending] / 100)
                });
            });

            if (col[key_data_type] === id_data_type__date) {
                color_data_type = color__date_data;
            }

        } else {
            data_type = id_data_type__categorical;
            color_data_type = color__categorical_data;

            all_descriptive_statistic_measures_numerical.forEach(function (key_stat) {
                data[0].push({
                    'axis': get_language_label_by_id(statistics_key__highest_relative_frequency),
                    value: Math.abs(col.descriptive_statistics[statistics_key__highest_relative_frequency + deviation_ending] / 100)
                });
            })
        }

        let color = d3version3.scale.ordinal()
            .range([color_data_type]);

        radarChartOptions.color = color;

        let radar_div = d3.select('#' + col[key_id] + id_likelihood_of_correlations_ending + id_likelihood_of_correlations_radar_plot_ending);

        d3.select('#' + col[key_id] + id_likelihood_of_correlations_ending).select('.' + id_class_heading)
            .transition().duration(animation_duration_time).style('background-color', myColor(index));
        RadarChart(radar_div.node(), data, radarChartOptions);

        radar_div.selectAll('.axisLabel').style('opacity', 0);

        if (data_type === id_data_type__categorical) {
            radar_div.selectAll('.legend').style('opacity', 0);
            radar_div.selectAll('.axisLabel').style('opacity', 0);
            radar_div.selectAll('.axis').style('opacity', 0);
        }
    })
}