|
28 | 28 | <div class="row"> |
29 | 29 | <div class="span6"> |
30 | 30 | <h2>Class Coverage Distribution</h2> |
31 | | - <div id="classCoverageDistribution"></div> |
| 31 | + <div id="classCoverageDistribution"> |
| 32 | + <svg></svg> |
| 33 | + </div> |
32 | 34 | </div> |
33 | 35 | <div class="span6"> |
34 | 36 | <h2>Class Complexity</h2> |
|
62 | 64 | <script src="js/nv.d3.min.js" type="text/javascript"></script> |
63 | 65 | <script type="text/javascript"> |
64 | 66 | $(document).ready(function() { |
65 | | - var classCoverageDistribution = new Highcharts.Chart({ |
66 | | - chart: { |
67 | | - renderTo: 'classCoverageDistribution', |
68 | | - type: 'column' |
69 | | - }, |
70 | | - title: {text: ''}, |
71 | | - legend: {enabled: false}, |
72 | | - credits: {enabled: false}, |
73 | | - tooltip: {enabled: false}, |
74 | | - xAxis: { |
75 | | - labels: {style: {fontSize: '8px'}}, |
76 | | - categories: [ |
77 | | - '0%','0-10%','10-20%','20-30%','30-40%','40-50%','50-60%','60-70%','70-80%','80-90%','90-100%','100%' |
78 | | - ], |
79 | | - min: 0 |
80 | | - }, |
81 | | - yAxis: { |
82 | | - title: '', |
83 | | - labels: {style: {fontSize: '8px'}}, |
84 | | - min: 0 |
85 | | - }, |
86 | | - series: [{ |
87 | | - data: {ccd_values} |
88 | | - }], |
89 | | - }); |
| 67 | + nv.addGraph(function() { |
| 68 | + var chart = nv.models.multiBarChart(); |
| 69 | + chart.tooltips(false) |
| 70 | + .showControls(false) |
| 71 | + .showLegend(false) |
| 72 | + .reduceXTicks(false) |
| 73 | + .staggerLabels(true) |
| 74 | + .yAxis.tickFormat(d3.format('d')); |
| 75 | + |
| 76 | + d3.select('#classCoverageDistribution svg') |
| 77 | + .datum(getCoverageDistributionData({ccd_values}, "Class Coverage")) |
| 78 | + .transition().duration(500).call(chart); |
| 79 | + |
| 80 | + nv.utils.windowResize(chart.update); |
| 81 | + |
| 82 | + return chart; |
| 83 | + }); |
| 84 | + |
| 85 | + function getCoverageDistributionData(data, label) { |
| 86 | + var labels = [ |
| 87 | + '0%', |
| 88 | + '0-10%', |
| 89 | + '10-20%', |
| 90 | + '20-30%', |
| 91 | + '30-40%', |
| 92 | + '40-50%', |
| 93 | + '50-60%', |
| 94 | + '60-70%', |
| 95 | + '70-80%', |
| 96 | + '80-90%', |
| 97 | + '90-100%', |
| 98 | + '100%' |
| 99 | + ]; |
| 100 | + var values = []; |
| 101 | + $.each(labels, function(key) { |
| 102 | + values.push({x: labels[key], y: data[key]}); |
| 103 | + }); |
| 104 | + |
| 105 | + return [ |
| 106 | + { |
| 107 | + key: label, |
| 108 | + values: values, |
| 109 | + color: "#4572A7" |
| 110 | + } |
| 111 | + ]; |
| 112 | + } |
90 | 113 |
|
91 | 114 | var classComplexity = new Highcharts.Chart({ |
92 | 115 | chart: { |
|
0 commit comments