Plugin Directory

Changeset 2289894


Ignore:
Timestamp:
04/23/2020 07:58:36 AM (6 years ago)
Author:
maxicharts
Message:

parameterize columns

Location:
maxicharts-d3js-add-on/trunk
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • maxicharts-d3js-add-on/trunk/js/dndTree.js

    r2259662 r2289894  
    2727
    2828
    29 function processTreeList(root_input, width, height, containerName) {
    30     const sample = treeList(width, height);
     29function processTreeList(root_input, width, height, containerName, atts = null) {
     30    const sample = treeList(width, height; atts);
    3131    d3.select(containerName).datum(root_input).call(sample);
    3232    //d3.select(containerName).attr()
     
    3939}
    4040
    41 function treeList(width, max_height) {
     41function treeList(width, max_height, atts) {
    4242    let margin = {top: 30, right: 20, bottom: 30, left: 30};
    4343    //let width = 1000;
     
    131131            .duration(200)     
    132132            .style("opacity", .9);     
    133         div .html("<b>Source originale:</b> "+d.data.id + "<br/><b>Accès lecture/écriture:</b> "+d.data.data['Accès restreint'] + "<br/><b>Remarques:</b> " + d.data.data['Remarques'])
     133        div .html("<b>Source originale:</b> "+d.data.id + "<br/><b>Accès lecture/écriture:</b> "+d.data.data[atts.more_infos_1_col] + "<br/><b>Remarques:</b> " + d.data.data[atts.more_infos_2_col])   
    134134            .style("left", (d3.event.pageX + 200) + "px")       
    135135            .style("top", (d3.event.pageY - 28) + "px");   
     
    10491049var MaxiChartsCollapsibleTree = class {
    10501050   
    1051     constructor(url_of_input_file, jsonStrObject, width, height, containerName, csv_child_col_name = null, csv_parent_col_name = null,csv_description_col_name = null)  {
     1051    constructor(url_of_input_file, jsonStrObject, width, height, containerName, maxicharts_d3js_ajax_shortcode_param = null)  {
    10521052        console.log("Building collapsible tree with url:"+url_of_input_file);
    10531053        console.log("or object:");
     
    10761076                    console.log(data[0]);     
    10771077                   
    1078                     var childColumn = "Chemin source";
    1079                     var parentColumn = "Parent";
    1080                     var accessColumn = "Access";
    1081                     var descriptionColumn = "Description";
     1078                    /*
     1079                     * Acces: "SP + BA"
     1080Chemin source: "RESSOURCES_HUMAINES"
     1081Parent: "Partage"
     1082Remarques: "Trouver un nom qui indique la nature du partage"
     1083                     *
     1084                     */
    10821085                   
     1086                    var childColumn = maxicharts_d3js_ajax_shortcode_param.child_col;//"Chemin source";
     1087                    var parentColumn = maxicharts_d3js_ajax_shortcode_param.child_col;//"Parent";
     1088                    /*var accessColumn = "Access";
     1089                    var descriptionColumn = "Description";*/
     1090                    // parent_col="Parent" child_col="Chemin source" more_infos_1_col="Acces" more_infos_1_col="Remarques"
    10831091
    10841092                    var stratify = d3.stratify()
     
    10921100                    console.log("After stratify:");
    10931101                    console.log(root);
    1094                     processTreeList(root, width, height, containerName);
     1102                    processTreeList(root, width, height, containerName, maxicharts_d3js_ajax_shortcode_param);
    10951103               
    10961104            })
  • maxicharts-d3js-add-on/trunk/js/maxicharts-d3js-frontend.js

    r2259662 r2289894  
    105105                        } else if (type == "tree"){
    106106                            // create tree from file - CSV or JSON
    107                             var myTree = new MaxiChartsCollapsibleTree(element, null,  width, height,'#visualization');
     107                            var myTree = new MaxiChartsCollapsibleTree(element, null,  width, height,'#visualization', maxicharts_d3js_ajax_object);
    108108                        }
    109109                    } else if (type == 'sunburst'){
  • maxicharts-d3js-add-on/trunk/maxicharts-d3js.php

    r2259861 r2289894  
    595595            'height' => '500px',
    596596            'groups' => '',
    597             'type' => 'sunburst'
     597            'type' => 'sunburst',
     598            'parent_col' => 'parent',
     599            'child_col' => 'child',
     600            'more_infos_1_col' => 'Acces',
     601            'more_infos_2_col' => 'Remarques',
    598602        ), $attributes);
     603        // parent_col="Parent" child_col="Chemin source" more_infos_1_col="Acces" more_infos_1_col="Remarques"
    599604        $show_buttons = isset($a['show_buttons']) ? boolval($a['show_buttons']) : true;
    600605        $data_path = isset($a['data_path']) ? $a['data_path'] : '';   
     
    626631        $this->MCD3JS_enqueue_scripts($type);
    627632        //$d3jsKey = 'network-frontend-js';
    628         wp_localize_script($this->d3js_frontend_key, 'maxicharts_d3js_ajax_object', array(
     633        $localized_array = array_merge($a, array(
    629634            'ajax_url' => admin_url('admin-ajax.php'),
    630635            'height' => $height,
     
    634639            'gf_form_id' => $gf_form_id,
    635640        ));
     641       
     642        wp_localize_script($this->d3js_frontend_key, 'maxicharts_d3js_ajax_object', $localized_array);
     643       
     644       
     645       
    636646        $buttons = '<p class="maxicharts_d3js_button_bar">
    637647  <input type="button" id="lastMonth" value="Last month"><br>
Note: See TracChangeset for help on using the changeset viewer.