提交 4a5f45b3 编写于 作者: S serge-rider

#4209 Dashboard: charts value type


Former-commit-id: ca5ef40b
上级 af69cab1
......@@ -630,7 +630,7 @@
<extension point="org.jkiss.dbeaver.dashboard">
<dashboard id="postgresql.sessionCount" label="Server sessions" type="histogram" group="Standard" updatePeriod="2000" calc="value" fetch="columns" showByDefault="true">
<dashboard id="postgresql.sessionCount" label="Server sessions" type="histogram" group="Standard" updatePeriod="2000" calc="value" value="integer" fetch="columns" showByDefault="true">
<datasource id="postgresql"/>
<query>
SELECT
......@@ -639,7 +639,7 @@
(SELECT count(*) as "Total" FROM pg_catalog.pg_stat_activity sa)
</query>
</dashboard>
<dashboard id="postgresql.transactionCount" label="Transactions per second" group="Standard" type="histogram" updatePeriod="2000" calc="delta" fetch="columns" showByDefault="true">
<dashboard id="postgresql.transactionCount" label="Transactions per second" group="Standard" type="histogram" updatePeriod="2000" calc="delta" value="integer" fetch="columns" showByDefault="true">
<datasource id="postgresql"/>
<query>
SELECT
......@@ -648,7 +648,7 @@
(SELECT sum(xact_rollback) AS "Rollback" FROM pg_stat_database)
</query>
</dashboard>
<dashboard id="postgresql.blockIO" label="Block IO" group="Standard" type="histogram" updatePeriod="2000" calc="delta" fetch="columns" showByDefault="true">
<dashboard id="postgresql.blockIO" label="Block IO" group="Standard" type="histogram" updatePeriod="2000" calc="delta" value="integer" fetch="columns" showByDefault="true">
<datasource id="postgresql"/>
<query>
SELECT
......
......@@ -237,6 +237,11 @@ public class DashboardItem extends Composite implements DashboardContainer {
return dashboardConfig.getDashboardDescriptor().getCalcType();
}
@Override
public DashboardValueType getDashboardValueType() {
return dashboardConfig.getDashboardDescriptor().getValueType();
}
@Override
public DashboardFetchType getDashboardFetchType() {
return dashboardConfig.getDashboardDescriptor().getFetchType();
......
......@@ -22,9 +22,7 @@ import org.eclipse.swt.widgets.Composite;
import org.jfree.chart.ChartFactory;
import org.jfree.chart.ChartPanel;
import org.jfree.chart.JFreeChart;
import org.jfree.chart.axis.DateAxis;
import org.jfree.chart.axis.DateTickMarkPosition;
import org.jfree.chart.axis.ValueAxis;
import org.jfree.chart.axis.*;
import org.jfree.chart.plot.PlotOrientation;
import org.jfree.chart.plot.XYPlot;
import org.jfree.chart.renderer.xy.XYItemRenderer;
......@@ -39,10 +37,7 @@ import org.jkiss.dbeaver.ui.AWTUtils;
import org.jkiss.dbeaver.ui.UIStyles;
import org.jkiss.dbeaver.ui.dashboard.control.DashboardChartComposite;
import org.jkiss.dbeaver.ui.dashboard.control.DashboardRenderer;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardViewConfiguration;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardContainer;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardFetchType;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardViewContainer;
import org.jkiss.dbeaver.ui.dashboard.model.*;
import org.jkiss.dbeaver.ui.dashboard.model.data.DashboardDataset;
import org.jkiss.dbeaver.ui.dashboard.model.data.DashboardDatasetRow;
......@@ -120,6 +115,9 @@ public class DashboardRendererHistogram implements DashboardRenderer {
rangeAxis.setLabel(null);
rangeAxis.setTickLabelPaint(gridColor);
rangeAxis.setTickLabelFont(DEFAULT_TICK_LABEL_FONT);
if (container.getDashboardValueType() == DashboardValueType.integer) {
rangeAxis.setStandardTickUnits(new NumberTickUnitSource(true));
}
//rangeAxis.setLowerMargin(0.2);
//rangeAxis.setLowerBound(.1);
......@@ -201,7 +199,8 @@ public class DashboardRendererHistogram implements DashboardRenderer {
return;
}
//System.out.println("LAST=" + lastUpdateTime + "; CUR=" + new Date());
long secondsPassed = (System.currentTimeMillis() - lastUpdateTime.getTime()) / 1000;
long currentTime = System.currentTimeMillis();
long secondsPassed = (currentTime - lastUpdateTime.getTime()) / 1000;
if (secondsPassed <= 0) {
secondsPassed = 1;
}
......@@ -212,6 +211,9 @@ public class DashboardRendererHistogram implements DashboardRenderer {
if (newValue instanceof Number && prevValue instanceof Number) {
double deltaValue = ((Number) newValue).doubleValue() - ((Number) prevValue).doubleValue();
deltaValue /= secondsPassed;
if (container.getDashboardValueType() == DashboardValueType.integer) {
deltaValue = Math.round(deltaValue);
}
series.add(
new FixedMillisecond(
row.getTimestamp().getTime()),
......
......@@ -31,6 +31,7 @@ public class DashboardConstants {
public static final int DEF_DASHBOARD_UPDATE_PERIOD = 5000;
public static final double DEF_DASHBOARD_WIDTH_RATIO = 1.5;
public static final DashboardCalcType DEF_DASHBOARD_CALC_TYPE = DashboardCalcType.value;
public static final DashboardValueType DEF_DASHBOARD_VALUE_TYPE = DashboardValueType.decimal;
public static final DashboardFetchType DEF_DASHBOARD_FETCH_TYPE = DashboardFetchType.columns;
public static final String CMD_ADD_DASHBOARD = "org.jkiss.dbeaver.ui.dashboard.add";
......
......@@ -38,6 +38,8 @@ public interface DashboardContainer {
DashboardCalcType getDashboardCalcType();
DashboardValueType getDashboardValueType();
DashboardFetchType getDashboardFetchType();
/**
......
/*
* DBeaver - Universal Database Manager
* Copyright (C) 2010-2019 Serge Rider (serge@jkiss.org)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jkiss.dbeaver.ui.dashboard.model;
/**
* Dashboard value type
*/
public enum DashboardValueType {
decimal,
integer
}
......@@ -22,10 +22,7 @@ import org.jkiss.dbeaver.model.DBPDataSourceContainer;
import org.jkiss.dbeaver.model.DBPNamedObject;
import org.jkiss.dbeaver.model.impl.AbstractContextDescriptor;
import org.jkiss.dbeaver.ui.dashboard.internal.UIDashboardActivator;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardCalcType;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardConstants;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardFetchType;
import org.jkiss.dbeaver.ui.dashboard.model.DashboardQuery;
import org.jkiss.dbeaver.ui.dashboard.model.*;
import org.jkiss.utils.CommonUtils;
import org.jkiss.utils.xml.XMLBuilder;
import org.jkiss.utils.xml.XMLUtils;
......@@ -60,6 +57,7 @@ public class DashboardDescriptor extends AbstractContextDescriptor implements DB
private long maxAge;
private boolean isCustom;
private DashboardValueType valueType;
private static class DataSourceMapping {
private final String dataSourceProvider;
......@@ -135,6 +133,7 @@ public class DashboardDescriptor extends AbstractContextDescriptor implements DB
this.type = registry.getDashboardType(config.getAttribute("type"));
this.widthRatio = (float) CommonUtils.toDouble(config.getAttribute("ratio"), DashboardConstants.DEF_DASHBOARD_WIDTH_RATIO); // Default ratio is 2 to 3
this.calcType = CommonUtils.valueOf(DashboardCalcType.class, config.getAttribute("calc"), DashboardConstants.DEF_DASHBOARD_CALC_TYPE);
this.valueType = CommonUtils.valueOf(DashboardValueType.class, config.getAttribute("value"), DashboardConstants.DEF_DASHBOARD_VALUE_TYPE);
this.fetchType = CommonUtils.valueOf(DashboardFetchType.class, config.getAttribute("fetch"), DashboardConstants.DEF_DASHBOARD_FETCH_TYPE);
this.updatePeriod = CommonUtils.toLong(config.getAttribute("updatePeriod"), DashboardConstants.DEF_DASHBOARD_UPDATE_PERIOD); // Default ratio is 2 to 3
this.maxItems = CommonUtils.toInt(config.getAttribute("maxItems"), DashboardConstants.DEF_DASHBOARD_MAXIMUM_ITEM_COUNT);
......@@ -165,6 +164,7 @@ public class DashboardDescriptor extends AbstractContextDescriptor implements DB
this.type = registry.getDashboardType(config.getAttribute("type"));
this.widthRatio = (float) CommonUtils.toDouble(config.getAttribute("ratio"), DashboardConstants.DEF_DASHBOARD_WIDTH_RATIO);
this.calcType = CommonUtils.valueOf(DashboardCalcType.class, config.getAttribute("calc"), DashboardConstants.DEF_DASHBOARD_CALC_TYPE);
this.valueType = CommonUtils.valueOf(DashboardValueType.class, config.getAttribute("value"), DashboardConstants.DEF_DASHBOARD_VALUE_TYPE);
this.fetchType = CommonUtils.valueOf(DashboardFetchType.class, config.getAttribute("fetch"), DashboardConstants.DEF_DASHBOARD_FETCH_TYPE);
this.updatePeriod = CommonUtils.toLong(config.getAttribute("updatePeriod"), DashboardConstants.DEF_DASHBOARD_UPDATE_PERIOD); // Default ratio is 2 to 3
this.maxItems = CommonUtils.toInt(config.getAttribute("maxItems"), DashboardConstants.DEF_DASHBOARD_MAXIMUM_ITEM_COUNT);
......@@ -194,6 +194,7 @@ public class DashboardDescriptor extends AbstractContextDescriptor implements DB
this.type = source.type;
this.widthRatio = source.widthRatio;
this.calcType = source.calcType;
this.valueType = source.valueType;
this.fetchType = source.fetchType;
this.updatePeriod = source.updatePeriod;
this.maxItems = source.maxItems;
......@@ -285,6 +286,14 @@ public class DashboardDescriptor extends AbstractContextDescriptor implements DB
this.calcType = calcType;
}
public DashboardValueType getValueType() {
return valueType;
}
public void setValueType(DashboardValueType valueType) {
this.valueType = valueType;
}
public DashboardFetchType getFetchType() {
return fetchType;
}
......@@ -347,6 +356,7 @@ public class DashboardDescriptor extends AbstractContextDescriptor implements DB
xml.addAttribute("type", type.getId());
xml.addAttribute("ratio", widthRatio);
xml.addAttribute("calc", calcType.name());
xml.addAttribute("value", valueType.name());
xml.addAttribute("fetch", fetchType.name());
xml.addAttribute("updatePeriod", updatePeriod);
xml.addAttribute("maxItems", maxItems);
......
......@@ -78,10 +78,11 @@ public class DashboardChartConfigDialog extends BaseDialog {
typeCombo.add(dashboardConfig.getDashboardDescriptor().getType().getTitle());
typeCombo.select(0);
UIUtils.createLabelText(infoGroup, "Calc type", dashboardConfig.getDashboardDescriptor().getCalcType().name(), SWT.BORDER | SWT.READ_ONLY);
UIUtils.createLabelText(infoGroup, "Value type", dashboardConfig.getDashboardDescriptor().getValueType().name(), SWT.BORDER | SWT.READ_ONLY);
UIUtils.createLabelText(infoGroup, "Fetch type", dashboardConfig.getDashboardDescriptor().getFetchType().name(), SWT.BORDER | SWT.READ_ONLY);
Composite btnGroup = UIUtils.createComposite(infoGroup, 1);
btnGroup.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 4, 1));
btnGroup.setLayoutData(new GridData(GridData.FILL, GridData.BEGINNING, true, false, 2, 1));
Button queriesButton = new Button(btnGroup, SWT.PUSH);
queriesButton.setText("SQL Queries ...");
queriesButton.setImage(DBeaverIcons.getImage(UIIcon.SQL_SCRIPT));
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册