dojox/charting/plot2d/StackedBars.js

  • Provides:

    • dojox.charting.plot2d.StackedBars
  • Requires:

    • dojox.charting.plot2d.common in common
    • dojox.charting.plot2d.Bars in common
    • dojox.lang.functional in common
    • dojox.lang.functional.reversed in common
    • dojox.lang.functional.sequence in common
  • dojox.charting.plot2d.StackedBars

    • type
      Function
    • chains:
      • dojox.charting.plot2d.Bars: (prototype)
      • dojox.charting.plot2d.Bars: (call)
    • summary
      The plot object representing a stacked bar chart (horizontal bars).
  • dojox.charting.plot2d.StackedBars.getSeriesStats

    • type
      Function
    • source: [view]
         var stats = dc.collectStackedStats(this.series), t;
         this._maxRunLength = stats.hmax;
         stats.hmin -= 0.5;
         stats.hmax += 0.5;
         t = stats.hmin, stats.hmin = stats.vmin, stats.vmin = t;
         t = stats.hmax, stats.hmax = stats.vmax, stats.vmax = t;
         return stats;
    • summary
      Calculate the min/max on all attached series in both directions.
    • return_summary
      Object
      {hmin, hmax, vmin, vmax} min/max in both directions.
  • dojox.charting.plot2d.StackedBars.render

    • type
      Function
    • parameters:
      • dim: (typeof Object)
        An object in the form of { width, height }
      • offsets: (typeof Object)
        An object of the form { l, r, t, b}.
    • source: [view]
         if(this._maxRunLength <= 0){
          return this;
         }


         // stack all values
         var acc = df.repeat(this._maxRunLength, "-> 0", 0);
         for(var i = 0; i < this.series.length; ++i){
          var run = this.series[i];
          for(var j = 0; j < run.data.length; ++j){
           var value = run.data[j];
           if(value !== null){
            var v = typeof value == "number" ? value : value.y;
            if(isNaN(v)){ v = 0; }
            acc[j] += v;
           }
          }
         }
         // draw runs in backwards
         if(this.zoom && !this.isDataDirty()){
          return this.performZoom(dim, offsets);
         }
         this.resetEvents();
         this.dirty = this.isDirty();
         if(this.dirty){
          dojo.forEach(this.series, purgeGroup);
          this._eventSeries = {};
          this.cleanGroup();
          var s = this.group;
          df.forEachRev(this.series, function(item){ item.cleanGroup(s); });
         }
         var t = this.chart.theme, f, gap, height,
          ht = this._hScaler.scaler.getTransformerFromModel(this._hScaler),
          vt = this._vScaler.scaler.getTransformerFromModel(this._vScaler),
          events = this.events();
         f = dc.calculateBarSize(this._vScaler.bounds.scale, this.opt);
         gap = f.gap;
         height = f.size;
         for(var i = this.series.length - 1; i >= 0; --i){
          var run = this.series[i];
          if(!this.dirty && !run.dirty){
           t.skip();
           this._reconnectEvents(run.name);
           continue;
          }
          run.cleanGroup();
          var theme = t.next("bar", [this.opt, run]), s = run.group,
           eventSeries = new Array(acc.length);
          for(var j = 0; j < acc.length; ++j){
           var value = run.data[j];
           if(value !== null){
            var v = acc[j],
             width = ht(v),
             finalTheme = typeof value != "number" ?
              t.addMixin(theme, "bar", value, true) :
              t.post(theme, "bar");
            if(width >= 1 && height >= 1){
             var rect = {
              x: offsets.l,
              y: dim.height - offsets.b - vt(j + 1.5) + gap,
              width: width, height: height
             };
             var specialFill = this._plotFill(finalTheme.series.fill, dim, offsets);
             specialFill = this._shapeFill(specialFill, rect);
             var shape = s.createRect(rect).setFill(specialFill).setStroke(finalTheme.series.stroke);
             run.dyn.fill = shape.getFill();
             run.dyn.stroke = shape.getStroke();
             if(events){
              var o = {
               element: "bar",
               index: j,
               run: run,
               shape: shape,
               x: v,
               y: j + 1.5
              };
              this._connectEvents(o);
              eventSeries[j] = o;
             }
             if(this.animate){
              this._animateBar(shape, offsets.l, -width);
             }
            }
           }
          }
          this._eventSeries[run.name] = eventSeries;
          run.dirty = false;
          // update the accumulator
          for(var j = 0; j < run.data.length; ++j){
           var value = run.data[j];
           if(value !== null){
            var v = typeof value == "number" ? value : value.y;
            if(isNaN(v)){ v = 0; }
            acc[j] -= v;
           }
          }
         }
         this.dirty = false;
         return this; // dojox.charting.plot2d.StackedBars
    • summary
      Run the calculations for any axes for this plot.
    • return_summary
      dojox.charting.plot2d.StackedBars
      A reference to this plot for functional chaining.
    • returns
      dojox.charting.plot2d.StackedBars
  • dojox.charting.plot2d.StackedBars._maxRunLength

    • summary
  • dojox.charting.plot2d.StackedBars.dirty

    • summary
  • dojox.charting.plot2d.StackedBars._eventSeries

    • summary
  • purgeGroup

    • summary
  • dojox.charting.plot2d

    • type
      Object
    • summary
  • dojox.charting

    • type
      Object
    • summary
  • dojox

    • type
      Object
    • summary