如何在d3雷达图中为每个形状添加链接?

时间:2015-06-25 07:00:47

标签: javascript d3.js

Bellow是我的代码片段,我已经在我的项目中集成了d3雷达图表,我只想添加一个链接到雷达图中绘制的每个形状。任何帮助将非常感激。请帮忙。 Bellow是我的代码片段,我已经在我的项目中集成了d3雷达图表,我只想添加一个链接到雷达图中绘制的每个形状。任何帮助将非常感激。请帮忙。

 **GET JSON FOR GETTING DATA FROM SERVER**


 function get_jsons1(page,divid,formid)
    {
            // $('#radar').html("");
            //alert("sfdsfdsf")
            $('#radar_legend').html("");
            $('#radar').html("");
            $('#test1').html(""); 
            $('#test2').html(""); 
            $('#test3').html(""); 
            $('#test4').html("");  
                $('#test5').html(""); 
                $('#links').html("");
                $("#search-month").html("");
               $('#total').html("No result found");
            var formvalues = do_it(formid);    
            url_page       = page;
            formvalues=formvalues.substring(1,formvalues.length); 
            // Call to check the status of global variable (is_csrf) and existence of token.
            temp_array     = [];
            temp_rr        = [];
            type_shape     = {};
            temp_array7    = []; 
            temp_array14   = []; 
            temp_array22   = []; 
            temp_array28   = [];
            temp_array32   = [];
            var params     = "";

            var cct = check_token();
            // Check if global variable is false or if its true but the token is not existed.
            if(cct == 0)
            {
                var params=formvalues+'&';
            }
            else
            {
                var params=formvalues+'&ci_csrf_token='+cct;
            }                             

            /*load loading image*/
            document.getElementById('loader').innerHTML ='<div align="center"><image src="/hrmis/images/loading.gif" border="0"></div>';     

            $.ajax({  
            dataType: "json",           
            url:      url_page,
            type:     'POST',
            data:     params,
            success:  function(response)
            {       

        $('#radar_legend').html("");
        var cur_type =[]; 
        $.each( response, function(key,val) 
        {
            if(val.pagination)
            {
                   //pagination
                    $.each( val.pagination, function(k,v) 
                    { 

                        if(v.links != 0)
                        {
                           $('#links').html(v.links);    
                        }
                        //$('#links').html(v.links);
                        $('#total').html(v.total);
                    });
            }
             $("#search-month").html(val.option); 
            var hours = []; 



            //== set parameters of form to temperary varible to send latar to server           
            param=val.param;  



            //$("#search-month").html(val.option);
            $("#search-month select").val(selected); 
            $.each( val.point, function(k,v) 
            {                                   

                if(temp_rr.length > 0)
                {
                    var temph =null;
                    $.each( hours, function(ss,hh)
                    {
                        temph = hh;
                        if(hh == v.hour)
                        {

                            temph = (v.hour);
                        }
                    });

                    temp_rr.push({axis:v.day,value:temph,color:v.color,label:v.c_type+"  ::   "+v.date_title+" ( "+v.urn+" ) ",shape:v.shape});
                    hours.push(v.hour); 
                }
                else
                {   
                    temp_rr.push({axis:v.day,value:v.hour,color:v.color,label:v.c_type+"  ::   "+v.date_title+" ( "+v.urn+" ) ",shape:v.shape});
                    hours.push(v.hour); 
                } 

                ///////////legend
                if(cur_type.indexOf(v.c_type)==-1)
                {   

                    get_rdr_legend(v,temp_rr);
                }
                cur_type.push(v.c_type);



        });              
        var final_rr = [temp_rr];
        console.log(JSON.stringify(final_rr));
        $('#radar').html(""); 
        RadarChart.draw("#radar", final_rr, mycfg);
             //==== remove the loader GIF 
              $("#loader").remove();
              $("#con_loader").append("<div id='loader'></div>"); 

            },   
            error:function(msg)
            {
                alert("error finding page");
            }
            });

        } 

radarchart

1 个答案:

答案 0 :(得分:0)

虽然标签提到了d3,但你的例子中没有d3代码。

当您开始使用de d3库时,您可以添加指向任何绘制对象的链接,如Hyperlinks in d3.js objects