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

📄 charting.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
/* * Bindows 1.01 * 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(){    BiComponent.call(this);    this._series = [];    this._charts = {    };    this._categories = [];    this._seriesMap = {    };    this._categoriesMap = {    };    this._points = {    };    this._presentationManager = new BiChartPresentationManager(this);    this._chartPresentations = {    };    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);    this.setSize(300, 200);    this.setForeColor("black");    this.addEventListener("click", this._onMouseEvent);    this.addEventListener("mousedown", this._onMouseEvent);    this.addEventListener("mouseup", this._onMouseEvent);    this.addEventListener("mouseover", this._onMouseEvent);    this.addEventListener("mouseout", this._onMouseEvent);    this.addEventListener("mousemove", this._onMouseEvent);    this.addEventListener("dblclick", this._onMouseEvent);    this.addEventListener("contextmenu", this._onMouseEvent);    this.addEventListener("mousewheel", this._onMouseEvent);};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 = BiGraph.prototype = new BiComponent;_p._className = "BiGraph";_p._chartType = "line"_p._xAxis = null;_p._yAxis = null;_p._gridLines = null;_p._chartArea = null;_p._chartAreaLeft = 100;_p._chartAreaTop = 100;_p._chartAreaWidth = 800;_p._chartAreaHeight = 800;_p._autoScale = true;_p._scaleFactor = 1e4;_p._catScaleFactor = 1e4;BiGraph.prototype.getPresentationManager = function(){    return this._presentationManager;} ;BiGraph.prototype.getChartArea = function(){    return this._chartArea;} ;BiGraph.prototype.getValueAxis = function(){    return this._valueAxis;} ;BiGraph.prototype.getCategoryAxis = function(){    return this._categoryAxis;} ;BiGraph.prototype.getGridLines = function(){    return this._gridLines;} ;BiGraph.prototype.getLegend = function(){    return this._legend;} ;BiGraph.prototype.getAutoScale = function(){    return this._autoScale;} ;_p.getGrid = function(){    return this._gridComponent;} ;_p._scaleFont = function(){    if (this._autoScale)    {        this.setFontSize(Math.min(this.getClientWidth(), this.getClientHeight()) / 25);    }};_p.setFontSize = function(n){    this._valueAxis.setFontSize(n);    this._categoryAxis.setFontSize(n);    this._legend.setFontSize(n);};_p.getFontSize = function(){    var s1 = this._valueAxis.getFontSize();    var s2 = this._categoryAxis.getFontSize();    var s3 = this._legend.getFontSize();    if (s1 == s2 && s2 == s3)        return s1;    return null;};_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(){    var cw = this.getClientWidth();    var ch = this.getClientHeight();    if (!this._autoScale)        this._contentArea.setHtmlProperty("coordsize", cw + "," + ch);    this._scaleFont();    BiComponent.prototype.layoutAllChildren.call(this);};_p.layoutAllChildrenX = function(){    var cw = this.getClientWidth();    var ch = this.getClientHeight();    if (!this._autoScale)        this._contentArea.setHtmlProperty("coordsize", cw + "," + ch);    this._scaleFont();    BiComponent.prototype.layoutAllChildrenX.call(this);};_p.layoutAllChildrenY = function(){    var cw = this.getClientWidth();    var ch = this.getClientHeight();    if (!this._autoScale)        this._contentArea.setHtmlProperty("coordsize", cw + "," + ch);    this._scaleFont();    BiComponent.prototype.layoutAllChildren.call(this);};_p.addSeries = function(oSeries){    var id = oSeries.getId();    this._series.push(oSeries);    this._seriesMap[id] = oSeries;    oSeries._index = this._series.length - 1;    this._chartPresentations[id] = new BiChartPresentation(this, oSeries);};_p.removeSeries = function(oSeries){    this._series.remove(oSeries);    delete this._seriesMap[oSeries.getId()];    var chart = this.getChartForSeries(oSeries);    this._removeChart(chart);    oSeries._index = null;    for (var i = 0; i < this._series.length; i++)        this._series[i]._index = i;};_p.clearSeries = function(){    for (var i = 0; i < this._series.length; i++)        this._series[i]._index = null;    this._series = [];    this._seriesMap = {    };};_p.getSeriesById = function(sId){    return this._seriesMap[sId];} ;BiGraph.prototype.getSeries = function(){    return this._series;} ;_p.setSeries = function(aSeries){    this.clearSeries();    for (var i = 0; i < aSeries.length; i++)        this.addSeries(aSeries[i]);};_p.addCategory = function(oCategory){    this._categories.push(oCategory);    this._categoriesMap[oCategory.getId()] = oCategory;    oCategory._index = this._categories.length - 1;};_p.removeCategory = function(oCategory){    this._categories.remove(oCategory);    delete this._categoriesMap[oCategory.getId()];    for (var i = 0; i < this._categories.length; i++)        this._categories[i]._index = i;};_p.clearCategories = function(){    for (var i = 0; i < this._categories.length; i++)        this._categories[i]._index = null;    this._categories = [];    this._categoriesMap = {    };};_p.getCategoryById = function(sId){    return this._categoriesMap[sId];} ;BiGraph.prototype.getCategories = function(){    return this._categories;} ;_p.setCategories = function(aCategories){    this.clearCategories();    for (var i = 0; i < aCategories.length; i++)        this.addCategory(aCategories[i]);};_p.addPoint = function(oPoint){    var sId = oPoint.getSeriesId();    var cId = oPoint.getCategoryId();    if (this._points[sId] == null)        this._points[sId] = {        };    this._points[sId][cId] = oPoint;};_p.removePoint = function(oPoint){    var sId = oPoint.getSeriesId();    var cId = oPoint.getCategoryId();    if (this._points[sId] == null)        return;    delete this._points[sId][cId];};_p.clearPoints = function(){    this._points = {    };} ;_p.getPointByIds = function(sSeriesId, sCategoryId){    if (this._points[sSeriesId])        return this._points[sSeriesId][sCategoryId];    return null;};_p.getPoints = function(){    var res = [];    for (var sId in this._points)    {        for (var cId in this._points[sId])            res.push(this._points[sId][cId]);    }    return res;};_p.setPoints = function(aPoints){    this.clearPoints();    for (var i = 0; i < aPoints.length; i++)        this.addPoint(aPoints[i]);};_p.getComponentByIds = function(sSeriesId, sCategoryId){    var c = this._charts[sSeriesId];    if (!c)        return null;    return c.getComponentByCategoryId(sCategoryId);};_p.getChartPresentation = _p.getChartPresentationBySeriesId = function(sSeriesId){    return this._chartPresentations[sSeriesId];} ;BiGraph.prototype.getChartType = function(){    return this._chartType;} ;_p.setChartType = function(sType){    if (this._chartType != sType)    {        var oldAxis = this._getCategoryOnXAxis();        var oldStacked = this._getStackedChart();        var oldPercentage = this._getPercentageStack();        var oldType = this._chartType;        this._chartType = sType;        this._currentColorIndex = 0;        this._syncChartForSeries();    }};_p.getCharts = function(){    var res = [];    for (var sId in this._charts)        res.push(this._charts[sId]);    return res;};_p.getChartForSeries = function(oSeries){    var id = oSeries.getId();    return this._charts[id];};_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);    if (this._valueAxis)        this._valueAxis._clearCache();};_p._syncChartForSeries = function(){    var sType = this.getChartType();    this._removeAllCharts();    if (sType != "grid")    {        if (this._gridComponent)        {            this.remove(this._gridComponent);            this._gridComponent.dispose();            this._gridComponent = null;        }        var l = sType == "pie" ? 1 : this._series.length;        for (var i = 0; i < l; i++)            this._createChartFromSeries(this._series[i]);    }    else    {        if (!this._gridComponent)        {            this._gridComponent = new BiGridChart(this);            this._gridComponent.setLocation(0, 0);            this._gridComponent.setRight(0);            this._gridComponent.setBottom(0);            this._gridComponent.setBorder(new BiBorder(0));            this.add(this._gridComponent);        }    }};_p._removeChart = function(oChart){    var id = oChart.getSeries().getId();    this._chartArea.remove(oChart);    delete this._charts[id];    oChart.dispose();    if (this._valueAxis)        this._valueAxis._clearCache();};_p._removeAllCharts = function(){    for (var id in this._charts)    {        this._chartArea.remove(this._charts[id]);        this._charts[id].dispose()        delete this._charts[id];    }    if (this._valueAxis)        this._valueAxis._clearCache();};_p.dispose = function(){    if (this._disposed)        return;    BiComponent.prototype.dispose.call(this);    var i, j;    for (var i = this._series.length - 1; i >= 0; i--)        this._series[i].dispose();    for (i = this._categories.length - 1; i >= 0; i--)        this._categories[i].dispose();    for (i in this._seriesMap)        this._seriesMap[i].dispose();    for (i in this._categoriesMap)        this._categoriesMap[i].dispose();    for (i in this._points)    {        for (j in this._points[i])            this._points[i][j].dispose();    }    for (i in this._charts)        this._charts[i].dispose();    for (i in this._chartPresentations)        this._chartPresentations[i].dispose();    this._presentationManager.dispose();

⌨️ 快捷键说明

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