?? charting2.js
字號:
/* * 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 BiChartArea2(oGraph)
{BiChartAreaBase.call(this,oGraph);this._backgroundComponent=new BiComponent;this._backgroundComponent.setLocation(0,0);this.setLocation(30,30)
this.setRight(30);this.setBottom(30);this.add(this._backgroundComponent,null,true);};var _p=BiChartArea2.prototype=new BiChartAreaBase;_p._className="BiChartArea2";_p.setFillColor=function(s){this._fillColor=s;this._backgroundComponent.setBackColor(s);};_p.setFillOpacity=function(n)
{this._fillOpacity=n;this._backgroundComponent.setOpacity(n);};_p.setStrokeColor=function(s){this._strokeColor=s;if(!this._strokeBorder)
this._strokeBorder=new BiBorder(1,"solid");this._strokeBorder.setWidth(s=="transparent"?0:1);this._strokeBorder.setColor(s);this._backgroundComponent.setBorder(this._strokeBorder);};BiChartArea2.fromXmlElement=function(oGraph,oNode){var ca=new BiChartArea2(oGraph);ca.fromXmlElement(oNode);return ca;};_p.layoutComponent=function()
{this._graph._resetScaleFactor();BiComponent.prototype.layoutComponent.call(this);this._backgroundComponent.setSize(this.getWidth(),this.getHeight());};_p.layoutComponentX=function()
{this._graph._resetScaleFactor();BiComponent.prototype.layoutComponentX.call(this);this._backgroundComponent.setWidth(this.getWidth());};_p.layoutComponentY=function()
{this._graph._resetScaleFactor();BiComponent.prototype.layoutComponentY.call(this);this._backgroundComponent.setHeight(this.getHeight());};function BiAbstractChart2(oGraph,oSeries)
{if(!oGraph)
return;BiAbstractChartBase.call(this,oGraph,oSeries);this.setLocation(0,0);this.setRight(0);this.setBottom(0);this.setStyleProperty("visibility","hidden");};var _p=BiAbstractChart2.prototype=new BiAbstractChartBase;_p._className="BiAbstractChart2";function BiAbstractChartSection2(oChart,oCategory)
{if(!oChart)
return;BiAbstractChartSectionBase.call(this,oChart,oCategory);this.setFillColor(this.getFillColor());this.setStrokeColor(this.getStrokeColor());this.setFillOpacity(this.getFillOpacity());this.setStyleProperty("visibility","visible");};var _p=BiAbstractChartSection2.prototype=new BiAbstractChartSectionBase;_p._className="BiAbstractChartSection2";_p._defaultStrokeBorder=new BiBorder(1,"solid","black");_p.setStrokeColor=function(s)
{this._strokeColor=s;if(!this._strokeBorder)
this._strokeBorder=new BiBorder(1,"solid");this._strokeBorder.setWidth(s=="transparent"?0:1);this._strokeBorder.setColor(s);this.setBorder(this._strokeBorder);};_p.setFillColor=function(s)
{this.setBackColor(s);};_p.setFillOpacity=function(n)
{this.setOpacity(n);};function BiChartCategoryAxis2(oGraph)
{BiChartCategoryAxisBase.call(this,oGraph);this.setStyleProperty("visibility","hidden");this.setLocation(0,0);this.setRight(0);this.setBottom(0);this._axisLine=new BiComponent;this._axisLine.setBackColor("black");this._axisLine.setStyleProperty("visibility","visible");this.add(this._axisLine);};var _p=BiChartCategoryAxis2.prototype=new BiChartCategoryAxisBase;_p._className="BiChartCategoryAxis2";_p._updateAxisLine=function()
{if(!this.getCreated()||!this._desiredVisible)
return;var onX=this._graph._getCategoryOnXAxis();var ca=this._graph.getChartArea();var sf=this._graph._getScaleFactor();var csf=this._graph._getCatScaleFactor();if(!onX)
{var minValue=this._graph.getValueAxis().getMinimum();this._axisLine.setBounds(ca.getLeft()-minValue*sf,ca.getTop(),1,ca.getHeight());}
else {var maxVal=this._graph.getValueAxis().getMaximum();this._axisLine.setBounds(ca.getLeft(),ca.getTop()+maxVal*sf-1,ca.getWidth(),1);}};_p._updateMajorTicks=function(){};_p._updateMinorTicks=function(){};_p._createLabels=function()
{if(!this.getCreated()||!this._desiredVisible)
return;var l;for(var i=this._labels.length-1;i>=0;i--)
{l=this._labels[i];this.remove(l);l.dispose();}
this._labels=[];if(this._showLabels)
{var major=this._graph._categoryAxis.getMajorTickInterval();var catMax=this._graph._categoryAxis.getMaximum();var x=this._axisBetweenCategories?0.5:0;var cats=this._graph.getCategories();var l;var onX=this._graph._getCategoryOnXAxis();while(x<=catMax)
{l=new BiLabel(cats[Math.floor(x)].getTitle());l.setStyleProperty("visibility","visible");l.setWidth(100);l._chartValue=x;l.setStyleProperty("fontSize",this._fontSize+"px");if(onX)
{l.setAlign("center");}
else{l.setAlign("right");}
this.add(l);this._labels.push(l);x+=major;}}};_p._layoutLabels=function()
{if(this.getCreated()&&this._showLabels&&this._desiredVisible)
{var l,v;var caTop=this._graph.getChartArea().getTop();var caHeight=this._graph.getChartArea().getHeight();var caLeft=this._graph.getChartArea().getLeft();var sf=this._graph._getScaleFactor();var csf=this._graph._getCatScaleFactor();var onX=this._graph._getCategoryOnXAxis();var maxVal=this._graph.getValueAxis().getMaximum();var minVal=this._graph.getValueAxis().getMinimum();for(var i=0;i<this._labels.length;i++)
{l=this._labels[i];v=l._chartValue;if(onX)
{l.setLocation(caLeft+v*csf-50,caTop+maxVal*sf+3);}
else {l.setLocation(caLeft-minVal*sf-103,caTop+caHeight-v*csf-l.getHeight()/2);}}}};_p._updateLabels=function()
{this._createLabels();this._layoutLabels();};_p.setFontSize=function(n)
{this._fontSize=n;for(var i=0;i<this._labels.length;i++)
this._labels[i].setStyleProperty("fontSize",n+"px");this._layoutLabels();};_p.setVisible=function(b)
{this._desiredVisible=b;var s=b&&this._graph._getSupportsCategoryAxis()?"visible":"hidden";this._axisLine.setStyleProperty("visibility",s);for(var i=0;i<this._labels.length;i++)
this._labels[i].setStyleProperty("visibility",s);};BiChartCategoryAxis2.fromXmlElement=function(oGraph,oNode){var ax=new BiChartCategoryAxis2(oGraph);ax.fromXmlElement(oNode);return ax;};_p.layoutAllChildren=function()
{BiComponent.prototype.layoutAllChildren.call(this);this._layoutLabels();this._updateAxisLine();};_p.layoutAllChildrenX=function()
{BiComponent.prototype.layoutAllChildrenX.call(this);this._layoutLabels();this._updateAxisLine();};_p.layoutAllChildrenY=function()
{BiComponent.prototype.layoutAllChildrenY.call(this);this._layoutLabels();this._updateAxisLine();};function BiChartValueAxis2(oGraph)
{BiChartValueAxisBase.call(this,oGraph);this.setStyleProperty("visibility","hidden");this.setLocation(0,0);this.setRight(0);this.setBottom(0);this._axisLine=new BiComponent;this._axisLine.setBackColor("black");this._axisLine.setStyleProperty("visibility","visible");this.add(this._axisLine);};_p=BiChartValueAxis2.prototype=new BiChartValueAxisBase;_p._className="BiChartValueAxis2";_p._showMajorTicks=false;_p._showMinorTicks=false;_p._updateAxisLine=function()
{if(!this.getCreated()||!this._desiredVisible)
return;var onX=this._graph._getCategoryOnXAxis();var ca=this._graph.getChartArea();if(onX)
{this._axisLine.setBounds(ca.getLeft(),ca.getTop(),1,ca.getHeight());}
else {this._axisLine.setBounds(ca.getLeft(),ca.getTop()+ca.getHeight()-1,ca.getWidth(),1);}};_p._updateMajorTicks=function(){};_p._updateMinorTicks=function(){};_p._createLabels=function()
{if(!this.getCreated()||!this._desiredVisible)
return;var l;for(var i=this._labels.length-1;i>=0;i--)
{l=this._labels[i];this.remove(l);l.dispose();}
this._labels=[];if(this._showLabels)
{var min=this.getMinimum();var max=this.getMaximum();var major=this.getMajorTickInterval();var y=min;if(y/major%1!=0)
y=y+(min<0?0:major)-y%major;var l,ys;var onX=this._graph._getCategoryOnXAxis();var percentage=this._graph._getPercentageStack();while(y<=max)
{if(percentage)
ys=Math.round(y*100)+"%";else ys=String(y);l=new BiLabel(ys);l.setStyleProperty("visibility","visible");l.setWidth(100);l._chartValue=y;l.setStyleProperty("fontSize",this._fontSize+"px");if(onX){l.setAlign("right");}
else{l.setAlign("center");}
this.add(l);this._labels.push(l);y+=major;y=Math.round(y/major)*major;}}};_p._layoutLabels=function()
{if(this.getCreated()&&this._showLabels&&this._desiredVisible)
{var onX=this._graph._getCategoryOnXAxis();var minVal=this.getMinimum();var maxVal=this.getMaximum();var sf=this._graph._getScaleFactor();var l,v;var caTop=this._graph.getChartArea().getTop();var caHeight=this._graph.getChartArea().getHeight();var caLeft=this._graph.getChartArea().getLeft();for(var i=0;i<this._labels.length;i++)
{l=this._labels[i];v=l._chartValue;if(onX)
{l.setLocation(caLeft-100-3,caTop+(maxVal-v)*sf-l.getHeight()/2);}
else {l.setLocation(caLeft+(v-minVal)*sf-50,caTop+caHeight+3);}}}};_p._updateLabels=function()
{this._createLabels();this._layoutLabels();};_p.setFontSize=function(n)
{this._fontSize=n;for(var i=0;i<this._labels.length;i++)
this._labels[i].setStyleProperty("fontSize",n+"px");this._layoutLabels();};_p.setVisible=function(b)
{this._desiredVisible=b;var s=b&&this._graph._getSupportsValueAxis()?"visible":"hidden";this._axisLine.setStyleProperty("visibility",s);for(var i=0;i<this._labels.length;i++)
this._labels[i].setStyleProperty("visibility",s);};BiChartValueAxis2.fromXmlElement=function(oGraph,oNode){var ax=new BiChartValueAxis2(oGraph);ax.fromXmlElement(oNode);return ax;};_p.layoutAllChildren=function()
{BiChartValueAxisBase.prototype.layoutAllChildren.call(this);this._layoutLabels();this._updateAxisLine();};_p.layoutAllChildrenX=function()
{BiChartValueAxisBase.prototype.layoutAllChildrenX.call(this);this._layoutLabels();this._updateAxisLine();};_p.layoutAllChildrenY=function()
{BiChartValueAxisBase.prototype.layoutAllChildrenY.call(this);this._layoutLabels();this._updateAxisLine();};function BiColumnChart2(oGraph,oSeries)
{if(!oGraph)
return;BiAbstractChart2.call(this,oGraph,oSeries);this._rectsByCat={};};_p=BiColumnChart2.prototype=new BiAbstractChart2;_p._className="BiColumnChart2";_p._isBar=false;_p._isStacked=false;_p._isPercentage=false;_p._barSpacing=1;_p.getComponentByCategoryId=function(sCatId){return this._rectsByCat[sCatId];};_p._updateChart=function()
{var cs=this._children;var c;for(var i=cs.length-1;i>=0;i--)
{c=cs[i];this.remove(c);c.dispose();}
var vs=this._series.getValues();var l=vs.length;var cats=this._graph.getCategories();var id;var rect;for(var i=0;i<l;i++)
{if(vs[i]!=null)
{id=cats[i].getId();rect=new BiColumnChartSection2(this,cats[i]);this._rectsByCat[id]=rect;this.add(rect);}}};_p.layoutChild=function(c)
{if(!c._layoutSuspendCount)
c._doLayout();BiAbstractChart2.prototype.layoutChild.call(this,c);};_p.layoutChildX=function(c)
{if(!c._layoutSuspendCount)
c._doLayout();BiAbstractChart2.prototype.layoutChildX.call(this,c);};_p.layoutChildY=function(c)
{if(!c._layoutSuspendCount)
c._doLayout();BiAbstractChart2.prototype.layoutChildY.call(this,c);};_p.update=function(){this._updateChart();};_p._updateValues=function(){var cats=this._graph.getCategories();for(var i=0;i<cats.length;i++){this._updateValueByCategoryId(cats[i].getId());}};_p._updateValueByCategoryId=function(sId){this._updateRectByCategoryId(sId);if(this._isStacked){var charts=this._graph.getCharts();var found=this._graph._getPercentageStack();for(var i=0;i<charts.length;i++){if(!found&&charts[i]==this){found=this;continue;}
if(found){charts[i]._updateRectByCategoryId(sId);}}}};_p._updateRectByCategoryId=function(sId){var rect=this._rectsByCat[sId];if(!rect)return;rect._doLayout();};_p._getRectHeight=function(sCategoryId){return Number(this._series.getValueByCategoryId(sCategoryId));};_p._getRectTop=function(sCategoryId){return 0;};_p.dispose=function(){if(this._disposed)return;BiAbstractChart2.prototype.dispose.call(this);for(var hc in this._rectsByCat)
delete this._rectsByCat[hc];this._rectsByCat=null;};function BiBarChart2(oGraph,oSeries){BiColumnChart2.call(this,oGraph,oSeries);};_p=BiBarChart2.prototype=new BiColumnChart2;_p._className="BiBarChart2";_p._isBar=true;function BiStackedColumnChart2(oGraph,oSeries){BiColumnChart2.call(this,oGraph,oSeries);};_p=BiStackedColumnChart2.prototype=new BiColumnChart2;_p._className="BiStackedColumnChart2";_p._isBar=false;_p._isStacked=true;_p._getRectHeight=function(sCategoryId){return Math.abs(this._series.getValueByCategoryId(sCategoryId));};_p._getRectTop=function(sCategoryId){var charts=this._graph.getCharts();var sum=0;for(var i=0;i<charts.length;i++){if(charts[i]==this)
return sum;sum+=Math.abs(charts[i]._series.getValueByCategoryId(sCategoryId));}
return sum;};function BiStackedBarChart2(oGraph,oSeries){BiStackedColumnChart2.call(this,oGraph,oSeries);};_p=BiStackedBarChart2.prototype=new BiStackedColumnChart2;_p._className="BiStackedBarChart2";_p._isBar=true;function BiPercentageStackedColumnChart2(oGraph,oSeries){BiColumnChart2.call(this,oGraph,oSeries);};_p=BiPercentageStackedColumnChart2.prototype=new BiColumnChart2;_p._className="BiPercentageStackedColumnChart2";_p._isBar=false;_p._isStacked=true;_p._isPercentage=true;_p._getRectHeight=function(sCategoryId){var charts=this._graph.getCharts();var sum=0;for(var i=0;i<charts.length;i++){sum+=Math.abs(charts[i]._series.getValueByCategoryId(sCategoryId));}
return Math.abs(this._series.getValueByCategoryId(sCategoryId))/sum;};_p._getRectTop=function(sCategoryId){var charts=this._graph.getCharts();var sum=0;var y;for(var i=0;i<charts.length;i++){if(charts[i]==this)
y=sum;sum+=Math.abs(charts[i]._series.getValueByCategoryId(sCategoryId));}
return y/sum;};function BiPercentageStackedBarChart2(oGraph,oSeries){BiPercentageStackedColumnChart2.call(this,oGraph,oSeries);};_p=BiPercentageStackedBarChart2.prototype=new BiPercentageStackedColumnChart2;_p._className="BiPercentageStackedBarChart2";_p._isBar=true;function BiColumnChartSection2(oChart,oCategory){BiAbstractChartSection2.call(this,oChart,oCategory);}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -