Skip to content

Commit

Permalink
fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
daizeyao committed Mar 25, 2024
1 parent 1bee9dd commit e03111d
Show file tree
Hide file tree
Showing 4 changed files with 54 additions and 554 deletions.
2 changes: 1 addition & 1 deletion web/OJ/template/hznu/daliy_detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,4 +127,4 @@ function getDaliyDetailData(lastday, today, alldata) {
}

window.addEventListener('resize', myChart.resize);
</script>
</script>
177 changes: 51 additions & 126 deletions web/OJ/template/hznu/study_detail.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,100 +2,26 @@

require_once("header.php");

require_once("study_detail_data.php");
?>

<?php
$user = $_GET['user'];
if (!is_valid_user_name($user)) {
echo "No such User!";
exit(0);
}

$studydata = array();
$studydata = array_fill_keys($studytags, 0);
//studydata['xx']=0;

$sql = "SELECT pt.tag, COUNT(DISTINCT s.problem_id) as count
FROM solution s
JOIN problem_tag pt ON s.problem_id = pt.problem_id
WHERE s.user_id = '$user' AND s.result = 4 AND pt.tag IN ('" . implode("', '", $studytags) . "')
GROUP BY pt.tag;";
$result = $mysqli->query($sql);

while ($row = $result->fetch_assoc()) {
$studydata[$row['tag']] = $row['count'];
}

$result->free();


///////////////////////////////////////////////////////////////////////////////cs
// if($user == "admin")
// foreach ($studytags as $tag)
// $studydata[$tag] = 1;

///////////////////////////////////////////////////////////////////////////////cs

//此处修改层次颜色
$color = ['#cccccc', '#d0f0c0', '#aadf8f', '#85c96e'];

$neednum = array();
$neednum = array_fill_keys($studytags, [0, 1, 2, 4]);
//neednum['xx'] = [0, 1, 2, 4];


foreach ($studytags3 as $tag) {
$studydata[$tagfa[$tag]] = 0;
$neednum[$tagfa[$tag]] = [0, 0, 0, 0];
}
foreach ($studytags2 as $tag) {
$studydata[$tagfa[$tag]] = 0;
$neednum[$tagfa[$tag]] = [0, 0, 0, 0];
}

foreach ($studytags3 as $tag) {
$studydata[$tagfa[$tag]] += $studydata[$tag];
$counts = $neednum[$tag];
for ($i = 0; $i < count($counts); $i++) {
$neednum[$tagfa[$tag]][$i] += $counts[$i];
}
}
foreach ($studytags2 as $tag) {
$studydata[$tagfa[$tag]] += $studydata[$tag];
$counts = $neednum[$tag];
for ($i = 0; $i < count($counts); $i++) {
$neednum[$tagfa[$tag]][$i] += $counts[$i];
<style>
html {
width: 100%;
height: 100%;
}
}


$nowcolor = array();

foreach ($studytags as $tag) {
for ($i = 3; $i >= 0; $i--) {
if ($studydata[$tag] >= $neednum[$tag][$i]) {
$nowcolor[$tag] = $color[$i];
break;
}
body {
width: 100%;
height: 100%;
}
}

?>

<style>
</style>

<div class="am-g" style="margin-top: 0px;">
<div class="am-u-sm-12" style="justify-content: center;">
<div id="main" style="width: 3100px;height: 700px;"></div>
<div class="am-g" style="width:85%;height:78%">
<div class="am-u-sm-12" style="justify-content: center;width: 100%;height: 100%;">
<div id="main" style="width: 100%;height: 100%;"></div>
</div>
</div>

<?php
require_once("footer.php");
?>

<div class="am-modal am-modal-no-btn" tabindex="-1" id="modal-study">
<div class="am-modal-dialog" style="font-size: 20px; width:30%; border-radius: 20px" tabindex="-1" id="modal-study">

Expand All @@ -117,19 +43,35 @@
</div>
</div>

<?php require_once("footer.php") ?>
<?php
require_once("footer.php");
?>

<script src="../../plugins/echarts/echarts.min.5.4.js"></script>
<script src="plugins/echarts/echarts.min.5.4.js"></script>
<script type="text/javascript">
var chartDom = document.getElementById('main');
var width = chartDom.offsetWidth;
var height = chartDom.offsetHeight;
var myChart = echarts.init(chartDom);
var option;

var studydata = <?php echo json_encode($studydata); ?>;
var studydata = <?php echo json_encode($studydata); ?>;
var neednum = <?php echo json_encode($neednum); ?>;

var updatedData = [];
<?php
$maxX = max(array_column($pointposition, 'x')) - 150;
$maxY = max(array_column($pointposition, 'y'));

foreach ($pointposition as $tag => $position) {
$relativeX = $position['x'] / $maxX;
$relativeY = $position['y'] / $maxY;

echo "updatedData.push({name: '" . $tag . "', x: " . $relativeX . " * width, y: " . $relativeY .
" * height, symbol:'circle', symbolSize: 50, itemStyle: {color:'" . $nowcolor[$tag] . "'}});";
}
?>

option = {
title: {
text: '学习里程碑',
Expand Down Expand Up @@ -160,62 +102,44 @@
type: 'graph',
layout: 'none',
symbol: "roundRect",
symbolSize: 70,
symbolSize: 50,
roam: false,
label: {
show: true,
fontSize: 12
fontSize: 10
},
edgeSymbolSize: [0, 14],
edgeSymbolSize: [0, 10],
edgeLabel: {
fontSize: 30
},
categories: [{
name: 'Newbie',
itemStyle: {
color: '#cccccc',
color: '<?php echo $pointcolor[0]; ?>',
}
}, {
name: 'Learner',
itemStyle: {
color: '#d0f0c0'
color: '<?php echo $pointcolor[1]; ?>',
}
}, {
name: 'Expert',
itemStyle: {
color: '#aadf8f'
color: '<?php echo $pointcolor[2]; ?>',
}
}, {
name: 'Master',
itemStyle: {
color: '#85c96e'
color: '<?php echo $pointcolor[3]; ?>',
}
}],
data: [
<?php
$count = 0;
foreach ($pointposition as $tag => $position) {
if ($count < 8) { //前八个方形
echo "{name: '" . $tag . "',x: " . $position['x'] . ",y: " . $position['y'] .
",itemStyle: {color:'" . $nowcolor[$tag] . "' }},";
} else {
echo "{name: '" . $tag . "',x: " . $position['x'] . ",y: " . $position['y'] .
", symbol:'circle', symbolSize: 70, itemStyle: {color:'" . $nowcolor[$tag] . "'}},";
}
$count++;
}
foreach ($breakpoint as $tag => $position) {
echo "{name: '" . $tag . "',x: " . $position['x'] . ",y: " . $position['y'] .
", symbol:'circle', symbolSize: 0, tooltip: { show: false }, label: {show: false}},";
}
?>
],
data: updatedData,
links: links,
lineStyle: {
opacity: 0.9,
width: 3,
curveness: 0,
color: '#996633'
width: 2,
curveness: 0.1,
color: '#ffbc61'
}
}, ]
};
Expand All @@ -224,13 +148,22 @@

myChart.on('click', function(params) {

if (params.dataType === 'node' && params.data.name[0] != 'b') {
if (fatarray.includes(params.data.name)) {
var dataIndex = params.dataIndex;
// 收起或展开节点
myChart.dispatchAction({
type: params.data.collapsed ? 'expand' : 'collapse',
seriesIndex: 0,
dataIndex: dataIndex
});
} else {

// 获取被点击的标签
var tag = params.data.name;

// 发送 AJAX 请求
$.ajax({
url: 'getstudyproblems.php',
url: './template/hznu/getstudyproblems.php',
type: 'POST',
data: {
user: '<?php echo $user; ?>',
Expand Down Expand Up @@ -266,14 +199,6 @@
else if (score <= 80) colorClass = 'am-badge-warning';
else colorClass = 'am-badge-danger';

/////////////////////////////////cs
// if (index <= 2) colorClass = 'am-badge-success';
// else if (index <= 4) colorClass = 'am-badge-secondary';
// else if (index <= 6) colorClass = 'am-badge-primary';
// else if (index <= 8) colorClass = 'am-badge-warning';
// else colorClass = 'am-badge-danger';
//////////////////////////////////cs

return '<span class="am-badge ' + colorClass + ' am-round">' +
'<a href="/OJ/problem.php?id=' + problem.id + '" style="color: white;">' + problem.id + '</a></span>';
});
Expand Down
Loading

0 comments on commit e03111d

Please sign in to comment.