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

📄 charting.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
        this._title = sTitle;    if (oValues)        this.setValues(oValues);}var _p = BiChartSeries.prototype = new BiObject;_p._className = "BiChartSeries";_p._title = "";_p._cachedSum = null;_p._cachedAbsSum = null;_p._cachedValues = null;_p._cachedMaximumValue = null;_p._cachedMinimumValue = null;BiChartSeries.fromXmlElement = function(oGraph, oNode){    var series = new BiChartSeries(oGraph);    series.fromXmlElement(oNode);    return series;};_p.fromXmlElement = function(oNode){    var id = oNode.getAttribute("Id");    var title = oNode.selectSingleNode("Title");    title = title ? title.text : null;    this._id = id;    this._title = title;    var values = oNode.selectNodes("Values/Value");    var l = values.length;    var catId;    for (var i = 0; i < l; i++)    {        catId = values[i].getAttribute("Category");        this.setValueByCategoryId(catId, Number(values[i].text));    }};_p.toXmlElement = function(oDoc){    var series = oDoc.createElement("Series");    series.setAttribute("Id", this.getId());    if (this.getTitle())    {        var titleEl = oDoc.createElement("Title");        titleEl.appendChild(oDoc.createTextNode(this.getTitle()));        series.appendChild(titleEl);    }    var valuesEl = oDoc.createElement("Values");    var valueEl;    for (var catId in this._categoryValueMap)    {        valueEl = oDoc.createElement("Value");        valueEl.setAttribute("Category", catId);        valueEl.appendChild(oDoc.createTextNode(this._categoryValueMap[catId].toString()));        valuesEl.appendChild(valueEl);    }    series.appendChild(valuesEl);    return series;};BiChartSeries.prototype.getTitle = function(){    return this._title;} ;BiChartSeries.prototype.setTitle = function(v){    this._title = v;} ;BiChartSeries.prototype.getId = function(){    return this._id;} ;BiChartSeries.prototype.getIndex = function(){    return this._index;} ;_p.getValueByCategory = function(oCategory){    return this.getValueByCategoryId(oCategory.getId());} ;_p.setValueByCategory = function(oCategory, nValue){    this.setValueByCategoryId(oCategory.getId(), nValue);} ;_p.getValueByCategoryId = function(sCatId){    var v = this._categoryValueMap[sCatId];    return isNaN(v) ? null : v;};_p.setValueByCategoryId = function(sCatId, nValue){    this._clearCache();    if (nValue == null || isNaN(nValue))        delete this._categoryValueMap[sCatId];    else        this._categoryValueMap[sCatId] = nValue;};_p.setValues = function(aValues){    var cats = this._graph.getCategories();    var l = cats.length;    var id;    this._values = new Array(l);    for (var i = 0; i < l; i++)    {        id = cats[i].getId();        if (aValues[i] == null || isNaN(aValues[i]))            delete this._categoryValueMap[id];        else            this._categoryValueMap[id] = aValues[i];    }    this._clearCache();};_p.getValues = function(){    if (this._cachedValues != null)        return this._cachedValues;    var cats = this._graph.getCategories();    var l = cats.length;    var res = new Array(l);    var v;    for (var i = 0; i < l; i++)    {        v = this._categoryValueMap[cats[i].getId()];        res[i] = isNaN(v) ? null : v;    }    return this._cachedValues = res;};_p.getValueByIndex = function(i){    var cat = this._graph.getCategories()[i]    return cat ? this.getValueByCategory(cat) : null;};_p.setValueByIndex = function(i, nValue){    var cat = this._graph.getCategories()[i];    if (cat)        this.setValueByCategory(cat, nValue)};_p.getMaximumValue = function(){    if (this._cachedMaximumValue != null)        return this._cachedMaximumValue;    return this._cachedMaximumValue = Math.max.apply(null, this.getValues());};_p.getMinimumValue = function(){    if (this._cachedMinimumValue != null)        return this._cachedMinimumValue;    return this._cachedMinimumValue = Math.min.apply(null, this.getValues());};_p.getSum = function(){    if (this._cachedSum != null)        return this._cachedSum;    var sum = 0;    for (var id in this._categoryValueMap)        sum += this._categoryValueMap[id];    return this._cachedSum = sum;};_p.getAbsSum = function(){    if (this._cachedAbsSum != null)        return this._cachedAbsSum;    var sum = 0;    for (var id in this._categoryValueMap)        sum += Math.abs(this._categoryValueMap[id]);    return this._cachedAbsSum = sum;};_p.dispose = function(){    if (this._disposed)        return;    for (var id in this._categoryValueMap)        delete this._categoryValueMap[id];    this._categoryValueMap = null;    this._clearCache();};_p._clearCache = function(){    this._cachedSum = null;    this._cachedAbsSum = null;    this._cachedValues = null;    this._cachedMaximumValue = null;    this._cachedMinimumValue = null;    if (this._graph && this._graph._valueAxis)        this._graph._valueAxis._clearCache();};function BiChartArea(oGraph){    BiComponent.call(this);    this._graph = 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 BiComponent;_p._className = "BiChartArea";_p._tagName = "v:group";_p._fillColor = null;_p._strokeColor = null;_p._updateCoordSize = function(sCoordSize, sCoordOrigin){} ;_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);};BiChartArea.prototype.getFillColor = function(){    return this._fillColor;} ;_p.hasFillColor = function(){    return this._fillColor != null;} ;_p.setStrokeColor = function(s){    this._strokeColor = s;    this._outlineRect.setHtmlProperty("stroked", s != "transparent");    this._outlineRect.setHtmlProperty("strokecolor", s);};BiChartArea.prototype.getStrokeColor = function(){    return this._strokeColor;} ;_p.hasStrokeColor = function(){    return this._strokeColor != null;} ;BiGraph._addExtendedFillInterface(_p);BiGraph._addExtendedStrokeInterface(_p);BiChartArea.fromXmlElement = function(oGraph, oNode){    var ca = new BiChartArea(oGraph);    ca.fromXmlElement(oNode);    return ca;};_p.fromXmlElement = function(oNode){    var n = oNode.selectSingleNode("Stroke/@Opacity");    if (n)        this.setStrokeOpacity(Number(n.text));    n = oNode.selectSingleNode("Stroke/@Color");    if (n)        this.setStrokeColor(n.text);    n = oNode.selectSingleNode("Fill/@Opacity");    if (n)        this.setFillOpacity(Number(n.text));    n = oNode.selectSingleNode("Fill/@Color");    if (n)        this.setFillColor(n.text);    n = oNode.selectSingleNode("Fill/@Color2");    if (n)        this.setFillColor2(n.text);    n = oNode.selectSingleNode("Fill/@Type");    if (n)        this.setFillType(n.text);    n = oNode.selectSingleNode("Fill/@Angle");    if (n)        this.setFillAngle(n.text);};_p.toXmlElement = function(oDoc){    if (!this.hasFillColor() && !this.hasStrokeColor()                                    && !this.hasFillColor2() && !this.hasFillType() && !this.hasFillAngle())        return oDoc.createDocumentFragment();    var ca = oDoc.createElement("ChartArea");    var el;    if (this.hasStrokeColor() || this.hasStrokeOpacity())    {        el = oDoc.createElement("Stroke");        if (this.hasStrokeOpacity())            el.setAttribute("Opacity", String(this.getStrokeOpacity()));        if (this.hasStrokeColor())            el.setAttribute("Color", this.getStrokeColor());        ca.appendChild(el);    }    if (this.hasFillColor() || this.hasFillColor2() || this.hasFillType() || this.hasFillAngle()        || this.hasFillOpacity())    {        el = oDoc.createElement("Fill");        if (this.hasFillOpacity())            el.setAttribute("Opacity", String(this.getFillOpacity()));        if (this.hasFillColor())            el.setAttribute("Color", this.getFillColor());        if (this.hasFillColor2())            el.setAttribute("Color2", this.getFillColor2());        if (this.hasFillType())            el.setAttribute("Type", this.getFillType());        if (this.hasFillAngle())            el.setAttribute("Angle", this.getFillAngle());        ca.appendChild(el);    }    return ca;};_p.dispose = function(){    if (this._disposed)        return;    BiComponent.prototype.dispose.call(this);    this._graph = null;    this._outlineRect = null    this._backgroundRect = null;    this._fillEl = null;};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)        this._textPathEl.style.fontSize = n + "px";};function BiChartValueAxis(oGraph){    BiComponent.call(this);    this._graph = oGraph;    this._majorTicks = BiGraph._createVmlElement();    this._minorTicks = BiGraph._createVmlElement();    this._axisLine = BiGraph._createVmlElement();

⌨️ 快捷键说明

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