modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java
| 3
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
| 13
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
| 22
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
| 8
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3MultiLineGraph.java
| 37 -
modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
| 234 +++++-----
6 files changed, 153 insertions(+), 164 deletions(-)
New commits:
commit 644b57605e5bcb79c2137ed8ad3902e600c9a9a0
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Sun Jul 7 14:15:08 2013 -0700
Consolidate the d3 time format stuff into rhq.js so all graphs have access.
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java
index 60b5e26..34ca60b 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityLineGraphType.java
@@ -32,9 +32,12 @@ import org.rhq.enterprise.gui.coregui.client.util.Log;
import org.rhq.enterprise.gui.coregui.client.util.MeasurementConverterClient;
/**
+ * This is now old and for demonstration purposes only.
* Contains the javascript chart definition for an implementation of the d3 availability
chart. This implementation is
* just a line that changes color based on availability type: up=green, down=red,
orange=disabled, unknown=grey,
* empty=grey, warn=yellow. This version of the availability graph shows continuous
intervals.
+ * @deprecated
+ * @see AvailabilityOverUnderGraphType
*
* @author Mike Thompson
*/
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
index 3822b59..7c5f80a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
@@ -171,7 +171,6 @@ public class AvailabilityOverUnderGraphType implements
AvailabilityGraphType {
.tickSize(13, 0, 0)
.orient("bottom"),
- customTimeFormat,
calcBarY = function (d) {
var ABOVE = -6,
@@ -253,17 +252,7 @@ public class AvailabilityOverUnderGraphType implements
AvailabilityGraphType {
return calcBarFill(d);
});
- customTimeFormat = timeFormat([
- [$wnd.d3.time.format("%Y"), function() { return true; }],
- [$wnd.d3.time.format("%B"), function(d) { return
d.getMonth(); }],
- [$wnd.d3.time.format("%b %d"), function(d) { return
d.getDate() != 1; }],
- [$wnd.d3.time.format("%a %d"), function(d) { return
d.getDay() && d.getDate() != 1; }],
- [$wnd.d3.time.format(availChartContext.chartXaxisTimeFormatHours),
function(d) { return d.getHours(); }],
-
[$wnd.d3.time.format(availChartContext.chartXaxisTimeFormatHoursMinutes), function(d) {
return d.getMinutes(); }],
- [$wnd.d3.time.format(":%S"), function(d) { return
d.getSeconds(); }],
- [$wnd.d3.time.format(".%L"), function(d) { return
d.getMilliseconds(); }]
- ]);
- xAxis.tickFormat(customTimeFormat);
+
xAxis.tickFormat($wnd.rhqCommon.getD3CustomTimeFormat(availChartContext.chartXaxisTimeFormatHours,
availChartContext.chartXaxisTimeFormatHoursMinutes));
// create x-axis
svg.append("g")
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
index 0178f93..b8c63f4 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
@@ -461,17 +461,8 @@ public class StackedBarMetricGraphImpl extends AbstractMetricGraph {
}
function createXandYAxes() {
- var customTimeFormat = timeFormat([
- [$wnd.d3.time.format("%Y"), function() { return true; }],
- [$wnd.d3.time.format("%B"), function(d) { return
d.getMonth(); }],
- [$wnd.d3.time.format("%b %d"), function(d) { return
d.getDate() != 1; }],
- [$wnd.d3.time.format("%a %d"), function(d) { return
d.getDay() && d.getDate() != 1; }],
- [$wnd.d3.time.format(chartContext.chartXaxisTimeFormatHours),
function(d) { return d.getHours(); }],
- [$wnd.d3.time.format(chartContext.chartXaxisTimeFormatHoursMinutes),
function(d) { return d.getMinutes(); }],
- [$wnd.d3.time.format(":%S"), function(d) { return
d.getSeconds(); }],
- [$wnd.d3.time.format(".%L"), function(d) { return
d.getMilliseconds(); }]
- ]);
- xAxis.tickFormat(customTimeFormat);
+
+
xAxis.tickFormat($wnd.rhqCommon.getD3CustomTimeFormat(chartContext.chartXaxisTimeFormatHours,
chartContext.chartXaxisTimeFormatHoursMinutes));
// create x-axis
svg.append("g")
@@ -495,15 +486,6 @@ public class StackedBarMetricGraphImpl extends AbstractMetricGraph {
}
- function timeFormat(formats) {
- return function(date) {
- var i = formats.length - 1, f = formats[i];
- while (!f[1](date)) f = formats[--i];
- return f[0](date);
- }
- }
-
-
function createAvgLines() {
var showBarAvgTrendline =
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::showBarAvgTrendLine()(),
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
index 7a4232a..7ade3f7 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3GraphListView.java
@@ -73,7 +73,7 @@ public abstract class CompositeGroupD3GraphListView extends
EnhancedVLayout impl
private final String chartHoverDateFormat = MSG.chart_hover_date_format();
private int groupId;
private int definitionId;
- private boolean isAutogroup;
+ private boolean isAutoGroup;
private MeasurementDefinition definition;
private MeasurementUserPreferences measurementUserPreferences;
private ButtonBarDateTimeRangeEditor buttonBarDateTimeRangeEditor;
@@ -86,10 +86,10 @@ public abstract class CompositeGroupD3GraphListView extends
EnhancedVLayout impl
private String chartTitle;
private Integer chartHeight;
- public CompositeGroupD3GraphListView(int groupId, int defId, boolean isAutogroup) {
+ public CompositeGroupD3GraphListView(int groupId, int defId, boolean isAutoGroup) {
super();
this.groupId = groupId;
- this.isAutogroup = isAutogroup;
+ this.isAutoGroup = isAutoGroup;
setDefinitionId(defId);
measurementForEachResource = new ArrayList<MultiLineGraphData>();
measurementUserPreferences = new
MeasurementUserPreferences(UserSessionManager.getUserPreferences());
@@ -105,7 +105,7 @@ public abstract class CompositeGroupD3GraphListView extends
EnhancedVLayout impl
ResourceGroupCriteria criteria = new ResourceGroupCriteria();
criteria.addFilterId(groupId);
criteria.fetchResourceType(true);
- criteria.addFilterVisible(!isAutogroup);
+ criteria.addFilterVisible(!isAutoGroup);
criteria.fetchExplicitResources(true);
measurementForEachResource.clear();
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3MultiLineGraph.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3MultiLineGraph.java
index be6d110..42e5f0c 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3MultiLineGraph.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/table/CompositeGroupD3MultiLineGraph.java
@@ -163,33 +163,8 @@ public class CompositeGroupD3MultiLineGraph extends
CompositeGroupD3GraphListVie
}
function createXandYAxes() {
- var customTimeFormat = timeFormat([
- [$wnd.d3.time.format("%Y"), function () {
- return true;
- }],
- [$wnd.d3.time.format("%B"), function (d) {
- return d.getMonth();
- }],
- [$wnd.d3.time.format("%b %d"), function (d) {
- return d.getDate() != 1;
- }],
- [$wnd.d3.time.format("%a %d"), function (d) {
- return d.getDay() && d.getDate() != 1;
- }],
- [$wnd.d3.time.format(chartContext.chartXaxisTimeFormatHours),
function (d) {
- return d.getHours();
- }],
- [$wnd.d3.time.format(chartContext.chartXaxisTimeFormatHoursMinutes),
function (d) {
- return d.getMinutes();
- }],
- [$wnd.d3.time.format(":%S"), function (d) {
- return d.getSeconds();
- }],
- [$wnd.d3.time.format(".%L"), function (d) {
- return d.getMilliseconds();
- }]
- ]);
- xAxis.tickFormat(customTimeFormat);
+
+
xAxis.tickFormat($wnd.rhqCommon.getD3CustomTimeFormat(chartContext.chartXaxisTimeFormatHours,
chartContext.chartXaxisTimeFormatHoursMinutes));
// create x-axis
svg.append("g")
@@ -213,13 +188,7 @@ public class CompositeGroupD3MultiLineGraph extends
CompositeGroupD3GraphListVie
}
- function timeFormat(formats) {
- return function (date) {
- var i = formats.length - 1, f = formats[i];
- while (!f[1](date)) f = formats[--i];
- return f[0](date);
- }
- }
+
function createHeader(titleName) {
diff --git a/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
b/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
index 435fd67..40c7ca8 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
+++ b/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
@@ -4,7 +4,8 @@
// Handle browsers not supporting console object
if (!window.console) window.console = {};
-if (!window.console.log) window.console.log = function () { };
+if (!window.console.log) window.console.log = function () {
+};
/**
* ChartContext Constructor Object
@@ -39,101 +40,146 @@ if (!window.console.log) window.console.log = function () { };
* @param chartXaxisTimeFormatHoursMinutes
* @constructor
*/
-var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, chartTitle,
yAxisUnits, minChartTitle, avgChartTitle, peakChartTitle, dateLabel, timeLabel, downLabel,
unknownLabel, noDataLabel, hoverStartLabel,hoverEndLabel, hoverPeriodLabel, hoverBarLabel,
chartHoverTimeFormat, chartHoverDateFormat, isPortalGraph, portalId,
buttonBarDateTimeFormat, singleValueLabel, chartXaxisTimeFormatHours,
chartXaxisTimeFormatHoursMinutes )
-{
- "use strict";
- if(!(this instanceof ChartContext)){
- throw new Error("ChartContext function cannot be called as a
function.")
- }
- this.chartId = chartId;
- this.chartHeight = chartHeight;
- this.data = jQuery.parseJSON(metricsData); // make into json
- this.xAxisLabel = xAxisLabel;
- this.chartTitle = chartTitle;
- this.yAxisUnits = yAxisUnits;
- this.minChartTitle = minChartTitle;
- this.avgChartTitle = avgChartTitle;
- this.peakChartTitle = peakChartTitle;
- this.dateLabel = dateLabel;
- this.timeLabel = timeLabel;
- this.downLabel = downLabel;
- this.unknownLabel = unknownLabel;
- this.singleValueLabel = singleValueLabel;
- this.noDataLabel = noDataLabel;
- this.hoverStartLabel = hoverStartLabel;
- this.hoverEndLabel = hoverEndLabel;
- this.hoverPeriodLabel = hoverPeriodLabel;
- this.hoverBarLabel = hoverBarLabel;
- this.chartHoverTimeFormat = chartHoverTimeFormat;
- this.chartHoverDateFormat = chartHoverDateFormat;
- this.isPortalGraph = isPortalGraph;
- this.portalId = portalId;
- if(isPortalGraph){
- this.chartHandle = "rChart-"+chartId+"-"+portalId;
- }else {
- this.chartHandle = "rChart-"+chartId;
- }
- this.chartSelection = this.chartHandle + " svg";
- this.buttonBarDateTimeFormat = buttonBarDateTimeFormat;
- this.chartXaxisTimeFormatHours = chartXaxisTimeFormatHours;
- this.chartXaxisTimeFormatHoursMinutes = chartXaxisTimeFormatHoursMinutes;
+var ChartContext = function (chartId, chartHeight, metricsData, xAxisLabel, chartTitle,
yAxisUnits, minChartTitle, avgChartTitle, peakChartTitle, dateLabel, timeLabel, downLabel,
unknownLabel, noDataLabel, hoverStartLabel, hoverEndLabel, hoverPeriodLabel,
hoverBarLabel, chartHoverTimeFormat, chartHoverDateFormat, isPortalGraph, portalId,
buttonBarDateTimeFormat, singleValueLabel, chartXaxisTimeFormatHours,
chartXaxisTimeFormatHoursMinutes) {
+ "use strict";
+ if (!(this instanceof ChartContext)) {
+ throw new Error("ChartContext function cannot be called as a
function.")
+ }
+ this.chartId = chartId;
+ this.chartHeight = chartHeight;
+ this.data = jQuery.parseJSON(metricsData); // make into json
+ this.xAxisLabel = xAxisLabel;
+ this.chartTitle = chartTitle;
+ this.yAxisUnits = yAxisUnits;
+ this.minChartTitle = minChartTitle;
+ this.avgChartTitle = avgChartTitle;
+ this.peakChartTitle = peakChartTitle;
+ this.dateLabel = dateLabel;
+ this.timeLabel = timeLabel;
+ this.downLabel = downLabel;
+ this.unknownLabel = unknownLabel;
+ this.singleValueLabel = singleValueLabel;
+ this.noDataLabel = noDataLabel;
+ this.hoverStartLabel = hoverStartLabel;
+ this.hoverEndLabel = hoverEndLabel;
+ this.hoverPeriodLabel = hoverPeriodLabel;
+ this.hoverBarLabel = hoverBarLabel;
+ this.chartHoverTimeFormat = chartHoverTimeFormat;
+ this.chartHoverDateFormat = chartHoverDateFormat;
+ this.isPortalGraph = isPortalGraph;
+ this.portalId = portalId;
+ if (isPortalGraph) {
+ this.chartHandle = "rChart-" + chartId + "-" +
portalId;
+ }
+ else {
+ this.chartHandle = "rChart-" + chartId;
+ }
+ this.chartSelection = this.chartHandle + " svg";
+ this.buttonBarDateTimeFormat = buttonBarDateTimeFormat;
+ this.chartXaxisTimeFormatHours = chartXaxisTimeFormatHours;
+ this.chartXaxisTimeFormatHoursMinutes = chartXaxisTimeFormatHoursMinutes;
-},
-/**
- * Availability Context object constructor
- * @param chartId
- * @param availData
- * @param dateLabel
- * @param timeLabel
- * @param hoverStartLabel
- * @param hoverBarLabel
- * @param availabilityLabel
- * @param chartHoverTimeFormat
- * @param chartHoverDateFormat
- * @param chartTitle
- * @param chartUpLabel
- * @param chartDownLabel
- * @param chartXaxisTimeFormatHours
- * @param chartXaxisTimeFormatHoursMinutes
- * @constructor
- */
-AvailChartContext = function (chartId, availData, dateLabel, timeLabel, hoverStartLabel,
hoverBarLabel, availabilityLabel, chartHoverTimeFormat, chartHoverDateFormat, chartTitle,
chartUpLabel, chartDownLabel, chartXaxisTimeFormatHours, chartXaxisTimeFormatHoursMinutes)
{
- "use strict";
- if (!(this instanceof AvailChartContext)) {
- throw new Error("AvailChartContext function cannot be called as a
function.")
- }
- this.chartId = chartId;
- this.chartHandle = "#availChart-" + this.chartId;
- this.chartSelection = this.chartHandle + " svg";
- this.data = jQuery.parseJSON(availData); // make into json
- this.dateLabel = dateLabel;
- this.timeLabel = timeLabel;
- this.hoverStartLabel = hoverStartLabel;
- this.hoverBarLabel = hoverBarLabel;
- this.hoverBarAvailabilityLabel = availabilityLabel;
- this.chartHoverTimeFormat = chartHoverTimeFormat;
- this.chartHoverDateFormat = chartHoverDateFormat;
- this.chartTitle = chartTitle;
- this.chartDownLabel = chartDownLabel;
- this.chartUpLabel = chartUpLabel;
- this.chartXaxisTimeFormatHours = chartXaxisTimeFormatHours;
- this.chartXaxisTimeFormatHoursMinutes = chartXaxisTimeFormatHoursMinutes;
+ },
+ /**
+ * Availability Context object constructor
+ * @param chartId
+ * @param availData
+ * @param dateLabel
+ * @param timeLabel
+ * @param hoverStartLabel
+ * @param hoverBarLabel
+ * @param availabilityLabel
+ * @param chartHoverTimeFormat
+ * @param chartHoverDateFormat
+ * @param chartTitle
+ * @param chartUpLabel
+ * @param chartDownLabel
+ * @param chartXaxisTimeFormatHours
+ * @param chartXaxisTimeFormatHoursMinutes
+ * @constructor
+ */
+ AvailChartContext = function (chartId, availData, dateLabel, timeLabel,
hoverStartLabel, hoverBarLabel, availabilityLabel, chartHoverTimeFormat,
chartHoverDateFormat, chartTitle, chartUpLabel, chartDownLabel, chartXaxisTimeFormatHours,
chartXaxisTimeFormatHoursMinutes) {
+ "use strict";
+ if (!(this instanceof AvailChartContext)) {
+ throw new Error("AvailChartContext function cannot be called as a
function.")
+ }
+ this.chartId = chartId;
+ this.chartHandle = "#availChart-" + this.chartId;
+ this.chartSelection = this.chartHandle + " svg";
+ this.data = jQuery.parseJSON(availData); // make into json
+ this.dateLabel = dateLabel;
+ this.timeLabel = timeLabel;
+ this.hoverStartLabel = hoverStartLabel;
+ this.hoverBarLabel = hoverBarLabel;
+ this.hoverBarAvailabilityLabel = availabilityLabel;
+ this.chartHoverTimeFormat = chartHoverTimeFormat;
+ this.chartHoverDateFormat = chartHoverDateFormat;
+ this.chartTitle = chartTitle;
+ this.chartDownLabel = chartDownLabel;
+ this.chartUpLabel = chartUpLabel;
+ this.chartXaxisTimeFormatHours = chartXaxisTimeFormatHours;
+ this.chartXaxisTimeFormatHoursMinutes = chartXaxisTimeFormatHoursMinutes;
+
+ },
+
+ /**
+ * GraphDateContext object constructor.
+ * @param startDate moment object representing startDate range
+ * @param endDate moment object representing endDate range
+ * @constructor
+ */
+ GraphDateContext = function (startDate, endDate) {
+ "use strict";
+ if (!(this instanceof GraphDateContext)) {
+ throw new Error("GraphDateContext function cannot be called as a
function.")
+ }
+ this.startDate = startDate;
+ this.endDate = endDate;
+ },
+ rhqCommon = (function () {
+
+
+ var timeFormat = function (formats) {
+ return function(date) {
+ var i = formats.length - 1, f = formats[i];
+ while (!f[1](date)) f = formats[--i];
+ return f[0](date);
+ }
+ };
+
+ return {
+ getD3CustomTimeFormat: function (xAxisTimeFormatHours,
xAxisTimeFormatHoursMinutes) {
+ return timeFormat([
+ [d3.time.format("%Y"), function () {
+ return true;
+ }],
+ [d3.time.format("%B"), function (d) {
+ return d.getMonth();
+ }],
+ [d3.time.format("%b %d"), function (d) {
+ return d.getDate() != 1;
+ }],
+ [d3.time.format("%a %d"), function (d) {
+ return d.getDay() && d.getDate() != 1;
+ }],
+ [d3.time.format(xAxisTimeFormatHours), function (d) {
+ return d.getHours();
+ }],
+ [d3.time.format(xAxisTimeFormatHoursMinutes), function (d) {
+ return d.getMinutes();
+ }],
+ [d3.time.format(":%S"), function (d) {
+ return d.getSeconds();
+ }],
+ [d3.time.format(".%L"), function (d) {
+ return d.getMilliseconds();
+ }]
+ ]);
+ }
+
+ }
+ })();
-},
-/**
- * GraphDateContext object constructor.
- * @param startDate moment object representing startDate range
- * @param endDate moment object representing endDate range
- * @constructor
- */
-GraphDateContext = function (startDate, endDate){
- "use strict";
- if (!(this instanceof GraphDateContext)) {
- throw new Error("GraphDateContext function cannot be called as a
function.")
- }
- this.startDate = startDate;
- this.endDate = endDate;
-};