jumpingrivers / ibmsunburst

R 📦 for the IBM ☀📈 for the Personality Insights data
https://jumpingrivers.github.io/ibmsunburst
Other
7 stars 2 forks source link

documentation of changes required in source library #3

Closed timelyportfolio closed 5 years ago

timelyportfolio commented 5 years ago

So that we don't forget I wanted to add some documentation of the changes that I made to the source sunburst-chart. The dist version of the library points to the d3v3 version, which also pollutes the global namespace with d3. This means that we will likely conflict with other htmlwidgets that use other versions of d3.

To resolve, I made commits

  1. https://github.com/timelyportfolio/sunburst-chart/commit/4b1ef692bce528ffbde8ab6e9ddb9e3b69882e96 - use d3v4 version
  2. https://github.com/timelyportfolio/sunburst-chart/commit/8aa4f377a9770ad778372e2a529a3e93a89177f4 - RStudio Viewer will be updated but as of now requires es5 JavaScript since it is a very outdated. Change .babelrc to target es5 and transpile Object.assign.
  3. https://github.com/timelyportfolio/sunburst-chart/commit/97a5c130281fce73fff9f72f425a1f3c0025e1c9 - babel the dist version which we use in htmlwidgets/lib

These steps ended up being quite straightforward and minimal but took a little longer than I expected. If we encouter again with an update of the source library, this should be quick and easy.

stephlocke commented 5 years ago

Do I need to do anything specific other than clone this ibmsunburst repo as I'm getting a blank widget return when I run the example code.


<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8"/>
<script src="lib/htmlwidgets-1.2/htmlwidgets.js"></script>

</head>
<body style="background-color:white;">
<div id="htmlwidget_container">
  <div id="htmlwidget-0567d61c68a5c057b070" style="width:960px;height:500px;" class="ibmsunburst html-widget"></div>
</div>
<script type="application/json" data-for="htmlwidget-0567d61c68a5c057b070">{"x":{"data":{"id":"*UNKNOWN*","source":"*UNKNOWN*","word_count":6582,"processed_lang":"en","tree":{"id":"r","name":"root","children":[{"id":"personality","name":"Big 5","children":[{"id":"Openness_parent","name":"Openness","category":"personality","percentage":0.9806,"children":[{"id":"Openness","name":"Openness","category":"personality","percentage":0.9806,"sampling_error":0.0506,"children":[{"id":"Adventurousness","name":"Adventurousness","category":"personality","percentage":0.9504,"sampling_error":0.0447},{"id":"Artistic interests","name":"Artistic interests","category":"personality","percentage":0.8849,"sampling_error":0.0915},{"id":"Emotionality","name":"Emotionality","category":"personality","percentage":0.1705,"sampling_error":0.0415},{"id":"Imagination","name":"Imagination","category":"personality","percentage":0.2011,"sampling_error":0.0554},{"id":"Intellect","name":"Intellect","category":"personality","percentage":0.9824,"sampling_error":0.0481},{"id":"Liberalism","name":"Authority-challenging","category":"personality","percentage":0.9649,"sampling_error":0.0742}]},{"id":"Conscientiousness","name":"Conscientiousness","category":"personality","percentage":0.8937,"sampling_error":0.0641,"children":[{"id":"Achievement striving","name":"Achievement striving","category":"personality","percentage":0.9217,"sampling_error":0.0871},{"id":"Cautiousness","name":"Cautiousness","category":"personality","percentage":0.9589,"sampling_error":0.081},{"id":"Dutifulness","name":"Dutifulness","category":"personality","percentage":0.7565,"sampling_error":0.0535},{"id":"Orderliness","name":"Orderliness","category":"personality","percentage":0.4813,"sampling_error":0.0615},{"id":"Self-discipline","name":"Self-discipline","category":"personality","percentage":0.8215,"sampling_error":0.0418},{"id":"Self-efficacy","name":"Self-efficacy","category":"personality","percentage":0.9086,"sampling_error":0.0801}]},{"id":"Extraversion","name":"Extraversion","category":"personality","percentage":0.3363,"sampling_error":0.0485,"children":[{"id":"Activity level","name":"Activity level","category":"personality","percentage":0.979,"sampling_error":0.0673},{"id":"Assertiveness","name":"Assertiveness","category":"personality","percentage":0.9825,"sampling_error":0.0716},{"id":"Cheerfulness","name":"Cheerfulness","category":"personality","percentage":0.1947,"sampling_error":0.0899},{"id":"Excitement-seeking","name":"Excitement-seeking","category":"personality","percentage":0.215,"sampling_error":0.0737},{"id":"Friendliness","name":"Outgoing","category":"personality","percentage":0.6006,"sampling_error":0.0663},{"id":"Gregariousness","name":"Gregariousness","category":"personality","percentage":0.2421,"sampling_error":0.0514}]},{"id":"Agreeableness","name":"Agreeableness","category":"personality","percentage":0.0534,"sampling_error":0.0861,"children":[{"id":"Altruism","name":"Altruism","category":"personality","percentage":0.8722,"sampling_error":0.0617},{"id":"Cooperation","name":"Cooperation","category":"personality","percentage":0.76,"sampling_error":0.0716},{"id":"Modesty","name":"Modesty","category":"personality","percentage":0.3495,"sampling_error":0.0474},{"id":"Morality","name":"Uncompromising","category":"personality","percentage":0.648,"sampling_error":0.0551},{"id":"Sympathy","name":"Sympathy","category":"personality","percentage":0.9812,"sampling_error":0.0855},{"id":"Trust","name":"Trust","category":"personality","percentage":0.9241,"sampling_error":0.0481}]},{"id":"Neuroticism","name":"Emotional range","category":"personality","percentage":0.9213,"sampling_error":0.0782,"children":[{"id":"Anger","name":"Fiery","category":"personality","percentage":0.0167,"sampling_error":0.0823},{"id":"Anxiety","name":"Prone to worry","category":"personality","percentage":0.0497,"sampling_error":0.0472},{"id":"Depression","name":"Melancholy","category":"personality","percentage":0.2726,"sampling_error":0.0492},{"id":"Immoderation","name":"Immoderation","category":"personality","percentage":0.006,"sampling_error":0.0464},{"id":"Self-consciousness","name":"Self-consciousness","category":"personality","percentage":0.1257,"sampling_error":0.0483},{"id":"Vulnerability","name":"Susceptible to stress","category":"personality","percentage":0.0578,"sampling_error":0.0738}]}]}]},{"id":"needs","name":"Needs","children":[{"id":"Ideal_parent","name":"Ideal","category":"needs","percentage":0.0082,"children":[{"id":"Challenge","name":"Challenge","category":"needs","percentage":0.0093,"sampling_error":0.0725},{"id":"Closeness","name":"Closeness","category":"needs","percentage":0.1601,"sampling_error":0.0719},{"id":"Curiosity","name":"Curiosity","category":"needs","percentage":0.6537,"sampling_error":0.1015},{"id":"Excitement","name":"Excitement","category":"needs","percentage":0.0936,"sampling_error":0.0914},{"id":"Harmony","name":"Harmony","category":"needs","percentage":0.0577,"sampling_error":0.0911},{"id":"Ideal","name":"Ideal","category":"needs","percentage":0.0082,"sampling_error":0.0827},{"id":"Liberty","name":"Liberty","category":"needs","percentage":0.0637,"sampling_error":0.1236},{"id":"Love","name":"Love","category":"needs","percentage":0.0285,"sampling_error":0.0834},{"id":"Practicality","name":"Practicality","category":"needs","percentage":0.0506,"sampling_error":0.0738},{"id":"Self-expression","name":"Self-expression","category":"needs","percentage":0.0409,"sampling_error":0.0709},{"id":"Stability","name":"Stability","category":"needs","percentage":0.3829,"sampling_error":0.0904},{"id":"Structure","name":"Structure","category":"needs","percentage":0.8207,"sampling_error":0.0686}]}]},{"id":"values","name":"Values","children":[{"id":"Hedonism_parent","name":"Hedonism","category":"values","percentage":0.003,"children":[{"id":"Conservation","name":"Conservation","category":"values","percentage":0.1606,"sampling_error":0.0627},{"id":"Openness to change","name":"Openness to change","category":"values","percentage":0.5884,"sampling_error":0.0567},{"id":"Hedonism","name":"Hedonism","category":"values","percentage":0.003,"sampling_error":0.1137},{"id":"Self-enhancement","name":"Self-enhancement","category":"values","percentage":0.0121,"sampling_error":0.0869},{"id":"Self-transcendence","name":"Self-transcendence","category":"values","percentage":0.1054,"sampling_error":0.0656}]}]}]},"warnings":[]},"version":"v2"},"evals":[],"jsHooks":[]}</script>
<script type="application/htmlwidget-sizing" data-for="htmlwidget-0567d61c68a5c057b070">{"viewer":{"width":450,"height":350,"padding":15,"fill":true},"browser":{"width":960,"height":500,"padding":40,"fill":false}}</script>
</body>
</html>
timelyportfolio commented 5 years ago

@stephlocke Well that is no good and certainly not the result I intended :( Can you add session info so I can attempt to debug? Also, if you open in a browser other than RStudio Viewer, do you get a chart? Sorry....

Looking at the code you pasted, the dependencies are missing. I only see htmlwidgets.js. What happens if you devtools::install_github("lockedata/ibmsunburst")?

stephlocke commented 5 years ago

How random ... load_all() didn't work but an install did :)

maelle commented 5 years ago

Moved from the README (useless I think given the above, feel free to delete my comment)

Fixed some integration issues

stephlocke commented 5 years ago

I'd lifted the info from here and put it in the README as issues forget to get looked in 🙈

maelle commented 5 years ago

but you agree that the README should now get clean-ish or should I add them back there?