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

📄 charting.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
    this._points = null;    this._chartPresentations = null;    this._charts = null;    this._series = null;    this._seriesMap = null;    this._categories = null;    this._categoriesMap = null;    this._gridComponent = null;    this._chartArea = null;    this._valueAxis = null;    this._categoryAxis = null;    this._legend = null;    this._contentArea = null;    this._gridLines = null;};_p._getCategoryOnXAxis = function(){    switch (this._chartType)    {        case "bar":        case "stackedbar":        case "percentagestackedbar":            return false;        default:            return true;    }};_p._getStackedChart = function(){    switch (this._chartType)    {        case "stackedcolumn":        case "stackedbar":        case "percentagestackedcolumn":        case "percentagestackedbar":            return true;        default:            return false;    }};_p._getPercentageStack = function(){    switch (this._chartType)    {        case "percentagestackedcolumn":        case "percentagestackedbar":            return true;        default:            return false;    }};_p._getSupportsValueAxis = function(){    var cs = this.getCharts();    if (cs.length == 0)        return false;    return cs[0].getSupportsValueAxis();};_p._getSupportsCategoryAxis = function(){    var cs = this.getCharts();    if (cs.length == 0)        return false;    return cs[0].getSupportsCategoryAxis()};_p._getSupportsGridLines = function(){    var cs = this.getCharts();    if (cs.length == 0)        return false;    return cs[0].getSupportsGridLines()};_p._updateCharts = function(){    for (var id in this._charts)        this._charts[id]._updateChart();};_p._updateCoordSize = function(){    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);};_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();};_p.updatePoint = function(sSeriesId, sCategoryId){    if (this.getChartType() == "grid")    {        if (!this._gridComponent)            return;        var c = this._gridComponent.getCellByIds(sSeriesId, sCategoryId);        if (c)            c.update();        else        {            var r = this._gridComponent.getRowById(sSeriesId);            if (r)                r.update();        }    }    else    {        var c = this.getChartForSeries(this.getSeriesById(sSeriesId));        if (!c)            return;        if (sCategoryId != null)            c._updateValueByCategoryId(sCategoryId);        else            c._updateValues();    }};_p.fromXmlDocument = function(oDoc){    this._removeAllCharts();    this.clearCategories();    this.clearSeries();    var docEl = oDoc.documentElement;    var title = docEl.selectSingleNode("Title");    title = title ? title.text : null;    var dataEl = docEl.selectSingleNode("Data");    var presentationEl = docEl.selectSingleNode("Presentation");    var categories = dataEl.selectNodes("Categories/Category");    var l = categories.length;    for (var i = 0; i < l; i++)        this.addCategory(BiChartCategory.fromXmlElement(this, categories[i]));    var series = dataEl.selectNodes("SeriesGroup/Series");    var l = series.length;    for (var i = 0; i < l; i++)        this.addSeries(BiChartSeries.fromXmlElement(this, series[i]));    var presentation = docEl.selectSingleNode("Presentation");    this.setChartType(presentation.getAttribute("Type") || "line");    var chartArea = presentation.selectSingleNode("ChartArea");    if (chartArea)        this._chartArea.fromXmlElement(chartArea);    var points = presentation.selectNodes("Points/Point");    var l = points.length;    for (var i = 0; i < l; i++)    {        this.addPoint(BiChartPoint.fromXmlElement(this, points[i]));    }    var charts = presentation.selectNodes("Charts/Chart");    l = charts.length;    var cp;    for (var i = 0; i < l; i++)    {        cp = BiChartPresentation.fromXmlElement(this, charts[i]);        if (cp)            this._chartPresentations[cp.getSeries().getId()] = cp;    }    var legend = presentation.selectSingleNode("Legend");    if (legend)        this._legend.fromXmlElement(legend);    var valueAxis = presentation.selectSingleNode("Axes/ValueAxis");    if (valueAxis)        this._valueAxis.fromXmlElement(valueAxis);    var categoryAxis = presentation.selectSingleNode("Axes/CategoryAxis");    if (categoryAxis)        this._categoryAxis.fromXmlElement(categoryAxis);    var gridLines = presentation.selectSingleNode("GridLines");    if (gridLines)    {        this._gridLines.fromXmlElement(gridLines);    }};_p.toXmlDocument = function(){    var doc = new BiXmlDocument();    doc.loadXML("<Graph><Data><Categories/><SeriesGroup/></Data><Presentation/></Graph>");    var docEl = doc.documentElement;    var categoriesEl = docEl.firstChild.firstChild;    for (var i = 0; i < this._categories.length; i++)        categoriesEl.appendChild(this._categories[i].toXmlElement(doc));    var seriesGroupEl = docEl.firstChild.lastChild;    for (var i = 0; i < this._series.length; i++)        seriesGroupEl.appendChild(this._series[i].toXmlElement(doc));    var presentationEl = docEl.lastChild;    presentationEl.setAttribute("Type", this.getChartType());    presentationEl.appendChild(this._legend.toXmlElement(doc));    var axesEl = doc.createElement("Axes");    presentationEl.appendChild(axesEl);    axesEl.appendChild(this._valueAxis.toXmlElement(doc));    axesEl.appendChild(this._categoryAxis.toXmlElement(doc));    presentationEl.appendChild(this._gridLines.toXmlElement(doc));    presentationEl.appendChild(this._chartArea.toXmlElement(doc));    var points = this.getPoints();    var pointsEl = doc.createElement("Points");    for (var i = 0; i < points.length; i++)        pointsEl.appendChild(points[i].toXmlElement(doc));    presentationEl.appendChild(pointsEl);    var chartsEl = doc.createElement("Charts");    for (var id in this._chartPresentations)        chartsEl.appendChild(this._chartPresentations[id].toXmlElement(doc));    presentationEl.appendChild(chartsEl);    return doc;};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;};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;    } ;};_p._onMouseEvent = function(e){    var c = e.getTarget();    while (c != null && c != this && ( typeof c.getSeries != "function" || typeof c.getCategory != "function"))        c = c.getParent();    if (c == this || c == null)        return;    var sType = "point" + e.getType();    var ce = new BiChartMouseEvent(sType, e._event, c.getSeries(), c.getCategory());    this.dispatchEvent(ce);    ce.dispose();};_p.getContextMenuForPoint = function(oSeries, oCategory){    return null;} ;_p.getToolTipForPoint = function(oSeries, oCategory){    var tt = BiToolTip.getTextToolTip(                 "Series \"" + oSeries.getTitle() + "\" Category \"" + oCategory.getTitle() + "\"\nValue: "                     + oSeries.getValueByCategoryId(oCategory.getId()));    tt.setHideInterval(600 * 1000);    return tt;};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 BiChartCategory(oGraph, sId, sTitle){    BiObject.call(this);    this._graph = oGraph;    this._id = sId;    if (sTitle)        this._title = sTitle;};var _p = BiChartCategory.prototype = new BiObject;_p._className = "BiChartCategory";_p._id = null;_p._title = "";_p._index = null;BiChartCategory.prototype.getId = function(){    return this._id;} ;BiChartCategory.prototype.getTitle = function(){    return this._title;} ;BiChartCategory.prototype.setTitle = function(v){    this._title = v;} ;BiChartCategory.prototype.getIndex = function(){    return this._index;} ;BiChartCategory.fromXmlElement = function(oGraph, oNode){    var cat = new BiChartCategory(oGraph);    cat.fromXmlElement(oNode);    return cat;};_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;};_p.toXmlElement = function(oDoc){    var category = oDoc.createElement("Category");    category.setAttribute("Id", this.getId());    if (this.getTitle())    {        var titleEl = oDoc.createElement("Title");        titleEl.appendChild(oDoc.createTextNode(this.getTitle()));        category.appendChild(titleEl);    }    return category;};_p.dispose = function(){    if (this._disposed)        return;    this._graph = null;};function BiChartSeries(oGraph, sId, sTitle, oValues){    BiObject.call(this);    this._graph = oGraph;    this._id = sId;    this._categoryValueMap = {    };    if (sTitle)

⌨️ 快捷键说明

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