From f1fd3f6e134d09a205de32f46f9329197a54e6c8 Mon Sep 17 00:00:00 2001 From: Joshua Shorenstein Date: Fri, 15 Apr 2016 16:37:12 -0700 Subject: [PATCH] show scale bar as svg --- emperor/support_files/css/emperor.css | 38 ------------------- .../support_files/js/color-view-controller.js | 25 ++++++++---- 2 files changed, 17 insertions(+), 46 deletions(-) diff --git a/emperor/support_files/css/emperor.css b/emperor/support_files/css/emperor.css index 6c3e3c3b..a4373582 100644 --- a/emperor/support_files/css/emperor.css +++ b/emperor/support_files/css/emperor.css @@ -306,44 +306,6 @@ a.media-button:hover img{ display: none; } -.gradient { - width: 85%; - white-space: nowrap; - position: relative; - display: inline-block; - top: 4px; - padding-bottom: 15px; -} - - -.gradient .domain-min { - position: absolute; - left: 0; - font-size: 11px; - bottom: 3px; -} -.gradient .domain-med { - position: absolute; - right: 25%; - left: 25%; - text-align: center; - font-size: 11px; - bottom: 3px; -} -.gradient .domain-max { - position: absolute; - right: 0; - font-size: 11px; - bottom: 3px; -} - - -.grad-step { - display: inline-block; - height: 20px; - width: 1%; -} - /* * SlickGrid specific * diff --git a/emperor/support_files/js/color-view-controller.js b/emperor/support_files/js/color-view-controller.js index 7b41900c..f7a3067c 100644 --- a/emperor/support_files/js/color-view-controller.js +++ b/emperor/support_files/js/color-view-controller.js @@ -57,7 +57,9 @@ define([ var name, value, colorItem; // Create checkbox for whether using scalar data or not - this.$colorScale = $("
"); + this.$scaleDiv = $('
') + this.$colorScale = $(""); + this.$scaleDiv.append(this.$colorScale); this.$scaled = $(""); this.$scaledLabel = $("") @@ -107,10 +109,12 @@ define([ if (scaled) { scope.setSlickGridDataset({}); scope.$gridDiv.hide(); + scope.$scaleDiv.show(); scope.$colorScale.show(); scope.$colorScale.html(colorInfo[1]); } else { scope.setSlickGridDataset(data); + scope.$scaleDiv.hide(); scope.$colorScale.hide(); scope.$gridDiv.show(); } @@ -131,7 +135,6 @@ define([ this.$header.append(this.$scaled); this.$header.append(this.$scaledLabel); this.$body.append(this.$colorScale); - console.log(this.$body); // the chosen select can only be set when the document is ready $(function() { @@ -213,16 +216,22 @@ define([ var max = _.max(numericValues); var mid = (min + max) / 2; step = (max - min) / 100; - var gradient = ''; + var stopColors = []; for (var s = min; s <= max; s += step) { - gradient += ""; + stopColors.push(interpolator(s).hex()); } - gradient += "" + min + "" - gradient += "" + mid + "" - gradient += "" + max + "" + + var gradientSVG = '' + for (pos in stopColors) { + gradientSVG += ''; + } + gradientSVG += '' + gradientSVG += '' + min + '' + gradientSVG += '' + mid + '' + gradientSVG += '' + max + '' } - return [colors, gradient]; + return [colors, gradientSVG]; }; /**