Skip to content

Instantly share code, notes, and snippets.

@victorono
Last active March 12, 2017 01:22
Show Gist options
  • Select an option

  • Save victorono/c84908ecb1ec49f5a234b721dab28a8c to your computer and use it in GitHub Desktop.

Select an option

Save victorono/c84908ecb1ec49f5a234b721dab28a8c to your computer and use it in GitHub Desktop.

Revisions

  1. victorono revised this gist Mar 12, 2017. 1 changed file with 11 additions and 0 deletions.
    11 changes: 11 additions & 0 deletions no-data-to-display.js
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,14 @@
    /*
    Highcharts JS v5.0.9 (2017-03-08)
    Plugin for displaying a message when there is no data visible in chart.
    Update to chart pie when data is null
    (c) 2010-2016 Highsoft AS
    Author: Oystein Moseng
    License: www.highcharts.com/license
    */

    (function(d) {
    "object" === typeof module && module.exports ? module.exports = d : d(Highcharts)
    })(function(d) {
  2. victorono revised this gist Mar 12, 2017. No changes.
  3. victorono revised this gist Mar 12, 2017. No changes.
  4. victorono created this gist Mar 12, 2017.
    67 changes: 67 additions & 0 deletions no-data-to-display.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    (function(d) {
    "object" === typeof module && module.exports ? module.exports = d : d(Highcharts)
    })(function(d) {
    (function(c) {
    function d() {
    var value = 0;
    for (var i = this.points.length - 1; i >= 0; i--) {
    if (this.points[i].options.y) {
    value = value + this.points[i].options.y;
    }
    }
    return value
    }

    function g() {
    this.hasData() ? this.hideNoData() : this.showNoData()
    }
    var h = c.seriesTypes,
    e = c.Chart.prototype,
    f = c.getOptions(),
    k = c.extend,
    l = c.each;
    k(f.lang, {
    noData: "No data to display"
    });
    f.noData = {
    position: {
    x: 0,
    y: 0,
    align: "center",
    verticalAlign: "middle"
    }
    };
    f.noData.style = {
    fontWeight: "bold",
    fontSize: "12px",
    color: "#666666"
    };
    l(["pie", "gauge", "waterfall", "bubble",
    "treemap"
    ], function(a) {
    h[a] && (h[a].prototype.hasData = d)
    });
    c.Series.prototype.hasData = function() {
    return this.visible && void 0 !== this.dataMax && void 0 !== this.dataMin
    };
    e.showNoData = function(a) {
    var b = this.options;
    a = a || b.lang.noData;
    b = b.noData;
    this.noDataLabel || (this.noDataLabel = this.renderer.label(a, 0, 0, null, null, null, b.useHTML, null, "no-data"), this.noDataLabel.attr(b.attr).css(b.style), this.noDataLabel.add(), this.noDataLabel.align(k(this.noDataLabel.getBBox(), b.position), !1, "plotBox"))
    };
    e.hideNoData = function() {
    this.noDataLabel &&
    (this.noDataLabel = this.noDataLabel.destroy())
    };
    e.hasData = function() {
    for (var a = this.series, b = a.length; b--;)
    if (a[b].hasData() && !a[b].options.isInternal) return !0;
    return !1
    };
    e.callbacks.push(function(a) {
    c.addEvent(a, "load", g);
    c.addEvent(a, "redraw", g)
    })
    })(d)
    });