This repository has been archived on 2026-06-20. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
wsh5485 7e47ce238b chore: 添加多个图片和资源文件
添加了管理后台所需的图片资源、Excel文件、安装程序以及设计相关的图片文件
2025-06-15 13:04:37 +08:00

139 lines
3.7 KiB
PHP
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?php
/*
参数说明
$data_x(如:$data_x=1月,2月,3月)
$data_y(如:$data_y=订量,10,20,30|客户数,1,2,3),多组数据用|分隔
$t(目前支持pie|bar|line
$title(标题)
*/
error_reporting(E_ERROR | E_WARNING | E_PARSE);
date_default_timezone_set('Asia/Shanghai');
$data_x=$_GET["data_x"];
$data_y=$_GET["data_y"];
$t=$_GET["t"]?$_GET["t"]:"pie";
$title=$_GET["title"];
$h=$_GET["h"]?$_GET["h"]:0;
//格式化数据
$str_data_x=$str_data_y=$str_legend="";
//
$arr1=explode("|",$data_y);
$arrx=explode(",",$data_x);
if($t=="pie"){
for($i=0;$i<count($arrx);$i++){
$str_legend.="\"".$arrx[$i]."\",";
}
}
for($i=0;$i<count($arr1);$i++){
if($arr1[$i]){
$arr2=explode(",",$arr1[$i]);
if($t=="pie"){
for($j=1;$j<count($arr2);$j++){
if($arr2[$j]>=0)
$tmp2.="{name:'".$arrx[$j-1]."',value:".$arr2[$j]."},";
}
$str_data_y.="{name:'".$arr2[0]."',label:{normal: {show: true, position: 'top'}},type:'".$t."',data:[".substr($tmp2,0,-1)."]},";
}else if($t=="line"){
if($arr2[0])
$str_legend.="\"".$arr2[0]."\",";
$tmp2=" ";
for($j=1;$j<count($arr2);$j++){
if($arr2[$j]>=0)
$tmp2.=$arr2[$j].",";
}
$str_data_y.="{name:'".$arr2[0]."',label:{normal: {show: true, position: 'top'}},type:'".$t."', yAxisIndex: ".$i.",data:[".substr($tmp2,0,-1)."]},";
}else{
if($arr2[0])
$str_legend.="\"".$arr2[0]."\",";
$tmp2=" ";
for($j=1;$j<count($arr2);$j++){
if($arr2[$j]>=0)
$tmp2.=$arr2[$j].",";
}
$str_data_y.="{name:'".$arr2[0]."',label:{normal: {show: true, position: 'top'}},type:'".$t."',data:[".substr($tmp2,0,-1)."]},";
}
}
}
if($str_data_y)
$str_data_y=substr($str_data_y,0,-1);
if($str_legend)
$str_legend=substr($str_legend,0,-1);
//处理data_x
for($i=0;$i<count($arrx);$i++){
$str_data_x.="\"".$arrx[$i]."\",";
}
if($str_data_x)
$str_data_x=substr($str_data_x,0,-1);
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="renderer" content="webkit">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
<title>echart图表</title>
<link rel="stylesheet" href="index.css">
<script src="js/echarts.common.min.js"></script>
</head>
<body style="background-color:#ffffff;">
<div style="width:100%;" id="other"></div>
<div style="width:100%;" id="chart"></div>
<script type="text/javascript">
//自适应高度
window.onload = windowHeight();
function windowHeight() {
var chart_h=<?php echo $h; ?>;
var bodyHeight = document.getElementById("chart");
if(chart_h==0){
var h = document.documentElement.clientHeight;
bodyHeight.style.height = (h - 25) + "px";
}else{
bodyHeight.style.height = chart_h + "px";
}
}
var myChart = echarts.init(document.getElementById('chart'));
var title="<?php echo $title; ?>";
var t="<?php echo $t; ?>";
var data_x=[<?php echo $str_data_x; ?>];
var data_y=[<?php echo $str_data_y; ?>];
var data_legend=[<?php echo $str_legend; ?>];
switch(t){
case "pie":
var option = {
title : {text: title,x:'center'},
tooltip : {
trigger: 'item',
formatter: "{a} <br/>{b} : {c} ({d}%)"
},
legend: {
orient: 'vertical',
left: 'left',
data: data_legend
},
series: data_y
};
break;
case "line":
var option = {
title: {text: title},
tooltip : {trigger: 'axis'},
legend: {data:data_legend},
xAxis: {data:data_x},
yAxis: [{type: 'value'},{type: 'value'}],
series: data_y
};
break;
case "bar":
var option = {
title: {text: title},
legend: {data:data_legend},
xAxis: {data:data_x},
yAxis: {type: 'value'},
series: data_y
};
break;
}
// 使用刚指定的配置项和数据显示图表。
myChart.setOption(option);
</script>
</body>
</html>