d3을 사용하여 기능을 전환하고 있습니다. 클릭 할 때 보이지 않는 객체를 숨기고 싶습니다. 다시 클릭하면 다시 볼 수 있습니다.이 요소를 전환하는 방법은 무엇입니까?
.on("click", function(d) { object1.style("visibility", "hidden");}
)
는 현재, 나는 단지 그것을 클릭하고 개체를 숨길,하지만 난 전환 할 수 없습니다
지금 나는이 기능을 얻었다. 내가 코드에 대한 질문이 있어요 .on("click", function(){ // Determine if current line is visible
var active = blueLine.active ? false : true,
newOpacity = active ? 0 : 1;
// Hide or show the elements
d3.select("#blueLine").style("opacity", newOpacity);
d3.select("#blueAxis").style("opacity", newOpacity);
// Update
whether or not the elements are active
blueLine.active = active; })
.text("Blue Line");
:이 예에서 http://bl.ocks.org/d3noob/5d621a60e2d1d02086bf
코드를 다음과 같이 외모를 전환 : 나는 그렇게 할 수있는이 좋은 예를 발견했다. 당신은 정의 새로운 변수
var active = blueLine.active ? false : true
현재 상태가 다음 예 예 경우를 위해, var active = false
활성화되어있는 경우, 확인?
다음 줄을 의미한다 :
newOpacity = active ? 0 : 1
이 newOpacity = false ? 0 : 1
가 newOpacity = 1
을 의미하는이 예에서 비슷한입니까? 그 맞습니까? 그리고,이 라인에서 :
blueLine.active = active
이 blueLine.active = false
로 전환? 누군가가이 혼란에서 나를 도울 수 있기를 바랍니다. 감사합니다.
감사를 다시 제라르! 당신이 나에게 짧은 설명을 해 주실 수 있습니까? '() =>' –
다음을보십시오 : https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions –