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

small change

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