Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/iwindow.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,15 +30,15 @@ define(['jquery', 'underscore', "hoverTract", "variables", "colors"], function($
}

var formatters = {
"%": function(n) {
"{0}%": function(n) {
return n.toFixed(2) + "%";
},

"#": function(n) {
"#{0}": function(n) {
return commaSeparate(n.toFixed(2));
},

"$": function(n) {
"${0}": function(n) {
return "$" + commaSeparate(n.toFixed(2));
}
};
Expand Down
10 changes: 5 additions & 5 deletions src/legend.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@ define(['jquery', 'underscore'], function($, _){
// <i style="background: #fff;"></i> $265 - $756
// <i style="background: #eee;"></i> $756 - $1000
// ...
var TEMPLATE = '<h4> <%= title %> </h4>'+
var TEMPLATE = _.template('<h4> <%= title %> </h4>'+
'<% _.each( data, function(entry){ %>'+
'<i style="background: <%= entry.color %>;"></i>'+
'<%= entry.unit %> <%= entry.min %> - '+
'<%= entry.unit %> <%= entry.max %> '+
'<%= entry.unit.replace("{0}", entry.min) %> - '+
'<%= entry.unit.replace("{0}", entry.max) %>'+
'<br>'+
'<% }) %>';
'<% }) %>');

// Legend Data is an object with a title attribute, and a data attribute which is an array of legend entries as follows:

Expand All @@ -28,7 +28,7 @@ define(['jquery', 'underscore'], function($, _){
// ]
function render(event, legendData){
var $el = $(SELECTOR);
$el.html( _.template(TEMPLATE, legendData));
$el.html(TEMPLATE(legendData));

}

Expand Down