-
-
Notifications
You must be signed in to change notification settings - Fork 322
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-Authored-By: Tom Sydney Kerckhove <[email protected]>
- Loading branch information
1 parent
96e77a9
commit 6ef0f22
Showing
3 changed files
with
37 additions
and
9 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -1,23 +1,40 @@ | ||
<label #register-pie-chart-label style=""><br> | ||
<div #register-pie-chart style="height:150px; margin-bottom:1em; display:block;"> | ||
<div #piehover> | ||
<script type=text/javascript> | ||
\$(document).ready(function() { | ||
var $chartdiv = $('#register-pie-chart'); | ||
if ($chartdiv.is(':visible')) { | ||
\$('#register-pie-chart-label').text('#{charttitle}'); | ||
var data = | ||
[ | ||
{ label: "Food", data: 5 }, | ||
{ label: "Rent", data: 10 }, | ||
{ label: "Internet", data: 85 } | ||
$forall (label, dat) <- labelDataTuples | ||
{ label: "#{label}", data: #{dat} }, | ||
]; | ||
function legendFormatter(label, series) { | ||
return Math.round(series.percent).toFixed(2) + '% ' + label; | ||
}; | ||
var options = { | ||
series: { | ||
pie: { | ||
show: true | ||
} | ||
}, | ||
grid: { | ||
hoverable: true | ||
}, | ||
legend: { | ||
show: true, | ||
labelFormatter: legendFormatter | ||
} | ||
}; | ||
\$.plot($chartdiv, data, options); | ||
\$chartdiv.bind("plothover", function(event, pos, obj) { | ||
if (!obj) { | ||
return; | ||
} | ||
var percent = parseFloat(obj.series.percent).toFixed(2); | ||
\$("#piehover").html("<span style='font-weight:bold; color:" + obj.series.color + "'>" + obj.series.label + " (" + percent + "%)</span>"); | ||
}); | ||
} | ||
}); |
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