提交 0afaa089 编写于 作者: F Frankie Wu

small change

上级 a1db878c
......@@ -86,6 +86,16 @@ public abstract class AbstractGraphPayload implements GraphPayload {
return 40;
}
@Override
public int getOffsetX() {
return 0;
}
@Override
public int getOffsetY() {
return 0;
}
@Override
public int getRows() {
return 5;
......@@ -119,5 +129,10 @@ public abstract class AbstractGraphPayload implements GraphPayload {
return getValues().length >= 16;
}
@Override
public boolean isStandalone() {
return true;
}
protected abstract double[] loadValues();
}
......@@ -135,6 +135,8 @@ public class DefaultGraphBuilder implements GraphBuilder {
}
protected void buildHeader(GraphPayload payload, XmlBuilder b, int maxValue) {
int offsetX = payload.getOffsetX();
int offsetY = payload.getOffsetY();
int height = payload.getHeight();
int width = payload.getWidth();
int top = payload.getMarginTop();
......@@ -142,9 +144,12 @@ public class DefaultGraphBuilder implements GraphBuilder {
int bottom = payload.getMarginBottom();
int right = payload.getMarginRight();
b.add("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n");
b.tag1("svg", "width", payload.getDisplayWidth(), "height", payload.getDisplayHeight(), "viewBox", "0,0," + width
+ "," + height, "xmlns", "http://www.w3.org/2000/svg");
if (payload.isStandalone()) {
b.add("<!DOCTYPE svg PUBLIC \"-//W3C//DTD SVG 1.1//EN\" \"http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd\">\r\n");
}
b.tag1("svg", "x", offsetX, "y", offsetY, "width", payload.getDisplayWidth(), "height",
payload.getDisplayHeight(), "viewBox", "0,0," + width + "," + height, "xmlns", "http://www.w3.org/2000/svg");
String title = payload.getTitle();
......@@ -217,9 +222,9 @@ public class DefaultGraphBuilder implements GraphBuilder {
if (rotated) {
String transform = "rotate(90," + x + "," + y + ")";
b.tagWithText("text", label, "x", x, "y", y, "transform", transform);
b.tagWithText("text", label, "x", x, "y", y, "font-size", "14", "transform", transform);
} else {
b.tagWithText("text", label, "x", x, "y", y);
b.tagWithText("text", label, "x", x, "y", y, "font-size", "14");
}
if (skipped) {
......@@ -248,14 +253,14 @@ public class DefaultGraphBuilder implements GraphBuilder {
int x = left - 12;
int y = top + 4 + ystep * i;
b.tagWithText("text", maxValue - maxValue / rows * i, "x", x, "y", y);
b.tagWithText("text", maxValue - maxValue / rows * i, "x", x, "y", y, "font-size", "14");
}
} else {
for (int i = 0; i < rows; i++) {
int x = left - 9;
int y = top + 4 + ystep * i;
b.tagWithText("text", maxValue - maxValue / rows * i, "x", x, "y", y);
b.tagWithText("text", maxValue - maxValue / rows * i, "x", x, "y", y, "font-size", "14");
}
}
......
......@@ -27,6 +27,10 @@ public interface GraphPayload {
public int getMarginTop();
public int getOffsetX();
public int getOffsetY();
public int getRows();
public String getTitle();
......@@ -38,4 +42,6 @@ public interface GraphPayload {
public boolean isAxisXLabelRotated();
public boolean isAxisXLabelSkipped();
public boolean isStandalone();
}
......@@ -148,8 +148,12 @@ public class Handler implements PageHandler<Context>, Initializable {
}
abstract class AbstractPayload extends AbstractGraphPayload {
public AbstractPayload(String title, String axisXLabel, String axisYLabel) {
private final TransactionName m_name;
public AbstractPayload(String title, String axisXLabel, String axisYLabel, TransactionName name) {
super(title, axisXLabel, axisYLabel);
m_name = name;
}
@Override
......@@ -167,27 +171,41 @@ public class Handler implements PageHandler<Context>, Initializable {
return (int) (super.getDisplayWidth() * 0.7);
}
protected TransactionName getTransactionName() {
return m_name;
}
@Override
public int getWidth() {
return super.getWidth() + 120;
}
@Override
public boolean isStandalone() {
return false;
}
@Override
public String getIdPrefix() {
return m_name.getId() + "-" + super.getIdPrefix();
}
}
final class AverageTimePayload extends AbstractPayload {
private final TransactionName m_name;
public AverageTimePayload(String title, String axisXLabel, String axisYLabel, TransactionName name) {
super(title, axisXLabel, axisYLabel);
super(title, axisXLabel, axisYLabel, name);
}
m_name = name;
@Override
public int getOffsetY() {
return getDisplayHeight() + 20;
}
@Override
protected double[] loadValues() {
double[] values = new double[12];
for (Range range : m_name.getRanges()) {
for (Range range : getTransactionName().getRanges()) {
int value = range.getValue();
int k = value / 5;
......@@ -199,12 +217,8 @@ public class Handler implements PageHandler<Context>, Initializable {
}
final class DurationPayload extends AbstractPayload {
private final TransactionName m_name;
public DurationPayload(String title, String axisXLabel, String axisYLabel, TransactionName name) {
super(title, axisXLabel, axisYLabel);
m_name = name;
super(title, axisXLabel, axisYLabel, name);
}
@Override
......@@ -236,7 +250,7 @@ public class Handler implements PageHandler<Context>, Initializable {
protected double[] loadValues() {
double[] values = new double[17];
for (Duration duration : m_name.getDurations()) {
for (Duration duration : getTransactionName().getDurations()) {
int d = duration.getValue();
Integer k = m_map.get(d);
......@@ -250,19 +264,25 @@ public class Handler implements PageHandler<Context>, Initializable {
}
final class FailurePayload extends AbstractPayload {
private final TransactionName m_name;
public FailurePayload(String title, String axisXLabel, String axisYLabel, TransactionName name) {
super(title, axisXLabel, axisYLabel);
super(title, axisXLabel, axisYLabel, name);
}
m_name = name;
@Override
public int getOffsetX() {
return getDisplayWidth();
}
@Override
public int getOffsetY() {
return getDisplayHeight() + 20;
}
@Override
protected double[] loadValues() {
double[] values = new double[12];
for (Range range : m_name.getRanges()) {
for (Range range : getTransactionName().getRanges()) {
int value = range.getValue();
int k = value / 5;
......@@ -274,19 +294,20 @@ public class Handler implements PageHandler<Context>, Initializable {
}
final class HitPayload extends AbstractPayload {
private final TransactionName m_name;
public HitPayload(String title, String axisXLabel, String axisYLabel, TransactionName name) {
super(title, axisXLabel, axisYLabel);
super(title, axisXLabel, axisYLabel, name);
}
m_name = name;
@Override
public int getOffsetX() {
return getDisplayWidth();
}
@Override
protected double[] loadValues() {
double[] values = new double[12];
for (Range range : m_name.getRanges()) {
for (Range range : getTransactionName().getRanges()) {
int value = range.getValue();
int k = value / 5;
......
......@@ -43,7 +43,3 @@ tr.link td {
.error {
color: red;
}
.graphs {
height: 1px;
}
\ No newline at end of file
......@@ -4,20 +4,26 @@ function showGraphs(anchor, id, domain, type, name) {
if (text == '[:: show ::]') {
anchor.innerHTML = '[:: hide ::]';
$.ajax({
type: "get",
url: "?op=graphs&domain="+domain+"&type="+type+"&name="+name,
success : function(data, textStatus) {
cell.innerHTML = data;
}
});
if (cell.nodeName == 'IMG') { // <img src='...'/>
cell.src = "?op=graphs&domain="+domain+"&type="+type+"&name="+name;
} else { // <div>...</div>
$.ajax({
type: "get",
url: "?op=graphs&domain="+domain+"&type="+type+"&name="+name,
success : function(data, textStatus) {
cell.innerHTML = data;
}
});
}
cell.style.display = 'block';
cell.parentNode.style.display = 'block';
} else {
anchor.innerHTML = '[:: show ::]';
cell.style.display = 'none';
cell.parentNode.style.display = 'none';
}
return false;
}
\ No newline at end of file
}
......@@ -45,7 +45,7 @@
<td><a href="${model.logViewBaseUri}/${empty e.failMessageUrl ? e.successMessageUrl : e.failMessageUrl}">Log View</a></td>
<td>${w:format(e.min,'0')}/${w:format(e.max,'0')}/${w:format(e.avg,'0.0')}/${w:format(e.std,'0.0')}</td>
</tr>
<tr class="graphs"><td colspan="6"><div id="${status.index}"></div></td></tr>
<tr class="graphs"><td colspan="6"><div id="${status.index}" style="display:none"></div></td></tr>
</c:forEach>
</c:otherwise>
</c:choose>
......
<%@ page contentType="image/svg+xml; charset=utf-8"%>
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<svg width="600" height="300" xmlns="http://www.w3.org/2000/svg">
<svg version="1.1" width="600" height="300" xmlns="http://www.w3.org/2000/svg">
<title>Duration</title>
<g id="coordinate" stroke="#003f7f" fill="white">
<path id="xy" d="M90,200 h480 m-480,0 v-150"/>
......
<%@ page contentType="text/html; charset=utf-8"%>
<jsp:useBean id="ctx" type="com.dianping.cat.report.page.transaction.Context" scope="request" />
<jsp:useBean id="payload" type="com.dianping.cat.report.page.transaction.Payload" scope="request" />
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd">
<jsp:useBean id="model" type="com.dianping.cat.report.page.transaction.Model" scope="request" />
<table>
<tr>
<td>${model.graph1}</td>
<td>${model.graph2}</td>
</tr>
<tr>
<td>${model.graph3}</td>
<td>${model.graph4}</td>
</tr>
</table>
<svg version="1.1" width="980" height="380" xmlns="http://www.w3.org/2000/svg">
${model.graph1}
${model.graph2}
${model.graph3}
${model.graph4}
</svg>
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册