Last active
June 29, 2018 14:12
-
-
Save leandrocosta/727747c1253044921e16288cb63da4fd to your computer and use it in GitHub Desktop.
Flavors (Aromas e Sabores) da Cerveja
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <!doctype html> | |
| <html> | |
| <head> | |
| <style> | |
| #container { | |
| min-width: 600px; | |
| max-width: 980px; | |
| margin: 0 auto | |
| } | |
| </style> | |
| <script src="https://code.highcharts.com/highcharts.js"></script> | |
| <script src="https://code.highcharts.com/modules/sunburst.js"></script> | |
| <script src="https://code.highcharts.com/modules/exporting.js"></script> | |
| <script type="text/javascript"> | |
| //fetch('http://gsx2json.com/api?id=1Oru0AboIyDrbzBxgzEecEd_nHTbH2cuWgtIU4tY4ITA&sheet=1&columns=false&integers=false') | |
| fetch('https://spreadsheets.google.com/feeds/list/1Oru0AboIyDrbzBxgzEecEd_nHTbH2cuWgtIU4tY4ITA/1/public/values?alt=json') | |
| .then(function(response) { | |
| return response.json(); | |
| }).then(function(sheet) { | |
| //var data = sheet.rows; | |
| var data = sheet.feed.entry | |
| .filter(function(entry) { return entry.gsx$id.$t != ''; }) | |
| .map(function(entry) { | |
| return { | |
| id: entry.gsx$id.$t, | |
| parent: (entry.gsx$id.$t === '0' ? '' : entry.gsx$id.$t.length > 1 ? entry.gsx$id.$t.substr(0, entry.gsx$id.$t.lastIndexOf('.')) : '0'), | |
| name: entry.gsx$name.$t | |
| }; | |
| }); | |
| data.forEach(function(obj) { | |
| if (!data.find(function(obj2) { return obj2.parent === obj.id; })) { | |
| obj.value = 1; | |
| } | |
| }); | |
| // Splice in transparent for the center circle | |
| Highcharts.getOptions().colors.splice(0, 0, 'transparent'); | |
| Highcharts.chart('container', { | |
| colors: ['#555555', '#ad5617' /* malt */, '#267018' /* hop */, '#eec600' /* yeast */, '#c8a2c8' /* brett */, '#78512d' /* wood */, '#a82a00' /* age */, '#277184' /* others */], | |
| chart: { | |
| height: '100%' | |
| }, | |
| title: { | |
| text: 'Flavors (Aromas e Sabores) da Cerveja' | |
| }, | |
| /*subtitle: { | |
| text: 'WIP' | |
| },*/ | |
| series: [{ | |
| type: "sunburst", | |
| data: data, | |
| allowDrillToNode: true, | |
| cursor: 'pointer', | |
| dataLabels: { | |
| allowOverlap: true, | |
| format: '{point.name}', | |
| filter: { | |
| property: 'innerArcLength', | |
| operator: '>', | |
| value: 16 | |
| } | |
| }, | |
| levels: [{ | |
| level: 1, | |
| levelIsConstant: false, | |
| dataLabels: { | |
| rotationMode: 'parallel', | |
| filter: { | |
| property: 'outerArcLength', | |
| operator: '>', | |
| value: 64 | |
| } | |
| } | |
| }, { | |
| level: 2, | |
| colorByPoint: true, | |
| dataLabels: { | |
| rotationMode: 'parallel' | |
| } | |
| }, { | |
| level: 3, | |
| colorVariation: { | |
| key: 'brightness', | |
| to: -0.5 | |
| } | |
| }, { | |
| level: 4, | |
| colorVariation: { | |
| key: 'brightness', | |
| to: 0.5 | |
| } | |
| }] | |
| }], | |
| tooltip: { | |
| headerFormat: "", | |
| pointFormat: '<b>{point.name}</b>' | |
| } | |
| }); | |
| }); | |
| </script> | |
| </head> | |
| <body> | |
| <div id="container"></div> | |
| </body> | |
| </html> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment