modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
| 8 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java
| 8 ++
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/AvailabilityOverUnderGraphType.java
| 32 +++++++++-
modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/graphtype/StackedBarMetricGraphImpl.java
| 24 +++++++
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
| 2
modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
| 2
modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
| 12 +++
13 files changed, 96 insertions(+), 4 deletions(-)
New commits:
commit c941bf3d5b9ecb063431cdb64bd6c02722939a94
Author: Mike Thompson <mithomps(a)redhat.com>
Date: Thu Jun 27 10:05:02 2013 -0700
[BZ 979115] Allow i18n date/time formats on Chart x-axis, currently defaults to US
formats.
(cherry picked from commit 3ccadc1ed259e404e334d00154bad3b4ea0b7d54)
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
index f89ace2..8661136 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/AbstractMetricGraph.java
@@ -183,6 +183,14 @@ public abstract class AbstractMetricGraph extends VLayout implements
HasD3Metric
return metricGraphData.getYAxisUnits();
}
+ public String getXAxisTimeFormatHours() {
+ return metricGraphData.getXAxisTimeFormatHours();
+ }
+
+ public String getXAxisTimeFormatHoursMinutes() {
+ return metricGraphData.getXAxisTimeFormatHoursMinutes();
+ }
+
public String getXAxisTitle() {
return metricGraphData.getXAxisTitle();
}
diff --git
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java
index edf80cb..16f3e4a 100644
---
a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java
+++
b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/graph/MetricGraphData.java
@@ -280,6 +280,14 @@ public class MetricGraphData implements JsonMetricProducer {
return MSG.view_charts_time_axis_label();
}
+ public String getXAxisTimeFormatHours() {
+ return MSG.chart_xaxis_time_format_hours();
+ }
+
+ public String getXAxisTimeFormatHoursMinutes() {
+ return MSG.chart_xaxis_time_format_hours_minutes();
+ }
+
@Override
/**
* Format the json for the front JSNI(javascript) UI to consume.
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 b086e0b..3822b59 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
@@ -131,7 +131,9 @@ public class AvailabilityOverUnderGraphType implements
AvailabilityGraphType {
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType::getChartHoverDateFormat()(),
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType::getAvailChartTitleLabel()(),
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType::getAvailChartUpLabel()(),
-
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType::getAvailChartDownLabel()()
+
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType::getAvailChartDownLabel()(),
+
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType::getChartXaxisTimeFormatHours()(),
+
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.graphtype.AvailabilityOverUnderGraphType::getChartXaxisTimeFormatHoursMinutes()()
);
@@ -169,6 +171,8 @@ public class AvailabilityOverUnderGraphType implements
AvailabilityGraphType {
.tickSize(13, 0, 0)
.orient("bottom"),
+ customTimeFormat,
+
calcBarY = function (d) {
var ABOVE = -6,
BELOW = 0,
@@ -249,6 +253,18 @@ 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);
+
// create x-axis
svg.append("g")
.attr("class", "x axis")
@@ -306,6 +322,14 @@ public class AvailabilityOverUnderGraphType implements
AvailabilityGraphType {
});
}
+ 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 formatHovers(d) {
var timeFormatter =
$wnd.d3.time.format(availChartContext.chartHoverTimeFormat),
dateFormatter =
$wnd.d3.time.format(availChartContext.chartHoverDateFormat),
@@ -381,4 +405,10 @@ public class AvailabilityOverUnderGraphType implements
AvailabilityGraphType {
public String getChartHoverDateFormat() {
return MSG.chart_hover_date_format();
}
+ public String getChartXaxisTimeFormatHours() {
+ return MSG.chart_xaxis_time_format_hours();
+ }
+ public String getChartXaxisTimeFormatHoursMinutes() {
+ return MSG.chart_xaxis_time_format_hours_minutes();
+ }
}
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 14f17c8..f81fb4f 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
@@ -71,7 +71,9 @@ public class StackedBarMetricGraphImpl extends AbstractMetricGraph {
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::isPortalGraph()(),
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getPortalId()(),
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getButtonBarDateTimeFormat()(),
-
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getChartSingleValueLabel()()
+
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getChartSingleValueLabel()(),
+
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getXAxisTimeFormatHours()(),
+
global.@org.rhq.enterprise.gui.coregui.client.inventory.common.graph.AbstractMetricGraph::getXAxisTimeFormatHoursMinutes()()
);
@@ -459,6 +461,17 @@ 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);
// create x-axis
svg.append("g")
@@ -482,6 +495,15 @@ 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/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
index 0fa2206..84e9c6e 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages.properties
@@ -32,6 +32,8 @@ chart_title_avg_label = Avg
chart_title_min_label = Min
chart_title_peak_label = Max
chart_unknown_label = Unknown
+chart_xaxis_time_format_hours = %I %p
+chart_xaxis_time_format_hours_minutes = %I:%M
common_alert_high = High
common_alert_low = Low
common_alert_medium = Medium
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
index 59892f8..d6a102b 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_cs.properties
@@ -55,6 +55,8 @@ chart_hover_time_format = %H:%M:%S
##chart_slider_button_bar_minute = Min
##chart_slider_button_bar_month = Month
##chart_slider_button_bar_year = Year
+chart_xaxis_time_format_hours = %H
+chart_xaxis_time_format_hours_minutes = %H:%M
common_alert_high = Vysoká
common_alert_low = Nízká
common_alert_medium = Střední
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
index 13fbc5b..bd8e0b4 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_de.properties
@@ -35,6 +35,8 @@ chart_title_avg_label = \u2300
chart_title_min_label = Min
chart_title_peak_label = Max
chart_unknown_label = Unbekannt
+chart_xaxis_time_format_hours = %H
+chart_xaxis_time_format_hours_minutes = %H:%M
common_alert_high = HOCH
common_alert_low = NIEDRIG
common_alert_medium = MITTEL
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
index 8e58f13..9237f76 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ja.properties
@@ -35,6 +35,8 @@
##chart_hover_end_label = End
##chart_hover_period_label = Period
##chart_hover_bar_label = Start
+##chart_xaxis_time_format_hours = %H
+##chart_xaxis_time_format_hours_minutes = %H:%M
common_alert_high = 高
common_alert_low = 低
common_alert_medium = 中
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
index 6ecc530..bd34f9b 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ko.properties
@@ -33,6 +33,8 @@
##chart_hover_end_label = End
##chart_hover_period_label = Period
##chart_hover_bar_label = Duration
+##chart_xaxis_time_format_hours = %H
+##chart_xaxis_time_format_hours_minutes = %H:%M
common_alert_high = 높음
common_alert_low = 낮음
common_alert_medium = 중간
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
index e3dca6f..1330eb7 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_pt.properties
@@ -32,6 +32,8 @@
##chart_hover_end_label = End
##chart_hover_period_label = Period
##chart_hover_bar_label = Duration
+##chart_xaxis_time_format_hours = %H
+##chart_xaxis_time_format_hours_minutes = %H:%M
common_alert_high = Alto
common_alert_low = Baixo
common_alert_medium = M\u00E9dio
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
index d266136..72a287b 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_ru.properties
@@ -32,6 +32,8 @@
##chart_hover_end_label = End
##chart_hover_period_label = Period
##chart_hover_bar_label = Duration
+##chart_xaxis_time_format_hours = %H
+##chart_xaxis_time_format_hours_minutes = %H:%M
#common_alert_high = High
#common_alert_low = Low
#common_alert_medium = Medium
diff --git
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
index 96c9a72..10f9b0a 100644
---
a/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
+++
b/modules/enterprise/gui/coregui/src/main/resources/org/rhq/enterprise/gui/coregui/client/Messages_zh.properties
@@ -32,6 +32,8 @@
##chart_hover_end_label = End
##chart_hover_period_label = Period
##chart_hover_bar_label = Duration
+##chart_xaxis_time_format_hours = %H
+##chart_xaxis_time_format_hours_minutes = %H:%M
common_alert_high = High
common_alert_low = Low
common_alert_medium = Medium
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 6939da6..435fd67 100644
--- a/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
+++ b/modules/enterprise/gui/coregui/src/main/webapp/js/rhq.js
@@ -35,9 +35,11 @@ if (!window.console.log) window.console.log = function () { };
* @param portalId
* @param buttonBarDateTimeFormat
* @param singleValueLabel
+ * @param chartXaxisTimeFormatHours
+ * @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 )
+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)){
@@ -73,6 +75,8 @@ var ChartContext = function (chartId, chartHeight, metricsData,
xAxisLabel, char
}
this.chartSelection = this.chartHandle + " svg";
this.buttonBarDateTimeFormat = buttonBarDateTimeFormat;
+ this.chartXaxisTimeFormatHours = chartXaxisTimeFormatHours;
+ this.chartXaxisTimeFormatHoursMinutes = chartXaxisTimeFormatHoursMinutes;
},
/**
@@ -89,9 +93,11 @@ var ChartContext = function (chartId, chartHeight, metricsData,
xAxisLabel, char
* @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) {
+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.")
@@ -110,6 +116,8 @@ AvailChartContext = function (chartId, availData, dateLabel,
timeLabel, hoverSta
this.chartTitle = chartTitle;
this.chartDownLabel = chartDownLabel;
this.chartUpLabel = chartUpLabel;
+ this.chartXaxisTimeFormatHours = chartXaxisTimeFormatHours;
+ this.chartXaxisTimeFormatHoursMinutes = chartXaxisTimeFormatHoursMinutes;
},