ksh
ksh

Reputation: 649

Disabling hover options in Morris Donut chart

how to disable hover option in morris donut chart and whenever user moves pointer over chart its value should remain same.

var m111 = new Morris.Donut({
    element: 'donut-chart111',
    data: [
      {label: "R", value: ra},
      {label: "C", value: cp},
      {label: "M", value: mp},
      {label: "MA", value: map},
      {label: "A", value: ap}
    ],
    colors: ['#D9534F','#1CAF9A','#428BCA','#5BC0DE','#428BCA']
});

Upvotes: 3

Views: 1638

Answers (1)

Halvor Holsten Strand
Halvor Holsten Strand

Reputation: 20536

You can loop through and modify the segment handlers to your liking.

To remove the hover handler (and optionally add a click handler) you could for example do this:

var donut = new Morris.Donut({
    // ...
});

for(i = 0; i < donut.segments.length; i++) {
    // Remove hover handlers:
    donut.segments[i].handlers['hover'] = [];

    // If you want select functionality through click:
    donut.segments[i].handlers['click'] = [donut.select];
}

See this JSFiddle demonstration of it in action.

Upvotes: 5

Related Questions