Commit dfe48400 authored by Pedro Eduardo Trujillo's avatar Pedro Eduardo Trujillo
Browse files

Implementa título de leyenda, se aplica a windRose

parent ff6821fa
Loading
Loading
Loading
Loading
+25 −8
Original line number Diff line number Diff line
@@ -98,7 +98,7 @@ define([

			this.gridManagement = new GridManagementImpl(this.gridManagementConfig);

			this.dataFilter = new DateFilterImpl({
			this.dateFilter = new DateFilterImpl({
				parentChannel: this.getChannel()
			});
		},
@@ -112,8 +112,8 @@ define([
				channel : this._domainSplitSelector.getChannel('TOOL_ACTUATED'),
				callback: '_subDomainSplitSelectorToolActuated'
			},{
				channel : this.dataFilter.getChannel('TOOL_ACTUATED'),
				callback: '_subDataFilterToolActuated'
				channel : this.dateFilter.getChannel('TOOL_ACTUATED'),
				callback: '_subDateFilterToolActuated'
			},{
				channel : this.chartsContainer.getChannel('SHOWN'),
				callback: '_subChartsContainerShown'
@@ -147,7 +147,7 @@ define([
				node: this.buttonsContainerChartsTopNode
			});

			this._publish(this.dataFilter.getChannel('SHOW'), {
			this._publish(this.dateFilter.getChannel('SHOW'), {
				node: this.buttonsContainerChartsTopNode
			});

@@ -248,7 +248,7 @@ define([
			this._updateQuery();
		},

		_subDataFilterToolActuated: function(res) {
		_subDateFilterToolActuated: function(res) {

			var value = res.value;

@@ -286,9 +286,27 @@ define([
				}
			};

			this._updateChartsLegendTitle();
			this._requestChartsData();
		},

		_updateChartsLegendTitle: function() {

			if (!this._startDate || !this._endDate) {
				return;
			}

			var param = this.i18n.speed,
				humanizedStartDate = moment(this._startDate).format('YYYY-MM-DD hh:mm:ss'),
				humanizedEndDate = moment(this._endDate).format('YYYY-MM-DD hh:mm:ss'),
				dateRange = humanizedStartDate + ' - ' + humanizedEndDate,
				legendTitle = param + ' (' + this.sourceUnit + ') ' + dateRange;

			this._publish(this.chartsContainer.getChannel('SET_PROPS'), {
				legendTitle: legendTitle
			});
		},

		_subChartsContainerShown: function() {

			//this._requestChartsData();
@@ -345,12 +363,11 @@ define([

		_getLayerLabel: function(i) {

			var param = this.i18n.frequency,
				limits = this._limits[i],
			var limits = this._limits[i],
				min = limits.min,
				max = limits.max;

			return param + ' (' + min + ' - ' + max + ')';
			return '[' + min + ' - ' + max + ')';
		},

		_createChartLayer: function(layerConfig) {
+12 −4
Original line number Diff line number Diff line
@@ -273,12 +273,15 @@ define([
				directionDataDefinitionIds = dataDefinitions.direction,
				speedDataDefinitionIds = dataDefinitions.speed;

			var maxTimeInterval;
			var maxTimeInterval, unitAcronym;

			for (var i = 0; i < data.length; i++) {
				var measurement = data[i],
					dataDefinitionId = measurement.dataDefinition.id,
					timeInterval = measurement.dataDefinition.timeInterval,
					dataDefinition = measurement.dataDefinition,
					unit = measurement.unit;

				var dataDefinitionId = dataDefinition.id,
					timeInterval = dataDefinition.timeInterval,
					isDirectionDataDefinition = directionDataDefinitionIds.indexOf(dataDefinitionId) !== -1,
					isSpeedDataDefinition = speedDataDefinitionIds.indexOf(dataDefinitionId) !== -1;

@@ -287,12 +290,17 @@ define([
						maxTimeInterval = timeInterval;
					}
				}

				if (isSpeedDataDefinition) {
					unitAcronym = unit.acronym;
				}
			}

			this._publish(this._widgets.windrose.getChannel('SET_PROPS'), {
				directionDataDefinitionIds: directionDataDefinitionIds,
				speedDataDefinitionIds: speedDataDefinitionIds,
				timeInterval: maxTimeInterval
				timeInterval: maxTimeInterval,
				sourceUnit: unitAcronym
			});
		},

+6 −1
Original line number Diff line number Diff line
@@ -82,7 +82,7 @@ define([
				color = this._getSingleColor(chartColor, i),
				entriesCount = props.entriesCount,
				label = props.label,
				clippedLabel = this._getClippedText(label);
				clippedLabel = this._getClippedElementText(label);

			if (!this._legendElements[chartId]) {
				this._legendElements[chartId] = {};
@@ -164,6 +164,11 @@ define([
		_setLegendElementColor: function(legendElement, color) {

			legendElement.select("text").attr('fill', color);
		},

		_onLegendTitlePropSet: function(res) {

			this._setLegendTitle(res.value);
		}
	});
});
+69 −5
Original line number Diff line number Diff line
@@ -24,9 +24,11 @@ define([

			this.config = {
				legendBarClass: "chartLegendBar",
				legendTitleClass: 'chartLegendTitle',
				legendElementClass: "chartLegendElement",
				legendElementMargin: 20,
				legendLabelMaxLength: 40,
				legendTitleMaxLength: 80,
				disabledLegendClass: "hiddenChartLegend",

				_currentLegendBarHeight: 0,
@@ -62,6 +64,8 @@ define([
				.attr("id", "legendBar")
				.attr("class", this.legendBarClass);

			this._createLegendTitle();

			this._applyLegendBarTranslateValues();

			this._currentLegendBarHeight = this._legendBarRowHeight;
@@ -72,6 +76,18 @@ define([
			this.svg.call(this.legendBarTooltip);
		},

		_createLegendTitle: function() {

			this.legendBarTitleArea = this.legendBarArea.append('svg:g')
				.attr('class', this.legendTitleClass);

			this.legendBarTitleElement = this.legendBarTitleArea.append('svg:text');

			this.legendBarTitleElement
				.on('mouseleave', lang.hitch(this, this._onLegendTitleMouseLeave))
				.on('mouseenter', lang.partial(this._onLegendTitleMouseEnter, this));
		},

		_createLegendElement: function() {

			var legendElement = this.legendBarArea.append("svg:g")
@@ -156,10 +172,20 @@ define([
			}
		},

		_getClippedText: function(text) {
		_getClippedElementText: function(text) {

			return this._getClippedText(text, this.legendLabelMaxLength);
		},

		_getClippedTitleText: function(text) {

			if (text.length > this.legendLabelMaxLength) {
				text = text.substring(0, this.legendLabelMaxLength) + '...';
			return this._getClippedText(text, this.legendTitleMaxLength);
		},

		_getClippedText: function(text, length) {

			if (text.length > length) {
				text = text.substring(0, length) + '...';
			}

			return text;
@@ -252,6 +278,17 @@ define([
			this._reorderAndTranslateLegend();
		},

		_onLegendTitleMouseEnter: function(self) {

			self.legendBarTooltip.html(self._currentLegendTitle);
			self.legendBarTooltip.show(null, this);
		},

		_onLegendTitleMouseLeave: function() {

			this.legendBarTooltip.hide();
		},

		_onLegendElementMouseEnter: function(self, text) {

			self.legendBarTooltip.html(text);
@@ -263,6 +300,13 @@ define([
			this.legendBarTooltip.hide();
		},

		_setLegendTitle: function(title) {

			this._currentLegendTitle = title;

			this.legendBarTitleElement.text(this._getClippedTitleText(title));
		},

		_placeLegendElement: function(legendElement) {

			var firstElement = false;
@@ -319,12 +363,32 @@ define([

			var node = this.legendBarArea ? this.legendBarArea.node() : null,
				bbox = node ? node.getBBox() : null,
				halfWidth = bbox ? bbox.width / 2 : 0,
				xTranslate = (this._innerWidth / 2) - halfWidth + this._horizontalTranslate,
				halfWidth = bbox ? bbox.width / 2 : 0;

			this._translateLegendBarArea(halfWidth);
			this._translateLegendBarTitle(halfWidth);
		},

		_translateLegendBarArea: function(halfWidth) {

			var xTranslate = (this._innerWidth / 2) - halfWidth + this._horizontalTranslate,
				yTranslate = this._height - this._currentLegendBarHeight,
				transform = "translate(" + xTranslate + "," + yTranslate + ")";

			this.legendBarArea && this.legendBarArea.transition().attr("transform", transform);
		},

		_translateLegendBarTitle: function(areaHalfWidth) {

			var titleNode = this.legendBarTitleArea ? this.legendBarTitleArea.node() : null,
				titleBbox = titleNode ? titleNode.getBBox() : null,
				titleHalfWidth = titleBbox ? titleBbox.width / 2 : 0;

			var xTranslate = areaHalfWidth - titleHalfWidth,
				yTranslate = -this._legendBarRowHeight,
				transform = 'translate(' + xTranslate + ',' + yTranslate + ')';

			this.legendBarTitleArea && this.legendBarTitleArea.transition().attr('transform', transform);
		}
	});
});
Compare 0415798c to 0414cd42
Original line number Diff line number Diff line
Subproject commit 0415798c125fb2e07ebad550f6ed6ab4fbf305cc
Subproject commit 0414cd423036a8c55fdbdfa81f7b1bdd78b63f56