TL;DR: 1. Iterate through all donuts within a Div. 2. Move label text outside the donut on mouseOver.
I came across this and this questions that got me half way there, but I am trying to iterate through several donuts. I'm new to jQuery and I've tried a few options, but I just don't have a complete understanding.
Here's my code. Any help would be appreciated:
HTML
`<div class="dials">
<div class="row">
<div class="col-md-4">
<asp:Label ID="lblSurvey1" Text="" runat="server" CssClass="page-subheader" />
<div id="divSurvey1"></div><span id="morrisDonutChartSpan"></span>
</div>
<div class="col-md-4">
<asp:Label ID="lblSurvey2" Text="" runat="server" CssClass="page-subheader" />
<div id="divSurvey2"></div><span id="morrisDonutChartSpan"></span>
</div>
</div>
</div>`
Donut script:
`
Morris.Donut({
element: 'divSurvey1',
colors: ['#2299DE', '#97C240', '#2c594f', '#002D40', '#BC0D20', '#FF8922', '#f0b71e', '#9369d2'],
labelColor: '#B5B5B5',
resize: false,
data: [
<asp:Literal id="litSurvey1Data" runat="server"></asp:Literal>
]
});
Morris.Donut({
element: 'divSurvey2',
colors: ['#2299DE', '#97C240', '#2c594f', '#002D40', '#BC0D20', '#FF8922', '#f0b71e', '#9369d2'],
labelColor: '#B5B5B5',
resize: false,
data: [
<asp:Literal id="litSurvey2Data" runat="server"></asp:Literal>
]
});
$( ".dial" ).mouseover(function() {
prepareMorrisDonutChart();
});
$( document ).ready(function() {
prepareMorrisDonutChart();
});
function prepareMorrisDonutChart() {
$(".dial tspan:first").css("display","none");
$(".dial tspan:nth-child(1)").css("font-size","40px");
var isi = $(".dial tspan:first").html();
$('.dial').text(isi);
}
`