~ubuntu-branches/ubuntu/trusty/horizon/trusty

« back to all changes in this revision

Viewing changes to horizon/static/horizon/js/horizon.d3piechart.js

  • Committer: Package Import Robot
  • Author(s): James Page, Chuck Short, James Page
  • Date: 2014-01-24 15:12:31 UTC
  • mfrom: (1.1.36)
  • Revision ID: package-import@ubuntu.com-20140124151231-la1dkibwm13fgrza
Tags: 1:2014.1~b2-0ubuntu1
[ Chuck Short ]
* New upstream release.
* debian/patches/fix-ubuntu-tests.patch: Dropped. 
* deban/patches/ubuntu-settings.patch: Refreshed

[ James Page ]
* debian/static: Refresh assets.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
    Draw pie chart in d3.
3
 
 
4
 
    To use, a div is required with the class .d3_pie_chart
5
 
    and a data-used attribute in the div
6
 
    that stores the percentage to fill the chart
7
 
 
8
 
    Example:
9
 
        <div class="d3_pie_chart"
10
 
            data-used="{% widthratio current_val max_val 100 %}">
11
 
        </div>
 
2
  Draw pie chart in d3.
 
3
 
 
4
  To use, a div is required with the class .d3_pie_chart
 
5
  and a data-used attribute in the div
 
6
  that stores the percentage to fill the chart
 
7
 
 
8
  Example:
 
9
    <div class="d3_pie_chart"
 
10
      data-used="{% widthratio current_val max_val 100 %}">
 
11
    </div>
12
12
*/
13
13
 
14
14
horizon.d3_pie_chart = {
28
28
    self.chart = d3.selectAll(".d3_pie_chart");
29
29
 
30
30
    for (var i = 0; i < pie_chart_data.length; i++) {
31
 
      used = parseInt($(pie_chart_data[i]).data("used"));
 
31
      var used = Math.min(parseInt($(pie_chart_data[i]).data("used")), 100);
32
32
      self.data = [{"percentage":used}, {"percentage":100 - used}];
33
33
      self.pieChart(i);
34
34
    }