From f957084320f4d819872804bd23761aa014e1b98e Mon Sep 17 00:00:00 2001 From: pratu16x7 Date: Sun, 12 Nov 2017 23:04:43 +0530 Subject: [PATCH] add github halloween colors demo to docs :D --- docs/assets/js/index.js | 50 ++++++++++++++++++++++++++++++++++++++++- docs/index.html | 8 +++++-- 2 files changed, 55 insertions(+), 3 deletions(-) diff --git a/docs/assets/js/index.js b/docs/assets/js/index.js index 137d928..1f8d58e 100755 --- a/docs/assets/js/index.js +++ b/docs/assets/js/index.js @@ -385,13 +385,61 @@ Array.prototype.slice.call( discrete_domains = 1; } + let colors = []; + let colors_mode = document + .querySelector('.heatmap-color-buttons .active') + .getAttribute('data-color'); + if(colors_mode === 'halloween') { + colors = ['#ebedf0', '#fdf436', '#ffc700', '#ff9100', '#06001c']; + } + new Chart({ parent: "#chart-heatmap", data: heatmap_data, type: 'heatmap', legend_scale: [0, 1, 2, 4, 5], height: 115, - discrete_domains: discrete_domains + discrete_domains: discrete_domains, + legend_colors: colors + }); + + Array.prototype.slice.call( + btn.parentNode.querySelectorAll('button')).map(el => { + el.classList.remove('active'); + }); + btn.classList.add('active'); + }); +}); + +Array.prototype.slice.call( + document.querySelectorAll('.heatmap-color-buttons button') +).map(el => { + el.addEventListener('click', (e) => { + let btn = e.target; + let colors_mode = btn.getAttribute('data-color'); + let colors = []; + + if(colors_mode === 'halloween') { + colors = ['#ebedf0', '#fdf436', '#ffc700', '#ff9100', '#06001c']; + } + + let discrete_domains = 1; + + let view_mode = document + .querySelector('.heatmap-mode-buttons .active') + .getAttribute('data-mode'); + if(view_mode === 'continuous') { + discrete_domains = 0; + } + + new Chart({ + parent: "#chart-heatmap", + data: heatmap_data, + type: 'heatmap', + legend_scale: [0, 1, 2, 4, 5], + height: 115, + discrete_domains: discrete_domains, + legend_colors: colors }); Array.prototype.slice.call( diff --git a/docs/index.html b/docs/index.html index 0de3b8c..d04098f 100644 --- a/docs/index.html +++ b/docs/index.html @@ -235,6 +235,10 @@ +
+ + +
  let heatmap = new Chart({
     parent: "#heatmap",
     type: 'heatmap',
@@ -248,9 +252,9 @@
                   // default: today's date in past year
                   //          for an annual heatmap
 
-    legend_colors: ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127'],
+    legend_colors: ['#ebedf0', '#fdf436', '#ffc700', '#ff9100', '#06001c'],
                   // Set of five incremental colors,
-                  // beginning with a muted color for zero data;
+                  // beginning with a low-saturation color for zero data;
                   // default: ['#ebedf0', '#c6e48b', '#7bc96f', '#239a3b', '#196127']
 
   });