How build a sunburst diagram that responds to a slider










0














I'm trying to build a sunburst diagram with an interactive slider. More specifically, I would like the slider, which is based on date, to appear and disappear slices in the sunburst according to the date associated with those slices.



I have created both the slider and the sunburst, but cannot get them to work together.



http://plnkr.co/edit/YIHd7o3fQ9RLFuN5PWVa?p=preview



I believe the problem lies in the 'updateData' function, which compares the date selected by the slider to the date associated with each datapoint. More specifically, the syntax obtaining the date of the slices appears to be incorrect, as it console.log() a "null" value.



Things I've tried:



To check syntax, I replaced d.data.Cattime with d.data.id. The latter logs the dataset information to the console - suggesting the syntax is correct. Strangely, this doesn't work with d.data.parentId.



I thought the problem might be that items under the Cattime heading is not represented as a date. But this code, console.log(parseDate(data[1].Cattime)); suggests that this is recognized as a date.



Any suggestions appreciated.










share|improve this question


























    0














    I'm trying to build a sunburst diagram with an interactive slider. More specifically, I would like the slider, which is based on date, to appear and disappear slices in the sunburst according to the date associated with those slices.



    I have created both the slider and the sunburst, but cannot get them to work together.



    http://plnkr.co/edit/YIHd7o3fQ9RLFuN5PWVa?p=preview



    I believe the problem lies in the 'updateData' function, which compares the date selected by the slider to the date associated with each datapoint. More specifically, the syntax obtaining the date of the slices appears to be incorrect, as it console.log() a "null" value.



    Things I've tried:



    To check syntax, I replaced d.data.Cattime with d.data.id. The latter logs the dataset information to the console - suggesting the syntax is correct. Strangely, this doesn't work with d.data.parentId.



    I thought the problem might be that items under the Cattime heading is not represented as a date. But this code, console.log(parseDate(data[1].Cattime)); suggests that this is recognized as a date.



    Any suggestions appreciated.










    share|improve this question
























      0












      0








      0







      I'm trying to build a sunburst diagram with an interactive slider. More specifically, I would like the slider, which is based on date, to appear and disappear slices in the sunburst according to the date associated with those slices.



      I have created both the slider and the sunburst, but cannot get them to work together.



      http://plnkr.co/edit/YIHd7o3fQ9RLFuN5PWVa?p=preview



      I believe the problem lies in the 'updateData' function, which compares the date selected by the slider to the date associated with each datapoint. More specifically, the syntax obtaining the date of the slices appears to be incorrect, as it console.log() a "null" value.



      Things I've tried:



      To check syntax, I replaced d.data.Cattime with d.data.id. The latter logs the dataset information to the console - suggesting the syntax is correct. Strangely, this doesn't work with d.data.parentId.



      I thought the problem might be that items under the Cattime heading is not represented as a date. But this code, console.log(parseDate(data[1].Cattime)); suggests that this is recognized as a date.



      Any suggestions appreciated.










      share|improve this question













      I'm trying to build a sunburst diagram with an interactive slider. More specifically, I would like the slider, which is based on date, to appear and disappear slices in the sunburst according to the date associated with those slices.



      I have created both the slider and the sunburst, but cannot get them to work together.



      http://plnkr.co/edit/YIHd7o3fQ9RLFuN5PWVa?p=preview



      I believe the problem lies in the 'updateData' function, which compares the date selected by the slider to the date associated with each datapoint. More specifically, the syntax obtaining the date of the slices appears to be incorrect, as it console.log() a "null" value.



      Things I've tried:



      To check syntax, I replaced d.data.Cattime with d.data.id. The latter logs the dataset information to the console - suggesting the syntax is correct. Strangely, this doesn't work with d.data.parentId.



      I thought the problem might be that items under the Cattime heading is not represented as a date. But this code, console.log(parseDate(data[1].Cattime)); suggests that this is recognized as a date.



      Any suggestions appreciated.







      d3.js






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 12 '18 at 22:32









      oymonk

      116113




      116113






















          1 Answer
          1






          active

          oldest

          votes


















          1














          You should compare two date objects in your return statement.



          svg.selectAll(".node").style("fill", function(d) 
          return new Date(((d.data.data.Cattime))) > new Date(h) ? "red" : "black";



          Also, initially you are setting fill color of path as a style property, but in your update function you are setting it as an attribute.



          Apparently, its value doesn't change when you set it as an attribute later on. So, either change update function to style or change your initialization to attribute.



          working example






          share|improve this answer




















          • It is working beautifully - thank you for figuring this out.
            – oymonk
            Nov 16 '18 at 3:10










          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271050%2fhow-build-a-sunburst-diagram-that-responds-to-a-slider%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          1














          You should compare two date objects in your return statement.



          svg.selectAll(".node").style("fill", function(d) 
          return new Date(((d.data.data.Cattime))) > new Date(h) ? "red" : "black";



          Also, initially you are setting fill color of path as a style property, but in your update function you are setting it as an attribute.



          Apparently, its value doesn't change when you set it as an attribute later on. So, either change update function to style or change your initialization to attribute.



          working example






          share|improve this answer




















          • It is working beautifully - thank you for figuring this out.
            – oymonk
            Nov 16 '18 at 3:10















          1














          You should compare two date objects in your return statement.



          svg.selectAll(".node").style("fill", function(d) 
          return new Date(((d.data.data.Cattime))) > new Date(h) ? "red" : "black";



          Also, initially you are setting fill color of path as a style property, but in your update function you are setting it as an attribute.



          Apparently, its value doesn't change when you set it as an attribute later on. So, either change update function to style or change your initialization to attribute.



          working example






          share|improve this answer




















          • It is working beautifully - thank you for figuring this out.
            – oymonk
            Nov 16 '18 at 3:10













          1












          1








          1






          You should compare two date objects in your return statement.



          svg.selectAll(".node").style("fill", function(d) 
          return new Date(((d.data.data.Cattime))) > new Date(h) ? "red" : "black";



          Also, initially you are setting fill color of path as a style property, but in your update function you are setting it as an attribute.



          Apparently, its value doesn't change when you set it as an attribute later on. So, either change update function to style or change your initialization to attribute.



          working example






          share|improve this answer












          You should compare two date objects in your return statement.



          svg.selectAll(".node").style("fill", function(d) 
          return new Date(((d.data.data.Cattime))) > new Date(h) ? "red" : "black";



          Also, initially you are setting fill color of path as a style property, but in your update function you are setting it as an attribute.



          Apparently, its value doesn't change when you set it as an attribute later on. So, either change update function to style or change your initialization to attribute.



          working example







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Nov 15 '18 at 6:39









          Umesh Maharshi

          1,040410




          1,040410











          • It is working beautifully - thank you for figuring this out.
            – oymonk
            Nov 16 '18 at 3:10
















          • It is working beautifully - thank you for figuring this out.
            – oymonk
            Nov 16 '18 at 3:10















          It is working beautifully - thank you for figuring this out.
          – oymonk
          Nov 16 '18 at 3:10




          It is working beautifully - thank you for figuring this out.
          – oymonk
          Nov 16 '18 at 3:10

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53271050%2fhow-build-a-sunburst-diagram-that-responds-to-a-slider%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Top Tejano songwriter Luis Silva dead of heart attack at 64

          政党

          天津地下鉄3号線