d3 Cannot read property 'getPropertyValue' of undefined on mouseover [duplicate]










0
















This question already has an answer here:



  • Arrow function vs function declaration / expressions: Are they equivalent / exchangeable?

    2 answers



  • D3.js event listeners cannot access “this” when ES6 arrow functions are used [duplicate]

    1 answer



Trying to use a callback function .call() on mouseover to change opacity. Is this is a wrong selection? I've noticed that if I change const mouseOverFunc = d => d3.selectAll("circle") or even const mouseOverFunc = d => circle this leads all circles to show up. How to display one circle at a time? I understand that the promblem is I dont have to do groups.selectAll("circle") instead I have to append circle to groups same as I do with a path, but what I don't understand is to have access emissions d.year and d.amount for "cx" : xScale and "cy" : yScale.



Codepen



 let groups = svg.selectAll("g")
.data(dataset)
.enter()
.append("g")



groups.append("title")
.text(d => d.country)


groups
.append("path").classed("line", true)
.attr("d", d => line(d.emissions))
.style("stroke-width", d =>
d.country === "China" ? 1 : 0.2
)

let circle = groups.selectAll("circle")
.data(d => d.emissions)
.enter()
.append("circle");


circle.attrs(
"cx": d => xScale(d.year),
"cy": d => yScale(d.amount),
"r" : 3
)
.style("opacity", 0)




circle.on("mouseover", () =>
d3.select(this)
.call(mouseOverFunc));

const mouseOverFunc = selection =>
selection
.transition()
.duration(10)
.style("opacity", 1)
.style("fill", "turquoise")
.attr("r", 3)









share|improve this question















marked as duplicate by altocumulus, Quentin javascript
Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

StackExchange.ready(function()
if (StackExchange.options.isMobile) return;

$('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
var $hover = $(this).addClass('hover-bound'),
$msg = $hover.siblings('.dupe-hammer-message');

$hover.hover(
function()
$hover.showInfoMessage('',
messageElement: $msg.clone().show(),
transient: false,
position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
dismissable: false,
relativeToBody: true
);
,
function()
StackExchange.helpers.removeMessages();

);
);
);
Nov 12 '18 at 11:13


This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.






















    0
















    This question already has an answer here:



    • Arrow function vs function declaration / expressions: Are they equivalent / exchangeable?

      2 answers



    • D3.js event listeners cannot access “this” when ES6 arrow functions are used [duplicate]

      1 answer



    Trying to use a callback function .call() on mouseover to change opacity. Is this is a wrong selection? I've noticed that if I change const mouseOverFunc = d => d3.selectAll("circle") or even const mouseOverFunc = d => circle this leads all circles to show up. How to display one circle at a time? I understand that the promblem is I dont have to do groups.selectAll("circle") instead I have to append circle to groups same as I do with a path, but what I don't understand is to have access emissions d.year and d.amount for "cx" : xScale and "cy" : yScale.



    Codepen



     let groups = svg.selectAll("g")
    .data(dataset)
    .enter()
    .append("g")



    groups.append("title")
    .text(d => d.country)


    groups
    .append("path").classed("line", true)
    .attr("d", d => line(d.emissions))
    .style("stroke-width", d =>
    d.country === "China" ? 1 : 0.2
    )

    let circle = groups.selectAll("circle")
    .data(d => d.emissions)
    .enter()
    .append("circle");


    circle.attrs(
    "cx": d => xScale(d.year),
    "cy": d => yScale(d.amount),
    "r" : 3
    )
    .style("opacity", 0)




    circle.on("mouseover", () =>
    d3.select(this)
    .call(mouseOverFunc));

    const mouseOverFunc = selection =>
    selection
    .transition()
    .duration(10)
    .style("opacity", 1)
    .style("fill", "turquoise")
    .attr("r", 3)









    share|improve this question















    marked as duplicate by altocumulus, Quentin javascript
    Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

    StackExchange.ready(function()
    if (StackExchange.options.isMobile) return;

    $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
    var $hover = $(this).addClass('hover-bound'),
    $msg = $hover.siblings('.dupe-hammer-message');

    $hover.hover(
    function()
    $hover.showInfoMessage('',
    messageElement: $msg.clone().show(),
    transient: false,
    position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
    dismissable: false,
    relativeToBody: true
    );
    ,
    function()
    StackExchange.helpers.removeMessages();

    );
    );
    );
    Nov 12 '18 at 11:13


    This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.




















      0












      0








      0









      This question already has an answer here:



      • Arrow function vs function declaration / expressions: Are they equivalent / exchangeable?

        2 answers



      • D3.js event listeners cannot access “this” when ES6 arrow functions are used [duplicate]

        1 answer



      Trying to use a callback function .call() on mouseover to change opacity. Is this is a wrong selection? I've noticed that if I change const mouseOverFunc = d => d3.selectAll("circle") or even const mouseOverFunc = d => circle this leads all circles to show up. How to display one circle at a time? I understand that the promblem is I dont have to do groups.selectAll("circle") instead I have to append circle to groups same as I do with a path, but what I don't understand is to have access emissions d.year and d.amount for "cx" : xScale and "cy" : yScale.



      Codepen



       let groups = svg.selectAll("g")
      .data(dataset)
      .enter()
      .append("g")



      groups.append("title")
      .text(d => d.country)


      groups
      .append("path").classed("line", true)
      .attr("d", d => line(d.emissions))
      .style("stroke-width", d =>
      d.country === "China" ? 1 : 0.2
      )

      let circle = groups.selectAll("circle")
      .data(d => d.emissions)
      .enter()
      .append("circle");


      circle.attrs(
      "cx": d => xScale(d.year),
      "cy": d => yScale(d.amount),
      "r" : 3
      )
      .style("opacity", 0)




      circle.on("mouseover", () =>
      d3.select(this)
      .call(mouseOverFunc));

      const mouseOverFunc = selection =>
      selection
      .transition()
      .duration(10)
      .style("opacity", 1)
      .style("fill", "turquoise")
      .attr("r", 3)









      share|improve this question

















      This question already has an answer here:



      • Arrow function vs function declaration / expressions: Are they equivalent / exchangeable?

        2 answers



      • D3.js event listeners cannot access “this” when ES6 arrow functions are used [duplicate]

        1 answer



      Trying to use a callback function .call() on mouseover to change opacity. Is this is a wrong selection? I've noticed that if I change const mouseOverFunc = d => d3.selectAll("circle") or even const mouseOverFunc = d => circle this leads all circles to show up. How to display one circle at a time? I understand that the promblem is I dont have to do groups.selectAll("circle") instead I have to append circle to groups same as I do with a path, but what I don't understand is to have access emissions d.year and d.amount for "cx" : xScale and "cy" : yScale.



      Codepen



       let groups = svg.selectAll("g")
      .data(dataset)
      .enter()
      .append("g")



      groups.append("title")
      .text(d => d.country)


      groups
      .append("path").classed("line", true)
      .attr("d", d => line(d.emissions))
      .style("stroke-width", d =>
      d.country === "China" ? 1 : 0.2
      )

      let circle = groups.selectAll("circle")
      .data(d => d.emissions)
      .enter()
      .append("circle");


      circle.attrs(
      "cx": d => xScale(d.year),
      "cy": d => yScale(d.amount),
      "r" : 3
      )
      .style("opacity", 0)




      circle.on("mouseover", () =>
      d3.select(this)
      .call(mouseOverFunc));

      const mouseOverFunc = selection =>
      selection
      .transition()
      .duration(10)
      .style("opacity", 1)
      .style("fill", "turquoise")
      .attr("r", 3)




      This question already has an answer here:



      • Arrow function vs function declaration / expressions: Are they equivalent / exchangeable?

        2 answers



      • D3.js event listeners cannot access “this” when ES6 arrow functions are used [duplicate]

        1 answer







      javascript arrays object d3.js






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 12 '18 at 0:25







      Edgar Kiljak

















      asked Nov 12 '18 at 0:09









      Edgar KiljakEdgar Kiljak

      396112




      396112




      marked as duplicate by altocumulus, Quentin javascript
      Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Nov 12 '18 at 11:13


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.









      marked as duplicate by altocumulus, Quentin javascript
      Users with the  javascript badge can single-handedly close javascript questions as duplicates and reopen them as needed.

      StackExchange.ready(function()
      if (StackExchange.options.isMobile) return;

      $('.dupe-hammer-message-hover:not(.hover-bound)').each(function()
      var $hover = $(this).addClass('hover-bound'),
      $msg = $hover.siblings('.dupe-hammer-message');

      $hover.hover(
      function()
      $hover.showInfoMessage('',
      messageElement: $msg.clone().show(),
      transient: false,
      position: my: 'bottom left', at: 'top center', offsetTop: -7 ,
      dismissable: false,
      relativeToBody: true
      );
      ,
      function()
      StackExchange.helpers.removeMessages();

      );
      );
      );
      Nov 12 '18 at 11:13


      This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
























          1 Answer
          1






          active

          oldest

          votes


















          0














          Like written in altocumulus' comment, the reason is that this does work differently with arrow functions. If you are using an arrow function, you cannot use d3.select(this).



          You can solve your problem in two ways:



          • use a normal function()

          • use (d, i, node) => d3.select(nodes[i])

          Examples:



           circle.on("mouseover", function() => 
          d3.select(this)
          .call(mouseOverFunc));

          const mouseOverFunc = selection =>
          selection
          .transition()
          .duration(10)
          .style("opacity", 1)
          .style("fill", "turquoise")
          .attr("r", 3);


          OR



           circle.on("mouseover", (d, i, nodes) => 
          d3.select(nodes[i])
          .call(mouseOverFunc));

          const mouseOverFunc = selection =>
          selection
          .transition()
          .duration(10)
          .style("opacity", 1)
          .style("fill", "turquoise")
          .attr("r", 3);





          share|improve this answer





























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Like written in altocumulus' comment, the reason is that this does work differently with arrow functions. If you are using an arrow function, you cannot use d3.select(this).



            You can solve your problem in two ways:



            • use a normal function()

            • use (d, i, node) => d3.select(nodes[i])

            Examples:



             circle.on("mouseover", function() => 
            d3.select(this)
            .call(mouseOverFunc));

            const mouseOverFunc = selection =>
            selection
            .transition()
            .duration(10)
            .style("opacity", 1)
            .style("fill", "turquoise")
            .attr("r", 3);


            OR



             circle.on("mouseover", (d, i, nodes) => 
            d3.select(nodes[i])
            .call(mouseOverFunc));

            const mouseOverFunc = selection =>
            selection
            .transition()
            .duration(10)
            .style("opacity", 1)
            .style("fill", "turquoise")
            .attr("r", 3);





            share|improve this answer



























              0














              Like written in altocumulus' comment, the reason is that this does work differently with arrow functions. If you are using an arrow function, you cannot use d3.select(this).



              You can solve your problem in two ways:



              • use a normal function()

              • use (d, i, node) => d3.select(nodes[i])

              Examples:



               circle.on("mouseover", function() => 
              d3.select(this)
              .call(mouseOverFunc));

              const mouseOverFunc = selection =>
              selection
              .transition()
              .duration(10)
              .style("opacity", 1)
              .style("fill", "turquoise")
              .attr("r", 3);


              OR



               circle.on("mouseover", (d, i, nodes) => 
              d3.select(nodes[i])
              .call(mouseOverFunc));

              const mouseOverFunc = selection =>
              selection
              .transition()
              .duration(10)
              .style("opacity", 1)
              .style("fill", "turquoise")
              .attr("r", 3);





              share|improve this answer

























                0












                0








                0







                Like written in altocumulus' comment, the reason is that this does work differently with arrow functions. If you are using an arrow function, you cannot use d3.select(this).



                You can solve your problem in two ways:



                • use a normal function()

                • use (d, i, node) => d3.select(nodes[i])

                Examples:



                 circle.on("mouseover", function() => 
                d3.select(this)
                .call(mouseOverFunc));

                const mouseOverFunc = selection =>
                selection
                .transition()
                .duration(10)
                .style("opacity", 1)
                .style("fill", "turquoise")
                .attr("r", 3);


                OR



                 circle.on("mouseover", (d, i, nodes) => 
                d3.select(nodes[i])
                .call(mouseOverFunc));

                const mouseOverFunc = selection =>
                selection
                .transition()
                .duration(10)
                .style("opacity", 1)
                .style("fill", "turquoise")
                .attr("r", 3);





                share|improve this answer













                Like written in altocumulus' comment, the reason is that this does work differently with arrow functions. If you are using an arrow function, you cannot use d3.select(this).



                You can solve your problem in two ways:



                • use a normal function()

                • use (d, i, node) => d3.select(nodes[i])

                Examples:



                 circle.on("mouseover", function() => 
                d3.select(this)
                .call(mouseOverFunc));

                const mouseOverFunc = selection =>
                selection
                .transition()
                .duration(10)
                .style("opacity", 1)
                .style("fill", "turquoise")
                .attr("r", 3);


                OR



                 circle.on("mouseover", (d, i, nodes) => 
                d3.select(nodes[i])
                .call(mouseOverFunc));

                const mouseOverFunc = selection =>
                selection
                .transition()
                .duration(10)
                .style("opacity", 1)
                .style("fill", "turquoise")
                .attr("r", 3);






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 12 '18 at 11:10









                thibautgthibautg

                1,0391510




                1,0391510















                    Popular posts from this blog

                    𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

                    Edmonton

                    Crossroads (UK TV series)