Highchart formatter函数每次执行两次

时间:2016-04-21 13:25:04

标签: javascript jquery highcharts formatter

我创建了一个高图表,但它的格式化程序函数执行了两次。

formatter: function() {
    console.log("start");
    return this.value;
}

Fiddle

2 个答案:

答案 0 :(得分:2)

基于Breakpoint Generator. ,看起来它是一个回调函数,只要显示工具提示就会触发它。

因此,每次将鼠标悬停在某个元素上时,系统会调用#Create a simulator object set ns [new Simulator] #Define different colors for data flows (for NAM) $ns color 1 Blue $ns color 2 Red #Open the NAM trace file set nf [open out.nam w] $ns namtrace-all $nf set nt [open test.tr w] $ns trace-all $nt #Define a 'finish' procedure proc finish {} { global ns nf nt $ns flush-trace #Close the NAM trace file close $nf close $nt #Execute NAM on the trace file exec nam out.nam & exit 0 } #Create four nodes set n1 [$ns node] set n2 [$ns node] set n3 [$ns node] set n4 [$ns node] set n5 [$ns node] set n6 [$ns node] #Create links between the nodes $ns duplex-link $n1 $n2 10Mb 10ms DropTail $ns duplex-link $n2 $n3 10Mb 20ms DropTail $ns duplex-link $n3 $n4 10Mb 10ms DropTail $ns duplex-link $n5 $n2 10Mb 10ms DropTail $ns duplex-link $n3 $n6 10Mb 10ms DropTail #Set Queue Size of link (n2-n3) to 10 $ns queue-limit $n2 $n3 10 #Give node position (for NAM) $ns duplex-link-op $n1 $n2 orient right-down $ns duplex-link-op $n5 $n2 orient right-up $ns duplex-link-op $n2 $n3 orient right $ns duplex-link-op $n3 $n4 orient right-up $ns duplex-link-op $n6 $n3 orient left-up #Monitor the queue for link (n2-n3). (for NAM) $ns duplex-link-op $n2 $n3 queuePos 0.5 #Setup a TCP connection set tcp [new Agent/TCP] $tcp set class_ 2 $ns attach-agent $n1 $tcp set sink [new Agent/TCPSink] $ns attach-agent $n4 $sink $ns connect $tcp $sink $tcp set fid_ 1 #Setup a FTP over TCP connection set ftp [new Application/FTP] $ftp attach-agent $tcp $ftp set type_ FTP #Setup a UDP connection set udp [new Agent/UDP] $ns attach-agent $n2 $udp set null [new Agent/Null] $ns attach-agent $n3 $sink $ns connect $udp $sink $udp set fid_ 2 #Setup a CBR over UDP connection set cbr [new Application/Traffic/CBR] $cbr attach-agent $udp $cbr set type_ CBR $cbr set packet_size_ 1000 $cbr set rate_ 1mb $cbr set random_ false #Schedule events for the CBR and FTP agents $ns at 0.1 "$cbr start" $ns at 1.0 "$ftp start" $ns at 4.0 "$ftp stop" $ns at 4.5 "$cbr stop" #Detach tcp and sink agents (not really necessary) $ns at 4.5 "$ns detach-agent $n1 $tcp ; $ns detach-agent $n4 $sink" 函数为该点生成相应的工具提示,如documentation for the formatter() function中的一组警报所示,并在下面演示:

this updated example

答案 1 :(得分:1)

我找到了解决方案。我使用的是旧版highchart

我已更新到最新解决问题。

感谢Rion和Sebastian