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

📄 charting.js

📁 Bindows 1.01 完全版 Bindows 框架提供给你: 基于类的面向对象 API; 一个完整的窗口系统
💻 JS
📖 第 1 页 / 共 5 页
字号:
    this._majorTicks.setVisible(this._showMajorTicks);    this._minorTicks.setVisible(this._showMinorTicks);    this.setStyleProperty("antialias", "false");    this.add(this._minorTicks);    this.add(this._majorTicks);    this.add(this._axisLine);    this.setLocation(0, 0);    this.setSize(1000, 1000);    this._labels = [];};var _p = BiChartValueAxis.prototype = new BiComponent;_p._className = "BiChartValueAxis";_p._tagName = "v:group";_p._majorTickInterval = null;_p._minorTickInterval = null;_p._labelInterval = null;_p._maximum = null;_p._minimum = null;_p._showMajorTicks = true;_p._showMinorTicks = true;_p._showLabels = true;_p._fontSize = 11;_p._desiredVisible = true;BiChartValueAxis.prototype.getShowMajorTicks = function(){    return this._showMajorTicks;} ;BiChartValueAxis.prototype.getShowMinorTicks = function(){    return this._showMinorTicks;} ;BiChartValueAxis.prototype.getShowLabels = function(){    return this._showLabels;} ;BiChartValueAxis.prototype.getFontSize = function(){    return this._fontSize;} ;_p.setMajorTickInterval = function(n){    this._majorTickInterval = n;    this._clearCache();};_p.setMinorTickInterval = function(n){    this._minorTickInterval = n;    this._clearCache();};_p.setMaximum = function(n){    this._maximum = n;    this._clearCache();};_p.setMinimum = function(n){    this._minimum = n;    this._clearCache();};_p.setShowMajorTicks = function(b){    if (this._showMajorTicks != b)    {        this._showMajorTicks = b;        this._updateMajorTicks();    }};_p.setShowMinorTicks = function(b){    if (this._showMinorTicks != b)    {        this._showMinorTicks = b;        this._updateMinorTicks();    }};_p.setShowLabels = function(b){    if (this._showLabel != b)    {        this._showLabels = b;        this._updateLabels();    }};_p.getMaximumValue = function(){    if (this._graph._getPercentageStack())        return 1;    var s = this._graph.getSeries();    if (this._graph._getStackedChart())    {        var cats = this._graph.getCategories();        var l = cats.length;        var sum, id;        var max = 0;        for (var j = 0; j < l; j++)        {            sum = 0;            id = cats[j].getId();            for (var i = 0; i < s.length; i++)            {                sum += Math.abs(s[i].getValueByCategoryId(id));            }            max = Math.max(max, sum);        }        return max;    }    else    {        var maxValue = -Infinity;        for (var i = 0; i < s.length; i++)            maxValue = Math.max(maxValue, s[i].getMaximumValue());        return maxValue;    }};_p.getMinimumValue = function(){    if (this._graph._getStackedChart())        return 0;    var minValue = Infinity;    var s = this._graph.getSeries();    for (var i = 0; i < s.length; i++)        minValue = Math.min(minValue, s[i].getMinimumValue());    return minValue;};_p.getMaximum = function(){    if (this._maximum != null)        return this._maximum;    if (this._graph._getPercentageStack())        return 1;    return this._getDefaultProperties().max;};_p.getMinimum = function(){    if (this._minimum != null)        return this._minimum;    return this._getDefaultProperties().min;};_p.getMajorTickInterval = function(){    if (this._majorTickInterval != null)        return this._majorTickInterval;    return this._getDefaultProperties().major;};_p.getMinorTickInterval = function(){    if (this._minorTickInterval != null)        return this._minorTickInterval;    return this._getDefaultProperties().minor;};_p.dispose = function(){    if (this._disposed)        return;    BiComponent.prototype.dispose.call(this);    this._graph = null;    for (var i = 0; i < this._labels.length; i++)        this._labels[i] = null;    this._labels = null;    this._clearCache();    this._majorTicks = null;    this._minorTicks = null;    this._axisLine = null;};_p._getDefaultProperties = function(){    if (this._cachedDefaultProperties != null)        return this._cachedDefaultProperties;    var max = this._maximum != null ? this._maximum : this.getMaximumValue();    var min = this._minimum != null ? this._minimum : Math.min(0, this.getMinimumValue());    var diff = max - min;    var zeros = Math.floor(Math.log(diff) / Math.log(10));    var major;    if (this._majorTickInterval != null)    {        major = this._majorTickInterval;    }    else    {        major = Math.pow(10, zeros);        var x = diff / major;        if (x < 2)            major = major / 5;        else if (x < 5)            major = major / 2;    }    var minor = this._minorTickInterval != null ? this._minorTickInterval : major / 5;    var newMax = Math.ceil((max + major / 2) / major) * major;    var newMin;    if (min == 0)        newMin = 0;    else        newMin = Math.floor((min - major / 2) / major) * major;    return this._cachedDefaultProperties = {        max: newMax, min: newMin, major: major, minor: minor    };};_p._updateCoordSize = function(sCoordSize, sCoordOrigin){    var p = sCoordSize.split(",");    var w = Number(p[0]), h = Number(p[1]);    p = sCoordOrigin.split(",");    var x = Number(p[0]), y = Number(p[1]);    this._coordSize = this._graph._getCategoryOnXAxis() ? w : h;    this.setHtmlProperty("coordsize", sCoordSize);    this._majorTicks.setHtmlProperty("coordsize", sCoordSize);    this._minorTicks.setHtmlProperty("coordsize", sCoordSize);    this._axisLine.setHtmlProperty("coordsize", sCoordSize);    this.setHtmlProperty("coordorigin", sCoordOrigin);    this._majorTicks.setHtmlProperty("coordorigin", sCoordOrigin);    this._minorTicks.setHtmlProperty("coordorigin", sCoordOrigin);    this._axisLine.setHtmlProperty("coordorigin", sCoordOrigin);    this._majorTicks.setLocation(x, y);    this._majorTicks.setSize(w, h);    this._minorTicks.setLocation(x, y);    this._minorTicks.setSize(w, h);    this._axisLine.setLocation(x, y);    this._axisLine.setSize(w, h);    var s = this._graph.getSeries();    var c;    for (var i = 0; i < s.length; i++)    {        c = this._graph.getChartForSeries(s[i]);        if (c)            c._updateCoordSize(sCoordSize, sCoordOrigin);    }    this._updateMajorTicks();    this._updateMinorTicks();    this._updateAxisLine();    this._updateLabels();};_p._updateAxisLine = function(){    var min = Math.round(this.getMinimum() * this._graph._scaleFactor);    var max = Math.round(this.getMaximum() * this._graph._scaleFactor);    var x0 = 0;    var onX = this._graph._getCategoryOnXAxis();    var sb = [];    var y = min;    if (onX)        this._axisLine.setHtmlProperty("path", "m " + x0 + "," + min + " l " + x0 + "," + max);    else        this._axisLine.setHtmlProperty("path", "m " + min + "," + x0 + " l " + max + "," + x0);};_p._updateMajorTicks = function(){    if (this._showMajorTicks)    {        var min = this.getMinimum();        var max = this.getMaximum();        var major = this.getMajorTickInterval();        var x0 = 0;        var x1 = -0.01 * this._coordSize;        var onX = this._graph._getCategoryOnXAxis();        var sb = [];        var y = min;        if (y / major % 1 != 0)            y = y + (min < 0 ? 0 : major) - y % major;        var y2;        while (y <= max)        {            y2 = Math.round(y * this._graph._scaleFactor);            if (onX)                sb.push("m " + x0 + "," + y2 + " l " + x1 + "," + y2);            else                sb.push("m " + y2 + "," + x0 + " l " + y2 + "," + x1);            y += major;            y = Math.round(y / major) * major;        }        this._majorTicks.setHtmlProperty("path", sb.join("") + "e");    }};_p._updateMinorTicks = function(){    if (this._showMinorTicks)    {        var min = this.getMinimum();        var max = this.getMaximum();        var minor = this.getMinorTickInterval();        var x0 = 0;        var x1 = -0.005 * this._coordSize;        var onX = this._graph._getCategoryOnXAxis();        var sb = [];        var y = min;        if (y / minor % 1 != 0)            y = y + (min < 0 ? 0 : minor) - y % minor;        var y2;        while (y <= max)        {            y2 = Math.round(y * this._graph._scaleFactor);            if (onX)                sb.push("m " + x0 + "," + y2 + " l " + x1 + "," + y2);            else                sb.push("m " + y2 + "," + x0 + " l " + y2 + "," + x1);            y += minor;            y = Math.round(y / minor) * minor;        }        this._minorTicks.setHtmlProperty("path", sb.join("") + "e");    }};_p._updateLabels = function(){    if (!this._created)        return;    var tmp;    for (var i = this._labels.length - 1; i >= 0; i--)    {        tmp = this._labels[i];        this.remove(tmp);        tmp.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 x2, l, ys;        var onX = this._graph._getCategoryOnXAxis();        var percentage = this._graph._getPercentageStack();        while (y <= max)        {            y2 = Math.round(y * this._graph._scaleFactor);            if (percentage)                ys = Math.round(y * 100) + "%";            else                ys = y;            l = new BiVmlLabel(ys);            l.setFontSize(this._fontSize);            if (onX)            {                l.setAlign("right");                l.setLocation(-0.02 * this._coordSize, y2);            }            else            {                l.setAlign("center");                l.setLocation(y2, -0.04 * this._coordSize);            }            this.add(l);            this._labels.push(l);            y += major;            y = Math.round(y / major) * major;        }    }};_p.setFontSize = function(n){    this._fontSize = n;    for (var i = 0; i < this._labels.length; i++)        this._labels[i].setFontSize(n);};_p.setVisible = function(b){    this._desiredVisible = b;    BiComponent.prototype.setVisible.call(this, b && this._graph._getSupportsValueAxis());};_p.getVisible = function(){    return this._desiredVisible;} ;_p._updateVisible = function(){    this.setVisible(this._desiredVisible);} ;BiChartValueAxis.fromXmlElement = function(oGraph, oNode){    var ax = new BiChartValueAxis(oGraph);    ax.fromXmlElement(oNode);    return ax;};_p.fromXmlElement = function(oNode){    var s = oNode.getAttribute("Visible");    if (s)        this.setVisible(s != "false");    s = oNode.getAttribute("ShowMajorTicks");    if (s)        this.setShowMajorTicks(s != "false");    s = oNode.getAttribute("ShowMinorTicks");    if (s)        this.setShowMinorTicks(s == "true");    s = oNode.getAttribute("ShowLabels");    if (s)        this.setShowLabels(s != "false");    s = oNode.getAttribute("MajorTickInterval");    if (s)        this.setMajorTickInterval(Number(s));    s = oNode.getAttribute("MinorTickInterval");    if (s)        this.setMinorTickInterval(Number(s));    s = oNode.getAttribute("Maximum");    if (s)        this.setMaximum(Number(s));    s = oNode.getAttribute("Minimum");    if (s)        this.setMinimum(Number(s));};_p.toXmlElement = function(oDoc){    var el = oDoc.createElement("ValueAxis");    el.setAttribute("Visible", String(this._desiredVisible));    if (this._showMajorTicks != null)        el.setAttribute("ShowMajorTicks", String(this._showMajorTicks));    if (this._showMinorTicks != null)        el.setAttribute("ShowMinorTicks", String(this._showMinorTicks));    if (this._showLabels != null)        el.setAttribute("ShowLabels", String(this._showLabels));    if (this._majorTickInterval != null)        el.setAttribute("MajorTickInterval", String(this._majorTickInterval));    if (this._minorTickInterval != null)        el.setAttribute("MinorTickInterval", String(this._minorTickInterval));    if (this._maximum != null)        el.setAttribute("Maximum", String(this._majorTickInterval));    if (this._minimum != null)        el.setAttribute("Minimum", String(this._minorTickInterval));    return el;};_p._clearCache = function(){    this._cachedDefaultProperties = null;} ;function BiChartCategoryAxis(oGraph){    BiComponent.call(this);    this._graph = oGraph;    this._majorTicks = BiGraph._createVmlElement();    this._minorTicks = BiGraph._createVmlElement();    this._axisLine = BiGraph._createVmlElement();    this._majorTicks.setVisible(this._showMajorTicks);    this._minorTicks.setVisible(this._showMinorTicks);    this.setStyleProperty("antialias", "false");    this.add(this._minorTicks);    this.add(this._majorTicks);    this.add(this._axisLine);    this.setLocation(0, 0);

⌨️ 快捷键说明

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