0

我有一个带有两条简单线条的 LineChart,我必须有可能隐藏特定系列的工具提示(呈现不可选择的线条)。是否可以通过提供的一些 api 来实现它?

我正在尝试发展我的特定行为:

onmouseover: function (d, node){
                if (d.id=="Requested")
                {
                    __  what here?
                }
            }
4

1 回答 1

0

我通过在内容生成器中添加 if 语句来解决。

tooltip: 
        {

            contents: function (d, defaultTitleFormat, defaultValueFormat, color) 
            {
                var $$ = this, config = $$.config, CLASS = $$.CLASS,
                titleFormat = config.tooltip_format_title || defaultTitleFormat,
                nameFormat = config.tooltip_format_name || function (name) { return name; },
                valueFormat = config.tooltip_format_value || defaultValueFormat,
                text, i, title, value, name, bgcolor;

            // You can access all of data like this:

                var count=0;
                for (i = 0; i < d.length; i++) 
                {

                    **if (d[i].id=="Requested")** {
                    if (! (d[i] && (d[i].value || d[i].value === 0))) { continue; }

                    // ADD



                    if (! text) 
                    {

                        var formats=d3.time.format('%Y%m%d');
                        var date= new Date(formats.parse(scene[d[i].index].date));

                        title = date.getDate()+"/"+date.getMonth()+1+"/"+date.getFullYear();
                        text = "<table class='" + CLASS.tooltip + "'>" + (title || title === 0 ? "<tr><th colspan='2'>" + title + "</th></tr>" : "");
                    }


                      }//if requested
                }
于 2015-06-26T11:19:58.117 回答