-
Notifications
You must be signed in to change notification settings - Fork 258
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
new report : radar chart, with repartition
- Loading branch information
Showing
26 changed files
with
280 additions
and
72 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.radar-chart .level{stroke:grey;stroke-width:.5}.radar-chart .axis line{stroke:grey;stroke-width:1}.radar-chart .axis .legend{font-family:sans-serif;font-size:10px}.radar-chart .axis .legend.top{dy:1em}.radar-chart .axis .legend.left{text-anchor:start}.radar-chart .axis .legend.middle{text-anchor:middle}.radar-chart .axis .legend.right{text-anchor:end}.radar-chart .tooltip{font-family:sans-serif;font-size:13px;transition:opacity 200ms;opacity:0}.radar-chart .tooltip.visible{opacity:1}.radar-chart .area{stroke-width:2;fill-opacity:.5}.radar-chart.focus .area{fill-opacity:.1}.radar-chart.focus .area.focused{fill-opacity:.7}.radar-chart .circle{fill-opacity:.9}.radar-chart .area,.radar-chart .circle{transition:opacity 300ms,fill-opacity 200ms;opacity:1}.radar-chart .d3-enter,.radar-chart .d3-exit{opacity:0} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% autoescape false %} | ||
<script type="text/javascript"> | ||
var RadarChart={defaultConfig:{containerClass:"radar-chart",w:600,h:600,factor:.95,factorLegend:1,levels:3,levelTick:!1,TickLength:10,maxValue:0,radians:2*Math.PI,color:d3.scale.category10(),axisLine:!0,axisText:!0,circles:!0,radius:5,axisJoin:function(a,b){return a.className||b},transitionDuration:300},chart:function(){function b(b){b.each(function(b){function h(b,c,d,e){return d="undefined"!=typeof d?d:1,c*(1-d*e(b*a.radians/f))}function i(a,b,c){return h(a,b,c,Math.sin)}function j(a,b,c){return h(a,b,c,Math.cos)}var c=d3.select(this);b=b.map(function(a){return a instanceof Array&&(a={axes:a}),a});var d=Math.max(a.maxValue,d3.max(b,function(a){return d3.max(a.axes,function(a){return a.value})})),e=b[0].axes.map(function(a){return a.axis}),f=e.length,g=a.factor*Math.min(a.w/2,a.h/2);c.classed(a.containerClass,1);var k=d3.range(0,a.levels).map(function(b){return g*((b+1)/a.levels)}),l=c.selectAll("g.level-group").data(k);l.enter().append("g"),l.exit().remove(),l.attr("class",function(a,b){return"level-group level-group-"+b});var m=l.selectAll(".level").data(function(a){return d3.range(0,f).map(function(){return a})});if(m.enter().append("line"),m.exit().remove(),a.levelTick?m.attr("class","level").attr("x1",function(b,c){return g==b?i(c,b):i(c,b)+a.TickLength/2*Math.cos(c*a.radians/f)}).attr("y1",function(b,c){return g==b?j(c,b):j(c,b)-a.TickLength/2*Math.sin(c*a.radians/f)}).attr("x2",function(b,c){return g==b?i(c+1,b):i(c,b)-a.TickLength/2*Math.cos(c*a.radians/f)}).attr("y2",function(b,c){return g==b?j(c+1,b):j(c,b)+a.TickLength/2*Math.sin(c*a.radians/f)}).attr("transform",function(b){return"translate("+(a.w/2-b)+", "+(a.h/2-b)+")"}):m.attr("class","level").attr("x1",function(a,b){return i(b,a)}).attr("y1",function(a,b){return j(b,a)}).attr("x2",function(a,b){return i(b+1,a)}).attr("y2",function(a,b){return j(b+1,a)}).attr("transform",function(b){return"translate("+(a.w/2-b)+", "+(a.h/2-b)+")"}),a.axisLine||a.axisText){var n=c.selectAll(".axis").data(e),o=n.enter().append("g");a.axisLine&&o.append("line"),a.axisText&&o.append("text"),n.exit().remove(),n.attr("class","axis"),a.axisLine&&n.select("line").attr("x1",a.w/2).attr("y1",a.h/2).attr("x2",function(b,c){return i(c,a.w/2,a.factor)}).attr("y2",function(b,c){return j(c,a.h/2,a.factor)}),a.axisText&&n.select("text").attr("class",function(a,b){var c=i(b,.5);return"legend "+(.4>c?"left":c>.6?"right":"middle")}).attr("dy",function(a,b){var c=j(b,.5);return.1>c?"1em":c>.9?"0":"0.5em"}).text(function(a){return a}).attr("x",function(b,c){return i(c,a.w/2,a.factorLegend)}).attr("y",function(b,c){return j(c,a.h/2,a.factorLegend)})}b.forEach(function(b){b.axes.forEach(function(b,c){b.x=i(c,a.w/2,parseFloat(Math.max(b.value,0))/d*a.factor),b.y=j(c,a.h/2,parseFloat(Math.max(b.value,0))/d*a.factor)})});var p=c.selectAll(".area").data(b,a.axisJoin);if(p.enter().append("polygon").classed({area:1,"d3-enter":1}).on("mouseover",function(){c.classed("focus",1),d3.select(this).classed("focused",1)}).on("mouseout",function(){c.classed("focus",0),d3.select(this).classed("focused",0)}),p.exit().classed("d3-exit",1).transition().duration(a.transitionDuration).remove(),p.each(function(a,b){var c={"d3-exit":0};c["radar-chart-serie"+b]=1,a.className&&(c[a.className]=1),d3.select(this).classed(c)}).style("stroke",function(b,c){return a.color(c)}).style("fill",function(b,c){return a.color(c)}).transition().duration(a.transitionDuration).attr("points",function(a){return a.axes.map(function(a){return[a.x,a.y].join(",")}).join(" ")}).each("start",function(){d3.select(this).classed("d3-enter",0)}),a.circles&&a.radius){var q=c.selectAll(".tooltip").data([1]);q.enter().append("text").attr("class","tooltip");var r=c.selectAll("g.circle-group").data(b,a.axisJoin);r.enter().append("g").classed({"circle-group":1,"d3-enter":1}),r.exit().classed("d3-exit",1).transition().duration(a.transitionDuration).remove(),r.each(function(a){var b={"d3-exit":0};a.className&&(b[a.className]=1),d3.select(this).classed(b)}).transition().duration(a.transitionDuration).each("start",function(){d3.select(this).classed("d3-enter",0)});var s=r.selectAll(".circle").data(function(a,b){return a.axes.map(function(a){return[a,b]})});s.enter().append("circle").classed({circle:1,"d3-enter":1}).on("mouseover",function(a){q.attr("x",a[0].x-10).attr("y",a[0].y-5).text(a[0].value).classed("visible",1),c.classed("focus",1),c.select(".area.radar-chart-serie"+a[1]).classed("focused",1)}).on("mouseout",function(a){q.classed("visible",0),c.classed("focus",0),c.select(".area.radar-chart-serie"+a[1]).classed("focused",0)}),s.exit().classed("d3-exit",1).transition().duration(a.transitionDuration).remove(),s.each(function(a){var b={"d3-exit":0};b["radar-chart-serie"+a[1]]=1,d3.select(this).classed(b)}).style("fill",function(b){return a.color(b[1])}).transition().duration(a.transitionDuration).attr("r",a.radius).attr("cx",function(a){return a[0].x}).attr("cy",function(a){return a[0].y}).each("start",function(){d3.select(this).classed("d3-enter",0)});var t=q.node();t.parentNode.appendChild(t)}})}var a=Object.create(RadarChart.defaultConfig);return b.config=function(c){return arguments.length?(arguments.length>1?a[arguments[0]]=arguments[1]:d3.entries(c||{}).forEach(function(b){a[b.key]=b.value}),b):a},b},draw:function(a,b,c){var d=RadarChart.chart().config(c),e=d.config();d3.select(a).select("svg").remove(),d3.select(a).append("svg").attr("width",e.w).attr("height",e.h).datum(b).call(d)}}; | ||
</script> | ||
{% endautoescape %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{% autoescape false %} | ||
<script type="text/javascript"> | ||
function updateScoreChart() { | ||
var score = [ | ||
{ | ||
className: 'score', | ||
axes: [ | ||
{% for name,value in scores %} | ||
{axis: "{{ name }}", value: {{ value |round }} }, | ||
{% endfor %} | ||
] | ||
} | ||
]; | ||
var chart = RadarChart.chart(); | ||
chart.config({maxValue: 100}) | ||
var svg = d3.select('#chart-score').append('svg') | ||
.attr('width', 500) | ||
.attr('height', 500); | ||
// darw one | ||
svg.append('g').classed('focus', 1).datum(score).call(chart); | ||
} | ||
</script> | ||
{% endautoescape %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.