📄 charting2.js
字号:
_p=BiColumnChartSection2.prototype=new BiAbstractChartSection2;_p._className="BiColumnChartSection2";_p._layoutSuspendCount=0;_p._doLayout=function()
{this._layoutSuspendCount++;var chartCount=this._graph.getCharts().length;var chartIndex=this._series.getIndex();var chart=this._chart;var bs=chart.getBarSpacing();var stacked=chart._isStacked;var w=stacked?1/(1+bs):1/(chartCount+bs);var dx=bs*w/2+(stacked?0:chartIndex*w)-(this._graph._categoryAxis.getAxisBetweenCategories()?0:0.5);var i=this._category.getIndex();var id=this._categoryId;var v=this._series.getValueByCategoryId(id);var sf=this._graph._getScaleFactor();var csf=this._graph._getCatScaleFactor();var minVal=this._graph._valueAxis.getMinimum();var maxVal=this._graph._valueAxis.getMaximum();var h=chart._getRectHeight(id);var t=chart._getRectTop(id);if(chart._isBar)
{var catCount=this._graph.getCategories().length;var hsf=Math.round(h*sf);var mtsf=(t-minVal)*sf;if(h>=0)
{this.setBounds(mtsf,csf*(catCount-1-i+dx),hsf,csf*w);}
else {this.setBounds(mtsf+hsf+1,csf*(catCount-1-i+dx),-hsf,csf*w);}}
else {var hsf=Math.round(h*sf);var mtsf=Math.round((maxVal-t)*sf);if(h>=0)
{this.setBounds(csf*(i+dx),mtsf-hsf,csf*w,hsf);}
else {this.setBounds(csf*(i+dx),mtsf-1,csf*w,-hsf);}}
this._layoutSuspendCount--;};function BiChartGridLines2(oGraph)
{BiChartGridLinesBase.call(this,oGraph);this.setLocation(0,0);this.setRight(0);this.setBottom(0);this._minorCategoryLines=[];this._minorValueLines=[];this._majorCategoryLines=[];this._majorValueLines=[];};var _p=BiChartGridLines2.prototype=new BiChartGridLinesBase;_p._className="BiChartGridLines2";_p.setMinorCategoryStrokeColor=function(s)
{this._minorCategoryStrokeColor=s;for(var i=0;i<this._minorCategoryLines.length;i++)
this._minorCategoryLines[i].setBackColor(s);};_p.setMajorCategoryStrokeColor=function(s)
{this._majorCategoryStrokeColor=s;for(var i=0;i<this._majorCategoryLines.length;i++)
this._majorCategoryLines[i].setBackColor(s);};_p.setMinorValueStrokeColor=function(s)
{this._minorValueStrokeColor=s;for(var i=0;i<this._minorValueLines.length;i++)
this._minorValueLines[i].setBackColor(s);};_p.setMajorValueStrokeColor=function(s)
{this._majorValueStrokeColor=s;for(var i=0;i<this._majorValueLines.length;i++)
this._majorValueLines[i].setBackColor(s);};_p.dispose=function(){if(this._disposed)return;BiChartGridLinesBase.prototype.dispose.call(this);for(var i=this._majorValueLines.length-1;i>=0;i--)
{this._majorValueLines[i].dispose();this._majorValueLines[i]=null;}
for(var i=this._minorValueLines.length-1;i>=0;i--)
{this._minorValueLines[i].dispose();this._minorValueLines[i]=null;}
for(var i=this._majorCategoryLines.length-1;i>=0;i--)
{this._majorCategoryLines[i].dispose();this._majorCategoryLines[i]=null;}
for(var i=this._minorCategoryLines.length-1;i>=0;i--)
{this._minorCategoryLines[i].dispose();this._minorCategoryLines[i]=null;}
this._minorValueLines=null;this._majorValueLines=null;this._minorCategoryLines=null;this._majorCategoryLines=null;};_p._createValueLines=function(oLines,bShow,nInterval,sColor)
{if(!this.getCreated())
return;for(var i=oLines.length-1;i>=0;i--)
{this.remove(oLines[i]);oLines[i].dispose();oLines[i]=null;}
oLines.length=0;if(bShow)
{var min=this._graph._valueAxis.getMinimum();var max=this._graph._valueAxis.getMaximum();var onX=this._graph._getCategoryOnXAxis();var y=min;if(y%nInterval!=0)
y=y+(min<0?0:nInterval)-y%nInterval;var l;while(y<=max)
{l=new BiComponent;l.setBackColor(sColor);l._chartValue=y;if(onX)
{l.setLeft(0);l.setHeight(1);}
else {l.setTop(0);l.setWidth(1);}
this.add(l);oLines.push(l);y+=nInterval;}}};_p._createCategoryLines=function(oLines,bShow,nInterval,sColor)
{if(!this.getCreated())
return;for(var i=oLines.length-1;i>=0;i--)
{this.remove(oLines[i]);oLines[i].dispose();oLines[i]=null;}
oLines.length=0;if(bShow)
{var catMax=this._graph._categoryAxis.getMaximum();var onX=this._graph._getCategoryOnXAxis();var x=nInterval;var backColor=sColor;while(x<=catMax)
{l=new BiComponent;l.setBackColor(sColor);l._chartValue=x;if(!onX)
{l.setLeft(0);l.setHeight(1);}
else {l.setTop(0);l.setWidth(1);}
this.add(l);oLines.push(l);x+=nInterval;}}};_p._layoutValueLines=function(oLines)
{var minVal=this._graph._valueAxis.getMinimum();var maxVal=this._graph._valueAxis.getMaximum();var sf=this._graph._getScaleFactor();var onX=this._graph._getCategoryOnXAxis();var l,y;var caHeight=this._graph.getChartArea().getHeight();var caWidth=this._graph.getChartArea().getWidth();for(var i=0;i<oLines.length;i++)
{l=oLines[i];y=l._chartValue;if(onX)
{l.setTop(Math.max((maxVal-y)*sf-1,0));l.setWidth(caWidth);}
else {l.setLeft(Math.min((y-minVal)*sf,caWidth-1));l.setHeight(caHeight);}}};_p._layoutCategoryLines=function(oLines)
{var catMax=this._graph._categoryAxis.getMaximum();var onX=this._graph._getCategoryOnXAxis();var csf=this._graph._getCatScaleFactor();var l,x;var caHeight=this._graph.getChartArea().getHeight();var caWidth=this._graph.getChartArea().getWidth();for(var i=0;i<oLines.length;i++)
{l=oLines[i];x=l._chartValue;if(onX)
{l.setLeft(Math.min(x*csf,caWidth-1));l.setHeight(caHeight);}
else {l.setTop(Math.max((catMax-x)*csf-1,0));l.setWidth(caWidth);}}};_p._createMajorValueLines=function()
{this._createValueLines(this._majorValueLines,this.getShowMajorValue(),this._graph._valueAxis.getMajorTickInterval(),this.getMajorValueStrokeColor());};_p._layoutMajorValueLines=function()
{if(this.getCreated()&&this.getShowMajorValue())
this._layoutValueLines(this._majorValueLines);};_p._updateMajorValue=function()
{this._createMajorValueLines();this._layoutMajorValueLines();};_p._createMinorValueLines=function()
{this._createValueLines(this._minorValueLines,this.getShowMinorValue(),this._graph._valueAxis.getMinorTickInterval(),this.getMinorValueStrokeColor());};_p._layoutMinorValueLines=function()
{if(this.getCreated()&&this.getShowMinorValue())
this._layoutValueLines(this._minorValueLines);};_p._updateMinorValue=function()
{this._createMinorValueLines();this._layoutMinorValueLines();};_p._createMajorCategoryLines=function()
{this._createCategoryLines(this._majorCategoryLines,this.getShowMajorCategory(),this._graph._categoryAxis.getMajorTickInterval(),this.getMajorCategoryStrokeColor());};_p._layoutMajorCategoryLines=function()
{if(this.getCreated()&&this.getShowMajorCategory())
this._layoutCategoryLines(this._majorCategoryLines);};_p._updateMajorCategory=function()
{this._createMajorCategoryLines();this._layoutMajorCategoryLines();};_p._createMinorCategoryLines=function()
{this._createCategoryLines(this._minorCategoryLines,this.getShowMinorCategory(),this._graph._categoryAxis.getMinorTickInterval(),this.getMinorCategoryStrokeColor());};_p._layoutMinorCategoryLines=function()
{if(this.getCreated()&&this.getShowMinorCategory())
this._layoutCategoryLines(this._minorCategoryLines);};_p._updateMinorCategory=function()
{this._createMinorCategoryLines();this._layoutMinorCategoryLines();};_p.layoutAllChildren=function()
{BiComponent.prototype.layoutAllChildren.call(this);this._layoutMinorCategoryLines();this._layoutMajorCategoryLines();this._layoutMinorValueLines();this._layoutMajorValueLines();};_p.layoutAllChildrenX=function()
{BiComponent.prototype.layoutAllChildrenX.call(this);this._layoutMinorCategoryLines();this._layoutMajorCategoryLines();this._layoutMinorValueLines();this._layoutMajorValueLines();};_p.layoutAllChildrenY=function()
{BiComponent.prototype.layoutAllChildrenY.call(this);this._layoutMinorCategoryLines();this._layoutMajorCategoryLines();this._layoutMinorValueLines();this._layoutMajorValueLines();};function BiGraph2(){BiGraphBase.call(this);this._chartArea=new BiChartArea2(this);this._valueAxis=new BiChartValueAxis2(this);this._categoryAxis=new BiChartCategoryAxis2(this);this._gridLines=new BiChartGridLines2(this);this._legend=new BiChartLegend(this);this.add(this._chartArea);this._chartArea.add(this._gridLines);this.add(this._valueAxis);this.add(this._categoryAxis);this.add(this._legend);};_p=BiGraph2.prototype=new BiGraphBase;_p._className="BiGraph2";_p._scaleChartArea=function()
{if(this._autoScale)
{var cw=this.getClientWidth();var ch=this.getClientHeight();this._chartArea.setRight(null);this._chartArea.setBottom(null);this._chartArea.setSize(this._chartAreaWidth/1000*cw,this._chartAreaHeight/1000*ch);this._chartArea.setLocation(this._chartAreaLeft/1000*cw,this._chartAreaTop/1000*ch);}
else {this._chartArea.setLocation(30,30)
this._chartArea.setRight(30);this._chartArea.setBottom(30);}};_p.setAutoScale=function(b)
{if(this._autoScale!=b)
{this._autoScale=b;this._scaleChartArea();if(!b)
this.setFontSize(11);if(this.getCreated())
this.update();}};_p.layoutAllChildren=function()
{if(this._autoScale)
this._scaleChartArea();this._scaleFont();BiGraphBase.prototype.layoutAllChildren.call(this);};_p.layoutAllChildrenX=function()
{if(this._autoScale)
this._scaleChartArea();this._scaleFont();BiGraphBase.prototype.layoutAllChildrenX.call(this);};_p.layoutAllChildrenY=function()
{if(this._autoScale)
this._scaleChartArea();this._scaleFont();BiGraphBase.prototype.layoutAllChildrenY.call(this);};_p._createChartFromSeries=function(oSeries){var c;switch(this._chartType){case"bar":c=new BiBarChart2(this,oSeries);break;case"stackedbar":c=new BiStackedBarChart2(this,oSeries);break;case"percentagestackedbar":c=new BiPercentageStackedBarChart2(this,oSeries);break;case"column":c=new BiColumnChart2(this,oSeries);break;case"stackedcolumn":c=new BiStackedColumnChart2(this,oSeries);break;case"percentagestackedcolumn":c=new BiPercentageStackedColumnChart2(this,oSeries);break;default:throw new Error("Chart type \""+this._chartType+"\" is not supported");break;}
this._charts[oSeries.getId()]=c;this._chartArea.add(c);};_p.update=function()
{this._syncChartForSeries();if(this.getChartType()!="grid")
{this._valueAxis._clearCache();this.layoutAllChildren();this._valueAxis._updateVisible();this._valueAxis._createLabels();this._valueAxis.layoutAllChildren();this._categoryAxis._updateVisible();this._categoryAxis._createLabels();this._categoryAxis.layoutAllChildren();this._updateCharts();this._legend._update();this._gridLines._createMinorCategoryLines();this._gridLines._createMajorCategoryLines();this._gridLines._createMinorValueLines();this._gridLines._createMajorValueLines();this._gridLines.layoutAllChildren();}
else this._gridComponent.update();};BiGraph2.fromXmlDocument=function(oDoc){var g=new BiGraph2;g.fromXmlDocument(oDoc);return g;};BiGraph2.fromUri=function(sUri){var g=new BiGraph2;var xmlLoader=new BiXmlLoader;xmlLoader.setAsync(false);xmlLoader.load(sUri);g.fromXmlDocument(xmlLoader.getDocument());xmlLoader.dispose();return g;};_p._getScaleFactor=function()
{if(this._scaleFactor!=null)
return this._scaleFactor;this._updateScaleFactor();return this._scaleFactor;};_p._getCatScaleFactor=function()
{if(this._catScaleFactor!=null)
return this._catScaleFactor;this._updateScaleFactor();return this._catScaleFactor;};_p._updateScaleFactor=function()
{var ca=this.getChartArea()
var cw=ca.getClientWidth();var ch=ca.getClientHeight();if(this._getCategoryOnXAxis())
{this._scaleFactor=ch/(this._valueAxis.getMaximum()-this._valueAxis.getMinimum());this._catScaleFactor=cw/this._categoryAxis.getMaximum();}
else {this._scaleFactor=cw/(this._valueAxis.getMaximum()-this._valueAxis.getMinimum());this._catScaleFactor=ch/this._categoryAxis.getMaximum();}};_p._resetScaleFactor=function()
{this._scaleFactor=null;this._catScaleFactor=null;};
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -