Charts: Connect data points with template url

This commit is contained in:
Aysam Guerler
2014-06-20 03:28:41 -04:00
parent f62e25c549
commit a71f9a5d51
3 changed files with 18 additions and 1 deletions
File diff suppressed because one or more lines are too long
@@ -98,6 +98,13 @@ return $.extend(true, {}, config_default, {
value : 'wysiwyg'
}
]
},
url_template: {
title : 'Url template',
info : 'Enter a url to link the labels with external sources. Use __LABEL__ as placeholder.',
type : 'text',
init : '',
placeholder : 'http://someurl.com?id=__LABEL__'
}
}
});
@@ -206,6 +206,16 @@ return Backbone.View.extend({
// add tooltip events
boxes.selectAll('rect')
.on('dblclick', function(d) {
d3.event.stopPropagation();
var xLabel = self.categories.array.x[d.x];
var yLabel = self.categories.array.y[d.y];
var url = self.chart.settings.get('url_template').trim();
if (url) {
window.open(url.replace('__LABEL__', xLabel));
window.open(url.replace('__LABEL__', yLabel));
}
})
.on('mouseover', function(d) {
self.tooltip.style('opacity', 0.9);
self.tooltip .html(self._templateTooltip(d))