Skip to content

Commit

Permalink
监控图表优化
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Dec 8, 2024
1 parent d846d30 commit ac6eeb0
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 57 deletions.
10 changes: 4 additions & 6 deletions Stardust.Web/Areas/Monitors/Controllers/AppDayStatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,10 @@ protected override IEnumerable<AppDayStat> Search(Pager p)
Height = 400,
};
chart.SetX(list2, _.StatDate);
//chart.SetY("调用次数");
chart.YAxis = new[] {
new { name = "调用次数", type = "value" },
new { name = "错误数", type = "value" }
};
chart.SetY(["调用次数", "错误数"], "value");
chart.AddDataZoom();
chart.Grid.Left = -5;
chart.Grid.Right = -5;
chart.AddLine(list2, _.Total, null, true);

chart.Add(list2, _.Apis);
Expand All @@ -89,7 +87,7 @@ protected override IEnumerable<AppDayStat> Search(Pager p)
chart.Add(list2, _.Others);

var line = chart.Add(list2, _.Errors);
line["yAxisIndex"] = 1;
line.YAxisIndex = 1;
line["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", };

chart.SetTooltip();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,11 @@ protected override IEnumerable<AppMinuteStat> Search(Pager p)
Height = 400,
};
chart.SetX(list2, _.StatTime);
//chart.SetY("调用次数");
chart.YAxis = new[] {
new { name = "调用次数", type = "value" },
new { name = "错误数", type = "value" }
};
chart.SetY(["调用次数", "错误数"], "value");
chart.AddLine(list2, _.Total, null, true);

var line = chart.Add(list2, _.Errors);
line["yAxisIndex"] = 1;
line.YAxisIndex = 1;
line["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", };

chart.SetTooltip();
Expand All @@ -99,7 +95,7 @@ protected override IEnumerable<AppMinuteStat> Search(Pager p)
chart.Add(list2, _.MinCost);

var line = chart.Add(list2, _.MaxCost);
line["yAxisIndex"] = 1;
line.YAxisIndex = 1;

chart.SetTooltip();
ViewBag.Charts2 = new[] { chart };
Expand Down Expand Up @@ -144,6 +140,7 @@ protected override IEnumerable<AppMinuteStat> Search(Pager p)
Type = "bar",
["stack"] = "总量",
["label"] = new { show = true, position = "left" },
["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", },
Data = list2.Select(e => -e.Errors).ToArray(),
});
chart.Add(new Series
Expand Down
39 changes: 24 additions & 15 deletions Stardust.Web/Areas/Monitors/Controllers/TraceDayStatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,19 +56,28 @@ protected override IEnumerable<TraceDayStat> Search(Pager p)
Height = 400,
};
chart.SetX(list2, _.StatDate);
//chart.SetY("调用次数");
chart.YAxis = new[] {
new { name = "调用次数", type = "value" },
new { name = "错误数", type = "value" }
};
chart.AddDataZoom();
chart.AddLine(list2, _.Total, null, true);

var line = chart.Add(list2, _.Errors);
line["yAxisIndex"] = 1;
//line["lineStyle"] = new { color = "rgba(255, 0, 0, 1)", };
line["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", };
var idx = 1;
var ys = new List<String> { "调用次数" };
if (list2.Any(e => e.Errors > 0))
{
ys.Add("错误数");
var line = chart.Add(list2, _.Errors);
line.YAxisIndex = idx++;
line["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", };
}

if (list2.Any(e => e.TotalValue > 0))
{
ys.Add("数值");
var line = chart.Add(list2, _.TotalValue);
line.YAxisIndex = idx++;
}

chart.SetY(ys.ToArray(), "value");
if (ys.Count == 1) chart.Grid.Right = -3;
chart.SetTooltip();
ViewBag.Charts = new[] { chart };
}
Expand All @@ -79,17 +88,17 @@ protected override IEnumerable<TraceDayStat> Search(Pager p)
Height = 400,
};
chart.SetX(list2, _.StatDate);
//chart.SetY("耗时");
chart.YAxis = new[] {
new { name = "耗时(ms)", type = "value" },
new { name = "最大耗时(ms)", type = "value" }
};
chart.SetY(["耗时(ms)", "最大耗时(ms)"], "value", ["{value}ms", "{value}ms"]);
//chart.YAxis = new[] {
// new { name = "耗时(ms)", type = "value" },
// new { name = "最大耗时(ms)", type = "value" }
//};
chart.AddDataZoom();
chart.AddLine(list2, _.Cost, null, true);
chart.Add(list2, _.MinCost);

var line = chart.Add(list2, _.MaxCost);
line["yAxisIndex"] = 1;
line.YAxisIndex = 1;

chart.SetTooltip();
ViewBag.Charts2 = new[] { chart };
Expand Down
38 changes: 24 additions & 14 deletions Stardust.Web/Areas/Monitors/Controllers/TraceHourStatController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,18 +55,28 @@ protected override IEnumerable<TraceHourStat> Search(Pager p)
Height = 400,
};
chart.SetX(list2, _.StatTime);
//chart.SetY("调用次数");
chart.YAxis = new[] {
new { name = "调用次数", type = "value" },
new { name = "错误数", type = "value" }
};
chart.AddDataZoom();
chart.AddLine(list2, _.Total, null, true);

var line = chart.Add(list2, _.Errors);
line["yAxisIndex"] = 1;
line["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", };
var idx = 1;
var ys = new List<String> { "调用次数" };
if (list2.Any(e => e.Errors > 0))
{
ys.Add("错误数");
var line = chart.Add(list2, _.Errors);
line.YAxisIndex = idx++;
line["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", };
}

if (list2.Any(e => e.TotalValue > 0))
{
ys.Add("数值");
var line = chart.Add(list2, _.TotalValue);
line.YAxisIndex = idx++;
}

chart.SetY(ys.ToArray(), "value");
if (ys.Count == 1) chart.Grid.Right = -3;
chart.SetTooltip();
ViewBag.Charts = new[] { chart };
}
Expand All @@ -77,17 +87,17 @@ protected override IEnumerable<TraceHourStat> Search(Pager p)
Height = 400,
};
chart.SetX(list2, _.StatTime);
//chart.SetY("耗时");
chart.YAxis = new[] {
new { name = "耗时(ms)", type = "value" },
new { name = "最大耗时(ms)", type = "value" }
};
chart.SetY(["耗时(ms)", "最大耗时(ms)"], "value", ["{value}ms", "{value}ms"]);
//chart.YAxis = new[] {
// new { name = "耗时(ms)", type = "value" },
// new { name = "最大耗时(ms)", type = "value" }
//};
chart.AddDataZoom();
chart.AddLine(list2, _.Cost, null, true);
chart.Add(list2, _.MinCost);

var line = chart.Add(list2, _.MaxCost);
line["yAxisIndex"] = 1;
line.YAxisIndex = 1;

chart.SetTooltip();
ViewBag.Charts2 = new[] { chart };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,28 @@ protected override IEnumerable<TraceMinuteStat> Search(Pager p)
Height = 400,
};
chart.SetX(list2, _.StatTime);
//chart.SetY("调用次数");
chart.YAxis = new[] {
new { name = "调用次数", type = "value" },
new { name = "错误数", type = "value" }
};
chart.AddDataZoom();
chart.AddLine(list2, _.Total, null, true);

var line = chart.Add(list2, _.Errors);
line["yAxisIndex"] = 1;
line["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", };
var idx = 1;
var ys = new List<String> { "调用次数" };
if (list2.Any(e => e.Errors > 0))
{
ys.Add("错误数");
var line = chart.Add(list2, _.Errors);
line.YAxisIndex = idx++;
line["itemStyle"] = new { color = "rgba(255, 0, 0, 0.5)", };
}

if (list2.Any(e => e.TotalValue > 0))
{
ys.Add("数值");
var line = chart.Add(list2, _.TotalValue);
line.YAxisIndex = idx++;
}

chart.SetY(ys.ToArray(), "value");
if (ys.Count == 1) chart.Grid.Right = -3;
chart.SetTooltip();
ViewBag.Charts = new[] { chart };
}
Expand All @@ -78,17 +88,17 @@ protected override IEnumerable<TraceMinuteStat> Search(Pager p)
Height = 400,
};
chart.SetX(list2, _.StatTime);
//chart.SetY("耗时");
chart.YAxis = new[] {
new { name = "耗时(ms)", type = "value" },
new { name = "最大耗时(ms)", type = "value" }
};
chart.SetY(["耗时(ms)", "最大耗时(ms)"], "value", ["{value}ms", "{value}ms"]);
//chart.YAxis = new[] {
// new { name = "耗时(ms)", type = "value" },
// new { name = "最大耗时(ms)", type = "value" }
//};
chart.AddDataZoom();
chart.AddLine(list2, _.Cost, null, true);
chart.Add(list2, _.MinCost);

var line = chart.Add(list2, _.MaxCost);
line["yAxisIndex"] = 1;
line.YAxisIndex = 1;

chart.SetTooltip();
ViewBag.Charts2 = new[] { chart };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
{
var ti = TraceItem.FindById(itemId);
<div class="form-group">
<a href="traceItem?Id=@itemId" class="btn btn-success btn-sm">@ti</a>
<a href="traceItem?Id=@itemId" class="btn btn-warning btn-sm">@ti</a>
</div>
}
@if (appId > 0)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
var appId = page["appId"].ToInt(-1);
var itemId = page["itemId"].ToInt(-1);
}
@if (itemId > 0)
{
var ti = TraceItem.FindById(itemId);
<div class="form-group">
<a href="traceItem?Id=@itemId" class="btn btn-warning btn-sm">@ti</a>
</div>
}
@if (appId > 0)
{
var app = AppTracer.FindByID(appId);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@
var appId = page["appId"].ToInt(-1);
var itemId = page["itemId"].ToInt(-1);
}
@if (itemId > 0)
{
var ti = TraceItem.FindById(itemId);
<div class="form-group">
<a href="traceItem?Id=@itemId" class="btn btn-warning btn-sm">@ti</a>
</div>
}
@if (appId > 0)
{
var app = AppTracer.FindByID(appId);
Expand Down

0 comments on commit ac6eeb0

Please sign in to comment.