From 6fcfb7c04d32e1c8b26a312295bf7ac3ec2d2ad7 Mon Sep 17 00:00:00 2001 From: Marvin Borner Date: Fri, 13 Jul 2018 19:06:45 +0200 Subject: Fixed many permissions and began admin interface --- public/bower_components/jvectormap/src/legend.js | 83 ++++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 public/bower_components/jvectormap/src/legend.js (limited to 'public/bower_components/jvectormap/src/legend.js') diff --git a/public/bower_components/jvectormap/src/legend.js b/public/bower_components/jvectormap/src/legend.js new file mode 100644 index 0000000..fdc3177 --- /dev/null +++ b/public/bower_components/jvectormap/src/legend.js @@ -0,0 +1,83 @@ +/** + * Represents map legend. + * @constructor + * @param {Object} params Configuration parameters. + * @param {String} params.cssClass Additional CSS class to apply to legend element. + * @param {Boolean} params.vertical If true legend will be rendered as vertical. + * @param {String} params.title Legend title. + * @param {Function} params.labelRender Method to convert series values to legend labels. + */ +jvm.Legend = function(params) { + this.params = params || {}; + this.map = this.params.map; + this.series = this.params.series; + this.body = jvm.$('
'); + this.body.addClass('jvectormap-legend'); + if (this.params.cssClass) { + this.body.addClass(this.params.cssClass); + } + + if (params.vertical) { + this.map.legendCntVertical.append( this.body ); + } else { + this.map.legendCntHorizontal.append( this.body ); + } + + this.render(); +} + +jvm.Legend.prototype.render = function(){ + var ticks = this.series.scale.getTicks(), + i, + inner = jvm.$('
').addClass('jvectormap-legend-inner'), + tick, + sample, + label; + + this.body.html(''); + if (this.params.title) { + this.body.append( + jvm.$('
').addClass('jvectormap-legend-title').html(this.params.title) + ); + } + this.body.append(inner); + + for (i = 0; i < ticks.length; i++) { + tick = jvm.$('
').addClass('jvectormap-legend-tick'); + sample = jvm.$('
').addClass('jvectormap-legend-tick-sample'); + + switch (this.series.params.attribute) { + case 'fill': + if (jvm.isImageUrl(ticks[i].value)) { + sample.css('background', 'url('+ticks[i].value+')'); + } else { + sample.css('background', ticks[i].value); + } + break; + case 'stroke': + sample.css('background', ticks[i].value); + break; + case 'image': + sample.css('background', 'url('+ticks[i].value+') no-repeat center center'); + break; + case 'r': + jvm.$('
').css({ + 'border-radius': ticks[i].value, + border: this.map.params.markerStyle.initial['stroke-width']+'px '+ + this.map.params.markerStyle.initial['stroke']+' solid', + width: ticks[i].value * 2 + 'px', + height: ticks[i].value * 2 + 'px', + background: this.map.params.markerStyle.initial['fill'] + }).appendTo(sample); + break; + } + tick.append( sample ); + label = ticks[i].label; + if (this.params.labelRender) { + label = this.params.labelRender(label); + } + tick.append( jvm.$('
'+label+'
').addClass('jvectormap-legend-tick-text') ); + inner.append(tick); + } + inner.append( jvm.$('
').css('clear', 'both') ); +} \ No newline at end of file -- cgit v1.2.3