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

📄 charting.js

📁 在流览器上仿CS界面的JAVASCRIPT脚本
💻 JS
📖 第 1 页 / 共 3 页
字号:
/* * Bindows 1.10 * http://www.bindows.net/ * Copyright (c) 2003-2004 MB Technologies * * Bindows(tm) belongs to MB Technologies (Georgia, USA). All rights reserved. * You are not allowed to copy or modify this code. Commercial use requires * license. */function BiGraph(){BiGraphBase.call(this);this._contentArea=new BiGraphContentArea;this._chartArea=new BiChartArea(this);this._valueAxis=new BiChartValueAxis(this);this._categoryAxis=new BiChartCategoryAxis(this);this._gridLines=new BiChartGridLines(this);this._legend=new BiChartLegend(this);this._contentArea.add(this._chartArea);this.add(this._contentArea);this._chartArea.add(this._gridLines);this._chartArea.add(this._valueAxis);this._chartArea.add(this._categoryAxis);this.add(this._legend);};_p=BiGraph.prototype=new BiGraphBase;_p._className="BiGraph";_p._chartType="line"
BiGraph._createVmlElement=function(sTagName){var c=new BiComponent;c._tagName=sTagName||"v:shape";return c;};BiGraph._vmlComponent1000=function(o){o.setHtmlProperty("coordsize","1000,1000");o.setHtmlProperty("coordorigin","0,0");o.setLocation(0,0);o.setSize(1000,1000);};_p._autoScale=true;_p._scaleFactor=1e4;_p._catScaleFactor=1e4;_p.setAutoScale=function(b)
{if(this._autoScale!=b)
{this._autoScale=b;if(b)
{this._contentArea.setHtmlProperty("coordsize","1000,1000");this._chartArea.setLocation(this._chartAreaLeft,this._chartAreaTop);this._chartArea.setSize(this._chartAreaWidth,this._chartAreaHeight);this._legend.setRight(10);this._legend.setWidth(null);this._legend.setLocation(null,null);this._legend._topSet=false;}
if(this.getCreated())
this.layoutAllChildren();}};_p.layoutAllChildren=function()
{if(!this._autoScale)
{this._contentArea.setHtmlProperty("coordsize",this.getClientWidth()+","+this.getClientHeight());}
this._scaleFont();BiGraphBase.prototype.layoutAllChildren.call(this);};_p.layoutAllChildrenX=function()
{if(!this._autoScale)
{this._contentArea.setHtmlProperty("coordsize",this.getClientWidth()+","+this.getClientHeight());}
this._scaleFont();BiGraphBase.prototype.layoutAllChildrenX.call(this);};_p.layoutAllChildrenY=function()
{if(!this._autoScale)
{this._contentArea.setHtmlProperty("coordsize",this.getClientWidth()+","+this.getClientHeight());}
this._scaleFont();BiGraphBase.prototype.layoutAllChildren.call(this);};_p._createChartFromSeries=function(oSeries){var c;switch(this._chartType){case"pie":c=new BiPieChart(this,oSeries);break;case"bar":c=new BiBarChart(this,oSeries);break;case"stackedbar":c=new BiStackedBarChart(this,oSeries);break;case"percentagestackedbar":c=new BiPercentageStackedBarChart(this,oSeries);break;case"column":c=new BiColumnChart(this,oSeries);break;case"stackedcolumn":c=new BiStackedColumnChart(this,oSeries);break;case"percentagestackedcolumn":c=new BiPercentageStackedColumnChart(this,oSeries);break;case"line":default:c=new BiLineChart(this,oSeries);break;}
this._charts[oSeries.getId()]=c;this._chartArea.add(c);};_p.update=function(){this._syncChartForSeries();this._updateCoordSize();this._updateCharts();this._legend._update();this._valueAxis._updateVisible();this._categoryAxis._updateVisible();this._gridLines._updateVisible();if(this.getChartType()=="grid")
this._gridComponent.update();};BiGraph.fromXmlDocument=function(oDoc){var g=new BiGraph;g.fromXmlDocument(oDoc);return g;};BiGraph.fromUri=function(sUri){var g=new BiGraph;var xmlLoader=new BiXmlLoader;xmlLoader.setAsync(false);xmlLoader.load(sUri);g.fromXmlDocument(xmlLoader.getDocument());xmlLoader.dispose();return g;};_p._updateCoordSize=function(){this._valueAxis._clearCache();var max=this._valueAxis.getMaximum();var min=this._valueAxis.getMinimum();var catCoordSize=this._categoryAxis.getMaximum();var absMax=Math.max(Math.abs(max),Math.abs(min));var pow=Math.floor(Math.log(absMax)/Math.log(10));this._scaleFactor=Math.pow(10,4-pow);max=Math.ceil(max*this._scaleFactor);min=Math.floor(min*this._scaleFactor);var coordSize,coordOrigin;if(this._getCategoryOnXAxis()){coordSize=catCoordSize*this._catScaleFactor+","+(max-min);coordOrigin="0,"+min;}
else{coordSize=(max-min)+","+catCoordSize*this._catScaleFactor;coordOrigin=min+",0";}
this._chartArea._updateCoordSize(coordSize,coordOrigin);this._valueAxis._updateCoordSize(coordSize,coordOrigin);this._categoryAxis._updateCoordSize(coordSize,coordOrigin);this._gridLines._updateCoordSize(coordSize,coordOrigin);};BiGraph._addExtendedFillInterface=function(p){p._fillOpacity=null;p._fillColor2=null;p._fillType=null;p._fillAngle=null;p._createFillEl=function(oParent){this._fillEl=BiGraph._createVmlElement("v:fill");(oParent||this).add(this._fillEl);this.setFillOpacity(this.getFillOpacity());this.setFillColor2(this.getFillColor2());this.setFillType(this.getFillType());this.setFillAngle(this.getFillAngle());};p.setFillOpacity=function(n){this._fillOpacity=n;this._fillEl.setHtmlProperty("opacity",n);};p.getFillOpacity=function(){return this._fillOpacity;};p.hasFillOpacity=function(){return this._fillOpacity!=null;};p.setFillColor2=function(s){this._fillColor2=s;this._fillEl.setHtmlProperty("color2",s);};p.getFillColor2=function(){return this._fillColor2;};p.hasFillColor2=function(){return this._fillColor2!=null;};p.setFillType=function(s){this._fillType=s;this._fillEl.setHtmlProperty("type",s);};p.getFillType=function(){return this._fillType;};p.hasFillType=function(){return this._fillType!=null;};p.setFillAngle=function(s){this._fillAngle=s;this._fillEl.setHtmlProperty("angle",s);};p.getFillAngle=function(){return this._fillAngle;};p.hasFillAngle=function(){return this._fillAngle!=null;};};BiGraph._addExtendedStrokeInterface=function(p){p._strokeOpacity=null;p._createStrokeEl=function(oParent){this._strokeEl=BiGraph._createVmlElement("v:stroke");(oParent||this).add(this._strokeEl);this.setStrokeOpacity(this.getStrokeOpacity());};p.setStrokeOpacity=function(n){this._strokeOpacity=n;this._strokeEl.setHtmlProperty("opacity",n);};p.getStrokeOpacity=function(){return this._strokeOpacity;};p.hasStrokeOpacity=function(){return this._strokeOpacity!=null;};};function BiGraphContentArea()
{BiComponent.call(this);this.setHtmlProperty("coordsize","1000,1000");this.setLocation(0,0);this.setRight(0);this.setBottom(0);}
_p=BiGraphContentArea.prototype=new BiComponent;_p._className="BiGraphContentArea";_p._tagName="V:group";_p.getClientWidth=function()
{var p=this.getParent();if(p)
return p.getClientWidth();return BiComponent.prototype.getClientWidth.call(this);};_p.getClientHeight=function()
{var p=this.getParent();if(p)
return p.getClientHeight();return BiComponent.prototype.getClientHeight.call(this);};function BiChartArea(oGraph)
{BiChartAreaBase.call(this,oGraph);this.setStyleProperty("flip","y");this.setLocation(oGraph._chartAreaLeft,oGraph._chartAreaTop);this.setSize(oGraph._chartAreaWidth,oGraph._chartAreaHeight);this.setHtmlProperty("coordsize","1000,1000");this.setHtmlProperty("coordorigin","0,0");this._backgroundRect=BiGraph._createVmlElement("v:rect");this._backgroundRect.setLocation(0,0);this._backgroundRect.setSize(1000,1000);this._backgroundRect.setHtmlProperty("stroked",false);this._backgroundRect.setHtmlProperty("fillcolor","white");this._backgroundRect.setZIndex(0);this._backgroundRect.setStyleProperty("antialias","false");this._outlineRect=BiGraph._createVmlElement("v:rect");this._outlineRect.setLocation(0,0);this._outlineRect.setSize(1000,1000);this._outlineRect.setHtmlProperty("filled",false);this._outlineRect.setHtmlProperty("strokecolor","black");this._outlineRect.setZIndex(1);this._outlineRect.setStyleProperty("antialias","false");this.add(this._backgroundRect);this.add(this._outlineRect);this._createFillEl(this._backgroundRect);this._createStrokeEl(this._backgroundRect);this.addEventListener("resize",this._onResize);};var _p=BiChartArea.prototype=new BiChartAreaBase;_p._className="BiChartArea";_p._tagName="v:group";_p._onResize=function(e){if(this._graph.getChartType()=="pie"&&this._graph.getCharts()[0]._updateAspectRatio){this._graph.getCharts()[0]._updateAspectRatio();}};_p.setFillColor=function(s){this._fillColor=s;this._backgroundRect.setHtmlProperty("filled",s!="transparent");this._backgroundRect.setHtmlProperty("fillcolor",s);};_p.setStrokeColor=function(s){this._strokeColor=s;this._outlineRect.setHtmlProperty("stroked",s!="transparent");this._outlineRect.setHtmlProperty("strokecolor",s);};BiGraph._addExtendedFillInterface(_p);BiGraph._addExtendedStrokeInterface(_p);BiChartArea.fromXmlElement=function(oGraph,oNode){var ca=new BiChartArea(oGraph);ca.fromXmlElement(oNode);return ca;};function BiVmlLabel(sText){BiComponent.call(this);this.setHtmlProperty("coordsize","1,1");this.setSize(10000,10000);if(sText!=null)this._text=sText;this.setStyleProperty("antialias","true");this.setStyleProperty("fontSize","11px");};var _p=BiVmlLabel.prototype=new BiComponent;_p._className="BiVmlLabel";_p._tagName="v:group";_p._text="";_p._align="center";_p._flipY=true;_p.setAlign=function(sAlign){if(this._align!=sAlign){this._align=sAlign;if(this.getCreated()){this._textPathEl.style["v-text-align"]=sAlign;var y=this._flipY?1:0;var x,w=100;if(this._align=="left")x=0;else if(this._align=="right")x= -100;else x= -50;se.path="m"+x+","+y+"l"+(x+w)+","+y;}}};BiVmlLabel.prototype.getAlign=function(){return this._align;};_p.setText=function(sText){if(this._text!=sText){this._text=sText;if(this.getCreated())
this._textPathEl.style["v-text-align"]=sAlign;}};_p._create=function(oDoc){BiComponent.prototype._create.call(this,oDoc);var se=this._shapeEl=this._document.createElement("v:shape");var pe=this._pathEl=this._document.createElement("v:path");var tp=this._textPathEl=this._document.createElement("v:textpath");se.stroked=false;se.style.width="100%";se.style.height="100%";se.fillcolor="black";if(this._flipY)se.style.flip="y";var y=this._flipY?1:0;var x,w=100;if(this._align=="left")x=0;else if(this._align=="right")x= -100;else x= -50;se.path="m"+x+","+y+"l"+(x+w)+","+y;pe.textpathok=true;tp.on=true;tp.string=this._text;tp.style["v-text-align"]=this._align;se.appendChild(pe);se.appendChild(tp);this._element.appendChild(se);};_p._dispose=function(){if(this._disposed)return;BiComponent.prototype.dispose.call(this);if(this._shapeEl)
this._shapeEl.outerHTML="";this._shapeEl=null;if(this._pathEl)
this._pathEl.outerHTML="";this._pathEl=null;if(this._textPathEl)
this._textPathEl.outerHTML="";this._textPathEl=null;};_p.setFontSize=function(n){this.setStyleProperty("fontSize",n+"px");if(this._created)

⌨️ 快捷键说明

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