1

Google Visualization API 組織図を使用して階層を生成しています。チャートが生成されたら、クリックされたボックスからIDを取得したい。

グラフを生成するために ID と名前を文字列として渡します。ボックスがクリックされたときに Id を選択し、これをセッション変数に保存したいと考えています。

4

1 に答える 1

0

以下は、組織図内のノードから html を取得する方法の例です。

        var data = new google.visualization.DataTable();
        data.addColumn('string', 'Question/Answer');
        data.addColumn('string', 'Prev_Question');
        data.addColumn('string', 'Count');
        data.addRows(tree_data);
        var chart = new google.visualization.OrgChart(document.getElementById('chart_div'));
        chart.draw(data, {
            allowHtml:true,
            allowCollapse:true
        });

        var selectHandler = function(e) {
            // get the selected node.
            var nodes = chart.getSelection();
            // get the node row id.
            var node_row = nodes[0].row;
            // get the node data.
            var node = data.xf[node_row].c;
            // select just the text from the node.
            var node_text = node[0].f;
            // out put the text.
            console.log(node_text);
        }

        // add event listening.
        google.visualization.events.addListener(chart, 'select', selectHandler);

node_text は、必要なノード html です。

于 2014-01-07T16:42:00.873 に答える