mirror of
https://github.com/PaiGramTeam/PaiGram.git
synced 2024-11-16 04:35:49 +00:00
🐛 Fix standard deviation is not showing correctly in dps line chart
* Fix standard deviation is not showing correctly in dps line chart * remove console.log * simpler math
This commit is contained in:
parent
19fb808cf2
commit
043b413285
@ -64,33 +64,12 @@ class GCSimResultRenderer:
|
|||||||
]
|
]
|
||||||
result["extra"]["damage"] = {
|
result["extra"]["damage"] = {
|
||||||
"xAxis": [i * 0.5 for i in range(len(result["statistics"]["damage_buckets"]["buckets"]))],
|
"xAxis": [i * 0.5 for i in range(len(result["statistics"]["damage_buckets"]["buckets"]))],
|
||||||
"series": [
|
"data": {
|
||||||
{
|
"mean": [bucket["mean"] for bucket in result["statistics"]["damage_buckets"]["buckets"]],
|
||||||
"data": [bucket["mean"] for bucket in result["statistics"]["damage_buckets"]["buckets"]],
|
"min": [bucket["min"] for bucket in result["statistics"]["damage_buckets"]["buckets"]],
|
||||||
"type": "line",
|
"max": [bucket["max"] for bucket in result["statistics"]["damage_buckets"]["buckets"]],
|
||||||
"stack": "x",
|
"sd": [bucket["sd"] for bucket in result["statistics"]["damage_buckets"]["buckets"]],
|
||||||
"areaStyle": {},
|
|
||||||
"name": "平均伤害",
|
|
||||||
},
|
},
|
||||||
{
|
|
||||||
"data": [bucket["min"] for bucket in result["statistics"]["damage_buckets"]["buckets"]],
|
|
||||||
"type": "line",
|
|
||||||
"stack": "x",
|
|
||||||
"name": "最小伤害",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": [bucket["max"] for bucket in result["statistics"]["damage_buckets"]["buckets"]],
|
|
||||||
"type": "line",
|
|
||||||
"stack": "x",
|
|
||||||
"name": "最大伤害",
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"data": [bucket["sd"] for bucket in result["statistics"]["damage_buckets"]["buckets"]],
|
|
||||||
"type": "line",
|
|
||||||
"stack": "x",
|
|
||||||
"name": "标准差",
|
|
||||||
},
|
|
||||||
],
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return result
|
return result
|
||||||
|
@ -10,6 +10,7 @@ from typing import Optional, Dict, List, Union, TYPE_CHECKING, Tuple, Coroutine,
|
|||||||
import gcsim_pypi
|
import gcsim_pypi
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
|
|
||||||
|
from gram_core.config import config
|
||||||
from metadata.shortname import idToName
|
from metadata.shortname import idToName
|
||||||
from modules.apihelper.client.components.remote import Remote
|
from modules.apihelper.client.components.remote import Remote
|
||||||
from modules.gcsim.cache import GCSimCache
|
from modules.gcsim.cache import GCSimCache
|
||||||
@ -171,6 +172,7 @@ class GCSimRunner:
|
|||||||
merged_script = GCSimConverter.merge_character_infos(script, character_infos)
|
merged_script = GCSimConverter.merge_character_infos(script, character_infos)
|
||||||
except ValueError:
|
except ValueError:
|
||||||
return GCSimResult(error="无法合并角色信息", user_id=user_id, uid=uid, script_key=script_key)
|
return GCSimResult(error="无法合并角色信息", user_id=user_id, uid=uid, script_key=script_key)
|
||||||
|
if not config.debug:
|
||||||
if file_id := await self.cache.get_cache(uid, hash(str(merged_script))):
|
if file_id := await self.cache.get_cache(uid, hash(str(merged_script))):
|
||||||
return GCSimResult(error=None, user_id=user_id, uid=uid, script_key=script_key, file_id=file_id)
|
return GCSimResult(error=None, user_id=user_id, uid=uid, script_key=script_key, file_id=file_id)
|
||||||
await self.player_gcsim_scripts.write_script(uid, script_key, str(merged_script))
|
await self.player_gcsim_scripts.write_script(uid, script_key, str(merged_script))
|
||||||
|
@ -1,5 +1,6 @@
|
|||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html lang="zh-CN">
|
<html lang="zh-CN">
|
||||||
|
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8" />
|
<meta charset="utf-8" />
|
||||||
<title>Title</title>
|
<title>Title</title>
|
||||||
@ -8,6 +9,7 @@
|
|||||||
<link type="text/css" href="../../styles/public.css" rel="stylesheet" />
|
<link type="text/css" href="../../styles/public.css" rel="stylesheet" />
|
||||||
|
|
||||||
</head>
|
</head>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<div class="mx-auto flex w-[48rem] flex-col space-y-2 bg-gray-400 px-2 py-2">
|
<div class="mx-auto flex w-[48rem] flex-col space-y-2 bg-gray-400 px-2 py-2">
|
||||||
<!-- START TEAM/DPS summary row -->
|
<!-- START TEAM/DPS summary row -->
|
||||||
@ -26,11 +28,23 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="flex h-56 w-1/2 items-center justify-center rounded-xl bg-slate-600" id="dps_by_element">
|
<div class="flex h-56 w-1/2 items-center justify-center rounded-xl bg-slate-600" id="dps_by_element">
|
||||||
</div>
|
</div>
|
||||||
|
</div>
|
||||||
|
<!-- END DPS distribution row -->
|
||||||
|
<!-- START Energy/Heal/Shield row -->
|
||||||
|
<div class="flex flex-row items-start justify-center space-x-2 rounded-lg">
|
||||||
|
{% include "genshin/gcsim/other_summary.jinja2" %}
|
||||||
|
|
||||||
|
</div>
|
||||||
|
<!-- END Energy/Heal/Shield row -->
|
||||||
|
<!-- START DPS line chart row -->
|
||||||
|
<div class="flex h-80 w-full flex-row items-start justify-center rounded-lg bg-slate-600" id="damage_overtime">
|
||||||
|
</div>
|
||||||
|
<!-- END DPS line chart row -->
|
||||||
|
</div>
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
var data = JSON.parse('{{ extra | tojson }}')
|
var data = JSON.parse('{{ extra | tojson }}')
|
||||||
// Initialize the echarts instance based on the prepared dom
|
// Initialize the echarts instance based on the prepared dom
|
||||||
var dpsByCharacter = echarts.init(document.getElementById('dps_by_character'));
|
var dpsByCharacter = echarts.init(document.getElementById('dps_by_character'));
|
||||||
var dpsByElement = echarts.init(document.getElementById('dps_by_element'));
|
|
||||||
dpsByCharacter.setOption({
|
dpsByCharacter.setOption({
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
@ -43,6 +57,7 @@
|
|||||||
],
|
],
|
||||||
animation: false
|
animation: false
|
||||||
});
|
});
|
||||||
|
var dpsByElement = echarts.init(document.getElementById('dps_by_element'));
|
||||||
dpsByElement.setOption({
|
dpsByElement.setOption({
|
||||||
series: [
|
series: [
|
||||||
{
|
{
|
||||||
@ -55,47 +70,94 @@
|
|||||||
],
|
],
|
||||||
animation: false
|
animation: false
|
||||||
});
|
});
|
||||||
</script>
|
|
||||||
</div>
|
|
||||||
<!-- END DPS distribution row -->
|
|
||||||
<!-- START Energy/Heal/Shield row -->
|
|
||||||
<div class="flex flex-row items-start justify-center space-x-2 rounded-lg">
|
|
||||||
{% include "genshin/gcsim/other_summary.jinja2" %}
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<!-- END Energy/Heal/Shield row -->
|
|
||||||
<!-- START DPS line chart row -->
|
|
||||||
<div class="flex h-80 w-full flex-row items-start justify-center rounded-lg bg-slate-600" id="damage_overtime">
|
|
||||||
|
|
||||||
</div>
|
|
||||||
<script type="text/javascript">
|
|
||||||
var data = JSON.parse('{{ extra | tojson }}')
|
|
||||||
// Initialize the echarts instance based on the prepared dom
|
|
||||||
var damageOvertime = echarts.init(document.getElementById('damage_overtime'));
|
var damageOvertime = echarts.init(document.getElementById('damage_overtime'));
|
||||||
damageOvertime.setOption({
|
damageOvertime.setOption({
|
||||||
xAxis: {
|
xAxis: {
|
||||||
data: data["damage"]["xAxis"],
|
data: data["damage"]["xAxis"],
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
color: 'white',
|
color: 'white',
|
||||||
|
interval: 19
|
||||||
|
},
|
||||||
|
axisTick: {
|
||||||
|
interval: 19
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
yAxis: {
|
yAxis: {
|
||||||
axisLabel: {
|
axisLabel: {
|
||||||
color: 'white'
|
color: 'white',
|
||||||
|
formatter: function (value, index) {
|
||||||
|
return value / 10000 + "万";
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
grid: {
|
||||||
|
left: '3%',
|
||||||
|
right: '3%',
|
||||||
|
bottom: '3%',
|
||||||
|
containLabel: true
|
||||||
},
|
},
|
||||||
legend: {
|
legend: {
|
||||||
textStyle: {
|
textStyle: {
|
||||||
color: 'white'
|
color: 'white'
|
||||||
}
|
|
||||||
},
|
},
|
||||||
series: data["damage"]["series"],
|
},
|
||||||
|
series: [
|
||||||
|
{
|
||||||
|
data: data["damage"]["data"]["mean"],
|
||||||
|
type: "line",
|
||||||
|
lineStyle: {
|
||||||
|
},
|
||||||
|
showSymbol: false,
|
||||||
|
name: "平均伤害",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: data["damage"]["data"]["min"],
|
||||||
|
type: "line",
|
||||||
|
lineStyle: {
|
||||||
|
opacity: 0.5,
|
||||||
|
},
|
||||||
|
showSymbol: false,
|
||||||
|
name: "最小伤害",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
data: data["damage"]["data"]["max"],
|
||||||
|
type: "line",
|
||||||
|
lineStyle: {
|
||||||
|
opacity: 0.5,
|
||||||
|
},
|
||||||
|
showSymbol: false,
|
||||||
|
name: "最大伤害",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "line",
|
||||||
|
data: data["damage"]["data"]["mean"].map((mean, idx) => mean - data["damage"]["data"]["sd"][idx] < 0 ? mean + data["damage"]["data"]["sd"][idx] : 2 * data["damage"]["data"]["sd"][idx]),
|
||||||
|
stack: 'confidence-band',
|
||||||
|
stackStrategy: 'positive',
|
||||||
|
lineStyle: {
|
||||||
|
opacity: 0
|
||||||
|
},
|
||||||
|
symbol: 'none',
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: "line",
|
||||||
|
data: data["damage"]["data"]["mean"].map((mean, idx) => mean - data["damage"]["data"]["sd"][idx] < 0 ? 0 : mean - data["damage"]["data"]["sd"][idx]),
|
||||||
|
stack: 'confidence-band',
|
||||||
|
stackStrategy: 'positive',
|
||||||
|
lineStyle: {
|
||||||
|
opacity: 0
|
||||||
|
},
|
||||||
|
areaStyle: {
|
||||||
|
opacity: 0.18,
|
||||||
|
color: '#4c9bd4'
|
||||||
|
},
|
||||||
|
symbol: 'none',
|
||||||
|
},
|
||||||
|
],
|
||||||
animation: false
|
animation: false
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<!-- END DPS line chart row -->
|
|
||||||
</div>
|
|
||||||
|
|
||||||
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
</html>
|
</html>
|
Loading…
Reference in New Issue
Block a user