⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 datagraphic.js

📁 花钱买的毕业设计。企业网络管理系统
💻 JS
字号:
// JavaScript Document
System.LoadUnit("BasicGraphic");
//直方图
function BarChart(arrData,arrClr,arrText,arrLabel)
{
  this.Data = arrData;
  this.Color = arrClr;
  this.Text = arrText;
  this.Label = arrLabel;
  this.BarWidth = 30;
  this.BarHeight = 200;
  this.BarInterval = 10;
  this.TextSize = 12;
  this.Draw = function()
  {
    var i;
    var x,y,w,h,c,lw;
    x = 0;
    y = 0;
    w = this.BarWidth;
    h = 0;
    for(i=0;i<this.Data.length;i++)
    {
      x = (this.BarInterval+this.BarWidth)*i;
      h = this.Data[i]*this.BarHeight;
      c = this.Color[i];
      (new Rectangle(x,y,w,h,c)).Draw();
      (new Text(new Point(x+5,y+h/2+this.TextSize/2),this.Text[i],this.TextSize)).Draw();
      (new Text(new Point(x+5,y-this.TextSize/2),this.Label[i],this.TextSize)).Draw();
    }
  }
}
//饼图
function CakeChart(arrData,arrClr,arrText)
{
  this.Data = arrData;
  this.Color = arrClr;
  this.Text = arrText;
	this.Center = new Point(100,0);
  this.Radius = 100;
  this.Interval = 10;
  this.TextSize = 10;
  this.Draw = function()
  {
    var i = 0;
    //sa StartAngle;ca CenterAngle;
    var sa,ca,a,x,y,r,c;
    sa = 0;
    r = this.Radius;
    //(new Circle(this.Center,this.Interval,"green")).Draw();
    for(i=0;i<this.Data.length;i++)
    {
      a = this.Data[i]*360;
      ca = sa + a/2;
      c = this.Color[i];
      x = this.Center.X+this.Interval*Math.cos(ca*Math.PI/180);
      y = this.Center.Y+this.Interval*Math.sin(ca*Math.PI/180);
      (new Arc(new Point(x,y),r,a,sa,c,true)).Draw();
      (new Text(new Point(x+r/2*Math.cos(ca*Math.PI/180),y+r/2*Math.sin(ca*Math.PI/180)+this.TextSize/2),this.Text[i],this.TextSize)).Draw();
      sa += a;
    }
  }

}
//走势图
function TrendChart(arrData,arrLabel,arrText,c,m)
{
  this.Data = arrData;
  this.Label = arrLabel;
  this.Text = arrText;
  this.Points = [];
  this.Interval = 40;
	this.Color = c;
  if(typeof(m)=="undefined")
    this.Multiple = 1;
  else
    this.Multiple = m;
  this.TextSize = 12;
  this.AddPoint = function(p)
  {
    var l = this.Points.length;
    this.Points[l] = p;
  }
  this.Draw = function()
  {
    var i;
    var x,y,w,h,c,lw;
    x = 0;
    y = 0;
    h = 0;
		c = this.Color;
    for(i=0;i<this.Data.length;i++)
    {
      x = this.Interval*i;
      h = this.Data[i]*this.Multiple;
      //(new Beeline(new Point(x,y),new Point(x,y+h),c)).Draw();
      (new Text(new Point(x-5,y+h/2+this.TextSize/2),this.Text[i],this.TextSize)).Draw();
      (new Text(new Point(x-5,y+this.TextSize/2),this.Label[i],this.TextSize)).Draw();
      this.AddPoint(new Point(x,y+h));
    }
    (new Polygon(this.Points,false,c)).Draw();
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -