modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java | 214 +++++++- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java | 31 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java | 171 ++++++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java | 3 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java | 35 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java | 246 ++++----- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java | 15 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java | 84 +-- modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java | 4 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java | 33 - modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java | 13 modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java | 80 +++ modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3GraphView.java | 253 ---------- 13 files changed, 659 insertions(+), 523 deletions(-)
New commits: commit 2d714af85454bfca2a5efaffa37a670348a24c91 Author: Mike Thompson mithomps@redhat.com Date: Wed Jan 30 10:43:38 2013 -0800
Charting - Fix Dashboard chart make AbstractGraph not inherit MetricGraphData. Major refactor.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java index b61d6b0..ea9edd3 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/dashboard/portlets/inventory/resource/graph/ResourceGraphPortlet.java @@ -18,6 +18,12 @@ */ package org.rhq.enterprise.gui.coregui.client.dashboard.portlets.inventory.resource.graph;
+import java.util.EnumSet; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import com.google.gwt.user.client.rpc.AsyncCallback; import com.smartgwt.client.data.Criteria; import com.smartgwt.client.types.Overflow; import com.smartgwt.client.widgets.Canvas; @@ -31,45 +37,62 @@ import com.smartgwt.client.widgets.form.fields.events.ChangedEvent;
import org.rhq.core.domain.common.EntityContext; import org.rhq.core.domain.configuration.PropertySimple; +import org.rhq.core.domain.criteria.AvailabilityCriteria; +import org.rhq.core.domain.criteria.ResourceCriteria; import org.rhq.core.domain.dashboard.DashboardPortlet; +import org.rhq.core.domain.measurement.Availability; +import org.rhq.core.domain.measurement.AvailabilityType; +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; +import org.rhq.core.domain.resource.Resource; +import org.rhq.core.domain.resource.ResourceType; +import org.rhq.core.domain.util.PageList; +import org.rhq.core.domain.util.PageOrdering; +import org.rhq.enterprise.gui.coregui.client.CoreGUI; import org.rhq.enterprise.gui.coregui.client.components.lookup.ResourceLookupComboBoxItem; import org.rhq.enterprise.gui.coregui.client.dashboard.CustomSettingsPortlet; import org.rhq.enterprise.gui.coregui.client.dashboard.Portlet; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletViewFactory; import org.rhq.enterprise.gui.coregui.client.dashboard.PortletWindow; +import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; +import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData; import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricStackedBarGraph; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3GraphView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3Graph; import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceScheduledMetricDatasource; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.util.Log; +import org.rhq.enterprise.gui.coregui.client.util.async.Command; +import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch; +import org.rhq.enterprise.server.measurement.util.MeasurementUtils;
/** * @author Greg Hinkle * @author Jay Shaughnessy */ -public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements CustomSettingsPortlet { +public class ResourceGraphPortlet extends ResourceMetricD3Graph implements CustomSettingsPortlet {
// A non-displayed, persisted identifier for the portlet public static final String KEY = "ResourceMetric"; // A default displayed, persisted name for the portlet public static final String NAME = MSG.view_portlet_defaultName_resourceMetric(); - - // set on initial configuration, the window for this portlet view. - private PortletWindow portletWindow; - public static final String CFG_RESOURCE_ID = "resourceId"; public static final String CFG_DEFINITION_ID = "definitionId"; + // set on initial configuration, the window for this portlet view. + private PortletWindow portletWindow;
public ResourceGraphPortlet(String locatorId) { super(locatorId); + isPortalGraph = true; //setChartHeight("100%"); setOverflow(Overflow.HIDDEN); - MetricStackedBarGraph chart = new MetricStackedBarGraph(); - setJsniChart(chart); + setGraph(new MetricStackedBarGraph(new MetricGraphData())); }
@Override public void configure(PortletWindow portletWindow, DashboardPortlet storedPortlet) { + Log.debug("\n\n\nPortlet Configure !!");
if (null == this.portletWindow && null != portletWindow) { this.portletWindow = portletWindow; @@ -81,27 +104,153 @@ public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements C
if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) { PropertySimple resourceIdProperty = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID); - if (resourceIdProperty!=null) { - Integer entityId = resourceIdProperty.getIntegerValue(); - if (entityId != null) - if(metricGraphData == null){ - this.metricGraphData = new MetricGraphData(); - } - metricGraphData.setEntityId(entityId); - getJsniChart().setEntityId(entityId); - - } PropertySimple measurementDefIdProperty = storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID); - if (measurementDefIdProperty!=null) { + if (resourceIdProperty != null && measurementDefIdProperty != null) { + final Integer entityId = resourceIdProperty.getIntegerValue(); + final Integer measurementDefId = measurementDefIdProperty.getIntegerValue(); + //this.metricGraphData = new MetricGraphData(); + graph.getMetricGraphData().setDefinitionId(measurementDefId); + graph.getMetricGraphData().setEntityId(entityId); + + if (entityId != null && measurementDefId != null) { + + queryResource(entityId, measurementDefId); + }
- Integer measurementDefId = measurementDefIdProperty.getIntegerValue(); - if (measurementDefId!=null) - metricGraphData.setDefinitionId(measurementDefId); - getJsniChart().setDefinitionId(measurementDefId); } } }
+ private void queryResource(Integer entityId, final Integer measurementDefId) { + final long startTime = System.currentTimeMillis(); + + ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); + + ResourceCriteria resourceCriteria = new ResourceCriteria(); + resourceCriteria.addFilterId(entityId); + resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught); + } + + @Override + public void onSuccess(PageList<Resource> result) { + if (result.isEmpty()) { + return; + } + // only concerned with first resource since this is a query by id + final Resource resource = result.get(0); + HashSet<Integer> typesSet = new HashSet<Integer>(); + typesSet.add(resource.getResourceType().getId()); + HashSet<String> ancestries = new HashSet<String>(); + ancestries.add(resource.getAncestry()); + // In addition to the types of the result resources, get the types of their ancestry + typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries)); + + ResourceTypeRepository.Cache.getInstance().getResourceTypes( + typesSet.toArray(new Integer[typesSet.size()]), + EnumSet.of(ResourceTypeRepository.MetadataType.measurements), + new ResourceTypeRepository.TypesLoadedCallback() { + + @Override + public void onTypesLoaded(Map<Integer, ResourceType> types) { + ResourceType type = types.get(resource.getResourceType().getId()); + Log.debug("MeasurementDefs.size(): " + type.getMetricDefinitions().size()); + for (final MeasurementDefinition def : type.getMetricDefinitions()) { + if (def.getId() == measurementDefId) { + Log.debug("Found portlet measurement definition !" + def); + + getJsniChart().setEntityId(resource.getId()); + getJsniChart().setDefinition(def); + queryMetricsDataForDashboardGraphs(resource.getId(), def); + break; + } + } + } + }); + } + }); + } + + private void queryMetricsDataForDashboardGraphs(final Integer entityId, final MeasurementDefinition def) { + final long startTime = System.currentTimeMillis(); + + // setting up a deferred Command to execute after all resource queries have completed (successfully or unsuccessfully) + // we know there are exactly 2 resources + final CountDownLatch countDownLatch = CountDownLatch.create(2, new Command() { + @Override + /** + * Satisfied only after ALL of the metric queries AND availability have completed + */ + public void execute() { + Log.debug("Time for Dashboard async query: " + (System.currentTimeMillis() - startTime)); + drawGraph(); + //redraw(); + } + }); + + queryAvailability(entityId, countDownLatch); + queryMeasurementsAndMetricData(entityId, countDownLatch); + // now the countDown latch will run sometime asynchronously after BOTH the previous 2 queries have executed + } + + private void queryAvailability(final Integer entityId, final CountDownLatch countDownLatch) { + + final long startTime = System.currentTimeMillis(); + + // now return the availability + AvailabilityCriteria c = new AvailabilityCriteria(); + c.addFilterResourceId(entityId); + c.addFilterInitialAvailability(false); + c.addSortStartTime(PageOrdering.ASC); + GWTServiceLookup.getAvailabilityService().findAvailabilityByCriteria(c, + new AsyncCallback<PageList<Availability>>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_availability_loadFailed(), caught); + countDownLatch.countDown(); + } + + @Override + public void onSuccess(PageList<Availability> availList) { + Log.debug("\nSuccessfully queried Dashboard availability in: " + + (System.currentTimeMillis() - startTime) + " ms."); + PageList<Availability> downAvailList = new PageList<Availability>(); + for (Availability availability : availList) { + if (availability.getAvailabilityType().equals(AvailabilityType.DOWN) + || availability.getAvailabilityType().equals(AvailabilityType.DISABLED)) { + downAvailList.add(availability); + } + } + graph.getMetricGraphData().setAvailabilityDownList(downAvailList); + countDownLatch.countDown(); + } + }); + } + + private void queryMeasurementsAndMetricData(final Integer entityId, final CountDownLatch countDownLatch) { + final long startTime = System.currentTimeMillis(); + // + GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(entityId, + new int[] { graph.getMetricGraphData().getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60, + new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() { + @Override + public void onFailure(Throwable caught) { + CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_loadFailed(), caught); + countDownLatch.countDown(); + } + + @Override + public void onSuccess(final List<List<MeasurementDataNumericHighLowComposite>> measurementData) { + Log.debug("\nSuccessfully queried Dashboard Metric data in: " + + (System.currentTimeMillis() - startTime) + " ms."); + graph.getMetricGraphData().setMetricData(measurementData.get(0)); + countDownLatch.countDown(); + } + }); + } + @Override public Canvas getHelpCanvas() { return new HTMLFlow(MSG.view_portlet_help_graph()); @@ -112,7 +261,7 @@ public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements C DashboardPortlet storedPortlet = portletWindow.getStoredPortlet();
PropertySimple simple = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID); - if (simple == null || simple.getIntegerValue()==null) { + if (simple == null || simple.getIntegerValue() == null) { removeMembers(getMembers()); addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>")); } else { @@ -161,12 +310,12 @@ public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements C
if (storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID) != null) { Integer integerValue = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID).getIntegerValue(); - if (integerValue!=null) { + if (integerValue != null) { form.setValue(CFG_RESOURCE_ID, integerValue); }
PropertySimple propertySimple = storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID); - if (propertySimple!=null && propertySimple.getIntegerValue()!=null) { + if (propertySimple != null && propertySimple.getIntegerValue() != null) { form.setValue(CFG_DEFINITION_ID, propertySimple.getIntegerValue()); } } @@ -199,19 +348,18 @@ public class ResourceGraphPortlet extends ResourceMetricD3GraphView implements C DashboardPortlet storedPortlet = portletWindow.getStoredPortlet(); PropertySimple simple = storedPortlet.getConfiguration().getSimple(CFG_RESOURCE_ID);
- if (simple == null || simple.getIntegerValue()==null) { + if (simple == null || simple.getIntegerValue() == null) { addMember(new Label("<i>" + MSG.view_portlet_configure_needed() + "</i>")); } else { - metricGraphData.setEntityId(simple.getIntegerValue()); + graph.getMetricGraphData().setEntityId(simple.getIntegerValue()); PropertySimple simpleDefId = storedPortlet.getConfiguration().getSimple(CFG_DEFINITION_ID); - Log.debug("EntityId from portal config: "+simple.getIntegerValue()); - Log.debug("DefintionId from portal config: "+simpleDefId.getIntegerValue()); - metricGraphData.setDefinitionId(simpleDefId.getIntegerValue()); - renderGraph(); + Log.debug("EntityId from portal config: " + simple.getIntegerValue()); + Log.debug("DefintionId from portal config: " + simpleDefId.getIntegerValue()); + graph.getMetricGraphData().setDefinitionId(simpleDefId.getIntegerValue()); + drawGraph(); } }
- public static final class Factory implements PortletViewFactory { public static PortletViewFactory INSTANCE = new Factory();
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java index 6396b61..7ccbd60 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/AbstractMetricD3GraphView.java @@ -26,6 +26,7 @@ import com.smartgwt.client.widgets.events.ClickHandler; import com.smartgwt.client.widgets.layout.HLayout;
import org.rhq.enterprise.gui.coregui.client.IconEnum; +import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph; import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData; import org.rhq.enterprise.gui.coregui.client.util.Log; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableHLayout; @@ -42,9 +43,8 @@ import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout; */ public abstract class AbstractMetricD3GraphView extends LocatableVLayout {
- protected HTMLFlow resourceTitle; - protected MetricGraphData metricGraphData; + protected AbstractGraph graph; private Integer chartHeight;
@@ -53,14 +53,13 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout { }
- public AbstractMetricD3GraphView(String locatorId, MetricGraphData metricGraphData){ + public AbstractMetricD3GraphView(String locatorId, AbstractGraph graph){ this(locatorId); - this.metricGraphData = metricGraphData; + this.graph = graph; setHeight100(); setWidth100(); }
- protected abstract void renderGraph();
protected HTMLFlow getEntityTitle(){ return resourceTitle; @@ -72,14 +71,14 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout { protected void onDraw() { super.onDraw(); removeMembers(getMembers()); - renderGraph(); + drawGraph(); }
@Override public void parentResized() { super.parentResized(); removeMembers(getMembers()); - renderGraph(); + drawGraph(); }
/** @@ -90,7 +89,7 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout { * */ protected void drawGraph() { - Log.debug("drawGraph marker in AbstractMetricD3GraphView for: " + metricGraphData.getChartId()); + Log.debug("drawGraph marker in AbstractMetricD3GraphView for: " + graph.getMetricGraphData().getChartId());
// HLayout titleHLayout = new LocatableHLayout(extendLocatorId("HTitle")); // @@ -112,7 +111,7 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout { // addMember(titleHLayout);
StringBuilder divAndSvgDefs = new StringBuilder(); - divAndSvgDefs.append("<div id="rChart-" + metricGraphData.getChartId() + "" ><svg xmlns="http://www.w3.org/2000/svg%5C" version="1.1" style="height:"+getChartHeight()+"px;">"); + divAndSvgDefs.append("<div id="rChart-" + graph.getMetricGraphData().getChartId() + "" ><svg xmlns="http://www.w3.org/2000/svg%5C" version="1.1" style="height:"+getChartHeight()+"px;">"); divAndSvgDefs.append(getSvgDefs()); divAndSvgDefs.append("</svg></div>"); HTMLFlow graph = new HTMLFlow(divAndSvgDefs.toString()); @@ -151,6 +150,14 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout { "</defs>"; }
+ public AbstractGraph getGraph() { + return graph; + } + + public void setGraph(AbstractGraph graph) { + this.graph = graph; + } + public abstract void drawJsniChart();
private Img createLiveGraphImage() { @@ -167,11 +174,11 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout { }
public void setChartHeight(Integer height) { - metricGraphData.setChartHeight(height); + graph.getMetricGraphData().setChartHeight(height); }
public Integer getChartHeight() { - return metricGraphData.getChartHeight(); + return graph.getMetricGraphData().getChartHeight(); }
/** @@ -180,7 +187,7 @@ public abstract class AbstractMetricD3GraphView extends LocatableVLayout { * @param metricGraphData */ public void setMetricGraphData(MetricGraphData metricGraphData) { - this.metricGraphData = metricGraphData; + graph.setMetricGraphData(metricGraphData); }
protected boolean supportsLiveGraphViewDialog() { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java new file mode 100644 index 0000000..ff13fab --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/AbstractGraph.java @@ -0,0 +1,171 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2013 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype; + +import java.util.List; + +import org.rhq.core.domain.measurement.Availability; +import org.rhq.core.domain.measurement.MeasurementDefinition; +import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; +import org.rhq.core.domain.measurement.composite.MeasurementOOBComposite; +import org.rhq.core.domain.util.PageList; + +/** + * Common Graph capability. + * The MetricGraphData delegate is wrapped for JSNI access via d3 charts. + * + * @author Mike Thompson + */ +public abstract class AbstractGraph implements HasD3JsniChart { + + private MetricGraphData metricGraphData; + + public MetricGraphData getMetricGraphData() { + return metricGraphData; + } + + public void setMetricGraphData(MetricGraphData metricGraphData) { + this.metricGraphData = metricGraphData; + } + + public int getEntityId() { + return metricGraphData.getEntityId(); + } + + @Override + public void setEntityId(int entityId) { + metricGraphData.setEntityId(entityId); + } + + public String getEntityName() { + return metricGraphData.getEntityName(); + } + + public int getDefinitionId() { + return metricGraphData.getDefinitionId(); + } + + @Override + public void setDefinitionId(int definitionId) { + metricGraphData.setDefinitionId(definitionId); + } + + public MeasurementDefinition getDefinition() { + return metricGraphData.getDefinition(); + } + + @Override + public void setDefinition(MeasurementDefinition definition) { + metricGraphData.setDefinition(definition); + } + + public String getChartId() { + return metricGraphData.getChartId(); + } + + public List<MeasurementDataNumericHighLowComposite> getMetricData() { + return metricGraphData.getMetricData(); + } + + public void setMetricData(List<MeasurementDataNumericHighLowComposite> metricData) { + metricGraphData.setMetricData(metricData); + } + + public void setAvailabilityDownList(PageList<Availability> availabilityDownList) { + metricGraphData.setAvailabilityDownList(availabilityDownList); + } + + public void setMeasurementOOBCompositeList(PageList<MeasurementOOBComposite> measurementOOBCompositeList) { + metricGraphData.setMeasurementOOBCompositeList(measurementOOBCompositeList); + } + + public String getChartTitleMinLabel() { + return metricGraphData.getChartTitleMinLabel(); + } + + public String getChartTitleAvgLabel() { + return metricGraphData.getChartTitleAvgLabel(); + } + + public String getChartTitlePeakLabel() { + return metricGraphData.getChartTitlePeakLabel(); + } + + public String getChartDateLabel() { + return metricGraphData.getChartDateLabel(); + } + + public String getChartDownLabel() { + return metricGraphData.getChartDownLabel(); + } + + public String getChartTimeLabel() { + return metricGraphData.getChartTimeLabel(); + } + + public String getChartUnknownLabel() { + return metricGraphData.getChartUnknownLabel(); + } + + public String getChartHoverStartLabel() { + return metricGraphData.getChartHoverStartLabel(); + } + + public String getChartHoverEndLabel() { + return metricGraphData.getChartHoverEndLabel(); + } + + public String getChartHoverPeriodLabel() { + return metricGraphData.getChartHoverPeriodLabel(); + } + + public String getChartHoverBarLabel() { + return metricGraphData.getChartHoverBarLabel(); + } + + public Integer getChartHeight() { + return metricGraphData.getChartHeight(); + } + + public void setChartHeight(Integer chartHeight) { + metricGraphData.setChartHeight(chartHeight); + } + + public String getYAxisTitle() { + return metricGraphData.getYAxisTitle(); + } + + public String getYAxisUnits() { + return metricGraphData.getYAxisUnits(); + } + + public String getXAxisTitle() { + return metricGraphData.getXAxisTitle(); + } + + public String getJsonMetrics() { + return metricGraphData.getJsonMetrics(); + } + + public boolean shouldDisplayDayOfWeekInXAxisLabel() { + return metricGraphData.shouldDisplayDayOfWeekInXAxisLabel(); + } + + +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java index 8fe4b32..6bd0d7e 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/HasD3JsniChart.java @@ -18,6 +18,8 @@ */ package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype;
+import org.rhq.core.domain.measurement.MeasurementDefinition; + /** * Defines GWT JSNI charting capability. Indicator of a class producing * d3 (javascript) charts. Allows us to quickly find, in a standard @@ -31,5 +33,6 @@ public interface HasD3JsniChart void drawJsniChart(); void setEntityId(int entityId) ; void setDefinitionId(int definitionId) ; + void setDefinition(MeasurementDefinition measurementDefinition) ;
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java index e8c2523..6deb6e4 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricGraphData.java @@ -79,15 +79,12 @@ public class MetricGraphData implements JsonMetricProducer { }
/** - * Constructor for the dashboard case when it as a saved configuration. + * * @param entityId - * @param measurementDefId + * @param entityName + * @param def + * @param metricData */ - public MetricGraphData(int entityId, int measurementDefId) { - setEntityId(entityId); - setDefinitionId(measurementDefId); - } - public MetricGraphData(int entityId, String entityName, MeasurementDefinition def, List<MeasurementDataNumericHighLowComposite> metricData) { this.entityName = entityName; @@ -97,13 +94,23 @@ public class MetricGraphData implements JsonMetricProducer { this.metricData = metricData; }
+ public MetricGraphData(int entityId, String entityName, MeasurementDefinition measurementDef, List<MeasurementDataNumericHighLowComposite> metrics, PageList<Availability> downAvailList, PageList<MeasurementOOBComposite> measurementOOBCompositeList) { + this.entityName = entityName; + setEntityId(entityId); + setDefinitionId(measurementDef.getId()); + this.definition = measurementDef; + this.metricData = metrics; + this.availabilityDownList = downAvailList; + this.measurementOOBCompositeList = measurementOOBCompositeList; + } + public int getEntityId() { return this.entityId; }
public void setEntityId(int entityId) { this.entityId = entityId; - this.definition = null; + //this.definition = null; }
public String getEntityName() { @@ -116,7 +123,7 @@ public class MetricGraphData implements JsonMetricProducer {
public void setDefinitionId(int definitionId) { this.definitionId = definitionId; - this.definition = null; + //this.definition = null; }
public MeasurementDefinition getDefinition() { @@ -139,17 +146,14 @@ public class MetricGraphData implements JsonMetricProducer { this.metricData = metricData; }
- public PageList<Availability> getAvailabilityDownList() { - return availabilityDownList; - }
public void setAvailabilityDownList(PageList<Availability> availabilityDownList) { this.availabilityDownList = availabilityDownList; }
- public PageList<MeasurementOOBComposite> getMeasurementOOBCompositeList() { - return measurementOOBCompositeList; - } +// public PageList<MeasurementOOBComposite> getMeasurementOOBCompositeList() { +// return measurementOOBCompositeList; +// }
public void setMeasurementOOBCompositeList(PageList<MeasurementOOBComposite> measurementOOBCompositeList) { this.measurementOOBCompositeList = measurementOOBCompositeList; @@ -213,6 +217,7 @@ public class MetricGraphData implements JsonMetricProducer { }
public String getYAxisTitle() { + if (null != definition.getDisplayName() && definition.getDisplayName().length() > 55) { return definition.getDisplayName().substring(0, 55) + "..."; } else { diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java index 15c4a2b..6057620 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricLineGraph.java @@ -23,145 +23,133 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype; * * @author Mike Thompson */ -public final class MetricLineGraph extends MetricGraphData implements HasD3JsniChart -{ - /** - * Constructor for dashboard portlet view as chart definition and data are deferred to later - * in the portlet configuration. - * - * @param locatorId - */ - public MetricLineGraph(String locatorId) { - //super(locatorId); - } - +public final class MetricLineGraph extends AbstractGraph {
/** * General constructor for stacked bar graph when you have all the data needed to * produce the graph. (This is true for all cases but the dashboard portlet). */ - public MetricLineGraph(MetricGraphData metricGraphData){ - super(metricGraphData.getEntityId(), metricGraphData.getEntityName(),metricGraphData.getDefinition(),metricGraphData.getMetricData()); + public MetricLineGraph(MetricGraphData metricGraphData) { + setMetricGraphData(metricGraphData); }
- /** * The magic JSNI to draw the charts with d3. */ public native void drawJsniChart() /*-{ - console.log("Draw Metric Line jsni chart"); - var global = this, - chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartId()(), - chartHandle = "#rChart-"+chartId, - chartSelection = chartHandle + " svg", - json = eval(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()()), - yAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisTitle()(), - yAxisUnits = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisUnits()(), - xAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getXAxisTitle()(); - - console.log("chart id: "+chartSelection ); - console.log(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()()); - - //var jsonData = eval([{ x:1352204720548, high:0.016642348035599646, low:0.016642348035599646, y:0.016642348035599646},{ x:1352211680548, high:12.000200003333388, low:0.0, y:3.500050000833347},{ x:1352211920548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352212160548, high:5.0, low:1.999966667222213, y:2.750000000277778},{ x:1352212400548, high:4.0, low:2.0, y:2.5000083334722243},{ x:1352212640548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352212880548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352213120548, high:3.000050000833347, low:1.999966667222213, y:2.2500041672916677},{ x:1352213360548, high:4.0, low:1.999966667222213, y:2.7499916668055535},{ x:1352213600548, high:2.000033333888898, low:1.999966667222213, y:2.000008333750002},{ x:1352213840548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352214080548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352214320548, high:4.0, low:2.0, y:2.5},{ x:1352214560548, high:3.0, low:1.999966667222213, y:2.250000000833347},{ x:1352214800548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352215040548, high:4.0, low:2.0, y:2.5},{ x:1352215280548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352215520548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352215760548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352216000548, high:4.0, low:2.0, y:2.5},{ x:1352216240548, high:2.000066668888963, low:1.999966667222213, y:2.000008334027794},{ x:1352216480548, high:3.0, low:1.999966667222213, y:2.2499916668055535}]); - - - function draw(data){ - "use strict"; - - var margin = {top: 10, right: 5, bottom: 30, left: 70}, - width = 400 - margin.left - margin.right, - height = 150 - margin.top - margin.bottom; - - var timeScale = $wnd.d3.time.scale() - .range([0, width]) - .domain($wnd.d3.extent(data, function(d) { return d.x; })); - - var yScale = $wnd.d3.scale.linear() - .rangeRound([height, 0]) - .domain([$wnd.d3.min(data.map(function(x) {return x.low;})), $wnd.d3.max(data.map(function(x){return x.high;}))]); - - var xAxis = $wnd.d3.svg.axis() - .scale(timeScale) - .ticks(5) - .orient("bottom"); - - var yAxis = $wnd.d3.svg.axis() - .scale(yScale) - .ticks(5) - .orient("left"); - - var interpolation = "basis"; - - var line = $wnd.d3.svg.line() - .interpolate(interpolation) - .x(function(d) { return timeScale(d.x); }) - .y(function(d) { return yScale(+d.y); }); - - var highLine = $wnd.d3.svg.line() - .interpolate(interpolation) - .x(function(d) { return timeScale(d.x); }) - .y(function(d) { return yScale(+d.high); }); - - var lowLine = $wnd.d3.svg.line() - .interpolate(interpolation) - .x(function(d) { return timeScale(d.x); }) - .y(function(d) { return yScale(+d.low); }); - - var svg = $wnd.d3.select(chartSelection).append("g") - .attr("width", width + margin.left + margin.right) - .attr("height", height + margin.top + margin.bottom) - .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); - - svg.append("g") - .attr("class", "x axis") - .attr("transform", "translate(0," + height + ")") - .call(xAxis); - - - svg.append("g") - .attr("class", "y axis") - .call(yAxis) - .append("text") - .attr("transform", "rotate(-90)") - .attr("y", -60) - .attr("dy", ".71em") - .style("text-anchor", "end") - .text(yAxisUnits === "NONE" ? "" : yAxisUnits); - - console.log("finished axes"); - - svg.append("path") - .datum(data) - .attr("class", "line") - .attr("fill", "none") - .attr("stroke", "steelblue") - .attr("stroke-width", "2") - .attr("d", line); - - svg.append("path") - .datum(data) - .attr("class", "highLine") - .attr("fill", "none") - .attr("stroke", "red") - .attr("stroke-width", "1.5") - //.attr("stroke-dasharray", "20,10,5,5,5,10") - .attr("stroke-dasharray", "5,5") - .attr("stroke-opacity", ".3") - .attr("d", highLine); - - svg.append("path") - .datum(data) - .attr("class", "lowLine") - .attr("fill", "none") - .attr("stroke", "blue") - .attr("stroke-width", "1.5") - .attr("stroke-dasharray", "5,5") - .attr("stroke-opacity", ".3") - .attr("d", lowLine); - - console.log("finished paths"); - }(data); - - }-*/; + console.log("Draw Metric Line jsni chart"); + var global = this, + chartId = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartId()(), + chartHandle = "#rChart-"+chartId, + chartSelection = chartHandle + " svg", + json = eval(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()()), + yAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisTitle()(), + yAxisUnits = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisUnits()(), + xAxisLabel = global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getXAxisTitle()(); + + console.log("chart id: "+chartSelection ); + console.log(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()()); + + //var jsonData = eval([{ x:1352204720548, high:0.016642348035599646, low:0.016642348035599646, y:0.016642348035599646},{ x:1352211680548, high:12.000200003333388, low:0.0, y:3.500050000833347},{ x:1352211920548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352212160548, high:5.0, low:1.999966667222213, y:2.750000000277778},{ x:1352212400548, high:4.0, low:2.0, y:2.5000083334722243},{ x:1352212640548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352212880548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352213120548, high:3.000050000833347, low:1.999966667222213, y:2.2500041672916677},{ x:1352213360548, high:4.0, low:1.999966667222213, y:2.7499916668055535},{ x:1352213600548, high:2.000033333888898, low:1.999966667222213, y:2.000008333750002},{ x:1352213840548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352214080548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352214320548, high:4.0, low:2.0, y :2.5},{ x:1352214560548, high:3.0, low:1.999966667222213, y:2.250000000833347},{ x:1352214800548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352215040548, high:4.0, low:2.0, y:2.5},{ x:1352215280548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352215520548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352215760548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352216000548, high:4.0, low:2.0, y:2.5},{ x:1352216240548, high:2.000066668888963, low:1.999966667222213, y:2.000008334027794},{ x:1352216480548, high:3.0, low:1.999966667222213, y:2.2499916668055535}]); + + + function draw(data){ + "use strict"; + + var margin = {top: 10, right: 5, bottom: 30, left: 70}, + width = 400 - margin.left - margin.right, + height = 150 - margin.top - margin.bottom; + + var timeScale = $wnd.d3.time.scale() + .range([0, width]) + .domain($wnd.d3.extent(data, function(d) { return d.x; })); + + var yScale = $wnd.d3.scale.linear() + .rangeRound([height, 0]) + .domain([$wnd.d3.min(data.map(function(x) {return x.low;})), $wnd.d3.max(data.map(function(x){return x.high;}))]); + + var xAxis = $wnd.d3.svg.axis() + .scale(timeScale) + .ticks(5) + .orient("bottom"); + + var yAxis = $wnd.d3.svg.axis() + .scale(yScale) + .ticks(5) + .orient("left"); + + var interpolation = "basis"; + + var line = $wnd.d3.svg.line() + .interpolate(interpolation) + .x(function(d) { return timeScale(d.x); }) + .y(function(d) { return yScale(+d.y); }); + + var highLine = $wnd.d3.svg.line() + .interpolate(interpolation) + .x(function(d) { return timeScale(d.x); }) + .y(function(d) { return yScale(+d.high); }); + + var lowLine = $wnd.d3.svg.line() + .interpolate(interpolation) + .x(function(d) { return timeScale(d.x); }) + .y(function(d) { return yScale(+d.low); }); + + var svg = $wnd.d3.select(chartSelection).append("g") + .attr("width", width + margin.left + margin.right) + .attr("height", height + margin.top + margin.bottom) + .attr("transform", "translate(" + margin.left + "," + margin.top + ")"); + + svg.append("g") + .attr("class", "x axis") + .attr("transform", "translate(0," + height + ")") + .call(xAxis); + + + svg.append("g") + .attr("class", "y axis") + .call(yAxis) + .append("text") + .attr("transform", "rotate(-90)") + .attr("y", -60) + .attr("dy", ".71em") + .style("text-anchor", "end") + .text(yAxisUnits === "NONE" ? "" : yAxisUnits); + + console.log("finished axes"); + + svg.append("path") + .datum(data) + .attr("class", "line") + .attr("fill", "none") + .attr("stroke", "steelblue") + .attr("stroke-width", "2") + .attr("d", line); + + svg.append("path") + .datum(data) + .attr("class", "highLine") + .attr("fill", "none") + .attr("stroke", "red") + .attr("stroke-width", "1.5") + //.attr("stroke-dasharray", "20,10,5,5,5,10") + .attr("stroke-dasharray", "5,5") + .attr("stroke-opacity", ".3") + .attr("d", highLine); + + svg.append("path") + .datum(data) + .attr("class", "lowLine") + .attr("fill", "none") + .attr("stroke", "blue") + .attr("stroke-width", "1.5") + .attr("stroke-dasharray", "5,5") + .attr("stroke-opacity", ".3") + .attr("d", lowLine); + + console.log("finished paths"); + }(data); + + }-*/;
} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java index 8c2dd04..d84bb92 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricNvd3BarChartGraph.java @@ -23,25 +23,14 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype; * * @author Mike Thompson */ -public final class MetricNvd3BarChartGraph extends MetricGraphData implements HasD3JsniChart +public final class MetricNvd3BarChartGraph extends AbstractGraph { - - /** - * Constructor for dashboard portlet view as chart definition and data are deferred to later - * in the portlet configuration. - * @param locatorId - */ - public MetricNvd3BarChartGraph(String locatorId) { - //super(locatorId); - } - /** * General constructor for stacked bar graph when you have all the data needed to * produce the graph. (This is true for all cases but the dashboard portlet). */ public MetricNvd3BarChartGraph(MetricGraphData metricGraphData){ - super(metricGraphData.getEntityId(), metricGraphData.getEntityName(), metricGraphData.getDefinition(),metricGraphData.getMetricData()); - + setMetricGraphData(metricGraphData); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java index 20d52b5..33998f8 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java @@ -23,21 +23,14 @@ package org.rhq.enterprise.gui.coregui.client.inventory.common.charttype; * * @author Mike Thompson */ -public final class MetricStackedBarGraph extends MetricGraphData implements HasD3JsniChart { - /** - * Constructor for dashboard portlet view as chart definition and data are deferred to later in the portlet - * configuration. - */ - public MetricStackedBarGraph() { - //super(locatorId); - } +public final class MetricStackedBarGraph extends AbstractGraph {
/** * General constructor for stacked bar graph when you have all the data needed to produce the graph. (This is true * for all cases but the dashboard portlet). */ public MetricStackedBarGraph(MetricGraphData metricGraphData) { - super(metricGraphData.getEntityId(), metricGraphData.getEntityName(), metricGraphData.getDefinition(), metricGraphData.getMetricData()); + setMetricGraphData(metricGraphData); }
@@ -50,29 +43,26 @@ public final class MetricStackedBarGraph extends MetricGraphData implements HasD console.log("Draw Stacked Bar jsni chart"); var global = this;
- // json metrics data for testing purposes - //var jsonMetrics = [{ x:1352204720548, high:0.016642348035599646, low:0.016642348035599646, y:0.016642348035599646},{ x:1352211680548, high:12.000200003333388, low:0.0, y:3.500050000833347},{ x:1352211920548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352212160548, high:5.0, low:1.999966667222213, y:2.750000000277778},{ x:1352212400548, high:4.0, low:2.0, y:2.5000083334722243},{ x:1352212640548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352212880548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352213120548, high:3.000050000833347, low:1.999966667222213, y:2.2500041672916677},{ x:1352213360548, high:4.0, low:1.999966667222213, y:2.7499916668055535},{ x:1352213600548, high:2.000033333888898, low:1.999966667222213, y:2.000008333750002},{ x:1352213840548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352214080548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352214320548, high:4.0, low:2.0, y: 2.5},{ x:1352214560548, high:3.0, low:1.999966667222213, y:2.250000000833347},{ x:1352214800548, high:2.000033333888898, low:1.999966667222213, y:2.000000000277778},{ x:1352215040548, high:4.0, low:2.0, y:2.5},{ x:1352215280548, high:3.0, low:2.0, y:2.2500083334722243},{ x:1352215520548, high:2.0, low:1.999966667222213, y:1.9999916668055533},{ x:1352215760548, high:3.0, low:1.999966667222213, y:2.250000000277778},{ x:1352216000548, high:4.0, low:2.0, y:2.5},{ x:1352216240548, high:2.000066668888963, low:1.999966667222213, y:2.000008334027794},{ x:1352216480548, high:3.0, low:1.999966667222213, y:2.2499916668055535}]; - // create a chartContext object (from rhq.js) with the data required to render to a chart // this same data could be passed to different chart types - // This way, we are decoupled from the dependency on globals and JSNI. - var chartContext = new $wnd.ChartContext(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartId()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHeight()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getJsonMetrics()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getXAxisTitle()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisTitle()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getYAxisUnits()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartTitleMinLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartTitleAvgLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartTitlePeakLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartDateLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartTimeLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartDownLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartUnknownLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHoverStartLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHoverEndLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHoverPeriodLabel()(), - global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData::getChartHoverBarLabel()() + // This way, we are decoupled from the dependency on globals and JSNI and kept all the java interaction right here. + var chartContext = new $wnd.ChartContext(global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartId()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHeight()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getJsonMetrics()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getXAxisTitle()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getYAxisTitle()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getYAxisUnits()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartTitleMinLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartTitleAvgLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartTitlePeakLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartDateLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartTimeLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartDownLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartUnknownLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverStartLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverEndLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverPeriodLabel()(), + global.@org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph::getChartHoverBarLabel()() );
@@ -465,9 +455,9 @@ public final class MetricStackedBarGraph extends MetricGraphData implements HasD var minuteBarThreshold = 4, firstDate = this.__data__[0].x, secondDate = this.__data__[1].x, - barDateDiffInMinutues = (secondDate - firstDate)/ (60000); + barDateDiffInMinutes = (secondDate - firstDate)/ (60000);
- if(barDateDiffInMinutues > minuteBarThreshold){ + if(barDateDiffInMinutes > minuteBarThreshold){ // on a bar avg line if the value is undefined then use the last defined value if(d.y == undefined){ if(i >= 1){ diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java index b911476..f7e9eae 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/D3GroupGraphListView.java @@ -39,7 +39,7 @@ import org.rhq.enterprise.gui.coregui.client.components.measurement.UserPreferen import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData; import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricStackedBarGraph; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3GraphView; +import org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring.ResourceMetricD3Graph; import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; import org.rhq.enterprise.gui.coregui.client.util.selenium.LocatableVLayout;
@@ -145,7 +145,7 @@ public class D3GroupGraphListView extends LocatableVLayout { MetricGraphData metricGraphData = new MetricGraphData(resourceGroup.getId(), resourceGroup.getName(), measurementDefinition, data); MetricStackedBarGraph graph = new MetricStackedBarGraph(metricGraphData); - ResourceMetricD3GraphView graphView = new ResourceMetricD3GraphView(extendLocatorId(measurementDefinition.getName()),metricGraphData, graph); + ResourceMetricD3Graph graphView = new ResourceMetricD3Graph(extendLocatorId(measurementDefinition.getName()), graph);
graphView.setWidth("95%"); graphView.setHeight(250); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java index 0fde8d9..904ce6a 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/groups/detail/monitoring/ResourceGroupMetricD3GraphView.java @@ -33,6 +33,7 @@ import org.rhq.core.domain.resource.Resource; import org.rhq.core.domain.resource.ResourceType; import org.rhq.core.domain.util.PageList; import org.rhq.enterprise.gui.coregui.client.CoreGUI; +import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph; import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.HasD3JsniChart; import org.rhq.enterprise.gui.coregui.client.LinkManager; import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; @@ -51,32 +52,30 @@ public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView { * Defines the jsniChart type like area, line, etc... * */ - private HasD3JsniChart jsniChart; + //private HasD3JsniChart jsniChart;
- public ResourceGroupMetricD3GraphView(String locatorId){ - super(locatorId); - //setChartHeight("150px"); - } +// public ResourceGroupMetricD3GraphView(String locatorId){ +// super(locatorId); +// //setChartHeight("150px"); +// }
- public ResourceGroupMetricD3GraphView(String locatorId, MetricGraphData metricGraphData, HasD3JsniChart jsniChart) { + public ResourceGroupMetricD3GraphView(String locatorId, AbstractGraph graph) {
//super(locatorId, entityId, entityName, def, data); - super(locatorId,metricGraphData); - this.jsniChart = jsniChart; + super(locatorId,graph); //setChartHeight("150px"); }
- @Override protected void renderGraph() { - if (null == metricGraphData.getDefinition()) { + if (null == graph.getMetricGraphData().getDefinition()) {
ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService();
ResourceCriteria resourceCriteria = new ResourceCriteria(); - resourceCriteria.addFilterId(metricGraphData.getEntityId()); + resourceCriteria.addFilterId(graph.getMetricGraphData().getEntityId()); resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() { @Override public void onFailure(Throwable caught) { @@ -112,11 +111,11 @@ public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView {
ResourceType type = types.get(resource.getResourceType().getId()); for (MeasurementDefinition def : type.getMetricDefinitions()) { - if (def.getId() == metricGraphData.getDefinitionId()) { - metricGraphData.setDefinition(def); + if (def.getId() == graph.getMetricGraphData().getDefinitionId()) { + graph.getMetricGraphData().setDefinition(def);
- GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(metricGraphData.getEntityId(), - new int[] { metricGraphData.getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60, + GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(graph.getMetricGraphData().getEntityId(), + new int[] { graph.getMetricGraphData().getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60, new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() { @Override public void onFailure(Throwable caught) { @@ -127,7 +126,7 @@ public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView { @Override public void onSuccess( List<List<MeasurementDataNumericHighLowComposite>> result) { - metricGraphData.setMetricData(result.get(0)); + graph.getMetricGraphData().setMetricData(result.get(0));
drawGraph(); } @@ -152,7 +151,7 @@ public class ResourceGroupMetricD3GraphView extends AbstractMetricD3GraphView { */ public void drawJsniChart() { - jsniChart.drawJsniChart(); + graph.drawJsniChart(); }
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java index 7c65f3b..9302529 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/D3GraphListView.java @@ -133,7 +133,7 @@ public class D3GraphListView extends LocatableVLayout { * Build whatever graph (summary or not) by grabbing the MeasurementDefinitions * that are defined for the resource and then querying the metric and availability data. */ - public void buildGraphs() { + private void buildGraphs() { final long startTimer = System.currentTimeMillis(); List<Long> startEndList = measurementRangeEditor.getBeginEndTimes(); final long startTime = startEndList.get(0); @@ -218,7 +218,7 @@ public class D3GraphListView extends LocatableVLayout { @Override public void onSuccess(List<List<MeasurementDataNumericHighLowComposite>> metrics) { metricsDataList = metrics; - Log.debug("Metric graph data queried in: " + Log.debug("Regular Metric graph data queried in: " + (System.currentTimeMillis() - startTimer + " ms.")); countDownLatch.countDown();
@@ -351,14 +351,13 @@ public class D3GraphListView extends LocatableVLayout { private void buildSingleGraph(PageList<Availability> downAvailList, PageList<MeasurementOOBComposite> measurementOOBCompositeList, MeasurementDefinition measurementDefinition, List<MeasurementDataNumericHighLowComposite> data, int height) { + MetricGraphData metricGraphData = new MetricGraphData(resource.getId(), resource.getName(), - measurementDefinition, data); + measurementDefinition, data, downAvailList, measurementOOBCompositeList); MetricStackedBarGraph graph = new MetricStackedBarGraph(metricGraphData); - graph.setAvailabilityDownList(downAvailList); - graph.setMeasurementOOBCompositeList(measurementOOBCompositeList);
- ResourceMetricD3GraphView graphView = new ResourceMetricD3GraphView( - extendLocatorId(measurementDefinition.getName()), metricGraphData, graph); + ResourceMetricD3Graph graphView = new ResourceMetricD3Graph( + extendLocatorId(measurementDefinition.getName()), graph);
graphView.setWidth("95%"); graphView.setHeight(height); diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java new file mode 100644 index 0000000..0fc84ad --- /dev/null +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3Graph.java @@ -0,0 +1,80 @@ +/* + * RHQ Management Platform + * Copyright (C) 2005-2012 Red Hat, Inc. + * All rights reserved. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation version 2 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ +package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring; + +import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMetricD3GraphView; +import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.AbstractGraph; +import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.HasD3JsniChart; +import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData; +import org.rhq.enterprise.gui.coregui.client.util.Log; + +public class ResourceMetricD3Graph extends AbstractMetricD3GraphView { + + protected boolean isPortalGraph = false; + /** + * Defines the jsniChart type like area, line, etc... + * + */ + //private HasD3JsniChart jsniChart; + + /** + * This constructor is for the use case in the Dashboard where we dont actually + * have a entity or measurement yet. + * @param locatorId + */ + public ResourceMetricD3Graph(String locatorId) { + super(locatorId); + //setChartHeight("150px"); + } + + public ResourceMetricD3Graph(String locatorId, AbstractGraph graph) { + + super(locatorId, graph); + //this.jsniChart = jsniChart; + //setChartHeight("150px"); + } + + + @Override + protected boolean supportsLiveGraphViewDialog() { + return true; + } + + @Override + /** + * Delegate the call to rendering the JSNI chart. + * This way the chart type can be swapped out at any time. + */ + public void drawJsniChart() { + graph.drawJsniChart(); + } + + public HasD3JsniChart getJsniChart() { + return graph; + } + +// public void setJsniChart(HasD3JsniChart jsniChart) { +// this.graph = jsniChart; +// } + + @Override + protected void displayLiveGraphViewDialog() { + LiveGraphD3View.displayAsDialog(getLocatorId(), graph.getMetricGraphData().getEntityId(), graph.getMetricGraphData().getDefinition()); + } +} diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3GraphView.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3GraphView.java deleted file mode 100644 index 90b5338..0000000 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/resource/detail/monitoring/ResourceMetricD3GraphView.java +++ /dev/null @@ -1,253 +0,0 @@ -/* - * RHQ Management Platform - * Copyright (C) 2005-2012 Red Hat, Inc. - * All rights reserved. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation version 2 of the License. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ -package org.rhq.enterprise.gui.coregui.client.inventory.resource.detail.monitoring; - -import java.util.List; - -import java.util.EnumSet; -import java.util.HashSet; -import java.util.Map; - -import com.google.gwt.user.client.rpc.AsyncCallback; - -import org.rhq.core.domain.criteria.AvailabilityCriteria; -import org.rhq.core.domain.criteria.ResourceCriteria; -import org.rhq.core.domain.measurement.Availability; -import org.rhq.core.domain.measurement.AvailabilityType; -import org.rhq.core.domain.measurement.MeasurementDefinition; -import org.rhq.core.domain.measurement.composite.MeasurementDataNumericHighLowComposite; -import org.rhq.core.domain.resource.Resource; -import org.rhq.core.domain.resource.ResourceType; -import org.rhq.core.domain.util.PageList; -import org.rhq.core.domain.util.PageOrdering; -import org.rhq.enterprise.gui.coregui.client.CoreGUI; -import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.HasD3JsniChart; -import org.rhq.enterprise.gui.coregui.client.gwt.GWTServiceLookup; -import org.rhq.enterprise.gui.coregui.client.gwt.ResourceGWTServiceAsync; -import org.rhq.enterprise.gui.coregui.client.inventory.common.AbstractMetricD3GraphView; -import org.rhq.enterprise.gui.coregui.client.inventory.common.charttype.MetricGraphData; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.AncestryUtil; -import org.rhq.enterprise.gui.coregui.client.inventory.resource.type.ResourceTypeRepository; -import org.rhq.enterprise.gui.coregui.client.util.Log; -import org.rhq.enterprise.gui.coregui.client.util.async.Command; -import org.rhq.enterprise.gui.coregui.client.util.async.CountDownLatch; -import org.rhq.enterprise.server.measurement.util.MeasurementUtils; - - -public class ResourceMetricD3GraphView extends AbstractMetricD3GraphView -{ - /** - * Defines the jsniChart type like area, line, etc... - * - */ - private HasD3JsniChart jsniChart; - - /** - * This constructor is for the use case in the Dashboard where we dont actually - * have a entity or measurement yet. - * @param locatorId - */ - public ResourceMetricD3GraphView(String locatorId){ - super(locatorId); - //setChartHeight("150px"); - } - - - - public ResourceMetricD3GraphView(String locatorId, MetricGraphData metricGraphData, HasD3JsniChart jsniChart ) { - - super(locatorId, metricGraphData); - this.jsniChart = jsniChart; - //setChartHeight("150px"); - } - - - @Override - /** - * Render the graph by determining if we need to load definition for - * the dashboard graph (which will be empty, all other graph types - * will have the definition already defined and we can just render the graph). - */ - protected void renderGraph() { - boolean isDashboardGraph = (null == metricGraphData.getDefinition()); - if (isDashboardGraph) { - Log.debug("Chart path for: dashboard metrics"); - queryMetricsDataForDashboardGraphs(); - } else { - Log.debug("Chart path for: non-dashboard metrics"); - drawGraph(); - } - } - - private void queryMetricsDataForDashboardGraphs(){ - Log.debug(" ** RenderGraph Dashboard Portlet path"); - final long startTime = System.currentTimeMillis(); - - ResourceGWTServiceAsync resourceService = GWTServiceLookup.getResourceService(); - - ResourceCriteria resourceCriteria = new ResourceCriteria(); - resourceCriteria.addFilterId(metricGraphData.getEntityId()); - resourceService.findResourcesByCriteria(resourceCriteria, new AsyncCallback<PageList<Resource>>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_graphs_lookupFailed(), caught); - } - - @Override - public void onSuccess(PageList<Resource> result) { - if (result.isEmpty()) { - return; - } - // only concerned with first resource since this is a query by id - final Resource firstResource = result.get(0); - - // setting up a deferred Command to execute after all resource queries have completed (successfully or unsuccessfully) - // we know there are exactly 2 resources - final CountDownLatch countDownLatch = CountDownLatch.create(2, - new Command() { - @Override - /** - * Satisfied only after ALL of the metric queries AND availability have completed - */ - public void execute() { - Log.debug("Time for async query: "+(System.currentTimeMillis() - startTime)); - drawGraph(); - //redraw(); - } - }); - - queryAvailability(firstResource, countDownLatch); - queryMeasurementsAndMetricData(firstResource, countDownLatch); - // now the countDown latch will run sometime asynchronously after BOTH the previous 2 queries have executed - } - }); - } - - private void queryAvailability(final Resource resource, final CountDownLatch countDownLatch){ - - final long startTime = System.currentTimeMillis(); - - // now return the availability - AvailabilityCriteria c = new AvailabilityCriteria(); - c.addFilterResourceId(resource.getId()); - c.addFilterInitialAvailability(false); - c.addSortStartTime(PageOrdering.ASC); - GWTServiceLookup.getAvailabilityService().findAvailabilityByCriteria(c, - new AsyncCallback<PageList<Availability>>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError(MSG.view_resource_monitor_availability_loadFailed(), caught); - countDownLatch.countDown(); - } - - @Override - public void onSuccess(PageList<Availability> availList) { - Log.debug("\nSuccessfully queried availability in: "+ (System.currentTimeMillis() - startTime) + " ms."); - PageList<Availability> downAvailList = new PageList<Availability>(); - for (Availability availability : availList) - { - if(availability.getAvailabilityType().equals(AvailabilityType.DOWN) - || availability.getAvailabilityType().equals(AvailabilityType.DISABLED)){ - downAvailList.add(availability); - } - } - metricGraphData.setAvailabilityDownList(downAvailList); - countDownLatch.countDown(); - } - }); - } - - - private void queryMeasurementsAndMetricData(final Resource resource, final CountDownLatch countDownLatch){ - final long startTime = System.currentTimeMillis(); - HashSet<Integer> typesSet = new HashSet<Integer>(); - typesSet.add(resource.getResourceType().getId()); - HashSet<String> ancestries = new HashSet<String>(); - ancestries.add(resource.getAncestry()); - // In addition to the types of the result resources, get the types of their ancestry - typesSet.addAll(AncestryUtil.getAncestryTypeIds(ancestries)); - - ResourceTypeRepository.Cache.getInstance().getResourceTypes( - typesSet.toArray(new Integer[typesSet.size()]), - EnumSet.of(ResourceTypeRepository.MetadataType.measurements), - new ResourceTypeRepository.TypesLoadedCallback() { - - @Override - public void onTypesLoaded(Map<Integer, ResourceType> types) { - ResourceType type = types.get(resource.getResourceType().getId()); - for (MeasurementDefinition def : type.getMetricDefinitions()) { - if (def.getId() == metricGraphData.getDefinitionId()) { - metricGraphData.setDefinition(def); - - GWTServiceLookup.getMeasurementDataService().findDataForResourceForLast(resource.getId(), - new int[] { metricGraphData.getDefinitionId() }, 8, MeasurementUtils.UNIT_HOURS, 60, - new AsyncCallback<List<List<MeasurementDataNumericHighLowComposite>>>() { - @Override - public void onFailure(Throwable caught) { - CoreGUI.getErrorHandler().handleError( - MSG.view_resource_monitor_graphs_loadFailed(), caught); - countDownLatch.countDown(); - } - - @Override - public void onSuccess(final - List<List<MeasurementDataNumericHighLowComposite>> measurementData) { - Log.debug("\nSuccessfully queried Metric data in: "+ (System.currentTimeMillis() - startTime)+ " ms." ); - metricGraphData.setMetricData(measurementData.get(0)); - countDownLatch.countDown(); - } - }); - } - } - } - }); - } - - @Override - protected boolean supportsLiveGraphViewDialog() { - return true; - } - - - - @Override - /** - * Delegate the call to rendering the JSNI chart. - * This way the chart type can be swapped out at any time. - */ - public void drawJsniChart() - { - jsniChart.drawJsniChart(); - } - - public void setJsniChart(HasD3JsniChart jsniChart) - { - this.jsniChart = jsniChart; - } - - public HasD3JsniChart getJsniChart() - { - return jsniChart; - } - - @Override - protected void displayLiveGraphViewDialog() { - LiveGraphD3View.displayAsDialog(getLocatorId(), metricGraphData.getEntityId(), metricGraphData.getDefinition()); - } -}
commit e0e2708de3ccd77644d412d01403b9b44f9bfb28 Author: Mike Thompson mithomps@redhat.com Date: Tue Jan 29 17:09:43 2013 -0800
Charting - Dont show avg bar line when individual bars are 4 minute bars or less.
diff --git a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java index f3bdbc9..20d52b5 100644 --- a/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java +++ b/modules/enterprise/gui/coregui/src/main/java/org/rhq/enterprise/gui/coregui/client/inventory/common/charttype/MetricStackedBarGraph.java @@ -461,23 +461,33 @@ public final class MetricStackedBarGraph extends MetricGraphData implements HasD return timeScale(d.x)+ ((width / chartContext.data.length - barOffset)/ 2); }) .y(function (d,i) { + + var minuteBarThreshold = 4, + firstDate = this.__data__[0].x, + secondDate = this.__data__[1].x, + barDateDiffInMinutues = (secondDate - firstDate)/ (60000); + + if(barDateDiffInMinutues > minuteBarThreshold){ // on a bar avg line if the value is undefined then use the last defined value - if(d.y == undefined){ - if(i >= 1){ - // count backward until there is a defined value - for(var j=i; j>=1;j--){ - if(this.__data__[j].y != undefined){ - //console.log( "using: "+j +" for :"+i+", value"+this.__data__[j].y); - return yScale(this.__data__[j].y); - } + if(d.y == undefined){ + if(i >= 1){ + // count backward until there is a defined value + for(var j=i; j>=1;j--){ + if(this.__data__[j].y != undefined){ + //console.log( "using: "+j +" for :"+i+", value"+this.__data__[j].y); + return yScale(this.__data__[j].y); + } + } + return yScale(0); + }else { + return yScale(0); } - return yScale(0); + }else { - return yScale(0); + return yScale(+d.y); } - }else { - return yScale(+d.y); + return yScale(0); } });
rhq-commits@lists.fedorahosted.org