Click here to Skip to main content
15,890,527 members
Please Sign up or sign in to vote.
5.00/5 (1 vote)
See more:
Hi I am making charts by using this Morris js http://www.oesmith.co.uk/morris.js/donuts.html[^]

I am able to bind these charts but i am able to add click handler on it

i want achieve some thing like this
http://www.jqueryscript.net/demo/Morris-Good-looking-Charts-Plugin/examples/donut.html[^]

C#
Morris.Donut({element: 'dvTestData',data: [ { label:  "platelets", value: 16.70 }, { label:  "Serum test", value: 50.00 }, { label:  "serum testing", value: 16.70 }, { label:  "Whole blood test", value: 16.70 }],formatter: function (x) { return x + ' % '}});


so when i will click it i can call a fucntion which will bind grid
Posted
Updated 3-Feb-14 19:03pm
v2

1 solution

Try is as below.

$("svg rect.bar-1").on 'click', -> console.log("clicked the first bar of bar chart")


Please check below mentioned link for more info.

Added support for handling click events

UPDATE

C#
Morris.Donut({
  element: 'donut-example',
  data: [
    {label: "Download Sales", value: 12},
    {label: "In-Store Sales", value: 30},
    {label: "Mail-Order Sales", value: 20}
  ]
});

$( "#donut-example" ).click(function() {
  alert( "Handler for .click() called." );
});


LIVE DEMO : JSBin

Color for each segments :

C#
Morris.Donut({
  element: 'donut-example',
  data: [
    {label: "Download Sales", value: 12 },
    {label: "In-Store Sales", value: 30},
    {label: "Mail-Order Sales", value: 20}
  ],
  colors:['#FF0000',"#00FF00","#FFFF00"]
});



Color Demo :
JsBin
 
Share this answer
 
v4
Comments
surajemo 4-Feb-14 0:54am    
how do i write it i am using pie chart that is for rectangle how do i implement it using this
http://www.jqueryscript.net/demo/Morris-Good-looking-Charts-Plugin/examples/donut.html[^]
Sampath Lokuge 4-Feb-14 0:56am    
Can you put your code snippet ?
surajemo 4-Feb-14 1:00am    
Morris.Donut({element: 'dvTestData',data: [ { label: "platelets", value: 16.70 }, { label: "Serum test", value: 50.00 }, { label: "serum testing", value: 16.70 }, { label: "Whole blood test", value: 16.70 }],formatter: function (x) { return x + ' % '}});


I am genreating this dynamically
surajemo 4-Feb-14 1:19am    
http://www.jqueryscript.net/demo/Morris-Good-looking-Charts-Plugin/examples/donut.html
check out this example and see in the console
Sampath Lokuge 4-Feb-14 1:37am    
Please check my 'UPDATE' section.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900